u.h: refactoring of syscalls
This commit is contained in:
parent
5261c8554c
commit
63d860eb99
|
@ -85,17 +85,4 @@ typedef __builtin_va_list va_list;
|
|||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
#define va_copy(v,l) __builtin_va_copy(v,l)
|
||||
|
||||
typedef union NativeTypes
|
||||
{
|
||||
volatile char c;
|
||||
volatile unsigned char uc;
|
||||
volatile short s;
|
||||
volatile unsigned short us;
|
||||
volatile int i;
|
||||
volatile unsigned int ui;
|
||||
volatile long l;
|
||||
volatile unsigned long ul;
|
||||
void* p;
|
||||
} NativeTypes;
|
||||
extern volatile NativeTypes* _sysargs;
|
||||
# include "syscalls.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2016-2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
* 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
|
||||
|
@ -120,7 +120,7 @@ static void* (*_rendezvousp)(void*, void*) = __rendezvous;
|
|||
#endif
|
||||
|
||||
# define RENDEZVOUS(...) (*_rendezvousp)(__VA_ARGS__)
|
||||
//# define RENDEZVOUS(...) sys_rendezvous(__VA_ARGS__)
|
||||
//# define RENDEZVOUS(...) rendezvous(__VA_ARGS__)
|
||||
//# define RENDEZVOUS(tag, val) __rendezvous(tag, __builtin_return_address(0))
|
||||
|
||||
/* this gets called by the thread library ONLY to get us to use its rendezvous */
|
||||
|
@ -821,4 +821,3 @@ jehanne_rwakeupall(Rendez *r)
|
|||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2015 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2015-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
|
||||
|
@ -22,5 +22,5 @@
|
|||
int
|
||||
read(int fd, void* buf, int nbytes)
|
||||
{
|
||||
return sys_pread(fd, buf, nbytes, ~0LL);
|
||||
return pread(fd, buf, nbytes, ~0LL);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2015 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2015-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
|
||||
|
@ -22,5 +22,5 @@
|
|||
int
|
||||
write(int fd, const void* buf, int nbytes)
|
||||
{
|
||||
return sys_pwrite(fd, buf, nbytes, ~0LL);
|
||||
return pwrite(fd, buf, nbytes, ~0LL);
|
||||
}
|
||||
|
|
|
@ -6,5 +6,3 @@ char *argv0;
|
|||
int32_t _mainpid;
|
||||
char *_privates;
|
||||
char *_nprivates;
|
||||
volatile NativeTypes* _sysargs;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-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
|
||||
|
@ -31,13 +31,11 @@ __jehanne_libc_init(int argc, char *argv[])
|
|||
{
|
||||
/* Initialize per process structures on the stack */
|
||||
void *privates[NPRIVATES];
|
||||
NativeTypes sysargs[6];
|
||||
|
||||
_nprivates = NPRIVATES;
|
||||
for(_nprivates = 0; _nprivates < NPRIVATES; ++_nprivates)
|
||||
privates[_nprivates] = nil;
|
||||
_privates = privates;
|
||||
_sysargs = &sysargs[0];
|
||||
|
||||
if(__libc_init != nil)
|
||||
__libc_init(argc, argv);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-2019 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -240,8 +240,7 @@ __libposix_setup_exec_environment(char * const *env)
|
|||
continue;
|
||||
end++; /* after '=' */
|
||||
len = strlen(end);
|
||||
sys_pwrite(fd, end, len, -1);
|
||||
sys_close(fd);
|
||||
pwrite(fd, end, len, -1);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-2019 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -173,7 +173,7 @@ __libposix_translate_errstr(uintptr_t caller)
|
|||
char err[ERRMAX];
|
||||
int ret;
|
||||
|
||||
if(sys_errstr(err, ERRMAX) < 0)
|
||||
if(errstr(err, ERRMAX) < 0)
|
||||
return __libposix_get_errno(PosixEINVAL);
|
||||
|
||||
handler = custom_handlers;
|
||||
|
@ -189,6 +189,6 @@ __libposix_translate_errstr(uintptr_t caller)
|
|||
if(perr == 0)
|
||||
perr = libposix_translate_kernel_errors(err);
|
||||
ret = __libposix_get_errno(perr);
|
||||
sys_errstr(err, ERRMAX);
|
||||
errstr(err, ERRMAX);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017-2018 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-2019 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -343,7 +343,7 @@ POSIX_open(int *errnop, const char *name, int flags, int mode)
|
|||
omode &= ~DMDIR;
|
||||
}
|
||||
if(cperm == 0){
|
||||
f = sys_open(name, omode);
|
||||
f = open(name, omode);
|
||||
} else {
|
||||
f = ocreate(name, (unsigned int)omode, (unsigned int)cperm);
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ POSIX_read(int *errnop, int fd, char *buf, size_t len)
|
|||
OnIgnoredSignalInterrupt:
|
||||
if(__libposix_should_not_block(fd))
|
||||
wkp = awake(2);
|
||||
r = sys_pread(fd, buf, len, -1);
|
||||
r = pread(fd, buf, len, -1);
|
||||
if(r < 0){
|
||||
if(wkp){
|
||||
if(!awakened(wkp))
|
||||
|
@ -402,7 +402,7 @@ POSIX_write(int *errnop, int fd, const void *buf, size_t len)
|
|||
OnIgnoredSignalInterrupt:
|
||||
if(__libposix_should_not_block(fd))
|
||||
wkp = awake(2);
|
||||
w = sys_pwrite(fd, buf, len, -1);
|
||||
w = pwrite(fd, buf, len, -1);
|
||||
if(w < 0){
|
||||
if(wkp){
|
||||
if(!awakened(wkp))
|
||||
|
@ -435,7 +435,7 @@ POSIX_lseek(int *errnop, int fd, off_t pos, int whence)
|
|||
*errnop = __libposix_get_errno(PosixEBADF);
|
||||
return -1;
|
||||
}
|
||||
r = sys_seek(fd, pos, stype);
|
||||
r = seek(fd, pos, stype);
|
||||
if(r >= 0)
|
||||
return r;
|
||||
*errnop = __libposix_translate_errstr((uintptr_t)POSIX_lseek);
|
||||
|
@ -454,7 +454,7 @@ POSIX_pread(int *errnop, int fd, char *buf, size_t len, long offset)
|
|||
OnIgnoredSignalInterrupt:
|
||||
if(__libposix_should_not_block(fd))
|
||||
wkp = awake(2);
|
||||
r = sys_pread(fd, buf, len, offset);
|
||||
r = pread(fd, buf, len, offset);
|
||||
if(r < 0){
|
||||
if(wkp){
|
||||
if(!awakened(wkp))
|
||||
|
@ -484,7 +484,7 @@ POSIX_pwrite(int *errnop, int fd, const char *buf, size_t len, long offset)
|
|||
OnIgnoredSignalInterrupt:
|
||||
if(__libposix_should_not_block(fd))
|
||||
wkp = awake(2);
|
||||
w = sys_pwrite(fd, buf, len, offset);
|
||||
w = pwrite(fd, buf, len, offset);
|
||||
if(w < 0){
|
||||
if(wkp){
|
||||
if(!awakened(wkp))
|
||||
|
@ -507,7 +507,7 @@ POSIX_close(int *errno, int file)
|
|||
{
|
||||
long ret;
|
||||
|
||||
ret = sys_close(file);
|
||||
ret = close(file);
|
||||
switch(ret){
|
||||
case 0:
|
||||
return 0;
|
||||
|
@ -529,7 +529,7 @@ POSIX_unlink(int *errnop, const char *name)
|
|||
*errnop = __libposix_get_errno(PosixENOENT);
|
||||
return -1;
|
||||
}
|
||||
ret = sys_remove(name);
|
||||
ret = remove(name);
|
||||
switch(ret){
|
||||
case 0:
|
||||
return 0;
|
||||
|
@ -552,7 +552,7 @@ POSIX_rmdir(int *errnop, const char *name)
|
|||
*errnop = __libposix_get_errno(PosixENOENT);
|
||||
return -1;
|
||||
}
|
||||
ret = sys_remove(name);
|
||||
ret = remove(name);
|
||||
switch(ret){
|
||||
case 0:
|
||||
return 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-2019 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -239,7 +239,7 @@ POSIX_setsid(int *errnop)
|
|||
assert(access("/dev/posix", AEXIST) != 0);
|
||||
|
||||
/* start the new session */
|
||||
switch(controlpid = sys_rfork(RFPROC|RFNOTEG|RFENVG|RFFDG)){
|
||||
switch(controlpid = rfork(RFPROC|RFNOTEG|RFENVG|RFFDG)){
|
||||
case -1:
|
||||
goto FailWithEPERM;
|
||||
case 0:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-2019 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -29,7 +29,7 @@ POSIX_isatty(int *errnop, int fd)
|
|||
*errnop = __libposix_get_errno(PosixEBADF);
|
||||
return 0;
|
||||
}
|
||||
if(sys_fd2path(fd, buf, sizeof(buf)) < 0){
|
||||
if(fd2path(fd, buf, sizeof(buf)) < 0){
|
||||
*errnop = __libposix_get_errno(PosixENOTTY);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-2019 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -1765,7 +1765,7 @@ tty_from_cons(int fd, int mode)
|
|||
int tmp;
|
||||
char buf[256];
|
||||
|
||||
if(sys_fd2path(fd, buf, sizeof(buf)) < 0)
|
||||
if(fd2path(fd, buf, sizeof(buf)) < 0)
|
||||
sysfatal("fd2path: %d", fd);
|
||||
tmp = strlen(buf);
|
||||
if(tmp < 9 || strcmp(buf+tmp-9, "/dev/cons") != 0)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-2019 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -179,9 +179,9 @@ POSIX_execve(int *errnop, const char *name, char * const*argv, char * const*env)
|
|||
// see http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
|
||||
if(env == environ){
|
||||
/* just get a copy of the current environment */
|
||||
sys_rfork(RFENVG);
|
||||
rfork(RFENVG);
|
||||
} else {
|
||||
sys_rfork(RFCENVG);
|
||||
rfork(RFCENVG);
|
||||
__libposix_setup_exec_environment(env);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
exec(name, argv);
|
||||
*errnop = __libposix_translate_errstr((uintptr_t)POSIX_execve);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue