From 6e7d1e41b41d69bc8d67b2a5acd185bfe81566ef Mon Sep 17 00:00:00 2001 From: wolfwood Date: Fri, 14 Oct 2011 00:45:06 -0400 Subject: [PATCH] remove pieces that are now implemented in D, change of lib name. MUST UPGRADE XOmB TOO! --- embedlibs.sh | 2 +- newlib-files/syscalls.c | 232 +--------------------------------------- 2 files changed, 3 insertions(+), 231 deletions(-) diff --git a/embedlibs.sh b/embedlibs.sh index 3b849f0..85e8347 100755 --- a/embedlibs.sh +++ b/embedlibs.sh @@ -5,7 +5,7 @@ cd .tempobjs ar x ../../xomb/runtimes/mindrt/drt0.a ar x ../../xomb/runtimes/mindrt/mindrt.a -ar x ../../xomb/user/c/lib/syscall.a +ar x ../../xomb/user/c/lib/cbindings.a ar -rs ../local/x86_64-pc-xomb/lib/libc.a *.o cd .. diff --git a/newlib-files/syscalls.c b/newlib-files/syscalls.c index eeba673..93c9f62 100644 --- a/newlib-files/syscalls.c +++ b/newlib-files/syscalls.c @@ -14,60 +14,14 @@ // first, the 13 required calls -// --- Process Control --- -int -_exit(int val){ - __exit(val); - return (-1); -} -int -_execve(char *name, char **argv, char **env) { - errno = ENOMEM; - return -1; -} - -/* - * getpid -- only one process, so just return 1. - */ -#define __MYPID 1 -int -getpid() -{ - return __MYPID; -} - - -int -fork(void) { - errno = ENOTSUP; - return -1; -} /* * kill -- go out via exit... */ -int -kill(pid, sig) - int pid; - int sig; -{ - if(pid == __MYPID) - _exit(sig); - errno = EINVAL; - return -1; -} - -int -wait(int *status) { - errno = ECHILD; - return -1; -} - -// --- I/O --- /* * isatty -- returns 1 if connected to a terminal device, @@ -76,123 +30,9 @@ wait(int *status) { */ -int gibOpen(const char* name, unsigned int nameLen, bool readOnly, bool append, bool create); -int gibRead(int fd, void* buf, unsigned int len); -int gibWrite(int fd, void* buf, unsigned int len); unsigned long long initHeap(); -int -_isatty(fd) - int fd; -{ - if(fd < 3){ - return 1; - }else{ - return 0; - } -} - -int -open(const char *name, int flags, ...) { - int nameLen = strlen(name); - bool readOnly = false, append = false, create = true; - int fd; - - // O_RDONLY isn't Quite a flag, is defined as 0 - if( flags == O_RDONLY ){ - readOnly = true; - } - - fd = gibOpen(name, nameLen, readOnly, append, create); - - if(fd == -1){ - errno = ENFILE; - return -1; - } - - return fd; -} - -int -close(int file) { - int err = gibClose(file); - - if(err < 0){ - errno = EBADF; - return -1; - }else{ - return 0; - } -} - -int -read(int file, char *ptr, int len) { - // XXX: keyboard support - if(file < 3){ - return -1; - } - - int err = gibRead(file, ptr, len); - - if(err == -1){ - errno = EBADF; - } - - return err; -} - -int -write(int file, char *ptr, int len) { - if(file == 1 || file == 2){ - wconsole(ptr, len); - - return len; - } - - int err = gibWrite(file, ptr, len); - - if(err >= 0){ - return err; - }else{ - errno = EBADF; - return -1; - } -} - - -/* XXX: implement these */ -int -lseek(int file, int ptr, int dir) { - return 0; -} - - -int -fstat(int file, struct stat *st) { - st->st_mode = S_IFCHR; - return 0; -} - -int -stat(const char *file, struct stat *st){ - st->st_mode = S_IFCHR; - return 0; -} - -int -link(char *old, char *new) { - errno = EMLINK; - return -1; -} - -int -unlink(char *name) { - errno = ENOENT; - return -1; -} - - // --- Memory --- #define PAGE_SIZE 4096ULL #define PAGE_MASK 0xFFFFFFFFFFFFF000ULL @@ -252,93 +92,25 @@ sbrk(int nbytes){ } -// some additional functions that aren't provided by default - static int fail(); -// missing binutils deps: fnctl, umask, chmod, access, lstat, pathconf, utime - -int fcntl(int fd, int cmd, ... ){ - errno = ENOSYS; - return -1; -} - -mode_t umask(mode_t mask){ - return 0777; -} - -int chmod(const char *path, mode_t mode){ - errno = ENOSYS; - return -1; -} - -int chown(const char *path, uid_t owner, gid_t group){ - errno = ENOSYS; - return -1; -} - -int access(const char *pathname, int mode){ - errno = ENOSYS; - return -1; -} - -int lstat(const char *path, struct stat *buf){ - return stat(path, buf); -} - -long pathconf(char *path, int name){ - // no limits - return -1; -} - int utime(const char *filename, const struct utimbuf *times){ // I ain't tellin' errno = EPERM; return -1; } -// missing gcc deps: sleep, alarm, pipe, dup2, execvp - -unsigned int sleep(unsigned int seconds){ - return 0; -} - -unsigned int alarm(unsigned int seconds){ - return 0; -} - -int pipe(int pipefd[2]){ - return fail(); -} - -int dup(int oldfd){ - // XXX: find a free fd - return dup2(oldfd, 7); -} - -int dup2(int oldfd, int newfd){ - return fail(); -} - int getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count){ return fail(); } -long sysconf(int name){ - return fail(); -} - -int chdir(const char *path){ - return fail(); -} - int getrusage(int who, struct rusage *usage){ return fail(); } -int fail(){ +/*int fail(){ errno = ENOSYS; return -1; -} + }*/