diff options
Diffstat (limited to 'emu/MacOSX')
| -rw-r--r-- | emu/MacOSX/NOTICE | 1 | ||||
| -rw-r--r-- | emu/MacOSX/asm-386.s | 28 | ||||
| -rw-r--r-- | emu/MacOSX/cmd.c | 25 | ||||
| -rw-r--r-- | emu/MacOSX/mkfile | 5 | ||||
| -rw-r--r-- | emu/MacOSX/os.c | 2 |
5 files changed, 50 insertions, 11 deletions
diff --git a/emu/MacOSX/NOTICE b/emu/MacOSX/NOTICE index cf4f254f..a14c52c9 100644 --- a/emu/MacOSX/NOTICE +++ b/emu/MacOSX/NOTICE @@ -1,2 +1,3 @@ MacOSX port Copyright © 2001-2003 Corpus Callosum Corporation, with portions Copyright © 2001-2003 Geoff Collyer +MacOSX-x86 Copyright © 2006 Corpus Callosum Corporation diff --git a/emu/MacOSX/asm-386.s b/emu/MacOSX/asm-386.s new file mode 100644 index 00000000..fc903bcb --- /dev/null +++ b/emu/MacOSX/asm-386.s @@ -0,0 +1,28 @@ +/* + * these are the same as on the PC (eg, Linux) +*/ + + .globl _FPsave +_FPsave: + pushl %ebp + movl %esp, %ebp + movl 8(%ebp), %eax + fstenv (%eax) + popl %ebp + ret + + .globl _FPrestore +_FPrestore: + pushl %ebp + movl %esp, %ebp + movl 8(%ebp), %eax + fldenv (%eax) + popl %ebp + ret + + .globl __tas +__tas: + movl $1, %eax + movl 4(%esp), %ecx + xchgl %eax, 0(%ecx) + ret diff --git a/emu/MacOSX/cmd.c b/emu/MacOSX/cmd.c index 49825f3c..58f6dba7 100644 --- a/emu/MacOSX/cmd.c +++ b/emu/MacOSX/cmd.c @@ -22,7 +22,7 @@ enum typedef struct Targ Targ; struct Targ { - int fd[2]; /* fd[0] is standard input, fd[1] is standard output */ + int fd[3]; /* fd[0] is standard input, fd[1] is standard output, fd[2] is standard error */ char** args; char* dir; int pid; @@ -44,15 +44,17 @@ childproc(Targ *t) nfd = getdtablesize(); for(i = 0; i < nfd; i++) - if(i != t->fd[0] && i != t->fd[1] && i != t->wfd) + if(i != t->fd[0] && i != t->fd[1] && i != t->fd[2] && i != t->wfd) close(i); dup2(t->fd[0], 0); dup2(t->fd[1], 1); - dup2(t->fd[1], 2); + dup2(t->fd[2], 2); close(t->fd[0]); close(t->fd[1]); + close(t->fd[2]); + /* should have an auth file to do host-specific authorisation? */ if(t->gid != -1){ if(setgid(t->gid) < 0 && getegid() == 0){ fprint(t->wfd, "can't set gid %d: %s", t->gid, strerror(errno)); @@ -83,10 +85,10 @@ childproc(Targ *t) } void* -oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) +oscmd(char **args, int nice, char *dir, int *fd) { Targ *t; - int r, fd0[2], fd1[2], wfd[2], n, pid; + int r, fd0[2], fd1[2], fd2[2], wfd[2], n, pid; t = mallocz(sizeof(*t), 1); if(t == nil) @@ -94,14 +96,16 @@ oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) fd0[0] = fd0[1] = -1; fd1[0] = fd1[1] = -1; + fd2[0] = fd2[1] = -1; wfd[0] = wfd[1] = -1; - if(pipe(fd0) < 0 || pipe(fd1) < 0 || pipe(wfd) < 0) + if(pipe(fd0) < 0 || pipe(fd1) < 0 || pipe(fd2) < 0 || pipe(wfd) < 0) goto Error; if(fcntl(wfd[1], F_SETFD, FD_CLOEXEC) < 0) /* close on exec to give end of file on success */ goto Error; t->fd[0] = fd0[0]; t->fd[1] = fd1[1]; + t->fd[2] = fd2[1]; t->wfd = wfd[1]; t->args = args; t->dir = dir; @@ -131,6 +135,7 @@ oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) close(fd0[0]); close(fd1[1]); + close(fd2[1]); close(wfd[1]); n = read(wfd[0], up->genbuf, sizeof(up->genbuf)-1); @@ -138,6 +143,7 @@ oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) if(n > 0){ close(fd0[1]); close(fd1[0]); + close(fd2[0]); free(t); up->genbuf[n] = 0; if(Debug) @@ -146,8 +152,9 @@ oscmd(char **args, int nice, char *dir, int *rfd, int *sfd) return nil; } - *sfd = fd0[1]; - *rfd = fd1[0]; + fd[0] = fd0[1]; + fd[1] = fd1[0]; + fd[2] = fd2[0]; return t; Error: @@ -158,6 +165,8 @@ Error: close(fd0[1]); close(fd1[0]); close(fd1[1]); + close(fd2[0]); + close(fd2[1]); close(wfd[0]); close(wfd[1]); error(strerror(r)); diff --git a/emu/MacOSX/mkfile b/emu/MacOSX/mkfile index 693eaf33..25fb99c6 100644 --- a/emu/MacOSX/mkfile +++ b/emu/MacOSX/mkfile @@ -1,8 +1,8 @@ SYSTARG=MacOSX -OBJTYPE=power +#OBJTYPE=power <../../mkconfig SYSTARG=MacOSX -OBJTYPE=power +#OBJTYPE=power #Configurable parameters @@ -30,6 +30,7 @@ OBJ=\ HFILES=\ CFLAGS='-DROOT="'$ROOT'"'\ + '-DOBJTYPE="'$OBJTYPE'"'\ -DEMU -I. -I../port\ -I$ROOT/$SYSTARG/$OBJTYPE/include\ -I$ROOT/include -I$ROOT/libinterp\ diff --git a/emu/MacOSX/os.c b/emu/MacOSX/os.c index e246f625..3363b5ad 100644 --- a/emu/MacOSX/os.c +++ b/emu/MacOSX/os.c @@ -42,7 +42,7 @@ enum DELETE = 0x7F }; char *hosttype = "MacOSX"; -char *cputype = "power"; +char *cputype = OBJTYPE; static pthread_key_t prdakey; |
