This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1060 from MartinNowak/pthread_np
add core.sys.freebsd.pthread_np
- Loading branch information
Showing
6 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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; | ||
} | ||
|
||
// no idea how to translate those | ||
//#define BITSET_T_INITIALIZER(x) \ | ||
// { .__bits = { x } } | ||
// | ||
//#define BITSET_FSET(n) \ | ||
// [ 0 ... ((n) - 1) ] = (-1L) |
This file contains 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 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 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