Skip to content

Commit aab4ee4

Browse files
committed
Add sys_ prefix to unwrapped system calls
This change also implements getlogin() and getlogin_r().
1 parent 8f56788 commit aab4ee4

File tree

811 files changed

+1112
-1796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

811 files changed

+1112
-1796
lines changed

libc/calls/calls.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ int flock(int, int);
9797
int fork(void);
9898
int fsync(int);
9999
int ftruncate(int, int64_t);
100-
int getdents(unsigned, void *, unsigned, long *);
101100
int getdomainname(char *, size_t);
102101
int getegid(void) nosideeffect;
103102
int geteuid(void) nosideeffect;
@@ -114,7 +113,7 @@ int getresuid(uint32_t *, uint32_t *, uint32_t *);
114113
int getsid(int) nosideeffect libcesque;
115114
int gettid(void) libcesque;
116115
int getuid(void) libcesque;
117-
int iopl(int);
116+
int sys_iopl(int);
118117
int ioprio_get(int, int);
119118
int ioprio_set(int, int, int);
120119
int issetugid(void);
@@ -133,11 +132,11 @@ int mkfifo(const char *, uint32_t);
133132
int mkfifoat(int, const char *, uint32_t);
134133
int mknod(const char *, uint32_t, uint64_t);
135134
int mknodat(int, const char *, int32_t, uint64_t);
136-
int mlock(const void *, size_t);
137-
int mlock2(const void *, size_t, int);
138-
int mlockall(int);
139-
int munlock(const void *, size_t);
140-
int munlockall(void);
135+
int sys_mlock(const void *, size_t);
136+
int sys_mlock2(const void *, size_t, int);
137+
int sys_mlockall(int);
138+
int sys_munlock(const void *, size_t);
139+
int sys_munlockall(void);
141140
int nice(int);
142141
int open(const char *, int, ...);
143142
int openat(int, const char *, int, ...);
@@ -179,7 +178,7 @@ int symlink(const char *, const char *);
179178
int symlinkat(const char *, int, const char *);
180179
int sync_file_range(int, int64_t, int64_t, unsigned);
181180
int sys_ptrace(int, ...);
182-
int sysctl(const int *, unsigned, void *, size_t *, void *, size_t);
181+
int sys_sysctl(const int *, unsigned, void *, size_t *, void *, size_t);
183182
int tcsetpgrp(int, int32_t);
184183
int tgkill(int, int, int);
185184
int tkill(int, int);

libc/calls/getcpucount.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static unsigned GetCpuCountBsd(void) {
5454
} else {
5555
cmd[1] = HW_NCPU;
5656
}
57-
if (!sysctl(cmd, 2, &c, &n, 0, 0)) {
57+
if (!sys_sysctl(cmd, 2, &c, &n, 0, 0)) {
5858
return c;
5959
} else {
6060
return 0;

libc/calls/gethostname-bsd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
int gethostname_bsd(char *name, size_t len, int kind) {
2626
int cmd[2] = {CTL_KERN, kind};
27-
if (sysctl(cmd, 2, name, &len, 0, 0) != -1) {
27+
if (sys_sysctl(cmd, 2, name, &len, 0, 0) != -1) {
2828
return 0;
2929
} else {
3030
if (errno == ENOMEM) {

libc/calls/getloadavg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
│ PERFORMANCE OF THIS SOFTWARE. │
1818
╚─────────────────────────────────────────────────────────────────────────────*/
1919
#include "libc/calls/calls.h"
20-
#include "libc/intrin/strace.internal.h"
2120
#include "libc/calls/struct/sysinfo.h"
2221
#include "libc/calls/syscall-nt.internal.h"
2322
#include "libc/dce.h"
23+
#include "libc/intrin/strace.internal.h"
2424
#include "libc/sysv/errfuns.h"
2525

2626
#define CTL_VM 2
@@ -62,7 +62,7 @@ int getloadavg(double *a, int n) {
6262
struct loadavg loadinfo;
6363
int mib[2] = {CTL_VM, VM_LOADAVG};
6464
size = sizeof(loadinfo);
65-
if ((rc = sysctl(mib, 2, &loadinfo, &size, 0, 0)) != -1) {
65+
if ((rc = sys_sysctl(mib, 2, &loadinfo, &size, 0, 0)) != -1) {
6666
for (i = 0; i < n; i++) {
6767
a[i] = (double)loadinfo.ldavg[i] / loadinfo.fscale;
6868
}

libc/calls/getprogramexecutablename.greg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static inline void GetProgramExecutableNameImpl(char *p, char *e) {
113113
}
114114
u.cmd[3] = -1; // current process
115115
n = e - p;
116-
if (sysctl(u.cmd, ARRAYLEN(u.cmd), p, &n, 0, 0) != -1) {
116+
if (sys_sysctl(u.cmd, ARRAYLEN(u.cmd), p, &n, 0, 0) != -1) {
117117
return;
118118
}
119119
}

libc/calls/sysinfo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
│ PERFORMANCE OF THIS SOFTWARE. │
1818
╚─────────────────────────────────────────────────────────────────────────────*/
1919
#include "libc/calls/calls.h"
20-
#include "libc/intrin/strace.internal.h"
2120
#include "libc/calls/struct/sysinfo.h"
2221
#include "libc/calls/struct/sysinfo.internal.h"
2322
#include "libc/calls/struct/timespec.h"
2423
#include "libc/calls/struct/timeval.h"
2524
#include "libc/calls/struct/vmmeter-meta.internal.h"
2625
#include "libc/dce.h"
2726
#include "libc/intrin/asan.internal.h"
27+
#include "libc/intrin/strace.internal.h"
2828
#include "libc/macros.internal.h"
2929
#include "libc/str/str.h"
3030
#include "libc/sysv/errfuns.h"
@@ -39,15 +39,15 @@ static int64_t GetUptime(void) {
3939
struct timeval x;
4040
size_t n = sizeof(x);
4141
int mib[] = {CTL_KERN, KERN_BOOTTIME};
42-
if (sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) return 0;
42+
if (sys_sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) return 0;
4343
return _timespec_real().tv_sec - x.tv_sec;
4444
}
4545

4646
static int64_t GetPhysmem(void) {
4747
uint64_t x;
4848
size_t n = sizeof(x);
4949
int mib[] = {CTL_HW, HW_PHYSMEM};
50-
if (sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) return 0;
50+
if (sys_sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) return 0;
5151
return x;
5252
}
5353

libc/calls/uname.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void GetBsdStr(int c0, int c1, char *s) {
5656
size_t n = SYS_NMLN;
5757
int cmd[2] = {c0, c1};
5858
bzero(s, n), --n;
59-
sysctl(cmd, 2, s, &n, NULL, 0);
59+
sys_sysctl(cmd, 2, s, &n, NULL, 0);
6060
errno = e;
6161
// sysctl kern.version is too verbose for uname
6262
if ((p = strchr(s, '\n'))) {

libc/intrin/sched_yield.S

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
sched_yield:
2929
push %rbp
3030
mov %rsp,%rbp
31+
xor %eax,%eax
32+
mov __hostos(%rip),%dl
33+
34+
#if SupportsMetal()
35+
testb $METAL,%dl
36+
jnz 9f
37+
#endif
3138

3239
#if SupportsWindows()
3340
// Windows Support
@@ -39,7 +46,7 @@ sched_yield:
3946
// threads ready to run and no user APCs are queued, the function
4047
// returns immediately, and the thread continues execution.
4148
// ──Quoth MSDN
42-
testb IsWindows()
49+
testb $WINDOWS,%dl
4350
jz 1f
4451
xor %ecx,%ecx
4552
xor %edx,%edx

libc/runtime/clktck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
1717
│ PERFORMANCE OF THIS SOFTWARE. │
1818
╚─────────────────────────────────────────────────────────────────────────────*/
19-
#include "libc/intrin/_getauxval.internal.h"
2019
#include "libc/calls/calls.h"
2120
#include "libc/dce.h"
2221
#include "libc/fmt/conv.h"
22+
#include "libc/intrin/_getauxval.internal.h"
2323
#include "libc/runtime/clktck.h"
2424
#include "libc/runtime/runtime.h"
2525
#include "libc/sysv/consts/auxv.h"
@@ -49,7 +49,7 @@ static dontinline int __clk_tck_init(void) {
4949
cmd[0] = 1; // CTL_KERN
5050
cmd[1] = 12; // KERN_CLOCKRATE
5151
len = sizeof(clock);
52-
if (sysctl(cmd, 2, &clock, &len, NULL, 0) != -1) {
52+
if (sys_sysctl(cmd, 2, &clock, &len, NULL, 0) != -1) {
5353
x = clock.hz;
5454
} else {
5555
x = -1;

libc/runtime/clone.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
│ PERFORMANCE OF THIS SOFTWARE. │
1818
╚─────────────────────────────────────────────────────────────────────────────*/
1919
#include "libc/calls/calls.h"
20-
#include "libc/intrin/strace.internal.h"
2120
#include "libc/calls/struct/ucontext-netbsd.internal.h"
2221
#include "libc/calls/syscall-sysv.internal.h"
2322
#include "libc/dce.h"
2423
#include "libc/errno.h"
2524
#include "libc/intrin/asan.internal.h"
25+
#include "libc/intrin/strace.internal.h"
2626
#include "libc/limits.h"
2727
#include "libc/macros.internal.h"
2828
#include "libc/nt/runtime.h"
@@ -200,7 +200,7 @@ static int CloneXnu(int (*fn)(void *), char *stk, size_t stksz, int flags,
200200
static int broken;
201201
struct CloneArgs *wt;
202202
if (!once) {
203-
if (bsdthread_register(XnuThreadThunk, 0, 0, 0, 0, 0, 0) == -1) {
203+
if (sys_bsdthread_register(XnuThreadThunk, 0, 0, 0, 0, 0, 0) == -1) {
204204
broken = errno;
205205
}
206206
once = true;
@@ -217,7 +217,8 @@ static int CloneXnu(int (*fn)(void *), char *stk, size_t stksz, int flags,
217217
wt->ztid = flags & CLONE_CHILD_CLEARTID ? ctid : &wt->tid;
218218
wt->tls = flags & CLONE_SETTLS ? tls : 0;
219219
wt->lock._lock = 1;
220-
if ((rc = bsdthread_create(fn, arg, wt, 0, PTHREAD_START_CUSTOM_XNU)) != -1) {
220+
if ((rc = sys_bsdthread_create(fn, arg, wt, 0, PTHREAD_START_CUSTOM_XNU)) !=
221+
-1) {
221222
pthread_spin_lock(&wt->lock);
222223
rc = wt->tid;
223224
pthread_spin_unlock(&wt->lock);

0 commit comments

Comments
 (0)