libc: refactoring

This commit is contained in:
Giacomo Tesio 2019-11-28 02:35:52 +01:00
parent f104c46858
commit 4067cb45cb
75 changed files with 596 additions and 355 deletions

View File

@ -1,7 +1,6 @@
{
"buildflags": {
"Cflags": [
"--sysroot=$JEHANNE",
"-fno-builtin",
"-fno-omit-frame-pointer",
"-fplan9-extensions",

102
arch/amd64/include/limits.h Normal file
View File

@ -0,0 +1,102 @@
/*
* This file is part of Jehanne.
*
* Copyright (C) 2016-2019 Giacomo Tesio <giacomo@tesio.it>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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___ */

View File

@ -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");

View File

@ -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);

View File

@ -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);

View File

@ -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());

View File

@ -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());

View File

@ -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");

View File

@ -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

View File

@ -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:

View File

@ -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);

View File

@ -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) {

View File

@ -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 */

View File

@ -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);

View File

@ -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");
}

View File

@ -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);

View File

@ -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");
}

View File

@ -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");
}

View File

@ -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");

View File

@ -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:

View File

@ -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();

View File

@ -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);

View File

@ -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)));
}

View File

@ -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");

View File

@ -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");

View File

@ -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)

View File

@ -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");
}

View File

@ -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");

View File

@ -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);

View File

@ -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();

View File

@ -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");
}

View File

@ -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");

View File

@ -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");
}

View File

@ -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);
}

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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];

View File

@ -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 */

View File

@ -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 {

View File

@ -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() {
}
}
}

View File

@ -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() {
}
}
}

View File

@ -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 */

View File

@ -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"

View File

@ -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"
],

View File

@ -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 */

119
sys/include/apw/limits.h Normal file
View File

@ -0,0 +1,119 @@
/*
* This file is part of Jehanne.
*
* Copyright (C) 2016 Giacomo Tesio <giacomo@tesio.it>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -15,8 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -15,8 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -15,7 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _STRING_H
#define _STRING_H
#ifndef _APW_STRING_H
#define _APW_STRING_H
#ifndef HIDE_JEHANNE_APW
#include "libc.wrapper.h"
#endif
#endif

View File

@ -15,7 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -15,10 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -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 <apw/errno.h>
/* 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);

View File

@ -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);
}

View File

@ -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));
if(main != nil){
main(argc, argv);
jehanne_exits("main");
} else {
jehanne_exits("missing main");
}
}

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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);