#include <stdio.h>
#include <sys/file.h>
+#include <sys/stat.h>
#include <time.h>
#include "tp.h"
# @(#)Makefile 5.4 (Berkeley) 9/5/85
#
-SRCS= chmod.c chown.c close.c dup2.c dup.c _exit.c fchmod.c fchown.c \
- fstat.c ftruncate.c getdtablesize.c getegid.c geteuid.c getgid.c \
- getpagesize.c getpgrp.c getpid.c getppid.c gettimeofday.c getuid.c \
- ioctl.c link.c linux.c lseek.c lstat.c read.c readv.c sbrk.c \
- setpgrp.c setregid.c setreuid.c settimeofday.c sigvec.c stat.c \
- symlink.c sync.c truncate.c umask.c unlink.c vopen.c write.c writev.c
-
-OBJS= chmod.o chown.o close.o dup2.o dup.o _exit.o fchmod.o fchown.o \
- fstat.o ftruncate.o getdtablesize.o getegid.o geteuid.o getgid.o \
- getpagesize.o getpgrp.o getpid.o getppid.o gettimeofday.o getuid.o \
- ioctl.o link.o linux.o lseek.o lstat.o read.o readv.o sbrk.o \
- setpgrp.o setregid.o setreuid.o settimeofday.o sigvec.o stat.o \
- symlink.o sync.o truncate.o umask.o unlink.o vopen.o write.o writev.o
+SRCS= chdir.c chmod.c chown.c chroot.c close.c dup2.c dup.c execve.c \
+ _exit.c fchmod.c fchown.c fork.c fstat.c ftruncate.c getdtablesize.c \
+ getegid.c geteuid.c getgid.c getpagesize.c getpgrp.c getpid.c \
+ getppid.c getrusage.c gettimeofday.c getuid.c ioctl.c link.c linux.c \
+ lseek.c lstat.c read.c readv.c sbrk.c setpgrp.c setregid.c \
+ setreuid.c settimeofday.c sigvec.c stat.c symlink.c sync.c \
+ truncate.c umask.c unlink.c utimes.c vopen.c wait.c write.c writev.c
+
+OBJS= chdir.o chmod.o chown.o chroot.o close.o dup2.o dup.o execve.o \
+ _exit.o fchmod.o fchown.o fork.o fstat.o ftruncate.o getdtablesize.o \
+ getegid.o geteuid.o getgid.o getpagesize.o getpgrp.o getpid.o \
+ getppid.o getrusage.o gettimeofday.o getuid.o ioctl.o link.o linux.o \
+ lseek.o lstat.o read.o readv.o sbrk.o setpgrp.o setregid.o \
+ setreuid.o settimeofday.o sigvec.o stat.o symlink.o sync.o \
+ truncate.o umask.o unlink.o utimes.o vopen.o wait.o write.o writev.o
+
TAGSFILE=tags
.c.o:
--- /dev/null
+#include <nox_errno.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys/proc.h>
+#include "linux.h"
+
+int chdir(s) char *s; {
+ if (nox_chdir(s)) {
+ errno = htot_errno(nox_errno);
+ return -1;
+ }
+ return 0;
+}
--- /dev/null
+#include <nox_errno.h>
+#include <nox_unistd.h>
+
+#include <errno.h>
+#include <sys/proc.h>
+#include "linux.h"
+
+int chroot(s) char *s; {
+ if (nox_chroot(s)) {
+ errno = htot_errno(nox_errno);
+ return -1;
+ }
+ return 0;
+}
--- /dev/null
+#include <nox_unistd.h>
+
+#include <sys/exec.h>
+
+void execve(s, v, e) char *s; char *v[]; char *e[]; {
+ nox_execve(s, v, e);
+}
--- /dev/null
+#include <nox_errno.h>
+#include <nox_unistd.h>
+
+#include <sys/errno.h>
+#include <sys/proc.h>
+#include <sys/types.h>
+#include "linux.h"
+
+int fork() {
+ nox_pid_t res;
+
+ res = nox_fork();
+ if (res == (nox_pid_t)-1)
+ errno = htot_errno(nox_errno);
+ return (int)res;
+}
--- /dev/null
+#include <nox_errno.h>
+#include <nox_stdlib.h>
+#include <sys/nox_resource.h>
+#include <nox_unistd.h>
+
+#include <sys/errno.h>
+#include <sys/resource.h>
+#include "linux.h"
+
+int getrusage(res, rip) int res; struct rusage *rip; {
+ nox_int who;
+ struct nox_rusage ru;
+
+ switch (res) {
+ case RUSAGE_SELF:
+ who = nox_RUSAGE_SELF;
+ break;
+ case RUSAGE_CHILDREN:
+ who = nox_RUSAGE_CHILDREN;
+ break;
+ default:
+ nox_write((nox_int)2, "getrusage(): invalid who\n", 25);
+ nox_abort();
+ }
+ if (nox_getrusage(who, &ru)) {
+ errno = htot_errno(nox_errno);
+ return -1;
+ }
+ rip->ru_utime.tv_sec = (time_t)ru.nox_ru_utime.nox_tv_sec;
+ rip->ru_utime.tv_usec = (time_t)ru.nox_ru_utime.nox_tv_usec;
+ rip->ru_stime.tv_sec = (time_t)ru.nox_ru_stime.nox_tv_sec;
+ rip->ru_stime.tv_usec = (time_t)ru.nox_ru_stime.nox_tv_usec;
+ rip->ru_maxrss = (long)ru.nox_ru_maxrss;
+ rip->ru_ixrss = (long)ru.nox_ru_ixrss;
+ rip->ru_idrss = (long)ru.nox_ru_idrss;
+ rip->ru_isrss = (long)ru.nox_ru_isrss;
+ rip->ru_minflt = (long)ru.nox_ru_minflt;
+ rip->ru_majflt = (long)ru.nox_ru_majflt;
+ rip->ru_nswap = (long)ru.nox_ru_nswap;
+ rip->ru_inblock = (long)ru.nox_ru_inblock;
+ rip->ru_oublock = (long)ru.nox_ru_oublock;
+ rip->ru_msgsnd = (long)ru.nox_ru_msgsnd;
+ rip->ru_msgrcv = (long)ru.nox_ru_msgrcv;
+ rip->ru_nsignals = (long)ru.nox_ru_nsignals;
+ rip->ru_nvcsw = (long)ru.nox_ru_nvcsw;
+ rip->ru_nivcsw = (long)ru.nox_ru_nivcsw;
+ return 0;
+}
#include <nox_errno.h>
+#include <nox_stdlib.h>
#include <nox_unistd.h>
#include <sys/nox_types.h>
-#include <gen.h>
#include <sys/errno.h>
#include <sys/file.h>
#include <sys/types.h>
whence = nox_SEEK_END;
break;
default:
- write(2, "lseek(): invalid whence\n", 24);
- abort();
+ nox_write((nox_int)2, "lseek(): invalid whence\n", 24);
+ nox_abort();
}
res = nox_lseek(f, (nox_off_t)o, whence);
if (res == (nox_off_t)-1)
#include <nox_errno.h>
+#include <nox_stdlib.h>
#include <nox_unistd.h>
#include <sys/nox_uio.h>
-#include <gen.h>
#include <sys/errno.h>
#include <sys/file.h>
#include <sys/uio.h>
int readv(f, v, l) int f; struct iovec *v; int l; {
int i;
- struct nox_iovec iov[8];
+ struct nox_iovec iov[16];
nox_int res;
- if (l > 8) {
- write(2, "readv(): iovec too large\n", 25);
- abort();
+ if (l > 16) {
+ nox_write((nox_int)2, "readv(): iovec too large\n", 25);
+ nox_abort();
}
for (i = 0; i < l; ++i) {
iov[i].nox_iov_base = v[i].iov_base;
#include <nox_errno.h>
#include <nox_signal.h>
+#include <nox_stdlib.h>
+#include <nox_unistd.h>
-#include <gen.h>
#include <errno.h>
#include <sys/file.h>
#include <sys/signal.h>
if (f->sv_flags & SV_ONSTACK)
act.nox_sa_flags |= nox_SA_ONSTACK;
if (f->sv_flags & SV_INTERRUPT) {
- write(2, "sigvec(): SV_INTERRUPT\n", 23);
- abort();
+ nox_write((nox_int)2, "sigvec(): SV_INTERRUPT\n", 23);
+ nox_abort();
}
if (c < 0 || c >= NSIG) {
- write(2, "sigvec(): out of range\n", 23);
- abort();
+ nox_write((nox_int)2, "sigvec(): out of range\n", 23);
+ nox_abort();
}
if (nox_sigaction(ttoh_signo[c], &act, &oldact)) {
errno = htot_errno(nox_errno);
--- /dev/null
+#include <nox_errno.h>
+#include <sys/nox_time.h>
+#include <sys/nox_types.h>
+
+#include <errno.h>
+#include <sys/time.h>
+#include "linux.h"
+
+int utimes(f, t) char *f; struct timeval t[2]; {
+ struct nox_timeval tv[2];
+
+ tv[0].nox_tv_sec = (nox_time_t)t[0].tv_sec;
+ tv[0].nox_tv_usec = (nox_suseconds_t)t[0].tv_usec;
+ tv[1].nox_tv_sec = (nox_time_t)t[1].tv_sec;
+ tv[1].nox_tv_usec = (nox_suseconds_t)t[1].tv_usec;
+ if (nox_utimes(f, tv)) {
+ errno = htot_errno(nox_errno);
+ return -1;
+ }
+ return 0;
+}
#include <nox_errno.h>
#include <nox_fcntl.h>
+#include <nox_stdlib.h>
#include <sys/nox_stat.h>
#include <nox_unistd.h>
-#include <gen.h>
#include <sys/errno.h>
#include <sys/file.h>
#ifdef __STDC__
flags = nox_O_RDWR;
break;
default:
- write(2, "vopen(): invalid flags\n", 23);
- abort();
+ nox_write((nox_int)2, "vopen(): invalid flags\n", 23);
+ nox_abort();
}
if (m & O_NDELAY)
flags |= nox_O_NDELAY;
--- /dev/null
+#include <nox_errno.h>
+#include <nox_stdlib.h>
+#include <sys/nox_types.h>
+#include <sys/nox_wait.h>
+#include <nox_unistd.h>
+
+#include <sys/errno.h>
+#include <sys/wait.h>
+#include "linux.h"
+
+int wait(s) int *s; {
+ nox_pid_t res;
+ nox_int stat;
+ union wait w;
+
+ res = nox_wait(&stat);
+ if (res == (nox_pid_t)-1) {
+ errno = htot_errno(nox_errno);
+ return -1;
+ }
+ if (nox_WIFEXITED(stat)) {
+ w.w_termsig = 0;
+ w.w_coredump = 0;
+ w.w_retcode = nox_WEXITSTATUS(stat);
+ }
+ else if (nox_WIFSIGNALED(stat)) {
+ w.w_termsig = htot_signo(nox_WTERMSIG(stat));
+ w.w_coredump = nox_WCOREDUMP(stat);
+ w.w_retcode = 0;
+ }
+ else if (nox_WIFSTOPPED(stat)) {
+ w.w_stopval = WSTOPPED;
+ w.w_stopsig = htot_signo(nox_WSTOPSIG(stat));
+ }
+ else {
+ nox_write((nox_int)2, "wait(): invalid status\n", 23);
+ nox_abort();
+ }
+ *s = w.w_status;
+ return (int)res;
+}
#include <nox_errno.h>
+#include <nox_stdlib.h>
#include <nox_unistd.h>
#include <sys/nox_uio.h>
-#include <gen.h>
#include <sys/errno.h>
#include <sys/file.h>
#include <sys/uio.h>
int writev(f, v, l) int f; struct iovec *v; int l; {
int i;
- struct nox_iovec iov[8];
+ struct nox_iovec iov[16];
nox_int res;
- if (l > 8) {
- write(2, "writev(): iovec too large\n", 26);
- abort();
+ if (l > 16) {
+ nox_write((nox_int)2, "writev(): iovec too large\n", 26);
+ nox_abort();
}
for (i = 0; i < l; ++i) {
iov[i].nox_iov_base = v[i].iov_base;
-#include <gen.h>
-/*#include <sys/exec.h> gen.h*/
-#include <sys/file.h>
+#include <sys/exec.h>
#ifdef __STDC__
#include <stdarg.h>
#define _va_start(argp, arg) va_start(argp, arg)
#define _va_start(argp, arg) va_start(argp)
#endif
-/*#include <varargs.h>*/
+#ifdef __x86_64__
+#include <gen.h>
+#include <sys/file.h>
+#endif
+
#ifdef __STDC__
void execl(char *f, ...)
#else
void execl(f, va_alist) char *f; va_dcl
#endif
{
- write(2, "execl()\n", 8);
- abort();
+ va_list argp;
+#ifdef __x86_64__
+ int i;
+ char *argv[32];
+
+ _va_start(argp, f);
+ for (i = 0; (argv[i] = va_arg(argp, char *)) != 0; ++i)
+ if (i >= 32) {
+ write(2, "execl(): too many arguments\n", 28);
+ abort();
+ }
+ execv(f, argv);
+#else
+ _va_start(argp, f);
+ execv(f, (char **)argp);
+#endif
}
-#include <gen.h>
-/*#include <sys/exec.h> gen.h*/
-#include <sys/file.h>
+#include <sys/exec.h>
#ifdef __STDC__
#include <stdarg.h>
#define _va_start(argp, arg) va_start(argp, arg)
#define _va_start(argp, arg) va_start(argp)
#endif
-/*#include <varargs.h>*/
+#ifdef __x86_64__
+#include <gen.h>
+#include <sys/file.h>
+#endif
+
#ifdef __STDC__
void execle(char *f, ...)
#else
void execle(f, va_alist) char *f; va_dcl
#endif
{
- write(2, "execle()\n", 9);
- abort();
+ va_list argp;
+#ifdef __x86_64__
+ int i;
+ char *argv[32];
+
+ _va_start(argp, f);
+ for (i = 0; (argv[i] = va_arg(argp, char *)) != 0; ++i)
+ if (i >= 32) {
+ write(2, "execle(): too many arguments\n", 29);
+ abort();
+ }
+#else
+ char **argv;
+
+ _va_start(argp, f);
+ argv = (char **)argp;
+ while (va_arg(argp, char *))
+ ;
+#endif
+ execve(f, argv, va_arg(argp, char **));
}
-#include <gen.h>
-/*#include <sys/exec.h> gen.h*/
-#include <sys/file.h>
+#include <sys/exec.h>
+
+extern char **environ;
void execv(s, v) char *s; char *v[]; {
- write(2, "execv()\n", 8);
- abort();
+ execve(s, v, environ);
}
mkdir -p lib/libc/stdio/profiled
mkdir -p lib/libc/sys/profiled
(cd lib/libc && make.sh clean && make.sh && make.sh install)
-(cd bin && make.sh clean && make.sh SUBDIR="as csh diff sed" NSTD= KMEM= && make.sh SUBDIR="as csh diff sed" NSTD= KMEM= install)
+(cd bin && make.sh clean && make.sh SUBDIR="as csh diff sed sh tp" NSTD= KMEM= && make.sh SUBDIR="as csh diff sed sh tp" NSTD= KMEM= install)
#(cd test && make clean && make)