diff --git a/build.lua b/build.lua index a1fe98e80..f675b96ea 100644 --- a/build.lua +++ b/build.lua @@ -7,23 +7,23 @@ vars.ackcflags = { vars.ackldflags = {} vars.plats = { "cpm", - "linux386", - "linux68k", - "linuxppc", - "osx386", - "osxppc", - --"qemuppc", - "pc86", - "rpi", - "pdpv7", - "em22", +-- "linux386", +-- "linux68k", +-- "linuxppc", +-- "osx386", +-- "osxppc", +-- --"qemuppc", +-- "pc86", +-- "rpi", +-- "pdpv7", +-- "em22", } vars.plats_with_tests = { - "linux68k", - "linux386", - "linuxppc", - --"qemuppc", - "pc86", +-- "linux68k", +-- "linux386", +-- "linuxppc", +-- --"qemuppc", +-- "pc86", } local plat_packages = {} diff --git a/lang/cem/libcc.ansi/headers/ack/config.h b/lang/cem/libcc.ansi/headers/ack/config.h index 13a3305c5..84174a11d 100644 --- a/lang/cem/libcc.ansi/headers/ack/config.h +++ b/lang/cem/libcc.ansi/headers/ack/config.h @@ -11,4 +11,12 @@ #define ACKCONF_WANT_STDIO_FLOAT ACKCONF_WANT_FLOAT #endif +#ifndef ACKCONF_WANT_STANDARD_O +#define ACKCONF_WANT_STANDARD_O 1 +#endif + +#ifndef ACKCONF_WANT_STANDARD_SIGNALS +#define ACKCONF_WANT_STANDARD_SIGNALS 1 +#endif + #endif diff --git a/lang/cem/libcc.ansi/headers/stdint.h b/lang/cem/libcc.ansi/headers/stdint.h index ce9cf3e38..e2eb4c201 100644 --- a/lang/cem/libcc.ansi/headers/stdint.h +++ b/lang/cem/libcc.ansi/headers/stdint.h @@ -58,6 +58,7 @@ typedef int16_t intptr_t; typedef uint16_t uintptr_t; typedef int16_t ptrdiff_t; typedef uint16_t size_t; +typedef int16_t ssize_t; #define INTPTR_MAX 32767 #define INTPTR_MIN (-32768) #define UINTPTR_MAX 65535 @@ -66,6 +67,7 @@ typedef int32_t intptr_t; typedef uint32_t uintptr_t; typedef int32_t ptrdiff_t; typedef uint32_t size_t; +typedef int32_t ssize_t; #define INTPTR_MAX 2147483647 #define INTPTR_MIN (-2147483647) #define UINTPTR_MAX 4294967295 diff --git a/plat/cpm/include/unistd.h b/lang/cem/libcc.ansi/headers/unistd.h similarity index 54% rename from plat/cpm/include/unistd.h rename to lang/cem/libcc.ansi/headers/unistd.h index 99f1fb2d4..65e0b9991 100644 --- a/plat/cpm/include/unistd.h +++ b/lang/cem/libcc.ansi/headers/unistd.h @@ -1,19 +1,20 @@ -/* - * unistd.h - standard system calls - */ -/* $Id$ */ - #ifndef _UNISTD_H #define _UNISTD_H +/* + * Generic Posix prototypes used by the rest of the libc. Plats don't have to + * implement these if they don't care about the functionality, but if they do, + * they must conform to these prototypes. + */ + +#include #include +#include +#include -/* Types */ - -typedef int pid_t; -typedef int mode_t; - -/* Constants for file access (open and friends) */ +#if ACKCONF_WANT_STANDARD_O +/* A standard set of flags for read/write/creat and friends for platforms + * where these aren't determined by the operating system. */ enum { @@ -28,31 +29,11 @@ enum O_APPEND = 02000, O_NONBLOCK = 04000 }; +#endif -/* Special variables */ - -extern char** environ; - -/* Implemented system calls */ - -extern void _exit(int); -extern pid_t getpid(void); -extern void* sbrk(int increment); -extern int isatty(int d); -extern off_t lseek(int fildes, off_t offset, int whence); -extern int close(int d); -extern int open(const char* path, int access, ...); -extern int creat(const char* path, mode_t mode); -extern int read(int fd, void* buffer, size_t count); -extern int write(int fd, void* buffer, size_t count); -extern int unlink(const char* path); - -/* Unimplemented system calls (these are just prototypes to let the library - * compile). */ - -extern int fcntl(int fd, int op, ...); - -/* Signal handling */ +#if ACKCONF_WANT_STANDARD_SIGNALS +/* A standard set of definitions for signal handling for platforms where these + * aren't determined by the operating system. */ typedef int sig_atomic_t; @@ -63,10 +44,37 @@ typedef int sig_atomic_t; #define SIGABRT 6 /* Abort (ANSI) */ #define SIGILL 11 /* Illegal instruction */ -#define _NSIG 32 /* Biggest signal number + 1 +#define _NSIG 16 /* Biggest signal number + 1 (not including real-time signals). */ typedef void (*sighandler_t)(int); -extern sighandler_t signal(int signum, sighandler_t handler); -extern int raise(int signum); +typedef uint16_t sigset_t; + +#endif + +/* Special variables */ + +extern char** environ; + +/* Implemented system calls */ + +extern int brk(void* ptr); +extern int close(int d); +extern int creat(const char* path, mode_t mode); +extern int execve(const char *path, char *const argv[], char *const envp[]); +extern int isatty(int d); +extern int isatty(int d); +extern int kill(pid_t old, int sig); +extern int open(const char* path, int access, ...); +extern int raise(int signum); +extern int sigprocmask(int, const sigset_t *, sigset_t *); +extern int unlink(const char* path); +extern off_t lseek(int fildes, off_t offset, int whence); +extern pid_t getpid(void); +extern sighandler_t signal(int signum, sighandler_t handler); +extern ssize_t read(int fd, void* buffer, size_t count); +extern ssize_t write(int fd, void* buffer, size_t count); +extern void _exit(int); +extern void* sbrk(int increment); +extern int fcntl(int fd, int op, ...); #endif diff --git a/plat/cpm/include/build.lua b/plat/cpm/include/build.lua index 0fdc2903d..9820e3e09 100644 --- a/plat/cpm/include/build.lua +++ b/plat/cpm/include/build.lua @@ -9,8 +9,8 @@ local function addheader(h) end addheader("ack/plat.h") +addheader("sys/types.h") addheader("cpm.h") -addheader("unistd.h") acklibrary { name = "headers", diff --git a/plat/cpm/include/sys/types.h b/plat/cpm/include/sys/types.h new file mode 100644 index 000000000..9b384113d --- /dev/null +++ b/plat/cpm/include/sys/types.h @@ -0,0 +1,7 @@ +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H + +typedef int pid_t; +typedef int mode_t; + +#endif diff --git a/plat/cpm/libsys/read.c b/plat/cpm/libsys/read.c index f81bda777..df4a3ef3b 100644 --- a/plat/cpm/libsys/read.c +++ b/plat/cpm/libsys/read.c @@ -8,7 +8,7 @@ #include #include -int read(int fd, void* buffer, size_t count) +ssize_t read(int fd, void* buffer, size_t count) { short save; unsigned char before_n; @@ -37,7 +37,7 @@ int read(int fd, void* buffer, size_t count) /* Read one line from the console. */ ((unsigned char*)buffer)[-2] = before_n; cpm_bc_register = CPM_BDOS_READ_CONSOLE_BUFFER; - cpm_de_register = (char*)buffer - 2; + cpm_de_register = (uint16_t)(char*)buffer - 2; cpm_bdos(); before_n = ((unsigned char*)buffer)[-1]; @@ -46,7 +46,7 @@ int read(int fd, void* buffer, size_t count) /* Echo '\n' to console. */ cpm_bc_register = CPM_BDOS_PRINT_STRING; - cpm_de_register = "\r\n$"; + cpm_de_register = (uint16_t)"\r\n$"; cpm_bdos(); return (int)before_n + 1; diff --git a/plat/cpm/libsys/write.c b/plat/cpm/libsys/write.c index 0b5f2613d..21dbc90c0 100644 --- a/plat/cpm/libsys/write.c +++ b/plat/cpm/libsys/write.c @@ -22,7 +22,7 @@ void _sys_write_tty(char c) } } -int write(int fd, void* buffer, size_t count) +ssize_t write(int fd, void* buffer, size_t count) { int i; char* p = buffer;