2017-05-02 21:30:46 +00:00
|
|
|
/* -*-comment-start: "//";comment-end:""-*-
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes --- Maxwell Equations of Software
|
core: Support fork, waitpid, execve.
* stage0/x86.M1 (SYS_fork, SYS_waitpid, SYS_execve): New define.
* lib/linux-gcc.c (fork, waitpid, execve): New function.
* lib/linux-mes.c (fork, waitpid, execve): New function.
* lib/libc.c (wait): New function.
* include/unistd.h (fork, execve): Declare.
* include/sys/wait.h (waitpid, wait): Declare.
* module/mes/posix.mes (search-path, execlp, system*, waitpid): New function.
* src/posix.c (primitive_fork, execl): New function.
2018-05-24 17:54:42 +00:00
|
|
|
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2017-05-02 21:30:46 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* This file is part of GNU Mes.
|
2017-05-02 21:30:46 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is free software; you can redistribute it and/or modify it
|
2017-05-02 21:30:46 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is distributed in the hope that it will be useful, but
|
2017-05-02 21:30:46 +00:00
|
|
|
* 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
|
2018-07-22 12:24:36 +00:00
|
|
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
2017-05-02 21:30:46 +00:00
|
|
|
*/
|
2017-05-23 05:16:08 +00:00
|
|
|
#ifndef __MES_UNISTD_H
|
|
|
|
#define __MES_UNISTD_H 1
|
2017-05-02 21:30:46 +00:00
|
|
|
|
2019-05-29 14:15:12 +00:00
|
|
|
#if SYSTEM_LIBC
|
2017-05-02 21:30:46 +00:00
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif
|
2017-07-23 13:49:03 +00:00
|
|
|
#undef __MES_UNISTD_H
|
2017-05-02 21:30:46 +00:00
|
|
|
#include_next <unistd.h>
|
|
|
|
|
2019-05-29 14:15:12 +00:00
|
|
|
#else // ! SYSTEM_LIBC
|
2017-05-02 21:30:46 +00:00
|
|
|
|
2018-11-10 07:32:42 +00:00
|
|
|
#if defined (BOOTSTRAP_WITH_POSIX)
|
mescc: Support GNU Bash.
* include/errno.h (EACCES, ENOSPC, ESPIPE): New macro.
* include/linux/x86/syscall.h (SYS_setuid, SYS_geteuid, SYS_getegid,
SYS_setgid): New macro.
* include/linux/x86_64/syscall.h: Likewise.
* include/stdint.h (LLONG_MIN, LLONG_MAX, SIZE_MAX): New macro.
* include/sys/stat.h (S_ISUID, S_ISGID, S_IXGRP, S_IXOTH, S_IRGRP,
S_IROTH, S_IWGRP, S_IWOTH, S_IRWXG, S_IRWXO): New macro.
* include/termio.h: New file.
* include/unistd.h (_POSIX_VERSION): New macro.
* lib/linux/gnu.c (geteuid, getegid, setuid, setgid): New function.
* lib/string/memchr.c: New file.
* lib/stub/getpwuid.c: New file.
* lib/stub/rand.c: New file.
* lib/stub/ttyname.c: New file.
* include/string.h (memchr): Declare.
* include/unistd.h (geteuid, getegid, setuid, setgid): Declare.
2018-11-09 20:26:10 +00:00
|
|
|
#define _POSIX_VERSION 199009L
|
2018-11-10 07:32:42 +00:00
|
|
|
#endif
|
mescc: Support GNU Bash.
* include/errno.h (EACCES, ENOSPC, ESPIPE): New macro.
* include/linux/x86/syscall.h (SYS_setuid, SYS_geteuid, SYS_getegid,
SYS_setgid): New macro.
* include/linux/x86_64/syscall.h: Likewise.
* include/stdint.h (LLONG_MIN, LLONG_MAX, SIZE_MAX): New macro.
* include/sys/stat.h (S_ISUID, S_ISGID, S_IXGRP, S_IXOTH, S_IRGRP,
S_IROTH, S_IWGRP, S_IWOTH, S_IRWXG, S_IRWXO): New macro.
* include/termio.h: New file.
* include/unistd.h (_POSIX_VERSION): New macro.
* lib/linux/gnu.c (geteuid, getegid, setuid, setgid): New function.
* lib/string/memchr.c: New file.
* lib/stub/getpwuid.c: New file.
* lib/stub/rand.c: New file.
* lib/stub/ttyname.c: New file.
* include/string.h (memchr): Declare.
* include/unistd.h (geteuid, getegid, setuid, setgid): Declare.
2018-11-09 20:26:10 +00:00
|
|
|
|
2018-06-19 18:23:38 +00:00
|
|
|
#include <sys/types.h>
|
2018-05-30 19:55:39 +00:00
|
|
|
#ifndef NULL
|
|
|
|
#define NULL 0
|
|
|
|
#endif
|
|
|
|
|
2018-06-06 11:16:25 +00:00
|
|
|
#ifndef STDIN_FILENO
|
|
|
|
#define STDIN_FILENO 0
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
#define STDERR_FILENO 2
|
|
|
|
#endif // STDIN_FILENO
|
|
|
|
|
2018-06-06 20:14:35 +00:00
|
|
|
#ifndef STDIN_FILE_NO
|
|
|
|
#define STDIN_FILE_NO 0
|
|
|
|
#define STDOUT_FILE_NO 1
|
|
|
|
#define STDERR_FILE_NO 2
|
|
|
|
#endif // STDIN_FILE_NO
|
|
|
|
|
2018-06-02 09:41:06 +00:00
|
|
|
#ifndef R_OK
|
|
|
|
#define F_OK 0
|
|
|
|
#define X_OK 1
|
|
|
|
#define W_OK 2
|
|
|
|
#define R_OK 4
|
|
|
|
#endif
|
|
|
|
|
2017-05-23 05:16:08 +00:00
|
|
|
int access (char const *s, int mode);
|
2018-06-02 09:41:06 +00:00
|
|
|
unsigned int alarm (unsigned int seconds);
|
2017-07-24 10:21:24 +00:00
|
|
|
int close (int fd);
|
2018-06-02 09:41:06 +00:00
|
|
|
int execv (char const *file_name, char *const argv[]);
|
2018-08-26 18:54:29 +00:00
|
|
|
int execl (char const *file_name, char const *arg, ...);
|
core: Support fork, waitpid, execve.
* stage0/x86.M1 (SYS_fork, SYS_waitpid, SYS_execve): New define.
* lib/linux-gcc.c (fork, waitpid, execve): New function.
* lib/linux-mes.c (fork, waitpid, execve): New function.
* lib/libc.c (wait): New function.
* include/unistd.h (fork, execve): Declare.
* include/sys/wait.h (waitpid, wait): Declare.
* module/mes/posix.mes (search-path, execlp, system*, waitpid): New function.
* src/posix.c (primitive_fork, execl): New function.
2018-05-24 17:54:42 +00:00
|
|
|
int execve (char const *file, char *const argv[], char *const env[]);
|
2017-07-24 18:33:15 +00:00
|
|
|
int execvp (char const *file, char *const argv[]);
|
2018-06-19 18:23:38 +00:00
|
|
|
int fork (void);
|
2019-06-08 13:36:22 +00:00
|
|
|
int fsync (int filedes);
|
2017-07-24 11:49:17 +00:00
|
|
|
char *getcwd (char *buf, size_t size);
|
2018-06-19 18:23:38 +00:00
|
|
|
uid_t getuid (void);
|
mescc: Support GNU Bash.
* include/errno.h (EACCES, ENOSPC, ESPIPE): New macro.
* include/linux/x86/syscall.h (SYS_setuid, SYS_geteuid, SYS_getegid,
SYS_setgid): New macro.
* include/linux/x86_64/syscall.h: Likewise.
* include/stdint.h (LLONG_MIN, LLONG_MAX, SIZE_MAX): New macro.
* include/sys/stat.h (S_ISUID, S_ISGID, S_IXGRP, S_IXOTH, S_IRGRP,
S_IROTH, S_IWGRP, S_IWOTH, S_IRWXG, S_IRWXO): New macro.
* include/termio.h: New file.
* include/unistd.h (_POSIX_VERSION): New macro.
* lib/linux/gnu.c (geteuid, getegid, setuid, setgid): New function.
* lib/string/memchr.c: New file.
* lib/stub/getpwuid.c: New file.
* lib/stub/rand.c: New file.
* lib/stub/ttyname.c: New file.
* include/string.h (memchr): Declare.
* include/unistd.h (geteuid, getegid, setuid, setgid): Declare.
2018-11-09 20:26:10 +00:00
|
|
|
gid_t getgid (void);
|
|
|
|
int setgid (gid_t newgid);
|
|
|
|
int setuid (uid_t newuid);
|
|
|
|
uid_t geteuid (void);
|
|
|
|
gid_t getegid (void);
|
2019-06-08 13:36:22 +00:00
|
|
|
pid_t getpid (void);
|
|
|
|
pid_t getppid (void);
|
2018-04-22 09:47:44 +00:00
|
|
|
int isatty (int fd);
|
2018-06-16 13:18:27 +00:00
|
|
|
int link (char const *oldname, char const *newname);
|
2017-07-24 15:33:33 +00:00
|
|
|
off_t lseek (int fd, off_t offset, int whence);
|
2018-06-03 16:54:26 +00:00
|
|
|
ssize_t read (int fd, void *buffer, size_t size);
|
2018-06-06 11:16:25 +00:00
|
|
|
#if __SBRK_CHAR_PTRDIFF
|
|
|
|
/* xmalloc in binutils <= 2.10.1 uses this old prototype */
|
2019-05-18 11:27:42 +00:00
|
|
|
char *sbrk (ptrdiff_t delta);
|
2018-06-06 11:16:25 +00:00
|
|
|
#else
|
2019-05-18 11:27:42 +00:00
|
|
|
void *sbrk (intptr_t delta);
|
2018-06-06 11:16:25 +00:00
|
|
|
#endif
|
2017-07-24 15:09:33 +00:00
|
|
|
int unlink (char const *file_name);
|
2018-06-03 16:54:26 +00:00
|
|
|
ssize_t write (int filedes, void const *buffer, size_t size);
|
2018-06-06 20:14:35 +00:00
|
|
|
pid_t getpid (void);
|
|
|
|
|
2019-05-29 14:15:12 +00:00
|
|
|
#endif // ! SYSTEM_LIBC
|
2017-05-02 21:30:46 +00:00
|
|
|
|
2017-05-23 05:16:08 +00:00
|
|
|
#endif // __MES_UNISTD_H
|