mirror of
https://github.com/Interlisp/maiko.git
synced 2026-02-14 19:56:28 +00:00
Haiku OS port (#485)
* Haiku OS port * haiku with X11 backend * haiku has stpncpy * Haiku is not Linux. * X not stable enough on Haiku * Haiku : settimeofday is a no-op * Haiku : no need to define settimeofday at all (pointed by nbriggs) --------- Signed-off-by: Anarchos <sylvain_kerjean@hotmail.com>
This commit is contained in:
29
src/inet.c
29
src/inet.c
@@ -107,8 +107,14 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li
|
||||
addr_class = LispNumToCInt(nameConn);
|
||||
protocol = LispNumToCInt(proto);
|
||||
result = socket(addr_class, protocol, 0);
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_ASYNC | O_NONBLOCK);
|
||||
#else
|
||||
fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_NONBLOCK);
|
||||
#endif
|
||||
#ifdef F_SETOWN
|
||||
fcntl(result, F_SETOWN, getpid());
|
||||
#endif
|
||||
|
||||
return (GetSmallp(result));
|
||||
case TCPconnect: /* args: hostname or (fixp)address, socket# */
|
||||
@@ -131,7 +137,9 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li
|
||||
return (NIL);
|
||||
}
|
||||
fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_NONBLOCK);
|
||||
#ifdef F_SETOWN
|
||||
fcntl(result, F_SETOWN, getpid());
|
||||
#endif
|
||||
|
||||
return (GetSmallp(result));
|
||||
|
||||
@@ -197,13 +205,20 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li
|
||||
sigset_t signals;
|
||||
|
||||
sigemptyset(&signals);
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
sigaddset(&signals, SIGIO);
|
||||
|
||||
#endif
|
||||
sigprocmask(SIG_BLOCK, &signals, NULL);
|
||||
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_ASYNC | O_NONBLOCK);
|
||||
fcntl(result, F_SETOWN, getpid());
|
||||
#else
|
||||
fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
#ifdef F_SETOWN
|
||||
fcntl(result, F_SETOWN, getpid());
|
||||
#endif
|
||||
if (listen(result, 5) == -1) {
|
||||
perror("TCP Listen");
|
||||
close(result);
|
||||
@@ -225,8 +240,9 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li
|
||||
return (NIL);
|
||||
}
|
||||
fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_NONBLOCK);
|
||||
#ifdef F_SETOWN
|
||||
fcntl(result, F_SETOWN, getpid());
|
||||
|
||||
#endif
|
||||
return (GetSmallp(result));
|
||||
|
||||
case INETpeername: /* socket#, buffer for name string */
|
||||
@@ -259,9 +275,14 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li
|
||||
close(result);
|
||||
return (NIL);
|
||||
}
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_ASYNC | O_NONBLOCK);
|
||||
#else
|
||||
fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | O_NONBLOCK);
|
||||
#endif
|
||||
#ifdef F_SETOWN
|
||||
fcntl(result, F_SETOWN, getpid());
|
||||
|
||||
#endif
|
||||
FD_SET(result, &LispIOFds); /* so we get interrupts */
|
||||
FD_SET(result, &LispReadFds);
|
||||
DBPRINT(("LispIOFds = %p\n", (void *)&LispIOFds));
|
||||
|
||||
@@ -140,9 +140,9 @@ void init_ifpage(unsigned sysout_size) {
|
||||
#endif /* BIGVM */
|
||||
|
||||
/* unfortunately, Lisp only looks at a 16 bit serial number */
|
||||
#ifndef DOS
|
||||
#if !defined(DOS) && !defined(MAIKO_OS_HAIKU)
|
||||
InterfacePage->serialnumber = 0xffff & gethostid();
|
||||
#endif /* DOS */
|
||||
#endif /* DOS MAIKO_OS_HAIKU */
|
||||
|
||||
/* get user name and stuff into vmem; this is the VMEM buffer;
|
||||
This is a BCPL string -- it starts with a length count. C strings
|
||||
|
||||
@@ -201,6 +201,7 @@ int main(int argc, char *argv[]) {
|
||||
} else {
|
||||
/* copy up to and including the final "/" in the path */
|
||||
dirsepp = stpncpy(filetorunpath, argv[0], dirsepp + 1 - argv[0]);
|
||||
|
||||
/* dirsepp now points to the trailing null in the copy */
|
||||
strncpy(dirsepp, filetorun, PATH_MAX - (dirsepp - filetorunpath));
|
||||
argv[0] = filetorunpath;
|
||||
|
||||
16
src/timer.c
16
src/timer.c
@@ -47,6 +47,10 @@ unsigned long tick_count = 0; /* approx 18 ticks per sec */
|
||||
#include <sys/time.h>
|
||||
#endif /* DOS */
|
||||
|
||||
#ifdef MAIKO_OS_HAIKU
|
||||
#include <OS.h>
|
||||
#endif
|
||||
|
||||
#if defined(USE_DLPI)
|
||||
#include <stropts.h>
|
||||
extern int ether_fd;
|
||||
@@ -301,6 +305,8 @@ void subr_settime(LispPTR args[])
|
||||
dosday.year = uxtime.tm_year;
|
||||
dosday.dayofweek = uxtime.tm_wday;
|
||||
_dos_setdate(&dosday);
|
||||
#elif defined(MAIKO_OS_HAIKU)
|
||||
(void)args[0];
|
||||
#elif defined(MAIKO_OS_EMSCRIPTEN)
|
||||
(void)args[0];
|
||||
#else
|
||||
@@ -556,17 +562,19 @@ static void int_io_service(int sig)
|
||||
/************************************************************************/
|
||||
|
||||
static void int_io_init(void) {
|
||||
#ifndef DOS
|
||||
#if !defined(DOS) || !defined(MAIKO_OS_HAIKU)
|
||||
struct sigaction io_action;
|
||||
io_action.sa_handler = int_io_service;
|
||||
sigemptyset(&io_action.sa_mask);
|
||||
io_action.sa_flags = 0;
|
||||
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
if (sigaction(SIGIO, &io_action, NULL) == -1) {
|
||||
perror("sigaction: SIGIO");
|
||||
} else {
|
||||
DBPRINT(("I/O interrupts enabled\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_DLPI)
|
||||
DBPRINT(("INIT ETHER: Doing I_SETSIG.\n"));
|
||||
@@ -578,7 +586,7 @@ static void int_io_init(void) {
|
||||
return;
|
||||
}
|
||||
#endif /* USE_DLPI */
|
||||
#endif /* DOS */
|
||||
#endif /* DOS MAIKO_OS_HAIKU */
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
@@ -600,7 +608,9 @@ void int_block(void) {
|
||||
sigset_t signals;
|
||||
sigemptyset(&signals);
|
||||
sigaddset(&signals, SIGVTALRM);
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
sigaddset(&signals, SIGIO);
|
||||
#endif
|
||||
sigaddset(&signals, SIGALRM);
|
||||
sigaddset(&signals, SIGXFSZ);
|
||||
#ifdef FLTINT
|
||||
@@ -628,7 +638,9 @@ void int_unblock(void) {
|
||||
sigset_t signals;
|
||||
sigemptyset(&signals);
|
||||
sigaddset(&signals, SIGVTALRM);
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
sigaddset(&signals, SIGIO);
|
||||
#endif
|
||||
sigaddset(&signals, SIGALRM);
|
||||
sigaddset(&signals, SIGXFSZ);
|
||||
#ifdef FLTINT
|
||||
|
||||
@@ -51,7 +51,11 @@ void tty_open(void)
|
||||
if (TTY_Fd < 0) {
|
||||
if ((TTY_Fd = open(TTY_Dev, O_RDWR)) >= 0) {
|
||||
tcgetattr(TTY_Fd, &options);
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
options.c_iflag &= ~(IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IGNPAR);
|
||||
#else
|
||||
options.c_iflag &= ~(IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IGNPAR);
|
||||
#endif
|
||||
options.c_iflag |= IGNBRK;
|
||||
options.c_oflag &= ~OPOST;
|
||||
options.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|TOSTOP);
|
||||
|
||||
@@ -219,7 +219,9 @@ int fork_Unix(void) {
|
||||
/* interrupts need to be blocked here so subprocess won't see them */
|
||||
sigemptyset(&signals);
|
||||
sigaddset(&signals, SIGVTALRM);
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
sigaddset(&signals, SIGIO);
|
||||
#endif
|
||||
sigaddset(&signals, SIGALRM);
|
||||
sigaddset(&signals, SIGXFSZ);
|
||||
sigaddset(&signals, SIGFPE);
|
||||
|
||||
@@ -864,7 +864,9 @@ int device_before_raid(void) {
|
||||
#ifdef XWINDOW
|
||||
/* So X events still get recognized. */
|
||||
sigemptyset(&signals);
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
sigaddset(&signals, SIGIO);
|
||||
#endif
|
||||
sigprocmask(SIG_UNBLOCK, &signals, NULL);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -231,10 +231,13 @@ LispPTR unix_getparm(LispPTR *args) {
|
||||
struct passwd *pwd;
|
||||
if ((pwd = getpwuid(getuid())) == NULL) return NIL;
|
||||
envvalue = pwd->pw_gecos;
|
||||
} else if (strcmp(envname, "HOSTID") == 0) {
|
||||
}
|
||||
#ifndef MAIKO_OS_HAIKU
|
||||
else if (strcmp(envname, "HOSTID") == 0) {
|
||||
snprintf(result, sizeof(result), "%lx", gethostid());
|
||||
envvalue = result;
|
||||
}
|
||||
#endif /* MAIKO_OS_HAIKU */
|
||||
#endif /* DOS */
|
||||
else
|
||||
return NIL;
|
||||
|
||||
Reference in New Issue
Block a user