From 4067cb45cb877501e8a9ed791fbcb92b3ab94d10 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 28 Nov 2019 02:35:52 +0100 Subject: [PATCH] libc: refactoring --- arch/amd64/include/cflags.json | 1 - arch/amd64/include/limits.h | 102 ++++++++++++++++++++++ qa/gnu/gcc/rune.c | 10 +-- qa/kern/alarm.c | 6 +- qa/kern/awake.c | 26 +++--- qa/kern/awake_note0.c | 10 +-- qa/kern/awake_note1.c | 10 +-- qa/kern/brk.c | 2 +- qa/kern/devshr.rc | 4 +- qa/kern/dup.c | 22 ++--- qa/kern/float.c | 4 +- qa/kern/fork.c | 4 +- qa/kern/fork_chain.c | 22 ++--- qa/kern/frexp.c | 4 +- qa/kern/getpid.c | 10 +-- qa/kern/getppid.c | 12 +-- qa/kern/memoryisolation.c | 8 +- qa/kern/memoryshare.c | 8 +- qa/kern/nested_note.c | 8 +- qa/kern/noexecmem.c | 24 +++--- qa/kern/notify.c | 4 +- qa/kern/nsclone.c | 42 ++++----- qa/kern/pipering.c | 10 +-- qa/kern/postnote.c | 8 +- qa/kern/psx.c | 2 +- qa/kern/sched0.c | 10 +-- qa/kern/stop_start.c | 6 +- qa/kern/syscall.c | 6 +- qa/kern/sysstatread.c | 6 +- qa/kern/tsemacquire.c | 18 ++-- qa/kern/waserror.c | 6 +- qa/lib/c/asmscall.c | 2 +- qa/lib/c/conswrite.c | 2 +- qa/lib/c/hcube.c | 44 +++++----- qa/lib/c/lockt.c | 8 +- qa/lib/c/privates2.c | 10 +-- qa/lib/c/qlockt0.c | 10 +-- qa/lib/c/qlockt1.c | 10 +-- qa/lib/c/qlockt2.c | 10 +-- qa/lib/c/rlockt0.c | 10 +-- qa/lib/c/rlockt1.c | 10 +-- qa/lib/c/rlockt2.c | 10 +-- qa/lib/c/rsleept0.c | 10 +-- qa/lib/c/rsleept1.c | 10 +-- qa/lib/c/rsleept2.c | 10 +-- qa/lib/c/rwakeup0.c | 30 +++---- qa/lib/c/rwakeup1.c | 24 +++--- qa/lib/c/sleep.c | 6 +- qa/lib/c/sleep2.c | 6 +- qa/lib/c/wlockt0.c | 10 +-- qa/lib/c/wlockt1.c | 10 +-- qa/lib/c/wlockt2.c | 10 +-- qa/lib/newlib/104-files-nonblocking.c | 8 +- qa/lib/newlib/121-fcntl.c | 10 +-- qa/lib/newlib/200-signals.c | 8 +- qa/lib/newlib/201-signals.c | 8 +- qa/lib/newlib/202-signals.c | 9 +- qa/lib/newlib/203-signals.c | 9 +- qa/lib/newlib/204-signals.c | 8 +- qa/lib/newlib/build.json | 16 ++-- qa/lib/newlib/testsuite/build.json | 8 +- sys/include/apw/errno.h | 18 +++- sys/include/apw/limits.h | 119 ++++++++++++++++++++++++++ sys/include/apw/stdio.h | 7 +- sys/include/apw/stdlib.h | 6 +- sys/include/apw/string.h | 6 +- sys/include/apw/sys/types.h | 6 +- sys/include/apw/unistd.h | 6 +- sys/include/posix.h | 4 +- sys/src/lib/c/9sys/pexec.c | 2 +- sys/src/lib/c/amd64/initlib.c | 10 ++- sys/src/lib/posix/files.c | 6 +- sys/src/lib/posix/kill.c | 4 +- sys/src/lib/posix/processes.c | 2 +- sys/src/lib/posix/sigqueue.c | 4 +- 75 files changed, 596 insertions(+), 355 deletions(-) create mode 100644 arch/amd64/include/limits.h create mode 100644 sys/include/apw/limits.h diff --git a/arch/amd64/include/cflags.json b/arch/amd64/include/cflags.json index a252393..5ef1b69 100644 --- a/arch/amd64/include/cflags.json +++ b/arch/amd64/include/cflags.json @@ -1,7 +1,6 @@ { "buildflags": { "Cflags": [ - "--sysroot=$JEHANNE", "-fno-builtin", "-fno-omit-frame-pointer", "-fplan9-extensions", diff --git a/arch/amd64/include/limits.h b/arch/amd64/include/limits.h new file mode 100644 index 0000000..408cf5a --- /dev/null +++ b/arch/amd64/include/limits.h @@ -0,0 +1,102 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2016-2019 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ + +#ifndef _JEHANNE_LIMITS_H +#define _JEHANNE_LIMITS_H + +#undef CHAR_BIT +#define CHAR_BIT __CHAR_BIT__ + +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 4 /* UTFmax in libc.h */ +#endif + +#define SCHAR_MAX 127 +#define SCHAR_MIN (-128) + +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +/* Jehanne's chars are signed */ +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX + +#define SHRT_MIN (-32768) +#define SHRT_MAX 32767 + +#define USHRT_MAX 65535 + +#define INT_MIN (-INT_MAX - 1) +#define INT_MAX 2147483647 + +#define UINT_MAX 4294967295U + +#define LONG_MAX 9223372036854775807L +#define LONG_MIN (-LONG_MAX - 1L) + +#define ULONG_MAX 18446744073709551615UL + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* Minimum and maximum values a `signed long long int' can hold. */ +#define LLONG_MAX 9223372036854775807LL +#define LLONG_MIN (-LLONG_MAX - 1LL) + +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ +# define ULLONG_MAX 18446744073709551615ULL + +# endif /* ISO C99 */ + +#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) +/* Minimum and maximum values a `signed long long int' can hold. */ +# undef LONG_LONG_MIN +# define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL) +# undef LONG_LONG_MAX +# define LONG_LONG_MAX 9223372036854775807L + +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ +# undef ULONG_LONG_MAX +# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL) +#endif + +#ifdef __STDC_WANT_IEC_60559_BFP_EXT__ +/* TS 18661-1 widths of integer types. */ +# undef CHAR_WIDTH +# define CHAR_WIDTH 8 +# undef SCHAR_WIDTH +# define SCHAR_WIDTH 8 +# undef UCHAR_WIDTH +# define UCHAR_WIDTH 8 +# undef SHRT_WIDTH +# define SHRT_WIDTH 16 +# undef USHRT_WIDTH +# define USHRT_WIDTH 16 +# undef INT_WIDTH +# define INT_WIDTH 32 +# undef UINT_WIDTH +# define UINT_WIDTH 32 +# undef LONG_WIDTH +# define LONG_WIDTH 64 +# undef ULONG_WIDTH +# define ULONG_WIDTH 64 +# undef LLONG_WIDTH +# define LLONG_WIDTH 64 +# undef ULLONG_WIDTH +# define ULLONG_WIDTH 64 +#endif + +#endif /* _LIMITS_H___ */ diff --git a/qa/gnu/gcc/rune.c b/qa/gnu/gcc/rune.c index d5b4855..55eaf35 100644 --- a/qa/gnu/gcc/rune.c +++ b/qa/gnu/gcc/rune.c @@ -32,20 +32,20 @@ main(void) print("FAIL: open: %r\n"); exits("FAIL"); } - if(write(fd, r, sizeof(r)) < 0){ + if(jehanne_write(fd, r, sizeof(r)) < 0){ print("FAIL: fprint: %r\n"); exits("FAIL"); } - close(fd); - if((fd = open("/tmp/runetest.txt", OREAD)) < 0) { + sys_close(fd); + if((fd = sys_open("/tmp/runetest.txt", OREAD)) < 0) { print("FAIL: open: %r\n"); exits("FAIL"); } - if(read(fd, (char*)buf, sizeof(buf)) < 0){ + if(jehanne_read(fd, (char*)buf, sizeof(buf)) < 0){ print("FAIL: read: %r\n"); exits("FAIL"); } - close(fd); + sys_close(fd); if (runestrcmp(r, buf) != 0){ print("FAIL: got '%S' instead of '%S'.\n", buf, r); exits("FAIL"); diff --git a/qa/kern/alarm.c b/qa/kern/alarm.c index fb19aa9..a6a07da 100644 --- a/qa/kern/alarm.c +++ b/qa/kern/alarm.c @@ -68,12 +68,12 @@ main(void) exits("atnotify fails"); } - alarm(2000); + sys_alarm(2000); a2000 = nsec(); - alarm(500); + sys_alarm(500); a500 = nsec(); - rendezvous(&a500, (void*)0x123); + sys_rendezvous(&a500, (void*)0x123); if(verbose) fprint(2, "%d: set alarm(2000)@%lld then alarm(500)@%lld; received after %lld nanosecond\n", getpid(), a2000, a500, alarmReceived-a500); diff --git a/qa/kern/awake.c b/qa/kern/awake.c index 9d7e9d3..a5eb122 100644 --- a/qa/kern/awake.c +++ b/qa/kern/awake.c @@ -40,7 +40,7 @@ writeTillBlock(int fd) memset(buf, 1, sizeof(buf)); while(i < 300) /* pipes should block after at most 256kb */ { - if(write(fd, buf, sizeof(buf)) < 0){ + if(jehanne_write(fd, buf, sizeof(buf)) < 0){ break; } ++i; @@ -56,21 +56,21 @@ main(void) int fds[2]; char buf[1]; - semacquire(&sem, 0); + sys_semacquire(&sem, 0); - alarm(40000); /* global timeout, FAIL if reached */ + sys_alarm(40000); /* global timeout, FAIL if reached */ if (!atnotify(failOnTimeout, 1)){ fprint(2, "%r\n"); exits("atnotify fails"); } - awake(100000); /* this will be handled by the kernel, see pexit */ + sys_awake(100000); /* this will be handled by the kernel, see pexit */ /* verify that rendezvous are interrupted */ fprint(2, "verify that rendezvous are interrupted\n", elapsed); - wkup = awake(1000); + wkup = sys_awake(1000); start = nsec(); - res = (int64_t)rendezvous(&elapsed, (void*)0x12345); + res = (int64_t)sys_rendezvous(&elapsed, (void*)0x12345); elapsed = (nsec() - start) / (1000 * 1000); if(verbose) fprint(2, "rendezvous interrupted, returned %#p, elapsed = %d ms\n", res, elapsed); @@ -82,7 +82,7 @@ main(void) /* verify that sleeps are NOT interrupted */ fprint(2, "verify that sleeps are NOT interrupted\n", elapsed); - wkup = awake(700); + wkup = sys_awake(700); start = nsec(); sleep(1500); elapsed = (nsec() - start) / (1000 * 1000); @@ -97,11 +97,11 @@ main(void) /* verify that semacquires are interrupted */ fprint(2, "verify that semacquires are interrupted\n", elapsed); pipe(fds); - wkup = awake(1000); + wkup = sys_awake(1000); start = nsec(); if(verbose) print("semacquire(&sem, 1)...\n"); - res = semacquire(&sem, 1); + res = sys_semacquire(&sem, 1); elapsed = (nsec() - start) / (1000 * 1000); if(verbose) print("semacquire(&sem, 1): returned %lld, elapsed = %d ms\n", res, elapsed); @@ -114,7 +114,7 @@ main(void) /* verify that tsemacquire are NOT interrupted */ fprint(2, "verify that tsemacquire are NOT interrupted\n", elapsed); start = nsec(); - wkup = awake(500); + wkup = sys_awake(500); res = tsemacquire(&sem, 1500); elapsed = (nsec() - start) / (1000 * 1000); if(verbose) @@ -131,9 +131,9 @@ main(void) print("FAIL: pipe\n"); exits("FAIL"); } - wkup = awake(1000); + wkup = sys_awake(1000); start = nsec(); - res = read(fds[0], buf, 1); + res = jehanne_read(fds[0], buf, 1); elapsed = (nsec() - start) / (1000 * 1000); if(verbose) fprint(2, "read(fds[0], buf, 1) returned %lld, elapsed = %d ms\n", res, elapsed); @@ -149,7 +149,7 @@ main(void) print("FAIL: pipe\n"); exits("FAIL"); } - wkup = awake(1000); + wkup = sys_awake(1000); start = nsec(); res = writeTillBlock(fds[0]); elapsed = (nsec() - start) / (1000 * 1000); diff --git a/qa/kern/awake_note0.c b/qa/kern/awake_note0.c index 49d382a..57af907 100644 --- a/qa/kern/awake_note0.c +++ b/qa/kern/awake_note0.c @@ -22,8 +22,8 @@ void handler(void *v, char *s) { int64_t wakeup; - wakeup = awake(1000); - while(rendezvous(&wakeup, (void*)1) == (void*)~0) + wakeup = sys_awake(1000); + while(sys_rendezvous(&wakeup, (void*)1) == (void*)~0) if(jehanne_awakened(wakeup)){ print("PASS\n"); exits(nil); @@ -39,12 +39,12 @@ main(int argc, char**argv) if(argc > 1){ fd = ocreate(argv[1], OWRITE, 0666); dup(fd, 1); - close(fd); + sys_close(fd); } - if (notify(handler)){ + if (sys_notify(handler)){ fprint(2, "%r\n"); - exits("notify fails"); + exits("sys_notify fails"); } print("%s %d: waiting for note", argv[0], getpid()); diff --git a/qa/kern/awake_note1.c b/qa/kern/awake_note1.c index 7c7321d..33f971d 100644 --- a/qa/kern/awake_note1.c +++ b/qa/kern/awake_note1.c @@ -22,8 +22,8 @@ void handler(void *v, char *s) { int64_t wakeup; - wakeup = awake(1000); - while(rendezvous(&wakeup, (void*)1) == (void*)~0) + wakeup = sys_awake(1000); + while(sys_rendezvous(&wakeup, (void*)1) == (void*)~0) if(jehanne_awakened(wakeup)){ print("PASS\n"); exits(nil); @@ -40,12 +40,12 @@ main(int argc, char**argv) if(argc > 1){ fd = ocreate(argv[1], OWRITE, 0666); dup(fd, 1); - close(fd); + sys_close(fd); } - if (notify(handler)){ + if (sys_notify(handler)){ fprint(2, "%r\n"); - exits("notify fails"); + exits("sys_notify fails"); } print("%s %d: waiting for note", argv[0], getpid()); diff --git a/qa/kern/brk.c b/qa/kern/brk.c index 26bdbf6..a9897e0 100644 --- a/qa/kern/brk.c +++ b/qa/kern/brk.c @@ -23,7 +23,7 @@ main(void) { long b, b1; - b = create("#0/brk/set", -1, 16*1024*1024); + b = sys_create("#0/brk/set", -1, 16*1024*1024); if(b >= 0){ print("FAIL: create returned fd %d.\n", b); exits("FAIL"); diff --git a/qa/kern/devshr.rc b/qa/kern/devshr.rc index 27c62b7..50a810d 100755 --- a/qa/kern/devshr.rc +++ b/qa/kern/devshr.rc @@ -1,8 +1,8 @@ #!/cmd/rc -rfork +sys_rfork -@{rfork n; mkdir '#σc'/testshr; ramfs -S testshr; echo 3 > '#σc'/testshr/ramfs <>[3]/srv/testshr; echo PASS > '#σ'/testshr/file } +@{sys_rfork n; mkdir '#σc'/testshr; ramfs -S testshr; echo 3 > '#σc'/testshr/ramfs <>[3]/srv/testshr; echo PASS > '#σ'/testshr/file } bind '#σ' /shr diff --git a/qa/kern/dup.c b/qa/kern/dup.c index d464c22..5788863 100644 --- a/qa/kern/dup.c +++ b/qa/kern/dup.c @@ -27,41 +27,41 @@ main(void) char buf[256]; int fd, r; - fd = open("/fd/0ctl", OREAD|OCEXEC); + fd = sys_open("/fd/0ctl", OREAD|OCEXEC); if(fd < 0) goto Fail; - r = read(fd, buf, sizeof(buf)); + r = jehanne_read(fd, buf, sizeof(buf)); if(r < 0) goto Fail; - close(fd); + sys_close(fd); print("Got 0ctl: %s\n", buf); - fd = open("/fd/1ctl", OREAD|OCEXEC); + fd = sys_open("/fd/1ctl", OREAD|OCEXEC); if(fd < 0) goto Fail; - r = read(fd, buf, sizeof(buf)); + r = jehanne_read(fd, buf, sizeof(buf)); if(r < 0) goto Fail; - close(fd); + sys_close(fd); print("Got 1ctl: %s\n", buf); - fd = open("/fd/2ctl", OREAD|OCEXEC); + fd = sys_open("/fd/2ctl", OREAD|OCEXEC); if(fd < 0) goto Fail; - r = read(fd, buf, sizeof(buf)); + r = jehanne_read(fd, buf, sizeof(buf)); if(r < 0) goto Fail; print("Got 2ctl: %s\n", buf); snprint(buf, sizeof(buf), "/fd/%dctl", fd); - fd = open(buf, OREAD); + fd = sys_open(buf, OREAD); if(fd < 0) goto Fail; - r = read(fd, buf, sizeof(buf)); + r = jehanne_read(fd, buf, sizeof(buf)); if(r < 0) goto Fail; print("Got: %s\n", buf); - close(fd); + sys_close(fd); exits(nil); Fail: diff --git a/qa/kern/float.c b/qa/kern/float.c index 351484d..fedd3e4 100644 --- a/qa/kern/float.c +++ b/qa/kern/float.c @@ -17,7 +17,7 @@ catcher(void *u, char *s) err = s; notejmp(u, errj, 0); } - noted(NDFLT); + sys_noted(NDFLT); } void @@ -56,7 +56,7 @@ main(void) q = d2l.l; err = 0; - notify(catcher); + sys_notify(catcher); setjmp(errj); if(err){ fprint(2, "FAIL: %s\n", err); diff --git a/qa/kern/fork.c b/qa/kern/fork.c index 0df2941..25a1880 100644 --- a/qa/kern/fork.c +++ b/qa/kern/fork.c @@ -15,9 +15,9 @@ main(void) { static int c; int pid; - pid = rfork(RFMEM|RFPROC); + pid = sys_rfork(RFMEM|RFPROC); if (pid < 0) { - print("FAIL: rfork\n"); + print("FAIL: sys_rfork\n"); exits("FAIL"); } if (pid > 0) { diff --git a/qa/kern/fork_chain.c b/qa/kern/fork_chain.c index d5b0f8b..f32e9ae 100644 --- a/qa/kern/fork_chain.c +++ b/qa/kern/fork_chain.c @@ -21,8 +21,8 @@ int r1; int r2; -#define CHILD_READY(pid) ((long)rendezvous(&r1, (void*)(~(pid)))) -//#define C2P_READY(pid) ((long)rendezvous(&r2, (void*)(~(pid)))) +#define CHILD_READY(pid) ((long)sys_rendezvous(&r1, (void*)(~(pid)))) +//#define C2P_READY(pid) ((long)sys_rendezvous(&r2, (void*)(~(pid)))) int *__target_pid; @@ -30,7 +30,7 @@ static void forwarding_note_handler(void *ureg, char *note) { postnote(PNPROC, *__target_pid, note); - noted(NDFLT); + sys_noted(NDFLT); } static void @@ -49,24 +49,24 @@ crazy_fork(void) int p2c; long c2p = -1, child = -1; - switch(p2c = rfork(RFPROC|RFMEM)){ + switch(p2c = sys_rfork(RFPROC|RFMEM)){ case -1: return -1; case 0: - switch(c2p = rfork(RFPROC|RFMEM)){ + switch(c2p = sys_rfork(RFPROC|RFMEM)){ case -1: - exits("rfork (c2p)"); + exits("sys_rfork (c2p)"); case 0: switch(child = fork()){ case -1: - exits("rfork (child)"); + exits("sys_rfork (child)"); case 0: return 0; default: while(CHILD_READY(child) == -1) ; *__target_pid = father; - notify(forwarding_note_handler); + sys_notify(forwarding_note_handler); donothing(); } default: @@ -74,7 +74,7 @@ crazy_fork(void) ; child = ~child; *__target_pid = child; - notify(forwarding_note_handler); + sys_notify(forwarding_note_handler); donothing(); } default: @@ -113,13 +113,13 @@ main(void) case 0: print("child is %d; child's parent is %d\n", getpid(), getppid()); *__target_pid = getppid(); - notify(forwarding_note_handler); + sys_notify(forwarding_note_handler); /* wait to be killed */ donothing(); break; default: print("father is %d; forked child is %d\n", getpid(), c); - sleep(1000); /* give children time to notify() */ + sleep(1000); /* give children time to sys_notify() */ print("starting note chain\n"); postnote(PNPROC, c, "die"); /* wait to be killed by the chain */ diff --git a/qa/kern/frexp.c b/qa/kern/frexp.c index 7369c45..85c283f 100644 --- a/qa/kern/frexp.c +++ b/qa/kern/frexp.c @@ -18,7 +18,7 @@ catcher(void *u, char *s) err = s; notejmp(u, errj, 0); } - noted(NDFLT); + sys_noted(NDFLT); } void @@ -51,7 +51,7 @@ main(void) int exp; err = 0; - notify(catcher); + sys_notify(catcher); setjmp(errj); if(err){ print("FAIL: %s\n", err); diff --git a/qa/kern/getpid.c b/qa/kern/getpid.c index 487edb2..e1510ef 100644 --- a/qa/kern/getpid.c +++ b/qa/kern/getpid.c @@ -23,21 +23,21 @@ main(void) { int pid; - rfork(RFNAMEG); + sys_rfork(RFNAMEG); pid = getmainpid(); // this comes from exec() syscall if(getpid() != pid){ print("FAIL: getpid() != getmainpid()\n"); exits("FAIL"); } - rfork(RFNOMNT); + sys_rfork(RFNOMNT); if(getpid() != pid){ - print("FAIL: rfork(RFNOMNT); getpid() != getmainpid()\n"); + print("FAIL: sys_rfork(RFNOMNT); getpid() != getmainpid()\n"); exits("FAIL"); } - rfork(RFNOMNT|RFCNAMEG); + sys_rfork(RFNOMNT|RFCNAMEG); if(getpid() != pid){ - print("FAIL: rfork(RFNOMNT|RFCNAMEG)); getpid() != getmainpid()\n"); + print("FAIL: sys_rfork(RFNOMNT|RFCNAMEG)); getpid() != getmainpid()\n"); exits("FAIL"); } diff --git a/qa/kern/getppid.c b/qa/kern/getppid.c index 32ba9ff..01637e1 100644 --- a/qa/kern/getppid.c +++ b/qa/kern/getppid.c @@ -24,22 +24,22 @@ main(void) int ppid; Waitmsg *w; - rfork(RFNAMEG); - if(rfork(RFPROC) == 0){ + sys_rfork(RFNAMEG); + if(sys_rfork(RFPROC) == 0){ ppid = getmainpid(); // this comes from exec() syscall if(getppid() != ppid){ print("FAIL: getppid() != getmainpid()\n"); exits("FAIL"); } - rfork(RFNOMNT); + sys_rfork(RFNOMNT); if(getppid() != ppid){ - print("FAIL: rfork(RFNOMNT); getppid() != getmainpid()\n"); + print("FAIL: sys_rfork(RFNOMNT); getppid() != getmainpid()\n"); exits("FAIL"); } - rfork(RFNOMNT|RFCNAMEG); + sys_rfork(RFNOMNT|RFCNAMEG); if(getppid() != ppid){ - print("FAIL: rfork(RFNOMNT|RFCNAMEG)); getppid() != getmainpid()\n"); + print("FAIL: sys_rfork(RFNOMNT|RFCNAMEG)); getppid() != getmainpid()\n"); exits("FAIL"); } exits(nil); diff --git a/qa/kern/memoryisolation.c b/qa/kern/memoryisolation.c index 5385ecc..4ed84b7 100644 --- a/qa/kern/memoryisolation.c +++ b/qa/kern/memoryisolation.c @@ -48,9 +48,9 @@ main(void) pipe(p); memset(buf, 0, sizeof buf); - switch((pid = rfork(RFPROC))){ + switch((pid = sys_rfork(RFPROC))){ case -1: - fprint(2, "FAIL: rfork: %r\n"); + fprint(2, "FAIL: sys_rfork: %r\n"); exits("FAIL"); break; case 0: @@ -60,7 +60,7 @@ main(void) fprint(2, "address %p, msg %s\n", msg, msg); fprint(2, "sending %s\n", buf); } - if(write(p[0], buf, i) < 0){ + if(jehanne_write(p[0], buf, i) < 0){ fprint(2, "FAIL: write: %r\n"); exits("FAIL"); } @@ -69,7 +69,7 @@ main(void) default: buf[0] = '0'; buf[1] = 'x'; - if((i = read(p[1], buf+2, (sizeof buf) - 2)) <= 0){ + if((i = jehanne_read(p[1], buf+2, (sizeof buf) - 2)) <= 0){ fprint(2, "FAIL: read: %r\n"); exits("FAIL"); } diff --git a/qa/kern/memoryshare.c b/qa/kern/memoryshare.c index 58f796d..ba2a026 100644 --- a/qa/kern/memoryshare.c +++ b/qa/kern/memoryshare.c @@ -48,9 +48,9 @@ main(void) pipe(p); memset(buf, 0, sizeof buf); - switch((pid = rfork(RFPROC|RFMEM))){ + switch((pid = sys_rfork(RFPROC|RFMEM))){ case -1: - fprint(2, "FAIL: rfork: %r\n"); + fprint(2, "FAIL: sys_rfork: %r\n"); exits("FAIL"); break; case 0: @@ -60,7 +60,7 @@ main(void) fprint(2, "address %p, msg %s\n", msg, msg); fprint(2, "sending %s\n", buf); } - if(write(p[0], buf, i) < 0){ + if(jehanne_write(p[0], buf, i) < 0){ fprint(2, "FAIL: write: %r\n"); exits("FAIL"); } @@ -69,7 +69,7 @@ main(void) default: buf[0] = '0'; buf[1] = 'x'; - if((i = read(p[1], buf+2, (sizeof buf) - 2)) <= 0){ + if((i = jehanne_read(p[1], buf+2, (sizeof buf) - 2)) <= 0){ fprint(2, "FAIL: read: %r\n"); exits("FAIL"); } diff --git a/qa/kern/nested_note.c b/qa/kern/nested_note.c index fac5f06..d93826d 100644 --- a/qa/kern/nested_note.c +++ b/qa/kern/nested_note.c @@ -37,7 +37,7 @@ handler(void *v, char *s) print("wait after %s terminated\n", s); waited++; } - noted(NCONT); + sys_noted(NCONT); } void @@ -47,12 +47,12 @@ main(int argc, char**argv) if(argc > 1){ fd = ocreate(argv[1], OWRITE, 0666); dup(fd, 1); - close(fd); + sys_close(fd); } - if (notify(handler)){ + if (sys_notify(handler)){ fprint(2, "%r\n"); - exits("notify fails"); + exits("sys_notify fails"); } print("note handler installed\n"); diff --git a/qa/kern/noexecmem.c b/qa/kern/noexecmem.c index 55101bf..ad08300 100644 --- a/qa/kern/noexecmem.c +++ b/qa/kern/noexecmem.c @@ -16,9 +16,9 @@ void callinsn(char *name, char *buf) { void (*f)(void); - if (notify(handler)){ + if (sys_notify(handler)){ fprint(2, "%r\n"); - exits("notify fails"); + exits("sys_notify fails"); } @@ -31,9 +31,9 @@ callinsn(char *name, char *buf) void writeptr(char *name, void *ptr) { - if (notify(handler)){ + if (sys_notify(handler)){ fprint(2, "%r\n"); - exits("notify fails"); + exits("sys_notify fails"); } *(uintptr_t*)ptr = 0xdeadbeef; @@ -48,9 +48,9 @@ main(void) char stk[128]; char *mem; - switch(rfork(RFMEM|RFPROC)){ + switch(sys_rfork(RFMEM|RFPROC)){ case -1: - sysfatal("rfork"); + sysfatal("sys_rfork"); case 0: stk[0] = RET; callinsn("exec stack", stk); @@ -59,9 +59,9 @@ main(void) waitpid(); } - switch(rfork(RFMEM|RFPROC)){ + switch(sys_rfork(RFMEM|RFPROC)){ case -1: - sysfatal("rfork"); + sysfatal("sys_rfork"); case 0: mem = malloc(128); mem[0] = RET; @@ -71,9 +71,9 @@ main(void) waitpid(); } - switch(rfork(RFMEM|RFPROC)){ + switch(sys_rfork(RFMEM|RFPROC)){ case -1: - sysfatal("rfork"); + sysfatal("sys_rfork"); case 0: writeptr("write code", (void*)&main); default: @@ -81,9 +81,9 @@ main(void) waitpid(); } - switch(rfork(RFMEM|RFPROC)){ + switch(sys_rfork(RFMEM|RFPROC)){ case -1: - sysfatal("rfork"); + sysfatal("sys_rfork"); case 0: writeptr("write rodata", (void*)str); default: diff --git a/qa/kern/notify.c b/qa/kern/notify.c index 7881c7b..010a1a1 100644 --- a/qa/kern/notify.c +++ b/qa/kern/notify.c @@ -13,9 +13,9 @@ void main(void) { void (*f)(void) = nil; - if (notify(handler)){ + if (sys_notify(handler)){ fprint(2, "%r\n"); - exits("notify fails"); + exits("sys_notify fails"); } f(); diff --git a/qa/kern/nsclone.c b/qa/kern/nsclone.c index 09fd300..79303da 100644 --- a/qa/kern/nsclone.c +++ b/qa/kern/nsclone.c @@ -24,20 +24,20 @@ void setup_ns(void) { int fd; - if(bind("#|", "/", MREPL) < 0){ - print("FAIL: rfork\n"); - write(sync[0], "FAIL", 5); + if(sys_bind("#|", "/", MREPL) < 0){ + print("FAIL: sys_rfork\n"); + jehanne_write(sync[0], "FAIL", 5); return; } - fd = open("/data", OWRITE); + fd = sys_open("/data", OWRITE); if(fd < 0){ - print("FAIL: open(/data)\n"); - write(sync[0], "FAIL", 5); + print("FAIL: sys_open(/data)\n"); + jehanne_write(sync[0], "FAIL", 5); return; } - write(fd, "hi!", 4); - close(fd); - write(sync[0], "DONE", 5); + jehanne_write(fd, "hi!", 4); + sys_close(fd); + jehanne_write(sync[0], "DONE", 5); sleep(10); } @@ -47,12 +47,12 @@ main(void) int child, fd; char buf[64]; - rfork(RFNOTEG|RFNAMEG); + sys_rfork(RFNOTEG|RFNAMEG); pipe(sync); - switch(child = rfork(RFPROC|RFCNAMEG|RFNOWAIT)){ + switch(child = sys_rfork(RFPROC|RFCNAMEG|RFNOWAIT)){ case -1: - print("FAIL: rfork\n"); + print("FAIL: sys_rfork\n"); exits("FAIL"); case 0: setup_ns(); @@ -61,27 +61,27 @@ main(void) break; } - read(sync[1], buf, sizeof(buf)); + jehanne_read(sync[1], buf, sizeof(buf)); if(strcmp("DONE", buf) != 0) exits("FAIL"); snprint(buf, sizeof(buf), "/proc/%d/ns", child); - fd = open(buf, OWRITE); + fd = sys_open(buf, OWRITE); if(fd < 0){ - print("FAIL: open(%s)\n", buf); + print("FAIL: sys_open(%s)\n", buf); exits("FAIL"); } - write(fd, "clone", 6); - close(fd); + jehanne_write(fd, "clone", 6); + sys_close(fd); memset(buf, 0, sizeof(buf)); - fd = open("/data1", OREAD); + fd = sys_open("/data1", OREAD); if(fd < 0){ - print("FAIL: open(/data1)\n"); + print("FAIL: sys_open(/data1)\n"); exits("FAIL"); } - read(fd, buf, sizeof(buf)); - close(fd); + jehanne_read(fd, buf, sizeof(buf)); + sys_close(fd); if(strcmp("hi!", buf) == 0){ print("PASS: read '%s' from /data1\n", buf); diff --git a/qa/kern/pipering.c b/qa/kern/pipering.c index a9e17e8..2359513 100644 --- a/qa/kern/pipering.c +++ b/qa/kern/pipering.c @@ -14,7 +14,7 @@ handler(void *v, char *s) { print("%d: %d iterations\n", id, i); if (intr++ < 16) - noted(NCONT); + sys_noted(NCONT); exits("too many interrupts"); } @@ -23,8 +23,8 @@ main(int argc, char *argv[]) { int pid; - if (notify(handler)){ - sysfatal("notify: %r"); + if (sys_notify(handler)){ + sysfatal("sys_notify: %r"); } if (argc > 1) @@ -57,11 +57,11 @@ main(int argc, char *argv[]) for(i = 0; debug && i < nring; i++ ) fprint(2, "pfd[%d,%d]\n", pfd[i*2],pfd[i*2+1]); for(i = 0; i < niter; i++) { if (debug) fprint(2, "%d: write %d\n", id, pfd[(id%nring)*2+1]); - int amt = write(pfd[(id%nring)*2+1], data, sizeof(data)); + int amt = jehanne_write(pfd[(id%nring)*2+1], data, sizeof(data)); if (amt < sizeof(data)) sysfatal(smprint("%d: write only got %d of %d: %r", id, amt, sizeof(data))); if (debug) print("%d: read %d\n", id, pfd[(id%nring)*2]); - amt = read(pfd[(id%nring)*2], data, sizeof(data)); + amt = jehanne_read(pfd[(id%nring)*2], data, sizeof(data)); if (amt < sizeof(data)) sysfatal(smprint("%d: read only got %d of %d: %r", id, amt, sizeof(data))); } diff --git a/qa/kern/postnote.c b/qa/kern/postnote.c index 0815005..d0bf61d 100644 --- a/qa/kern/postnote.c +++ b/qa/kern/postnote.c @@ -73,19 +73,19 @@ main(void) exits("atnotify fails"); } - rfork(RFNOTEG|RFNAMEG); + sys_rfork(RFNOTEG|RFNAMEG); - if(rfork(RFPROC) == 0){ + if(sys_rfork(RFPROC) == 0){ ppid = getppid(); // this comes from exec() syscall postnote(PNPROC, ppid, "proc"); postnote(PNGROUP, getpid(), "group"); - rfork(RFNOMNT); + sys_rfork(RFNOMNT); postnote(PNPROC, ppid, "proc"); postnote(PNGROUP, getpid(), "group"); - rfork(RFNOMNT|RFCNAMEG); + sys_rfork(RFNOMNT|RFCNAMEG); if(postnote(PNPROC, ppid, "proc") != -1 || postnote(PNGROUP, getpid(), "group") != -1){ exits("FAIL"); diff --git a/qa/kern/psx.c b/qa/kern/psx.c index b5cac3e..9a03884 100644 --- a/qa/kern/psx.c +++ b/qa/kern/psx.c @@ -27,7 +27,7 @@ main(int argc, char *argv[]) } if (pid == 0) { char *args[] = {"ps", nil}; - exec("/arch/amd64/cmd/ps", args); + sys_exec("/arch/amd64/cmd/ps", (const char **)args); fprint(2,"Exec fails: %r\n"); print("FAIL\n"); exits("FAIL"); diff --git a/qa/kern/sched0.c b/qa/kern/sched0.c index 781b90b..3550c39 100644 --- a/qa/kern/sched0.c +++ b/qa/kern/sched0.c @@ -27,10 +27,10 @@ int spin; void main(void) { - rfork(RFNOTEG); - switch(rfork(RFPROC|RFMEM)){ + sys_rfork(RFNOTEG); + switch(sys_rfork(RFPROC|RFMEM)){ case -1: - exits("rfork"); + exits("sys_rfork"); case 0: spin = 1; while(spin) @@ -40,9 +40,9 @@ main(void) while(spin == 0) ; } - switch(rfork(RFPROC|RFMEM)){ + switch(sys_rfork(RFPROC|RFMEM)){ case -1: - exits("rfork"); + exits("sys_rfork"); case 0: spin = 2; while(spin) diff --git a/qa/kern/stop_start.c b/qa/kern/stop_start.c index b921854..b3a2705 100644 --- a/qa/kern/stop_start.c +++ b/qa/kern/stop_start.c @@ -25,17 +25,17 @@ main(int argc, char**argv) char *path; path = smprint("/proc/%d/ctl", getpid()); - fd = open(path, OWRITE); + fd = sys_open(path, OWRITE); if(fd < 0){ print("FAIL: open"); exits("FAIL"); } - n = write(fd, "stop", 4); + n = jehanne_write(fd, "stop", 4); if(n < 0){ print("FAIL: write"); exits("FAIL"); } - close(fd); + sys_close(fd); print("PASS\n"); exits("PASS"); } diff --git a/qa/kern/syscall.c b/qa/kern/syscall.c index 222afbd..ad76dc5 100644 --- a/qa/kern/syscall.c +++ b/qa/kern/syscall.c @@ -11,14 +11,14 @@ main(void) fail = 0; for(i = 0; i < 10000; i++){ - fd = open("/proc/1/status", OREAD); - n = read(fd, buf, sizeof buf); + fd = sys_open("/proc/1/status", OREAD); + n = jehanne_read(fd, buf, sizeof buf); if(i != 0 && n != oldn){ fprint(2, "read %d, want %d\n", n, oldn); fail++; } oldn = n; - close(fd); + sys_close(fd); } print("PASS\n"); exits("PASS"); diff --git a/qa/kern/sysstatread.c b/qa/kern/sysstatread.c index a670cd2..78ece53 100644 --- a/qa/kern/sysstatread.c +++ b/qa/kern/sysstatread.c @@ -13,7 +13,7 @@ main(void) int fd, n; char buf[1]; - fd = open("/dev/sysstat", OREAD); + fd = sys_open("/dev/sysstat", OREAD); if(fd < 0){ print("FAIL: couldn't open /dev/sysstat: %r\n"); exits("FAIL"); @@ -21,13 +21,13 @@ main(void) ret = 0; for(;;){ - n = read(fd, buf, sizeof(buf)); + n = jehanne_read(fd, buf, sizeof(buf)); if(n <= 0) break; if(n > sizeof(buf)) ret = 1; } - close(fd); + sys_close(fd); if(ret){ print("FAIL: %d bytes read from /dev/sysstat\n", n); diff --git a/qa/kern/tsemacquire.c b/qa/kern/tsemacquire.c index 074dfba..9be5d82 100644 --- a/qa/kern/tsemacquire.c +++ b/qa/kern/tsemacquire.c @@ -17,7 +17,7 @@ tsemloop(void) sleep(10); incr++; i++; - semrelease(&x, 1); + sys_semrelease(&x, 1); } else { //print("pid %d timeout\n", getpid()); } @@ -31,10 +31,10 @@ semloop(void) int i; i = 0; while(i < nloops){ - if(semacquire(&x, 1)){ + if(sys_semacquire(&x, 1)){ incr++; i++; - semrelease(&x, 1); + sys_semrelease(&x, 1); } else { sysfatal("semacquire failed"); } @@ -49,9 +49,9 @@ main(void) incr = 0; for(i = 0; i < nprocs; i++){ - switch(rfork(RFMEM|RFPROC)){ + switch(sys_rfork(RFMEM|RFPROC)){ case -1: - sysfatal("rfork"); + sysfatal("sys_rfork"); case 0: tsemloop(); exits("PASS"); @@ -69,9 +69,9 @@ main(void) incr = 0; for(i = 0; i < nprocs; i++){ - switch(rfork(RFMEM|RFPROC)){ + switch(sys_rfork(RFMEM|RFPROC)){ case -1: - sysfatal("rfork"); + sysfatal("sys_rfork"); case 0: semloop(); exits("PASS"); @@ -89,9 +89,9 @@ main(void) incr = 0; for(i = 0; i < nprocs; i++){ - switch(rfork(RFMEM|RFPROC)){ + switch(sys_rfork(RFMEM|RFPROC)){ case -1: - sysfatal("rfork"); + sysfatal("sys_rfork"); case 0: if((i&1) == 0) semloop(); diff --git a/qa/kern/waserror.c b/qa/kern/waserror.c index 81a042a..72fca17 100644 --- a/qa/kern/waserror.c +++ b/qa/kern/waserror.c @@ -11,13 +11,13 @@ main(void) char buf[1]; int i; // Just to be sure. - if (close(3) >= 0) { - print("waserror: close of 3 did not get an error\n"); + if (sys_close(3) >= 0) { + print("waserror: sys_close of 3 did not get an error\n"); exits("FAIL"); } for(i = 0; i < 100000; i++) { - if (read(3, buf, 1) >= 0){ + if (jehanne_read(3, buf, 1) >= 0){ print("waserror: read of 3 did not get an error\n"); exits("FAIL"); } diff --git a/qa/lib/c/asmscall.c b/qa/lib/c/asmscall.c index 4093dbe..e808e8d 100644 --- a/qa/lib/c/asmscall.c +++ b/qa/lib/c/asmscall.c @@ -52,7 +52,7 @@ main(void) } int fd; - fd = open("#|", ORDWR); + fd = sys_open("#|", ORDWR); sys_mount(fd, -1, "/tmp", MREPL, "", 'M'); print("PASS\n"); diff --git a/qa/lib/c/conswrite.c b/qa/lib/c/conswrite.c index de5a244..9088e7a 100644 --- a/qa/lib/c/conswrite.c +++ b/qa/lib/c/conswrite.c @@ -29,7 +29,7 @@ main(void) memset(msg, '1', BUFSZ); - if((w = write(2, msg, BUFSZ)) < BUFSZ){ + if((w = jehanne_write(2, msg, BUFSZ)) < BUFSZ){ print("\nFAIL, written %d instead of %d\n", w, BUFSZ); exits("FAIL"); } diff --git a/qa/lib/c/hcube.c b/qa/lib/c/hcube.c index e032590..63c9398 100644 --- a/qa/lib/c/hcube.c +++ b/qa/lib/c/hcube.c @@ -20,40 +20,40 @@ fdfork(int fd, int post) if(pfd == -1) sysfatal("fdfork: create: %r"); snprint(buf, sizeof buf, "%d", ch[0]); - if(write(pfd, buf, strlen(buf)) != strlen(buf)){ - remove(path); + if(jehanne_write(pfd, buf, strlen(buf)) != strlen(buf)){ + sys_remove(path); sysfatal("fdfork: post '%s': %r", buf); } - close(ch[0]); + sys_close(ch[0]); - if(write(fd, path, len) != len){ - remove(path); + if(jehanne_write(fd, path, len) != len){ + sys_remove(path); sysfatal("fdfork: write to peer: %r"); } - len = read(fd, buf, sizeof buf-1); + len = jehanne_read(fd, buf, sizeof buf-1); if(len <= 0){ - remove(path); + sys_remove(path); sysfatal("fdfork: read ack: %s from peer: %r", len == -1 ? "error" : "eof"); } buf[len] = '\0'; if(strcmp(path, buf)){ - remove(path); + sys_remove(path); print("ack from wrong peer: got '%s' want '%s'\n", buf, path); sysfatal("ack from wrong peer"); } - close(pfd); - //remove(path); + sys_close(pfd); + //sys_remove(path); return ch[1]; } else { - len = read(fd, path, sizeof path-1); + len = jehanne_read(fd, path, sizeof path-1); if(len <= 0) sysfatal("fdfork: read path: %s from peer: %r", len == -1 ? "error" : "eof"); path[len] = '\0'; - pfd = open(path, OWRITE); + pfd = sys_open(path, OWRITE); if(pfd == -1) sysfatal("fdfork: open: %r"); - if(write(fd, path, len) != len) + if(jehanne_write(fd, path, len) != len) sysfatal("fdfork: write ack to peer: %r"); return pfd; @@ -61,7 +61,7 @@ fdfork(int fd, int post) } int -hyperfork(int *fd, int id, int dim) +hypesys_rfork(int *fd, int id, int dim) { int chfd[dim]; int ch[2]; @@ -72,20 +72,20 @@ hyperfork(int *fd, int id, int dim) pipe(ch); switch(fork()){ case -1: - sysfatal("rfork"); + sysfatal("sys_rfork"); case 0: for(i = 0; i < dim; i++){ - close(fd[i]); + sys_close(fd[i]); fd[i] = chfd[i]; } id |= 1 << dim; - close(ch[0]); + sys_close(ch[0]); fd[dim] = ch[1]; break; default: for(i = 0; i < dim; i++) - close(chfd[i]); - close(ch[1]); + sys_close(chfd[i]); + sys_close(ch[1]); fd[dim] = ch[0]; break; } @@ -106,13 +106,13 @@ main(int argc, char *argv[]) id = 0; chdir("/srv"); for(i = 0; i < dim; i++) - id = hyperfork(fd, id, i); + id = hypesys_rfork(fd, id, i); for(i = 0; i < dim; i++){ int tlen, rlen; tlen = snprint(buf, sizeof buf, "hello %d\n", id); - write(fd[i], buf, tlen); - rlen = read(fd[i], buf, sizeof buf-1); + jehanne_write(fd[i], buf, tlen); + rlen = jehanne_read(fd[i], buf, sizeof buf-1); buf[rlen] = '\0'; snprint(buf2, sizeof buf2, "%d: %s", id, buf); } diff --git a/qa/lib/c/lockt.c b/qa/lib/c/lockt.c index b4698b5..44e8369 100644 --- a/qa/lib/c/lockt.c +++ b/qa/lib/c/lockt.c @@ -43,7 +43,7 @@ spawnWaiter(Lock *l) int pid; int64_t start; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: /* wait for the alwaysLocked to be locked by the main process */ @@ -64,7 +64,7 @@ spawnWaiter(Lock *l) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -79,7 +79,7 @@ main(void) int64_t start, elapsed, res; static Lock l; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; resInWaiter = 0xff; @@ -87,7 +87,7 @@ main(void) spawnWaiter(&l); jehanne_lock(&l); - alarm(20000); /* global timeout, FAIL if reached */ + sys_alarm(20000); /* global timeout, FAIL if reached */ if (!atnotify(failOnTimeout, 1)){ fprint(2, "%r\n"); exits("atnotify fails"); diff --git a/qa/lib/c/privates2.c b/qa/lib/c/privates2.c index af02b54..79753b6 100644 --- a/qa/lib/c/privates2.c +++ b/qa/lib/c/privates2.c @@ -27,10 +27,10 @@ main(void) test = (char **)privalloc(); *test = smprint("Hello from %d (at %p)\n", getpid(), test); - rfork(RFNOTEG); - switch(rfork(RFPROC|RFMEM)){ + sys_rfork(RFNOTEG); + switch(sys_rfork(RFPROC|RFMEM)){ case -1: - exits("rfork"); + exits("sys_rfork"); case 0: *test = smprint("Hello from %d (at %p)\n", getpid(), test); spin = 1; @@ -43,9 +43,9 @@ main(void) while(spin == 0) ; } - switch(rfork(RFPROC|RFMEM)){ + switch(sys_rfork(RFPROC|RFMEM)){ case -1: - exits("rfork"); + exits("sys_rfork"); case 0: *test = smprint("Hello from %d (at %p)\n", getpid(), test); spin = 2; diff --git a/qa/lib/c/qlockt0.c b/qa/lib/c/qlockt0.c index ccb6ea5..ab8498c 100644 --- a/qa/lib/c/qlockt0.c +++ b/qa/lib/c/qlockt0.c @@ -44,7 +44,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -56,7 +56,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "%r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: killerProc = pid; atexit(killKiller); @@ -131,7 +131,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = waiter(index); @@ -139,7 +139,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -157,7 +157,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/qlockt1.c b/qa/lib/c/qlockt1.c index d7c08b0..f61deed 100644 --- a/qa/lib/c/qlockt1.c +++ b/qa/lib/c/qlockt1.c @@ -46,7 +46,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -58,7 +58,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "%r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: killerProc = pid; atexit(killKiller); @@ -135,7 +135,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = waiter(index); @@ -143,7 +143,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -158,7 +158,7 @@ main(void) int i; int64_t average, end; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/qlockt2.c b/qa/lib/c/qlockt2.c index ddb4a87..d144e39 100644 --- a/qa/lib/c/qlockt2.c +++ b/qa/lib/c/qlockt2.c @@ -44,7 +44,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -56,7 +56,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "%r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: killerProc = pid; atexit(killKiller); @@ -132,7 +132,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = waiter(index); @@ -140,7 +140,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -158,7 +158,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/rlockt0.c b/qa/lib/c/rlockt0.c index 8357a25..7b4cd46 100644 --- a/qa/lib/c/rlockt0.c +++ b/qa/lib/c/rlockt0.c @@ -44,7 +44,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -56,7 +56,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "stopAllAfter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: if(verbose) print("killer proc spawn: pid %d\n", getpid()); @@ -132,7 +132,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = waiter(index); @@ -140,7 +140,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -158,7 +158,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/rlockt1.c b/qa/lib/c/rlockt1.c index 3246f0f..e7697d2 100644 --- a/qa/lib/c/rlockt1.c +++ b/qa/lib/c/rlockt1.c @@ -46,7 +46,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -58,7 +58,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "stopAllAfter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: if(verbose) print("killer proc spawn: pid %d\n", pid); @@ -136,7 +136,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = waiter(index); @@ -144,7 +144,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -162,7 +162,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/rlockt2.c b/qa/lib/c/rlockt2.c index a370358..13492ac 100644 --- a/qa/lib/c/rlockt2.c +++ b/qa/lib/c/rlockt2.c @@ -44,7 +44,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -56,7 +56,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "stopAllAfter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: if(verbose) print("killer proc spawn: pid %d\n", getpid()); @@ -133,7 +133,7 @@ spawnWaiter(int index) int pid, ls = lastspawn; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: ++lastspawn; @@ -142,7 +142,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: while(ls == lastspawn) @@ -162,7 +162,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/rsleept0.c b/qa/lib/c/rsleept0.c index 3b7e6d1..cabe6c4 100644 --- a/qa/lib/c/rsleept0.c +++ b/qa/lib/c/rsleept0.c @@ -45,7 +45,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -57,7 +57,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "%r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: killerProc = pid; atexit(killKiller); @@ -134,7 +134,7 @@ spawnsleeper(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = sleeper(index); @@ -142,7 +142,7 @@ spawnsleeper(int index) break; case -1: print("spawnsleeper: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -160,7 +160,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/rsleept1.c b/qa/lib/c/rsleept1.c index 9810539..44d842e 100644 --- a/qa/lib/c/rsleept1.c +++ b/qa/lib/c/rsleept1.c @@ -47,7 +47,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -59,7 +59,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "%r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: killerProc = pid; atexit(killKiller); @@ -138,7 +138,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = sleeper(index); @@ -146,7 +146,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -164,7 +164,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/rsleept2.c b/qa/lib/c/rsleept2.c index 93572e8..5851ed0 100644 --- a/qa/lib/c/rsleept2.c +++ b/qa/lib/c/rsleept2.c @@ -45,7 +45,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -57,7 +57,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "%r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: killerProc = pid; atexit(killKiller); @@ -137,7 +137,7 @@ spawnsleeper(int index) int pid, ls = lastspawn; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: ++lastspawn; @@ -146,7 +146,7 @@ spawnsleeper(int index) break; case -1: print("spawnsleeper: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: while(ls == lastspawn) @@ -166,7 +166,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/rwakeup0.c b/qa/lib/c/rwakeup0.c index 52f72a3..f859642 100644 --- a/qa/lib/c/rwakeup0.c +++ b/qa/lib/c/rwakeup0.c @@ -51,7 +51,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -63,7 +63,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "%r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: killerProc = pid; atexit(killKiller); @@ -78,7 +78,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); if (!atnotify(handletimeout, 1)){ fprint(2, "%r\n"); exits("atnotify fails"); @@ -88,7 +88,7 @@ main(int argc, char* argv[]) stopAllAfter(30); /* one process to sleep */ - switch((s = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((s = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: qlock(&l); @@ -98,8 +98,8 @@ main(int argc, char* argv[]) exits(nil); break; case -1: - print("rfork: %r\n"); - exits("rfork fails"); + print("sys_rfork: %r\n"); + exits("sys_rfork fails"); break; default: while(ready == 0) @@ -107,7 +107,7 @@ main(int argc, char* argv[]) break; } /* one process to wakeup */ - switch((w = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((w = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: qlock(&l); @@ -117,8 +117,8 @@ main(int argc, char* argv[]) exits(nil); break; case -1: - print("rfork: %r\n"); - exits("rfork fails"); + print("sys_rfork: %r\n"); + exits("sys_rfork fails"); break; default: while(ready == 1) @@ -132,13 +132,13 @@ main(int argc, char* argv[]) print("PASS\n"); exits("PASS"); } - if((s = open(smprint("/proc/%d/ctl", s), OWRITE)) >= 0){ - write(s, "kill", 5); - close(s); + if((s = sys_open(smprint("/proc/%d/ctl", s), OWRITE)) >= 0){ + jehanne_write(s, "kill", 5); + sys_close(s); } - if((w = open(smprint("/proc/%d/ctl", w), OWRITE)) >= 0){ - write(s, "kill", 5); - close(s); + if((w = sys_open(smprint("/proc/%d/ctl", w), OWRITE)) >= 0){ + jehanne_write(s, "kill", 5); + sys_close(s); } print("FAIL\n"); exits("FAIL"); diff --git a/qa/lib/c/rwakeup1.c b/qa/lib/c/rwakeup1.c index decf9b5..f73ac65 100644 --- a/qa/lib/c/rwakeup1.c +++ b/qa/lib/c/rwakeup1.c @@ -51,7 +51,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -63,7 +63,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "%r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: killerProc = pid; atexit(killKiller); @@ -78,7 +78,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); if (!atnotify(handletimeout, 1)){ fprint(2, "%r\n"); exits("atnotify fails"); @@ -88,7 +88,7 @@ main(int argc, char* argv[]) stopAllAfter(30); /* one process to sleep for 100ms */ - switch((s = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((s = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: qlock(&l); @@ -98,8 +98,8 @@ main(int argc, char* argv[]) exits(nil); break; case -1: - print("rfork: %r\n"); - exits("rfork fails"); + print("sys_rfork: %r\n"); + exits("sys_rfork fails"); break; default: while(ready == 0) @@ -113,13 +113,13 @@ main(int argc, char* argv[]) print("PASS\n"); exits("PASS"); } - if((s = open(smprint("/proc/%d/ctl", s), OWRITE)) >= 0){ - write(s, "kill", 5); - close(s); + if((s = sys_open(smprint("/proc/%d/ctl", s), OWRITE)) >= 0){ + jehanne_write(s, "kill", 5); + sys_close(s); } - if((w = open(smprint("/proc/%d/ctl", w), OWRITE)) >= 0){ - write(s, "kill", 5); - close(s); + if((w = sys_open(smprint("/proc/%d/ctl", w), OWRITE)) >= 0){ + jehanne_write(s, "kill", 5); + sys_close(s); } print("FAIL\n"); exits("FAIL"); diff --git a/qa/lib/c/sleep.c b/qa/lib/c/sleep.c index d3d26ee..da678ed 100644 --- a/qa/lib/c/sleep.c +++ b/qa/lib/c/sleep.c @@ -64,16 +64,16 @@ main(void) exits("atnotify fails"); } - alarm(2000); + sys_alarm(2000); a2000 = nsec(); - alarm(500); + sys_alarm(500); a500 = nsec(); tStart = nsec(); sleep(1000); tEnd = nsec(); if(verbose) - fprint(2, "%d: set alarm(2000)@%lld then alarm(500)@%lld; elapsed in sleep() %lld nanosecond\n", getpid(), a2000, a500, tEnd-tStart); + fprint(2, "%d: set sys_alarm(2000)@%lld then sys_alarm(500)@%lld; elapsed in sleep() %lld nanosecond\n", getpid(), a2000, a500, tEnd-tStart); if(tEnd-tStart > 1200 * 1000 * 1000){ print("FAIL: should sleep less\n"); diff --git a/qa/lib/c/sleep2.c b/qa/lib/c/sleep2.c index 5dc8c5b..d5ebca7 100644 --- a/qa/lib/c/sleep2.c +++ b/qa/lib/c/sleep2.c @@ -57,16 +57,16 @@ main(void) exits("atnotify fails"); } - alarm(5000); + sys_alarm(5000); a2000 = nsec(); - alarm(500); + sys_alarm(500); a500 = nsec(); tStart = nsec(); sleep(1000); tEnd = nsec(); if(verbose) - fprint(2, "%d: set alarm(2000)@%lld then alarm(500)@%lld; elapsed in sleep() %lld nanosecond\n", getpid(), a2000, a500, tEnd-tStart); + fprint(2, "%d: set sys_alarm(2000)@%lld then sys_alarm(500)@%lld; elapsed in sleep() %lld nanosecond\n", getpid(), a2000, a500, tEnd-tStart); if((tEnd-tStart)/(1000 * 1000) > 500+2000+400 /* 400ms = acceptable error */){ print("FAIL: should sleep less\n"); diff --git a/qa/lib/c/wlockt0.c b/qa/lib/c/wlockt0.c index 7803241..587aac8 100644 --- a/qa/lib/c/wlockt0.c +++ b/qa/lib/c/wlockt0.c @@ -44,7 +44,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -56,7 +56,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "stopAllAfter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: if(verbose) print("killer proc spawn: pid %d\n", getpid()); @@ -132,7 +132,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = waiter(index); @@ -140,7 +140,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -158,7 +158,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/wlockt1.c b/qa/lib/c/wlockt1.c index 52259ee..c7fa84e 100644 --- a/qa/lib/c/wlockt1.c +++ b/qa/lib/c/wlockt1.c @@ -46,7 +46,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -58,7 +58,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "stopAllAfter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: if(verbose) print("killer proc spawn: pid %d\n", pid); @@ -136,7 +136,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = waiter(index); @@ -144,7 +144,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -162,7 +162,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/c/wlockt2.c b/qa/lib/c/wlockt2.c index 2cdae23..519a495 100644 --- a/qa/lib/c/wlockt2.c +++ b/qa/lib/c/wlockt2.c @@ -44,7 +44,7 @@ stopAllAfter(int seconds) { int pid; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: if(verbose) @@ -56,7 +56,7 @@ stopAllAfter(int seconds) exits("FAIL"); case -1: fprint(2, "stopAllAfter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); default: if(verbose) print("killer proc spawn: pid %d\n", getpid()); @@ -132,7 +132,7 @@ spawnWaiter(int index) int pid; char * res; - switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT))) + switch((pid = sys_rfork(RFMEM|RFPROC|RFNOWAIT))) { case 0: res = waiter(index); @@ -140,7 +140,7 @@ spawnWaiter(int index) break; case -1: print("spawnWaiter: %r\n"); - exits("rfork fails"); + exits("sys_rfork fails"); break; default: if(verbose) @@ -158,7 +158,7 @@ main(int argc, char* argv[]) ARGBEGIN{ }ARGEND; - rfork(RFNOTEG|RFREND); + sys_rfork(RFNOTEG|RFREND); rStart.l = &rl; rCompleted.l = &rl; diff --git a/qa/lib/newlib/104-files-nonblocking.c b/qa/lib/newlib/104-files-nonblocking.c index b391f70..48fb787 100644 --- a/qa/lib/newlib/104-files-nonblocking.c +++ b/qa/lib/newlib/104-files-nonblocking.c @@ -17,7 +17,7 @@ void parent_read(int p[]) char buf[MSGSIZE]; // write link - close(p[1]); + sys_close(p[1]); while (1) { @@ -45,7 +45,7 @@ void parent_read(int p[]) printf("End of conversation\n"); // read link - close(p[0]); + sys_close(p[0]); exit(0); default: @@ -62,7 +62,7 @@ void child_write(int p[]) int i; // read link - close(p[0]); + sys_close(p[0]); // write 3 times "hello" in 3 second interval for (i = 0; i < 3; i++) { @@ -74,7 +74,7 @@ void child_write(int p[]) write(p[1], msg2, MSGSIZE); // here after write all bytes then write end - // doesn't close so read end block but + // doesn't sys_close so read end block but // because of fcntl block doesn't happen.. exit(0); } diff --git a/qa/lib/newlib/121-fcntl.c b/qa/lib/newlib/121-fcntl.c index ce423aa..81fdc4b 100644 --- a/qa/lib/newlib/121-fcntl.c +++ b/qa/lib/newlib/121-fcntl.c @@ -32,18 +32,18 @@ main(int argc, char *argv[]) pipe(sync); outfd = dup(1); - nullfd = open("/dev/null", O_WRONLY); + nullfd = sys_open("/dev/null", O_WRONLY); tmp = fcntl(sync[0], F_DUPFD_CLOEXEC, 1); - close(sync[0]); + sys_close(sync[0]); sync[0] = tmp; tmp = fcntl(sync[1], F_DUPFD_CLOEXEC, 1); - close(sync[1]); + sys_close(sync[1]); sync[1] = tmp; tmp = fcntl(outfd, F_DUPFD_CLOEXEC, 1); - close(outfd); + sys_close(outfd); outfd = tmp; tmp = fcntl(nullfd, F_DUPFD_CLOEXEC, 1); - close(nullfd); + sys_close(nullfd); nullfd = tmp; eargv[0] = argv[0]; diff --git a/qa/lib/newlib/200-signals.c b/qa/lib/newlib/200-signals.c index a5a1746..75a9547 100644 --- a/qa/lib/newlib/200-signals.c +++ b/qa/lib/newlib/200-signals.c @@ -59,8 +59,8 @@ main() { printf("\nChild going to loop...\n\n"); write(p[1], "", 1); - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); for(;;); /* loop for ever */ } else /* parent */ @@ -70,8 +70,8 @@ main() { printf("sync read"); exit(EXIT_FAILURE); } - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); printf("\nPARENT: sending SIGHUP\n\n"); kill(pid,SIGHUP); sleep(3); /* pause for 3 secs */ diff --git a/qa/lib/newlib/201-signals.c b/qa/lib/newlib/201-signals.c index 99ee57e..666d264 100644 --- a/qa/lib/newlib/201-signals.c +++ b/qa/lib/newlib/201-signals.c @@ -27,8 +27,8 @@ main() { if (pid == 0) { printf("\nI am the new child!\n\n"); write(p[1], "", 1); - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); for(;;){ /* loop for ever */ printf("."); @@ -41,8 +41,8 @@ main() { printf("sync read"); exit(EXIT_FAILURE); } - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); printf("\nPARENT: sending SIGINT\n\n"); kill(pid,SIGINT); do { diff --git a/qa/lib/newlib/202-signals.c b/qa/lib/newlib/202-signals.c index 49f2560..107b4ea 100644 --- a/qa/lib/newlib/202-signals.c +++ b/qa/lib/newlib/202-signals.c @@ -29,8 +29,8 @@ main() { signal(SIGCONT,sigcont); /* set function calls */ printf("Child going to loop...\n"); write(p[1], "", 1); - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); for(;;){ /* loop for ever */ printf("."); @@ -40,8 +40,8 @@ main() { else /* parent */ { read(p[0], &dummy, 1); - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); printf("PARENT: sending SIGCONT\n\n"); kill(pid,SIGCONT); child = wait(&cstatus); @@ -54,4 +54,3 @@ main() { } } } - diff --git a/qa/lib/newlib/203-signals.c b/qa/lib/newlib/203-signals.c index a14febb..3d162fb 100644 --- a/qa/lib/newlib/203-signals.c +++ b/qa/lib/newlib/203-signals.c @@ -24,8 +24,8 @@ void childloop(void) signal(SIGSTOP,sigstop); /* set function calls */ printf("Child %d going to loop...\n", getpid()); write(p[1], "", 1); - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); for(;;){ /* loop for ever */ printf("."); @@ -56,8 +56,8 @@ main() { else /* parent */ { read(p[0], &dummy, 1); - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); sleep(2); printf("PARENT: sending SIGSTOP\n"); kill(pid,SIGSTOP); @@ -76,4 +76,3 @@ main() { } } } - diff --git a/qa/lib/newlib/204-signals.c b/qa/lib/newlib/204-signals.c index cf2c2b2..ebbe7e7 100644 --- a/qa/lib/newlib/204-signals.c +++ b/qa/lib/newlib/204-signals.c @@ -48,16 +48,16 @@ main() { printf("Child going to loop...\n"); write(p[1], "", 1); - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); for(;;); /* loop for ever */ } else /* parent */ { signal(SIGCHLD,sigchld); read(p[0], &dummy, 1); - close(p[1]); - close(p[0]); + sys_close(p[1]); + sys_close(p[0]); printf("PARENT: sending SIGHUP\n"); kill(pid,SIGHUP); sleep(3); /* pause for 3 secs */ diff --git a/qa/lib/newlib/build.json b/qa/lib/newlib/build.json index 9afdbb9..c95559c 100644 --- a/qa/lib/newlib/build.json +++ b/qa/lib/newlib/build.json @@ -6,10 +6,10 @@ "Cflags": [ "-fstack-check", "-fstack-protector-all", - "/arch/$ARCH/lib/newlib/libc.a", - "/arch/$ARCH/lib/newlib/libm.a", - "/arch/$ARCH/lib/newlib/libg.a", - "-I", "/sys/posix/newlib", + "/pkgs/newlib/x86_64-jehanne/lib/libc.a", + "/pkgs/newlib/x86_64-jehanne/lib/libm.a", + "/pkgs/newlib/x86_64-jehanne/lib/libg.a", + "-I", "/posix/include", "-O2", "-std=gnu11" ], @@ -73,10 +73,10 @@ "Cflags": [ "-fstack-check", "-fstack-protector-all", - "/arch/$ARCH/lib/newlib/libc.a", - "/arch/$ARCH/lib/newlib/libm.a", - "/arch/$ARCH/lib/newlib/libg.a", - "-I", "/sys/posix/newlib", + "/pkgs/newlib/x86_64-jehanne/lib/libc.a", + "/pkgs/newlib/x86_64-jehanne/lib/libm.a", + "/pkgs/newlib/x86_64-jehanne/lib/libg.a", + "-I", "/posix/include", "-O2", "-DWITH_SIGCHLD", "-std=gnu11" diff --git a/qa/lib/newlib/testsuite/build.json b/qa/lib/newlib/testsuite/build.json index f811209..6976f47 100644 --- a/qa/lib/newlib/testsuite/build.json +++ b/qa/lib/newlib/testsuite/build.json @@ -9,10 +9,10 @@ "-Wno-unused-variable", "-Wno-format", "-fstack-protector-all", - "/arch/$ARCH/lib/newlib/libc.a", - "/arch/$ARCH/lib/newlib/libm.a", - "/arch/$ARCH/lib/newlib/libg.a", - "-I", "/sys/posix/newlib", + "/pkgs/newlib/x86_64-jehanne/lib/libc.a", + "/pkgs/newlib/x86_64-jehanne/lib/libm.a", + "/pkgs/newlib/x86_64-jehanne/lib/libg.a", + "-I", "/posix/include", "-O2", "-std=gnu11" ], diff --git a/sys/include/apw/errno.h b/sys/include/apw/errno.h index 651ce97..a44bf02 100644 --- a/sys/include/apw/errno.h +++ b/sys/include/apw/errno.h @@ -108,11 +108,16 @@ typedef enum PosixError #endif -#ifndef _ERRNO_H -#define _ERRNO_H +#ifndef _APW_ERRNO_H +#ifdef __cplusplus +extern "C" { +#endif -extern int __errno(); -#define errno __errno() +#define _APW_ERRNO_H +#ifndef HIDE_JEHANNE_APW + +extern int *__errno (void); +#define errno (*__errno()) /* See The Open Group Base Specifications Issue 7 * IEEE Std 1003.1-2008, 2016 Edition got from @@ -212,4 +217,9 @@ extern int __errno(); #define EWOULDBLOCK PosixEWOULDBLOCK #define EXDEV PosixEXDEV +#endif /* HIDE_JEHANNE_APW */ + +#ifdef __cplusplus +} #endif +#endif /* _APW_ERRNO_H */ diff --git a/sys/include/apw/limits.h b/sys/include/apw/limits.h new file mode 100644 index 0000000..a7d36f3 --- /dev/null +++ b/sys/include/apw/limits.h @@ -0,0 +1,119 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2016 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ +#ifndef _APW_LIMITS_H +#define _APW_LIMITS_H +#ifndef HIDE_JEHANNE_APW + +#undef CHAR_BIT +#define CHAR_BIT __CHAR_BIT__ + +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 4 /* UTFmax in libc.h */ +#endif + +#undef SCHAR_MIN +#define SCHAR_MIN (-SCHAR_MAX - 1) +#undef SCHAR_MAX +#define SCHAR_MAX __SCHAR_MAX__ + +#undef UCHAR_MAX +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +#ifdef __CHAR_UNSIGNED__ +# undef CHAR_MIN +# define CHAR_MIN 0 +# undef CHAR_MAX +# define CHAR_MAX UCHAR_MAX +#else +# undef CHAR_MIN +# define CHAR_MIN SCHAR_MIN +# undef CHAR_MAX +# define CHAR_MAX SCHAR_MAX +#endif + +#undef SHRT_MIN +#define SHRT_MIN (-SHRT_MAX - 1) +#undef SHRT_MAX +#define SHRT_MAX __SHRT_MAX__ + +#undef USHRT_MAX +#define USHRT_MAX (SHRT_MAX * 2 + 1) + +#undef INT_MIN +#define INT_MIN (-INT_MAX - 1) +#undef INT_MAX +#define INT_MAX __INT_MAX__ + +#undef UINT_MAX +#define UINT_MAX (INT_MAX * 2U + 1U) + +#undef LONG_MIN +#define LONG_MIN (-LONG_MAX - 1L) +#undef LONG_MAX +#define LONG_MAX __LONG_MAX__ + +#undef ULONG_MAX +#define ULONG_MAX (LONG_MAX * 2UL + 1UL) + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# undef LLONG_MIN +# define LLONG_MIN (-LLONG_MAX - 1LL) +# undef LLONG_MAX +# define LLONG_MAX __LONG_LONG_MAX__ + +# undef ULLONG_MAX +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +#endif + +#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) +# undef LONG_LONG_MIN +# define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL) +# undef LONG_LONG_MAX +# define LONG_LONG_MAX __LONG_LONG_MAX__ + +# undef ULONG_LONG_MAX +# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL) +#endif + +#ifdef __STDC_WANT_IEC_60559_BFP_EXT__ +# undef CHAR_WIDTH +# define CHAR_WIDTH __SCHAR_WIDTH__ +# undef SCHAR_WIDTH +# define SCHAR_WIDTH __SCHAR_WIDTH__ +# undef UCHAR_WIDTH +# define UCHAR_WIDTH __SCHAR_WIDTH__ +# undef SHRT_WIDTH +# define SHRT_WIDTH __SHRT_WIDTH__ +# undef USHRT_WIDTH +# define USHRT_WIDTH __SHRT_WIDTH__ +# undef INT_WIDTH +# define INT_WIDTH __INT_WIDTH__ +# undef UINT_WIDTH +# define UINT_WIDTH __INT_WIDTH__ +# undef LONG_WIDTH +# define LONG_WIDTH __LONG_WIDTH__ +# undef ULONG_WIDTH +# define ULONG_WIDTH __LONG_WIDTH__ +# undef LLONG_WIDTH +# define LLONG_WIDTH __LONG_LONG_WIDTH__ +# undef ULLONG_WIDTH +# define ULLONG_WIDTH __LONG_LONG_WIDTH__ +#endif + +#endif +#endif diff --git a/sys/include/apw/stdio.h b/sys/include/apw/stdio.h index 49c9b6e..d943715 100644 --- a/sys/include/apw/stdio.h +++ b/sys/include/apw/stdio.h @@ -15,8 +15,9 @@ * You should have received a copy of the GNU General Public License * along with Jehanne. If not, see . */ -#ifndef _STDIO_H -#define _STDIO_H +#ifndef _APW_STDIO_H +#define _APW_STDIO_H +#ifndef HIDE_JEHANNE_APW /* Simple trick to avoid name clash between native and standard headers: * @@ -40,4 +41,4 @@ extern "C" { } #endif #endif - +#endif diff --git a/sys/include/apw/stdlib.h b/sys/include/apw/stdlib.h index 594768a..62caa9f 100644 --- a/sys/include/apw/stdlib.h +++ b/sys/include/apw/stdlib.h @@ -15,8 +15,9 @@ * You should have received a copy of the GNU General Public License * along with Jehanne. If not, see . */ -#ifndef _STDLIB_H -#define _STDLIB_H +#ifndef _APW_STDLIB_H +#define _APW_STDLIB_H +#ifndef HIDE_JEHANNE_APW #include "libc.wrapper.h" #define EXIT_SUCCESS 0 @@ -53,3 +54,4 @@ extern void __eprintf(const char *format, const char *file, unsigned int line, const char *expression); #endif +#endif diff --git a/sys/include/apw/string.h b/sys/include/apw/string.h index fa122df..0b2b8d6 100644 --- a/sys/include/apw/string.h +++ b/sys/include/apw/string.h @@ -15,7 +15,9 @@ * You should have received a copy of the GNU General Public License * along with Jehanne. If not, see . */ -#ifndef _STRING_H -#define _STRING_H +#ifndef _APW_STRING_H +#define _APW_STRING_H +#ifndef HIDE_JEHANNE_APW #include "libc.wrapper.h" #endif +#endif diff --git a/sys/include/apw/sys/types.h b/sys/include/apw/sys/types.h index e6f967c..e67d4b7 100644 --- a/sys/include/apw/sys/types.h +++ b/sys/include/apw/sys/types.h @@ -15,7 +15,9 @@ * You should have received a copy of the GNU General Public License * along with Jehanne. If not, see . */ -#ifndef _SYS_TYPES_H -#define _SYS_TYPES_H +#ifndef _APW_SYS_TYPES_H +#define _APW_SYS_TYPES_H +#ifndef HIDE_JEHANNE_APW #include "libc.wrapper.h" #endif +#endif diff --git a/sys/include/apw/unistd.h b/sys/include/apw/unistd.h index fe8383f..03382cb 100644 --- a/sys/include/apw/unistd.h +++ b/sys/include/apw/unistd.h @@ -15,10 +15,12 @@ * You should have received a copy of the GNU General Public License * along with Jehanne. If not, see . */ -#ifndef _UNISTD_H -#define _UNISTD_H +#ifndef _APW_UNISTD_H +#define _APW_UNISTD_H +#ifndef HIDE_JEHANNE_APW #include "libc.wrapper.h" extern int execv(const char*, char* const[]); extern int execve(const char*, char* const[], char* const[]); extern int execvp(const char*, char* const[]); #endif +#endif diff --git a/sys/include/posix.h b/sys/include/posix.h index 743a001..0aeac79 100644 --- a/sys/include/posix.h +++ b/sys/include/posix.h @@ -91,7 +91,7 @@ typedef enum PosixRUsages } PosixRUsages; /* errno values */ -#define _ERRNO_H // skip the Posix part, we just need the enum +#define _APW_ERRNO_H // skip the Posix part, we just need the enum #include /* signals */ @@ -312,7 +312,7 @@ extern int POSIX_waitpid(int *errnop, int pid, int *status, int options); extern long POSIX_write(int *errnop, int fd, const void *buf, size_t len); extern int POSIX_gettimeofday(int *errnop, void *timeval, void *timezone); extern char* POSIX_getenv(int *errnop, const char *name); -extern int POSIX_setenv(int *errno, const char *name, const char *value, int overwrite); +extern int POSIX_setenv(int *errnop, const char *name, const char *value, int overwrite); extern int POSIX_unsetenv(int *errnop, const char *name); extern void *POSIX_sbrk(int *errnop, ptrdiff_t incr); extern void * POSIX_malloc(int *errnop, size_t size); diff --git a/sys/src/lib/c/9sys/pexec.c b/sys/src/lib/c/9sys/pexec.c index 8169cec..93db5f8 100644 --- a/sys/src/lib/c/9sys/pexec.c +++ b/sys/src/lib/c/9sys/pexec.c @@ -32,7 +32,7 @@ jehanne_pexec(const char *f, char *args[]) n = jehanne_getfields(epath, entries, nelem(entries), 1, ":"); for(i = 0; i < n; ++i){ path = jehanne_smprint("%s/%s", entries[i], f); - sys_exec(path, args); + sys_exec(path, (const char**)args); jehanne_free(path); } diff --git a/sys/src/lib/c/amd64/initlib.c b/sys/src/lib/c/amd64/initlib.c index d2c7276..6ce47a6 100644 --- a/sys/src/lib/c/amd64/initlib.c +++ b/sys/src/lib/c/amd64/initlib.c @@ -45,8 +45,12 @@ __jehanne_libc_init(int argc, char *argv[]) static void call_main(int argc, char *argv[]) { - extern void main(int argc, char *argv[]); + extern void main(int argc, char *argv[]) __attribute__((weak)); - main(argc, argv); - jehanne_exits("main"); + if(main != nil){ + main(argc, argv); + jehanne_exits("main"); + } else { + jehanne_exits("missing main"); + } } diff --git a/sys/src/lib/posix/files.c b/sys/src/lib/posix/files.c index 65eeece..b02c67e 100644 --- a/sys/src/lib/posix/files.c +++ b/sys/src/lib/posix/files.c @@ -503,7 +503,7 @@ OnIgnoredSignalInterrupt: } int -POSIX_close(int *errno, int file) +POSIX_close(int *errnop, int file) { long ret; @@ -512,10 +512,10 @@ POSIX_close(int *errno, int file) case 0: return 0; case ~0: - *errno = __libposix_translate_errstr((uintptr_t)POSIX_close); + *errnop = __libposix_translate_errstr((uintptr_t)POSIX_close); break; default: - *errno = ret; + *errnop = ret; break; } return -1; diff --git a/sys/src/lib/posix/kill.c b/sys/src/lib/posix/kill.c index 1eca2d7..f32ee44 100644 --- a/sys/src/lib/posix/kill.c +++ b/sys/src/lib/posix/kill.c @@ -27,7 +27,7 @@ POSIX_kill(int *errnop, int pid, int signo) { PosixError perror; PosixSignalInfo siginfo; - int errno; + int throwaway_errno; if(signo < 1 || signo > PosixNumberOfSignals){ *errnop = __libposix_get_errno(PosixEINVAL); @@ -37,7 +37,7 @@ POSIX_kill(int *errnop, int pid, int signo) siginfo.si_signo = signo; siginfo.si_pid = *__libposix_pid; siginfo.si_code = PosixSIUser; - siginfo.si_uid = POSIX_getuid(&errno); + siginfo.si_uid = POSIX_getuid(&throwaway_errno); if(pid == siginfo.si_pid) perror = __libposix_receive_signal(&siginfo); else diff --git a/sys/src/lib/posix/processes.c b/sys/src/lib/posix/processes.c index 2ae2879..18c18d5 100644 --- a/sys/src/lib/posix/processes.c +++ b/sys/src/lib/posix/processes.c @@ -189,7 +189,7 @@ POSIX_execve(int *errnop, const char *name, char * const*argv, char * const*env) __libposix_close_on_exec(); __libposix_sighelper_cmd(PHCallingExec, 0); - sys_exec(name, argv); + sys_exec(name, (const char**)argv); *errnop = __libposix_translate_errstr((uintptr_t)POSIX_execve); return -1; } diff --git a/sys/src/lib/posix/sigqueue.c b/sys/src/lib/posix/sigqueue.c index 319fdac..1d2f0fa 100644 --- a/sys/src/lib/posix/sigqueue.c +++ b/sys/src/lib/posix/sigqueue.c @@ -25,7 +25,7 @@ POSIX_sigqueue(int *errnop, int pid, int signo, const union sigval value) { PosixError perror; PosixSignalInfo siginfo; - int errno; + int throwaway_errno; if(signo < 1 || signo > PosixNumberOfSignals){ *errnop = __libposix_get_errno(PosixEINVAL); @@ -35,7 +35,7 @@ POSIX_sigqueue(int *errnop, int pid, int signo, const union sigval value) siginfo.si_signo = signo; siginfo.si_pid = *__libposix_pid; siginfo.si_code = PosixSIQueue; - siginfo.si_uid = POSIX_getuid(&errno); + siginfo.si_uid = POSIX_getuid(&throwaway_errno); siginfo.si_value._sival_raw = value._sival_raw; if(pid == siginfo.si_pid) perror = __libposix_receive_signal(&siginfo);