Make linux386 work with the new libc layout.

This commit is contained in:
David Given 2018-06-23 12:13:33 +02:00
parent 32c881474e
commit 66815ff987
10 changed files with 96 additions and 112 deletions

View file

@ -7,7 +7,7 @@ vars.ackcflags = {
vars.ackldflags = {}
vars.plats = {
"cpm",
-- "linux386",
"linux386",
-- "linux68k",
-- "linuxppc",
-- "osx386",
@ -20,7 +20,7 @@ vars.plats = {
}
vars.plats_with_tests = {
-- "linux68k",
-- "linux386",
"linux386",
-- "linuxppc",
-- --"qemuppc",
-- "pc86",

View file

@ -7,10 +7,9 @@
#define _TIME_H
#include <stddef.h>
#include <sys/types.h>
#define CLOCKS_PER_SEC 1000000
typedef unsigned long time_t; /* type returned by TOD clock */
typedef unsigned long clock_t; /* type returned by real time clock */
struct tm {
@ -25,7 +24,9 @@ struct tm {
int tm_isdst; /* Daylight Saving Time flag */
};
/* Not a system call; this calls gettimeofday() or times() to do the work */
extern clock_t clock(void);
extern double difftime(time_t _time1, time_t _time0);
extern time_t mktime(struct tm *_timeptr);
extern time_t time(time_t *_timeptr);

View file

@ -13,44 +13,61 @@
#include <sys/types.h>
#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. */
/* A standard set of flags for read/write/creat and friends for platforms
* where these aren't determined by the operating system. */
enum
{
O_ACCMODE = 0x3,
enum
{
O_ACCMODE = 0x3,
O_RDONLY = 0,
O_WRONLY = 1,
O_RDWR = 2,
O_RDONLY = 0,
O_WRONLY = 1,
O_RDWR = 2,
O_CREAT = 0100,
O_TRUNC = 01000,
O_APPEND = 02000,
O_NONBLOCK = 04000
};
O_CREAT = 0100,
O_TRUNC = 01000,
O_APPEND = 02000,
O_NONBLOCK = 04000
};
#else
#include <ack/fcntl.h>
#endif
#if ACKCONF_WANT_STANDARD_SIGNALS
/* A standard set of definitions for signal handling for platforms where these
* aren't determined by the operating system. */
/* A standard set of definitions for signal handling for platforms where these
* aren't determined by the operating system. */
typedef int sig_atomic_t;
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 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 16 /* Biggest signal number + 1
(not including real-time signals). */
typedef void (*sighandler_t)(int);
typedef uint16_t sigset_t;
#define SIGABRT 6 /* Abort (ANSI) */
#define SIGILL 11 /* Illegal instruction */
#define _NSIG 16 /* Biggest signal number + 1
(not including real-time signals). */
typedef void (*sighandler_t)(int);
typedef uint16_t sigset_t;
#else
#include <ack/signal.h>
#endif
/* Time handling. */
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
};
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
}; /* obsolete, unused */
/* Special variables */
extern char** environ;
@ -61,11 +78,14 @@ 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 fcntl(int fd, int op, ...);
extern int gettimeofday(struct timeval* tv, struct timezone* tz);
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 settimeofday(const struct timeval* tv, const struct timezone* tz);
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);
@ -75,6 +95,6 @@ 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

View file

@ -3,5 +3,7 @@
typedef int pid_t;
typedef int mode_t;
typedef long time_t;
typedef long suseconds_t;
#endif

View file

@ -7,5 +7,5 @@
*/
int ioctl(int fd, unsigned long request, void *argp)
{
return _syscall(__NR_ioctl, fd, request, argp);
return _syscall(__NR_ioctl, fd, request, (quad)argp);
}

View file

@ -0,0 +1,19 @@
#ifndef _ACK_FCNTL_H
#define _ACK_FCNTL_H
/* Linux O_ constants. */
enum
{
O_ACCMODE = 0x3,
O_RDONLY = 0,
O_WRONLY = 1,
O_RDWR = 2,
O_CREAT = 0x40,
O_TRUNC = 0x200,
O_APPEND = 0x400
};
#endif

View file

@ -11,4 +11,9 @@
/* #define ACKCONF_TIME_IS_A_SYSCALL */
/* Linux has its own O_ definitions. */
#define ACKCONF_WANT_STANDARD_O 0
#define ACKCONF_WANT_STANDARD_SIGNALS 0
#endif

View file

@ -1,76 +1,7 @@
/*
* unistd.h - standard system calls
*/
/* $Id$ */
#ifndef _ACK_SIGNAL_H
#define _ACK_SIGNAL_H
#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);
/* File access. */
enum
{
O_ACCMODE = 0x3,
O_RDONLY = 0,
O_WRONLY = 1,
O_RDWR = 2,
O_CREAT = 0x40,
O_TRUNC = 0x200,
O_APPEND = 0x400
};
extern int open(const char* path, int access, ...);
extern int creat(const char* path, mode_t mode);
extern int close(int d);
extern int read(int fd, void* buffer, size_t count);
extern int write(int fd, void* buffer, size_t count);
extern off_t lseek(int fildes, off_t offset, int whence);
extern int fcntl(int fd, int op, ...);
extern int unlink(const char* path);
/* Special variables */
extern char** environ;
/* Implemented system calls */
extern void _exit(int);
extern pid_t getpid(void);
extern int brk(void* ptr);
extern void* sbrk(int increment);
extern int isatty(int d);
extern int execve(const char *path, char *const argv[], char *const envp[]);
/* Signal handling */
/* Signal constants. */
typedef int sig_atomic_t;
@ -124,10 +55,5 @@ typedef int sig_atomic_t;
typedef unsigned long sigset_t;
typedef void (*sighandler_t)(int);
extern sighandler_t signal(int signum, sighandler_t handler);
extern int sigprocmask(int, const sigset_t *, sigset_t *);
extern int raise(int signum);
#endif

View file

@ -9,8 +9,10 @@ local function addheader(h)
end
addheader("ack/plat.h")
addheader("ack/fcntl.h")
addheader("ack/signal.h")
addheader("sys/ioctl.h")
addheader("unistd.h")
addheader("sys/types.h")
acklibrary {
name = "headers",

View file

@ -0,0 +1,9 @@
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
typedef int pid_t;
typedef int mode_t;
typedef long suseconds_t;
typedef long time_t;
#endif