Create a basic and probably wrong common unistd.h, which replaces the plat one.
Made this work with cpm (but nothing else yet).
This commit is contained in:
parent
dd0f959245
commit
32c881474e
30
build.lua
30
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 = {}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <ack/config.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* 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
|
|
@ -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",
|
||||
|
|
7
plat/cpm/include/sys/types.h
Normal file
7
plat/cpm/include/sys/types.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef _SYS_TYPES_H
|
||||
#define _SYS_TYPES_H
|
||||
|
||||
typedef int pid_t;
|
||||
typedef int mode_t;
|
||||
|
||||
#endif
|
|
@ -8,7 +8,7 @@
|
|||
#include <unistd.h>
|
||||
#include <cpm.h>
|
||||
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue