Skip to content

Commit c6c5244

Browse files
ibuclawdlang-bot
authored andcommitted
druntime: Add bindings for Solaris thread.h
1 parent 8211063 commit c6c5244

5 files changed

Lines changed: 70 additions & 1 deletion

File tree

druntime/mak/COPY

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ COPY=\
374374
$(IMPDIR)\core\sys\solaris\libelf.d \
375375
$(IMPDIR)\core\sys\solaris\link.d \
376376
$(IMPDIR)\core\sys\solaris\stdlib.d \
377+
$(IMPDIR)\core\sys\solaris\thread.d \
377378
$(IMPDIR)\core\sys\solaris\time.d \
378379
\
379380
$(IMPDIR)\core\sys\solaris\sys\elf.d \

druntime/mak/DOCS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ DOCS=\
329329
$(DOCDIR)\core_sys_solaris_execinfo.html \
330330
$(DOCDIR)\core_sys_solaris_libelf.html \
331331
$(DOCDIR)\core_sys_solaris_link.html \
332+
$(DOCDIR)\core_sys_solaris_thread.html \
332333
$(DOCDIR)\core_sys_solaris_time.html \
333334
\
334335
$(DOCDIR)\core_sys_solaris_sys_elf.html \

druntime/mak/SRCS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ SRCS=\
369369
src\core\sys\solaris\libelf.d \
370370
src\core\sys\solaris\link.d \
371371
src\core\sys\solaris\stdlib.d \
372+
src\core\sys\solaris\thread.d \
372373
src\core\sys\solaris\time.d \
373374
src\core\sys\solaris\sys\elf.d \
374375
src\core\sys\solaris\sys\elf_386.d \
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* D header file for Solaris thread.h.
3+
*
4+
* Copyright: Copyright © 2025, The D Language Foundation
5+
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
6+
* Authors: Iain Buclaw
7+
*/
8+
module core.sys.solaris.thread;
9+
10+
version (Solaris):
11+
extern (C):
12+
nothrow:
13+
@nogc:
14+
15+
import core.stdc.config : c_long;
16+
import core.sys.posix.signal : sigset_t, stack_t;
17+
18+
/*
19+
* definitions needed to use the thread interface except synchronization.
20+
*/
21+
alias thread_t = int;
22+
alias thread_key_t = int;
23+
24+
int thr_create(void*, size_t, void* function(void*), void*, c_long, thread_t*);
25+
int thr_join(thread_t, thread_t*, void**);
26+
int thr_setconcurrency(int);
27+
int thr_getconcurrency();
28+
noreturn thr_exit(void*);
29+
thread_t thr_self();
30+
31+
int thr_sigsetmask(int, const scope sigset_t*, sigset_t*);
32+
33+
int thr_stksegment(stack_t*);
34+
35+
int thr_main();
36+
int thr_kill(thread_t, int);
37+
int thr_suspend(thread_t);
38+
int thr_continue(thread_t);
39+
void thr_yield();
40+
int thr_setprio(thread_t, int);
41+
int thr_getprio(thread_t, int*);
42+
int thr_keycreate(thread_key_t*, void function(void*));
43+
int thr_keycreate_once(thread_key_t*, void function(void*));
44+
int thr_setspecific(thread_key_t, void*);
45+
int thr_getspecific(thread_key_t, void**);
46+
size_t thr_min_stack();
47+
48+
alias THR_MIN_STACK = thr_min_stack;
49+
50+
/*
51+
* thread flags (one word bit mask)
52+
*/
53+
enum : c_long
54+
{
55+
THR_BOUND = 0x00000001, // = PTHREAD_SCOPE_SYSTEM
56+
THR_NEW_LWP = 0x00000002,
57+
THR_DETACHED = 0x00000040, // = PTHREAD_CREATE_DETACHED
58+
THR_SUSPENDED = 0x00000080,
59+
THR_DAEMON = 0x00000100,
60+
}
61+
62+
/*
63+
* The key to be created by thr_keycreate_once()
64+
* must be statically initialized with THR_ONCE_KEY.
65+
*/
66+
enum thread_key_t THR_ONCE_KEY = -1;

druntime/src/core/thread/osthread.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ version (Solaris)
125125
import core.sys.posix.sys.wait : idtype_t;
126126
import core.sys.solaris.sys.priocntl : PC_CLNULL, PC_GETCLINFO, PC_GETPARMS, PC_SETPARMS, pcinfo_t, pcparms_t, priocntl;
127127
import core.sys.solaris.sys.types : P_MYID, pri_t;
128+
import core.sys.solaris.thread : thr_stksegment;
128129
}
129130

130131
version (GNU)
@@ -1531,7 +1532,6 @@ extern (C) @nogc nothrow
15311532

15321533
version (PThread_Getattr_NP) int pthread_getattr_np(pthread_t thread, pthread_attr_t* attr);
15331534
version (PThread_Attr_Get_NP) int pthread_attr_get_np(pthread_t thread, pthread_attr_t* attr);
1534-
version (Solaris) int thr_stksegment(stack_t* stk);
15351535
version (OpenBSD) int pthread_stackseg_np(pthread_t thread, stack_t* sinfo);
15361536
}
15371537

0 commit comments

Comments
 (0)