Made the rpi platform work with the new libc layout.
authorDavid Given <dg@cowlark.com>
Sat, 23 Jun 2018 11:05:27 +0000 (13:05 +0200)
committerDavid Given <dg@cowlark.com>
Sat, 23 Jun 2018 11:05:27 +0000 (13:05 +0200)
build.lua
plat/rpi/include/build.lua
plat/rpi/include/sys/select.h
plat/rpi/include/sys/types.h [new file with mode: 0644]
plat/rpi/include/unistd.h [deleted file]
plat/rpi/libsys/read.c
plat/rpi/libsys/select.c
plat/rpi/libsys/write.c

index 8a765c0..09142db 100644 (file)
--- a/build.lua
+++ b/build.lua
@@ -14,7 +14,7 @@ vars.plats = {
        "osxppc",
 --     --"qemuppc",
        "pc86",
---     "rpi",
+       "rpi",
 --     "pdpv7",
 --     "em22",
 }
index 105f059..e568b6a 100644 (file)
@@ -11,8 +11,8 @@ end
 addheader("ack/plat.h")
 addheader("pi.h")
 addheader("sys/select.h")
+addheader("sys/types.h")
 addheader("termios.h")
-addheader("unistd.h")
 
 acklibrary {
        name = "headers",
index df7488d..d126bbf 100644 (file)
@@ -8,6 +8,16 @@
 #ifndef _SYS_SELECT_H
 #define _SYS_SELECT_H
 
-#include <unistd.h>
+#include <stdint.h>
+
+typedef uint32_t fd_set;
+
+extern int select(int nfds, fd_set *readfds, fd_set *writefds,
+                  fd_set *exceptfds, struct timeval *timeout);
+
+#define FD_ZERO(set) do { *set = 0; } while (0)
+#define FD_SET(fd, set) do { *set |= (1<<fd); } while (0);
+#define FD_CLR(fd, set) do { *set &= ~(1<<fd); } while (0);
+#define FD_ISSET(fd, set) (*set | (1<<fd))
 
 #endif
diff --git a/plat/rpi/include/sys/types.h b/plat/rpi/include/sys/types.h
new file mode 100644 (file)
index 0000000..6a0c3d3
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _SYS_TYPES_H
+#define _SYS_TYPES_H
+
+typedef int pid_t;
+typedef int mode_t;
+typedef long time_t;
+typedef long suseconds_t;
+
+#endif
diff --git a/plat/rpi/include/unistd.h b/plat/rpi/include/unistd.h
deleted file mode 100644 (file)
index 506d781..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Raspberry Pi support library for the ACK
- * © 2013 David Given
- * This file is redistributable under the terms of the 3-clause BSD license.
- * See the file 'Copying' in the root of the distribution for the full text.
- */
-
-#ifndef _UNISTD_H
-#define _UNISTD_H
-
-#include <stddef.h>
-#include <time.h>
-
-/* Types */
-
-typedef int pid_t;
-typedef int mode_t;
-
-typedef long suseconds_t;
-
-/* Time handling. */
-
-struct timeval
-{
-       time_t tv_sec;
-       suseconds_t tv_usec;
-};
-
-struct timezone
-{
-       int tz_minuteswest;
-       int tz_dsttime;
-}; /* obsolete, unused */
-
-extern int gettimeofday(struct timeval* tv, struct timezone* tz);
-extern int settimeofday(const struct timeval* tv, const struct timezone* tz);
-
-/* Constants for file access (open and friends) */
-
-enum
-{
-       O_ACCMODE = 0x3,
-       
-       O_RDONLY = 0,
-       O_WRONLY = 1,
-       O_RDWR = 2,
-       
-       O_CREAT = 0100,
-       O_TRUNC = 01000,
-       O_APPEND = 02000,
-       O_NONBLOCK = 04000
-};
-
-/* 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 */
-
-typedef int sig_atomic_t;
-
-#define SIG_ERR ((sighandler_t) -1)           /* Error return.  */
-#define SIG_DFL ((sighandler_t) 0)            /* Default action.  */
-#define SIG_IGN ((sighandler_t) 1)            /* Ignore signal.  */
-
-#define SIGABRT         6       /* Abort (ANSI) */
-#define SIGILL          11      /* Illegal instruction */
-
-#define _NSIG           32      /* 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);
-extern int kill(pid_t pid, int sig);
-
-/* Select */
-
-typedef uint32_t fd_set;
-
-extern int select(int nfds, fd_set *readfds, fd_set *writefds,
-                  fd_set *exceptfds, struct timeval *timeout);
-
-#define FD_ZERO(set) do { *set = 0; } while (0)
-#define FD_SET(fd, set) do { *set |= (1<<fd); } while (0);
-#define FD_CLR(fd, set) do { *set &= ~(1<<fd); } while (0);
-#define FD_ISSET(fd, set) (*set | (1<<fd))
-
-#endif
index 227c899..21ca3e9 100644 (file)
@@ -11,7 +11,7 @@
 #include <termios.h>
 #include "libsys.h"
 
-int read(int fd, void* buffer, size_t count)
+ssize_t read(int fd, void* buffer, size_t count)
 {
        char i;
        
index 280bfd6..4ea87e7 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
+#include <sys/select.h>
 #include <time.h>
 #include <pi.h>
 #include "libsys.h"
index 0fba498..29cae0c 100644 (file)
@@ -20,7 +20,7 @@ void _sys_write_tty(char c)
                _sys_rawwrite('\r');
 }
 
-int write(int fd, void* buffer, size_t count)
+ssize_t write(int fd, void* buffer, size_t count)
 {
        int i;
        char* p = buffer;