Skip to content

Commit 0896895

Browse files
committed
[GC] Save the TID in the thread cache.
1 parent 6b70ec0 commit 0896895

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

sdlib/core/stdc/unistd.d

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,24 @@ enum STDERR_FILENO = 2;
99

1010
extern(C):
1111

12+
// TODO: access, euidaccess, eaccess, execveat
13+
// TODO: lseek, lseek64
14+
1215
int close(int fd);
1316

17+
// TODO: closefrom
18+
1419
ssize_t read(int fd, void* buf, size_t nbytes);
1520
ssize_t write(int fd, const void* buf, size_t nbytes);
1621

17-
// TODO: pread/pwrite
22+
// TODO: pread, pwrite
23+
// TODO: pipe, pipe2
1824

1925
uint alarm(uint seconds);
2026
uint sleep(uint seconds);
27+
28+
// TODO: ualarm, usleep
29+
2130
int pause();
2231

2332
// TODO: chown, chdir, fchdir, etc...
@@ -244,4 +253,51 @@ enum : int {
244253

245254
long sysconf(int __name);
246255

247-
// TODO: getpid and so on.
256+
pid_t getpid();
257+
pid_t getppid();
258+
pid_t getpgrp();
259+
260+
// TODO: getpgid
261+
262+
int setpgid(pid_t __pid, pid_t __pgid);
263+
264+
// TODO: setpgrp
265+
266+
pid_t setsid();
267+
268+
// TODO: getsid
269+
270+
uid_t getuid();
271+
uid_t geteuid();
272+
gid_t getgid();
273+
gid_t getegid();
274+
275+
// TODO: getgroups, group_member
276+
277+
int setuid(uid_t __uid);
278+
279+
// TODO: setreuid, seteuid
280+
281+
int setgid(gid_t __gid);
282+
283+
// TODO: setregid, setegid
284+
// TODO: getresuid, getresgid, setresuid, setresgid
285+
// TODO: fork, vfork
286+
// TODO: ttyname, isatty, ttyslot
287+
// TODO: link, linkat, symlink, readlink, symlinkat, readlinkat, unlinkat
288+
// TODO: rmdir
289+
// TODO: tcgetpgrp, tcsetpgrp
290+
// TODO: getlogin, getlogin_r, setlogin
291+
// TODO: gethostname, sethostname, sethostid, getdomainname, setdomainname
292+
// TODO: vhangup, revoke, profil
293+
// TODO: ...
294+
295+
long syscall(long __sysno, ...);
296+
297+
// TODO: copy_file_range, fdatasync
298+
// TODO: ...
299+
300+
/**
301+
* Linux specifc extension.
302+
*/
303+
pid_t gettid();

sdlib/d/gc/tcache.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ private:
5656
import core.stdc.pthread;
5757
pthread_t self;
5858

59+
import sys.posix.types;
60+
pid_t tid;
61+
5962
RNode rnode;
6063

6164
void* stackBottom;
@@ -102,6 +105,9 @@ public:
102105

103106
self = pthread_self();
104107

108+
import core.stdc.unistd;
109+
tid = gettid();
110+
105111
nextAllocationEvent = DefaultEventWait;
106112
nextDeallocationEvent = DefaultEventWait;
107113
nextGCRun = DefaultEventWait;

sdlib/d/sync/futex/futex.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import sys.linux.futex;
88
import core.stdc.errno_;
99

1010
enum SYS_futex = 202;
11-
extern(C) long syscall(long __sysno, ...);
1211

1312
int futex_wait(shared(Atomic!uint)* futex,
1413
uint expected, /* TODO: timeout */ ) {
14+
import core.stdc.unistd;
1515
auto err = syscall(SYS_futex, cast(uint*) futex, Futex.WaitPrivate,
1616
expected, null);
1717
if (likely(err < 0)) {
@@ -22,6 +22,7 @@ int futex_wait(shared(Atomic!uint)* futex,
2222
}
2323

2424
int futex_wake(shared Atomic!uint* futex, uint count) {
25+
import core.stdc.unistd;
2526
auto err = syscall(SYS_futex, cast(uint*) futex, Futex.WakePrivate, count);
2627
if (unlikely(err < 0)) {
2728
return -errno;

sdlib/sys/posix/types.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ alias ssize_t = c_long;
77

88
alias pid_t = int;
99
alias uid_t = uint;
10+
alias gid_t = uint;
1011
alias clock_t = c_long;

0 commit comments

Comments
 (0)