This repository was archived by the owner on Oct 12, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 411
add core.sys.freebsd.pthread_np #1060
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * D header file for FreeBSD. | ||
| * | ||
| * Authors: Martin Nowak | ||
| */ | ||
| module core.sys.freebsd.pthread; | ||
|
|
||
| version (FreeBSD): | ||
| extern (C) nothrow @nogc: | ||
|
|
||
| public import core.sys.posix.sys.types; | ||
| // TODO: add full core.sys.freebsd.sys.cpuset; | ||
| public import core.sys.freebsd.sys._cpuset; | ||
| public import core.sys.posix.time; | ||
|
|
||
| enum __BSD_VISIBLE = true; | ||
|
|
||
| alias pthread_switch_routine_t = void function(pthread_t, pthread_t); | ||
|
|
||
| int pthread_attr_setcreatesuspend_np(pthread_attr_t *); | ||
| int pthread_attr_get_np(pthread_t, pthread_attr_t *); | ||
| int pthread_attr_getaffinity_np(const(pthread_attr_t)*, size_t, cpuset_t *); | ||
| int pthread_attr_setaffinity_np(pthread_attr_t *, size_t, const(cpuset_t)*); | ||
| int pthread_getaffinity_np(pthread_t, size_t, cpuset_t *); | ||
| int pthread_getthreadid_np(); | ||
| int pthread_main_np(); | ||
| int pthread_multi_np(); | ||
| int pthread_mutexattr_getkind_np(pthread_mutexattr_t); | ||
| int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int); | ||
| void pthread_resume_all_np(); | ||
| int pthread_resume_np(pthread_t); | ||
| void pthread_set_name_np(pthread_t, const(char)*); | ||
| int pthread_mutex_getspinloops_np(pthread_mutex_t *mutex, int *count); | ||
| int pthread_mutex_setspinloops_np(pthread_mutex_t *mutex, int count); | ||
| int pthread_mutex_getyieldloops_np(pthread_mutex_t *mutex, int *count); | ||
| int pthread_mutex_setyieldloops_np(pthread_mutex_t *mutex, int count); | ||
| int pthread_mutex_isowned_np(pthread_mutex_t *mutex); | ||
| int pthread_setaffinity_np(pthread_t, size_t, const(cpuset_t)*); | ||
| int pthread_single_np(); | ||
| void pthread_suspend_all_np(); | ||
| int pthread_suspend_np(pthread_t); | ||
| int pthread_switch_add_np(pthread_switch_routine_t); | ||
| int pthread_switch_delete_np(pthread_switch_routine_t); | ||
| int pthread_timedjoin_np(pthread_t, void **, const(timespec)*); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /** | ||
| * D header file for FreeBSD. | ||
| * | ||
| * Authors: Martin Nowak | ||
| */ | ||
| module core.sys.freebsd.sys._bitset; | ||
|
|
||
| version (FreeBSD): | ||
| extern (C) pure nothrow @nogc: | ||
|
|
||
| import core.stdc.config : c_long; | ||
|
|
||
| enum NBBY = 8; // number of bits per byte | ||
|
|
||
| enum _BITSET_BITS = c_long.sizeof * NBBY; | ||
|
|
||
| enum __bitset_words(size_t s) = (s + _BITSET_BITS - 1) / _BITSET_BITS; | ||
|
|
||
| c_long __bitset_mask(size_t s)(size_t n) | ||
| { | ||
| static if (__bitset_words!s == 1) | ||
| return (cast(c_long)1) << n; | ||
| else | ||
| return (cast(c_long)1) << n % _BITSET_BITS; | ||
| } | ||
|
|
||
| size_t __bitset_word(size_t s)(size_t n) | ||
| { | ||
| static if (__bitset_words!s == 1) | ||
| return 0; | ||
| else | ||
| return n / _BITSET_BITS; | ||
| } | ||
|
|
||
| struct BITSET_DEFINE(size_t s) | ||
| { | ||
| c_long[__bitset_words!s] __bits; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are double-underscore symbols supposed to be reserved only for the compiler or also druntime?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just matches the C header. |
||
| } | ||
|
|
||
| // no idea how to translate those | ||
| //#define BITSET_T_INITIALIZER(x) \ | ||
| // { .__bits = { x } } | ||
| // | ||
| //#define BITSET_FSET(n) \ | ||
| // [ 0 ... ((n) - 1) ] = (-1L) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * D header file for FreeBSD. | ||
| * | ||
| * Authors: Martin Nowak | ||
| */ | ||
| module core.sys.freebsd.sys._cpuset; | ||
|
|
||
| version (FreeBSD): | ||
| extern (C) pure nothrow @nogc: | ||
|
|
||
| public import core.sys.freebsd.sys._bitset; | ||
|
|
||
| static if (is(typeof(_KERNEL))) | ||
| alias CPU_SETSIZE = MAXCPU; | ||
|
|
||
| enum CPU_MAXSIZE = 256; | ||
|
|
||
| static if (!is(typeof(CPU_SETSIZE))) | ||
| alias CPU_SETSIZE = CPU_MAXSIZE; | ||
|
|
||
| enum _NCPUBITS = _BITSET_BITS; | ||
| enum _NCPUWORDS = __bitset_words!CPU_SETSIZE; | ||
|
|
||
| alias _cpuset = BITSET_DEFINE!(CPU_SETSIZE); | ||
| alias cpuset_t = _cpuset; | ||
|
|
||
| // no idea how to translate those | ||
| //#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) | ||
| //#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these modules have an underscore prepended? Just to match what the C files do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep