1 /* -*-comment-start: "//";comment-end:""-*-
2 * GNU Mes --- Maxwell Equations of Software
3 * Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
5 * This file is part of GNU Mes.
7 * GNU Mes is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
12 * GNU Mes is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
22 #define SYS_getpid 0x14
23 #define SYS_getuid 0x18
25 #define SYS_rename 0x26
26 #define SYS_mkdir 0x27
29 #define SYS_getgid 0x2f
30 #define SYS_signal 0x30
31 #define SYS_fcntl 0x37
33 #define SYS_getrusage 0x4d
34 #define SYS_lstat 0x6b
35 #define SYS_setitimer 0x68
36 #define SYS_fstat 0x6c
37 #define SYS_nanosleep 0xa2
39 #include <sys/resource.h>
42 link (char const *old_name, char const *new_name)
44 return _sys_call2 (SYS_link, (long)old_name, (long)new_name);
50 return _sys_call (SYS_getpid);
56 return _sys_call (SYS_getuid);
60 kill (pid_t pid, int signum)
62 return _sys_call2 (SYS_kill, (long)pid, (long)signum);
66 rename (char const *old_name, char const *new_name)
68 return _sys_call2 (SYS_rename, (long)old_name, (long)new_name);
72 mkdir (char const *file_name, mode_t mode)
74 return _sys_call2 (SYS_mkdir, (long)file_name, (long)mode);
80 return _sys_call1 (SYS_dup, (long)old);
86 return _sys_call (SYS_getgid);
91 signal (int signum, void * action)
94 signal (int signum, sighandler_t action)
97 return _sys_call2 (SYS_signal, signum, action);
101 fcntl (int filedes, int command, ...)
104 va_start (ap, command);
105 int data = va_arg (ap, int);
106 int r = _sys_call3 (SYS_fcntl, (long)filedes, (long)command, (long)data);
112 pipe (int filedes[2])
114 return _sys_call1 (SYS_pipe, (long)filedes);
118 dup2 (int old, int new)
120 return _sys_call2 (SYS_dup2, (long)old, (long)new);
124 getrusage (int processes, struct rusage *rusage)
126 return _sys_call2 (SYS_getrusage, (long)processes, (long)rusage);
130 lstat (char const *file_name, struct stat *statbuf)
132 return _sys_call2 (SYS_lstat, (long)file_name, (long)statbuf);
136 nanosleep (const struct timespec *requested_time,
137 struct timespec *remaining)
139 return _sys_call2 (SYS_nanosleep, (long)requested_time, (long)remaining);
143 setitimer (int which, struct itimerval const *new,
144 struct itimerval *old)
146 return _sys_call3 (SYS_setitimer, (long)which, (long)new, (long)old);
150 fstat (int fd, struct stat *statbuf)
152 return _sys_call2 (SYS_fstat, (long)fd, (long)statbuf);