mescc: Mes C Library: Explode linux/gnu.c.
* lib/linux/chdir.c: New file. * lib/linux/fcntl.c: New file. * lib/linux/fstat.c: New file. * lib/linux/getdents.c: New file. * lib/linux/getegid.c: New file. * lib/linux/geteuid.c: New file. * lib/linux/getgid.c: New file. * lib/linux/getpid.c: New file. * lib/linux/getppid.c: New file. * lib/linux/getrusage.c: New file. * lib/linux/getuid.c: New file. * lib/linux/kill.c: New file. * lib/linux/link.c: New file. * lib/linux/lstat.c: New file. * lib/linux/mkdir.c: New file. * lib/linux/nanosleep.c: New file. * lib/linux/pipe.c: New file. * lib/linux/rename.c: New file. * lib/linux/setgid.c: New file. * lib/linux/settimer.c: New file. * lib/linux/setuid.c: New file. * lib/linux/signal.c: New file. * lib/linux/sigprogmask.c: New file. * lib/linux/gnu.c: Include them. (chdir, fcntl, fstat, getdents, getegid, geteuid, getgid, getpid, getppid, getrusage, getuid, kill, link, lstat, mkdir, munmap, nanosleep, pipe, rename, setgid, settimer, setuid, signal, sigprogmask): Remove.
This commit is contained in:
parent
f5ab659569
commit
3a12301a25
|
@ -21,7 +21,7 @@
|
||||||
#include <libc+tcc.c>
|
#include <libc+tcc.c>
|
||||||
|
|
||||||
#if __GNU__
|
#if __GNU__
|
||||||
#include <linux/gnu.c>
|
#error TODO, see wip-hurd
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
#include <linux/gnu.c>
|
#include <linux/gnu.c>
|
||||||
#else
|
#else
|
||||||
|
|
25
lib/linux/chdir.c
Normal file
25
lib/linux/chdir.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
chdir (char const *file_name)
|
||||||
|
{
|
||||||
|
return _sys_call1 (SYS_chdir, (long)file_name);
|
||||||
|
}
|
30
lib/linux/fcntl.c
Normal file
30
lib/linux/fcntl.c
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
fcntl (int filedes, int command, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start (ap, command);
|
||||||
|
int data = va_arg (ap, int);
|
||||||
|
int r = _sys_call3 (SYS_fcntl, (int)filedes, (int)command, (int)data);
|
||||||
|
va_end (ap);
|
||||||
|
return r;
|
||||||
|
}
|
25
lib/linux/fstat.c
Normal file
25
lib/linux/fstat.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
fstat (int filedes, struct stat *statbuf)
|
||||||
|
{
|
||||||
|
return _sys_call2 (SYS_fstat, (int)filedes, (long)statbuf);
|
||||||
|
}
|
25
lib/linux/getdents.c
Normal file
25
lib/linux/getdents.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
getdents (int filedes, char *buffer, size_t nbytes)
|
||||||
|
{
|
||||||
|
return _sys_call3 (SYS_getdents, (int)filedes, (long)buffer, (long)nbytes);
|
||||||
|
}
|
25
lib/linux/getegid.c
Normal file
25
lib/linux/getegid.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
gid_t
|
||||||
|
getegid ()
|
||||||
|
{
|
||||||
|
return _sys_call (SYS_getegid);
|
||||||
|
}
|
25
lib/linux/geteuid.c
Normal file
25
lib/linux/geteuid.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
uid_t
|
||||||
|
geteuid ()
|
||||||
|
{
|
||||||
|
return _sys_call (SYS_geteuid);
|
||||||
|
}
|
25
lib/linux/getgid.c
Normal file
25
lib/linux/getgid.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
gid_t
|
||||||
|
getgid ()
|
||||||
|
{
|
||||||
|
return _sys_call (SYS_getgid);
|
||||||
|
}
|
25
lib/linux/getpid.c
Normal file
25
lib/linux/getpid.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
getpid ()
|
||||||
|
{
|
||||||
|
return _sys_call (SYS_getpid);
|
||||||
|
}
|
25
lib/linux/getppid.c
Normal file
25
lib/linux/getppid.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
getppid ()
|
||||||
|
{
|
||||||
|
return _sys_call (SYS_getppid);
|
||||||
|
}
|
25
lib/linux/getrusage.c
Normal file
25
lib/linux/getrusage.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
getrusage (int processes, struct rusage *rusage)
|
||||||
|
{
|
||||||
|
return _sys_call2 (SYS_getrusage, (int)processes, (long)rusage);
|
||||||
|
}
|
25
lib/linux/getuid.c
Normal file
25
lib/linux/getuid.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
uid_t
|
||||||
|
getuid ()
|
||||||
|
{
|
||||||
|
return _sys_call (SYS_getuid);
|
||||||
|
}
|
202
lib/linux/gnu.c
202
lib/linux/gnu.c
|
@ -18,182 +18,26 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/resource.h>
|
#include <linux/chdir.c>
|
||||||
#include <time.h>
|
#include <linux/fcntl.c>
|
||||||
|
#include <linux/fstat.c>
|
||||||
int
|
#include <linux/getdents.c>
|
||||||
link (char const *old_name, char const *new_name)
|
#include <linux/getegid.c>
|
||||||
{
|
#include <linux/geteuid.c>
|
||||||
return _sys_call2 (SYS_link, (long)old_name, (long)new_name);
|
#include <linux/getgid.c>
|
||||||
}
|
#include <linux/getpid.c>
|
||||||
|
#include <linux/getppid.c>
|
||||||
pid_t
|
#include <linux/getrusage.c>
|
||||||
getpid ()
|
#include <linux/getuid.c>
|
||||||
{
|
#include <linux/kill.c>
|
||||||
return _sys_call (SYS_getpid);
|
#include <linux/link.c>
|
||||||
}
|
#include <linux/lstat.c>
|
||||||
|
#include <linux/mkdir.c>
|
||||||
uid_t
|
#include <linux/nanosleep.c>
|
||||||
getuid ()
|
#include <linux/pipe.c>
|
||||||
{
|
#include <linux/rename.c>
|
||||||
return _sys_call (SYS_getuid);
|
#include <linux/setgid.c>
|
||||||
}
|
#include <linux/settimer.c>
|
||||||
|
#include <linux/setuid.c>
|
||||||
int
|
#include <linux/signal.c>
|
||||||
kill (pid_t pid, int signum)
|
#include <linux/sigprogmask.c>
|
||||||
{
|
|
||||||
return _sys_call2 (SYS_kill, (long)pid, (long)signum);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
rename (char const *old_name, char const *new_name)
|
|
||||||
{
|
|
||||||
return _sys_call2 (SYS_rename, (long)old_name, (long)new_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
mkdir (char const *file_name, mode_t mode)
|
|
||||||
{
|
|
||||||
return _sys_call2 (SYS_mkdir, (long)file_name, (long)mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
gid_t
|
|
||||||
getgid ()
|
|
||||||
{
|
|
||||||
return _sys_call (SYS_getgid);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __x86_64__
|
|
||||||
void
|
|
||||||
_restorer (void)
|
|
||||||
{
|
|
||||||
_sys_call (SYS_rt_sigreturn);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# define __sigmask(sig) \
|
|
||||||
(((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
|
|
||||||
|
|
||||||
sighandler_t
|
|
||||||
signal (int signum, sighandler_t action)
|
|
||||||
{
|
|
||||||
#if __i386__
|
|
||||||
return _sys_call2 (SYS_signal, signum, action);
|
|
||||||
#else
|
|
||||||
static struct sigaction setup_action = {-1};
|
|
||||||
static struct sigaction old = {0};
|
|
||||||
|
|
||||||
setup_action.sa_handler = action;
|
|
||||||
setup_action.sa_restorer = _restorer;
|
|
||||||
setup_action.sa_mask = __sigmask (signum);
|
|
||||||
old.sa_handler = SIG_DFL;
|
|
||||||
setup_action.sa_flags = SA_RESTORER | SA_RESTART;
|
|
||||||
int r = _sys_call4 (SYS_rt_sigaction, signum, &setup_action, &old, sizeof (sigset_t));
|
|
||||||
if (r)
|
|
||||||
return 0;
|
|
||||||
return old.sa_handler;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
fcntl (int filedes, int command, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
va_start (ap, command);
|
|
||||||
int data = va_arg (ap, int);
|
|
||||||
int r = _sys_call3 (SYS_fcntl, (int)filedes, (int)command, (int)data);
|
|
||||||
va_end (ap);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
pipe (int filedes[2])
|
|
||||||
{
|
|
||||||
return _sys_call1 (SYS_pipe, (long)filedes);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
getrusage (int processes, struct rusage *rusage)
|
|
||||||
{
|
|
||||||
return _sys_call2 (SYS_getrusage, (int)processes, (long)rusage);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
lstat (char const *file_name, struct stat *statbuf)
|
|
||||||
{
|
|
||||||
return _sys_call2 (SYS_lstat, (long)file_name, (long)statbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
nanosleep (const struct timespec *requested_time,
|
|
||||||
struct timespec *remaining)
|
|
||||||
{
|
|
||||||
return _sys_call2 (SYS_nanosleep, (long)requested_time, (long)remaining);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
setitimer (int which, struct itimerval const *new,
|
|
||||||
struct itimerval *old)
|
|
||||||
{
|
|
||||||
return _sys_call3 (SYS_setitimer, (long)which, (long)new, (long)old);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
fstat (int filedes, struct stat *statbuf)
|
|
||||||
{
|
|
||||||
return _sys_call2 (SYS_fstat, (int)filedes, (long)statbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
getdents (int filedes, char *buffer, size_t nbytes)
|
|
||||||
{
|
|
||||||
return _sys_call3 (SYS_getdents, (int)filedes, (long)buffer, (long)nbytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
chdir (char const *file_name)
|
|
||||||
{
|
|
||||||
return _sys_call1 (SYS_chdir, (long)file_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bash
|
|
||||||
uid_t
|
|
||||||
geteuid ()
|
|
||||||
{
|
|
||||||
return _sys_call (SYS_geteuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
gid_t
|
|
||||||
getegid ()
|
|
||||||
{
|
|
||||||
return _sys_call (SYS_getegid);
|
|
||||||
}
|
|
||||||
|
|
||||||
pid_t
|
|
||||||
getppid ()
|
|
||||||
{
|
|
||||||
return _sys_call (SYS_getppid);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
setuid (uid_t newuid)
|
|
||||||
{
|
|
||||||
return _sys_call1 (SYS_setuid, (long)newuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
setgid (gid_t newgid)
|
|
||||||
{
|
|
||||||
return _sys_call1 (SYS_setgid, (long)newgid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// make+POSIX
|
|
||||||
int
|
|
||||||
sigprocmask (int how, sigset_t const *set, sigset_t *oldset)
|
|
||||||
{
|
|
||||||
#if __i386__
|
|
||||||
return _sys_call3 (SYS_sigprocmask, (long)how, (long)set, (long)oldset);
|
|
||||||
#else
|
|
||||||
return _sys_call3 (SYS_rt_sigprocmask, (long)how, (long)set, (long)oldset);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
25
lib/linux/kill.c
Normal file
25
lib/linux/kill.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
kill (pid_t pid, int signum)
|
||||||
|
{
|
||||||
|
return _sys_call2 (SYS_kill, (long)pid, (long)signum);
|
||||||
|
}
|
25
lib/linux/link.c
Normal file
25
lib/linux/link.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
link (char const *old_name, char const *new_name)
|
||||||
|
{
|
||||||
|
return _sys_call2 (SYS_link, (long)old_name, (long)new_name);
|
||||||
|
}
|
25
lib/linux/lstat.c
Normal file
25
lib/linux/lstat.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
lstat (char const *file_name, struct stat *statbuf)
|
||||||
|
{
|
||||||
|
return _sys_call2 (SYS_lstat, (long)file_name, (long)statbuf);
|
||||||
|
}
|
25
lib/linux/mkdir.c
Normal file
25
lib/linux/mkdir.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
mkdir (char const *file_name, mode_t mode)
|
||||||
|
{
|
||||||
|
return _sys_call2 (SYS_mkdir, (long)file_name, (long)mode);
|
||||||
|
}
|
26
lib/linux/nanosleep.c
Normal file
26
lib/linux/nanosleep.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
nanosleep (const struct timespec *requested_time,
|
||||||
|
struct timespec *remaining)
|
||||||
|
{
|
||||||
|
return _sys_call2 (SYS_nanosleep, (long)requested_time, (long)remaining);
|
||||||
|
}
|
25
lib/linux/pipe.c
Normal file
25
lib/linux/pipe.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
pipe (int filedes[2])
|
||||||
|
{
|
||||||
|
return _sys_call1 (SYS_pipe, (long)filedes);
|
||||||
|
}
|
25
lib/linux/rename.c
Normal file
25
lib/linux/rename.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
rename (char const *old_name, char const *new_name)
|
||||||
|
{
|
||||||
|
return _sys_call2 (SYS_rename, (long)old_name, (long)new_name);
|
||||||
|
}
|
25
lib/linux/setgid.c
Normal file
25
lib/linux/setgid.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
setgid (gid_t newgid)
|
||||||
|
{
|
||||||
|
return _sys_call1 (SYS_setgid, (long)newgid);
|
||||||
|
}
|
26
lib/linux/settimer.c
Normal file
26
lib/linux/settimer.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
setitimer (int which, struct itimerval const *new,
|
||||||
|
struct itimerval *old)
|
||||||
|
{
|
||||||
|
return _sys_call3 (SYS_setitimer, (long)which, (long)new, (long)old);
|
||||||
|
}
|
25
lib/linux/setuid.c
Normal file
25
lib/linux/setuid.c
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
setuid (uid_t newuid)
|
||||||
|
{
|
||||||
|
return _sys_call1 (SYS_setuid, (long)newuid);
|
||||||
|
}
|
51
lib/linux/signal.c
Normal file
51
lib/linux/signal.c
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __x86_64__
|
||||||
|
void
|
||||||
|
_restorer (void)
|
||||||
|
{
|
||||||
|
_sys_call (SYS_rt_sigreturn);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# define __sigmask(sig) \
|
||||||
|
(((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
|
||||||
|
|
||||||
|
sighandler_t
|
||||||
|
signal (int signum, sighandler_t action)
|
||||||
|
{
|
||||||
|
#if __i386__
|
||||||
|
return _sys_call2 (SYS_signal, signum, action);
|
||||||
|
#else
|
||||||
|
static struct sigaction setup_action = {-1};
|
||||||
|
static struct sigaction old = {0};
|
||||||
|
|
||||||
|
setup_action.sa_handler = action;
|
||||||
|
setup_action.sa_restorer = _restorer;
|
||||||
|
setup_action.sa_mask = __sigmask (signum);
|
||||||
|
old.sa_handler = SIG_DFL;
|
||||||
|
setup_action.sa_flags = SA_RESTORER | SA_RESTART;
|
||||||
|
int r = _sys_call4 (SYS_rt_sigaction, signum, &setup_action, &old, sizeof (sigset_t));
|
||||||
|
if (r)
|
||||||
|
return 0;
|
||||||
|
return old.sa_handler;
|
||||||
|
#endif
|
||||||
|
}
|
29
lib/linux/sigprogmask.c
Normal file
29
lib/linux/sigprogmask.c
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes 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; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
sigprocmask (int how, sigset_t const *set, sigset_t *oldset)
|
||||||
|
{
|
||||||
|
#if __i386__
|
||||||
|
return _sys_call3 (SYS_sigprocmask, (long)how, (long)set, (long)oldset);
|
||||||
|
#else
|
||||||
|
return _sys_call3 (SYS_rt_sigprocmask, (long)how, (long)set, (long)oldset);
|
||||||
|
#endif
|
||||||
|
}
|
Loading…
Reference in a new issue