Changes for Mac OS X. Most important is stack sizes in samterm,
which were completely bogus. (Libthread used to ignore them but not anymore. Maybe we really should ignore them, but that breaks Venti, which needs *really* big stacks.)
This commit is contained in:
parent
2db9e4821d
commit
912fba95e7
17 changed files with 46 additions and 26 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
char errbuf[ERRMAX];
|
char errbuf[ERRMAX];
|
||||||
int ignerr = 0;
|
int ignerr = 0;
|
||||||
|
|
||||||
void
|
static void
|
||||||
err(char *f)
|
err(char *f)
|
||||||
{
|
{
|
||||||
if(!ignerr){
|
if(!ignerr){
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
|
||||||
|
#undef INFINITY /* Darwin declares this as HUGE_VAL */
|
||||||
#define INFINITY 0x7FFFFFFFL
|
#define INFINITY 0x7FFFFFFFL
|
||||||
#define INCR 25
|
#define INCR 25
|
||||||
#define STRSIZE (2*BLOCKSIZE)
|
#define STRSIZE (2*BLOCKSIZE)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,6 @@ CFLAGS=$CFLAGS -I../sam
|
||||||
LDFLAGS=$LDFLAGS -lframe -ldraw -lthread -l9 -lregexp9 \
|
LDFLAGS=$LDFLAGS -lframe -ldraw -lthread -l9 -lregexp9 \
|
||||||
-lbio -lfmt -lutf -L$X11/lib -lX11 -lm
|
-lbio -lfmt -lutf -L$X11/lib -lX11 -lm
|
||||||
|
|
||||||
o.samterm: $PLAN9/lib/libdraw.a
|
o.samterm: $PLAN9/lib/libframe.a $PLAN9/lib/libdraw.a $PLAN9/lib/libthread.a
|
||||||
|
|
||||||
<$PLAN9/src/mkone
|
<$PLAN9/src/mkone
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
static char *exname;
|
static char *exname;
|
||||||
|
|
||||||
|
#define STACK 8192
|
||||||
|
|
||||||
void
|
void
|
||||||
getscreen(int argc, char **argv)
|
getscreen(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
@ -163,7 +165,7 @@ extstart(void)
|
||||||
plumbc = chancreate(sizeof(int), 0);
|
plumbc = chancreate(sizeof(int), 0);
|
||||||
arg[0] = plumbc;
|
arg[0] = plumbc;
|
||||||
arg[1] = (void*)fd;
|
arg[1] = (void*)fd;
|
||||||
proccreate(extproc, arg, 8192);
|
proccreate(extproc, arg, STACK);
|
||||||
atexit(removeextern);
|
atexit(removeextern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,7 +258,7 @@ plumbstart(void)
|
||||||
}
|
}
|
||||||
arg[0] =plumbc;
|
arg[0] =plumbc;
|
||||||
arg[1] = &fd;
|
arg[1] = &fd;
|
||||||
proccreate(plumbproc, arg, 4096);
|
proccreate(plumbproc, arg, STACK);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -293,5 +295,5 @@ void
|
||||||
hoststart(void)
|
hoststart(void)
|
||||||
{
|
{
|
||||||
hostc = chancreate(sizeof(int), 0);
|
hostc = chancreate(sizeof(int), 0);
|
||||||
proccreate(hostproc, hostc, 1024);
|
proccreate(hostproc, hostc, STACK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ it:V: all
|
||||||
<$PLAN9/src/mkmany
|
<$PLAN9/src/mkmany
|
||||||
|
|
||||||
$SLIB: $LIBOFILES
|
$SLIB: $LIBOFILES
|
||||||
ar rvc $SLIB $LIBOFILES
|
$AR rvc $SLIB $LIBOFILES
|
||||||
|
|
||||||
# xml.c:D: mkxml dat.h
|
# xml.c:D: mkxml dat.h
|
||||||
# ./mkxml dat.h > xml.c
|
# ./mkxml dat.h > xml.c
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
int sig;
|
int sig;
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,16 @@
|
||||||
|
|
||||||
extern int _p9dir(struct stat*, char*, Dir*, char**, char*);
|
extern int _p9dir(struct stat*, char*, Dir*, char**, char*);
|
||||||
|
|
||||||
#if !defined(_HAVEGETDENTS) && defined(_HAVEGETDIRENTRIES)
|
/* everyone has getdirentries, just use that */
|
||||||
static int
|
static int
|
||||||
getdents(int fd, char *buf, int n)
|
mygetdents(int fd, char *buf, int n)
|
||||||
{
|
{
|
||||||
ssize_t nn;
|
ssize_t nn;
|
||||||
|
#if _GETDIRENTRIES_TAKES_LONG
|
||||||
|
long off;
|
||||||
|
#else
|
||||||
off_t off;
|
off_t off;
|
||||||
|
#endif
|
||||||
|
|
||||||
off = seek(fd, 0, 1);
|
off = seek(fd, 0, 1);
|
||||||
nn = getdirentries(fd, buf, n, &off);
|
nn = getdirentries(fd, buf, n, &off);
|
||||||
|
|
@ -24,7 +28,6 @@ getdents(int fd, char *buf, int n)
|
||||||
seek(fd, off, 0);
|
seek(fd, off, 0);
|
||||||
return nn;
|
return nn;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
countde(char *p, int n)
|
countde(char *p, int n)
|
||||||
|
|
@ -123,7 +126,7 @@ dirread(int fd, Dir **dp)
|
||||||
if(buf == nil)
|
if(buf == nil)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
n = getdents(fd, (void*)buf, st.st_blksize);
|
n = mygetdents(fd, (void*)buf, st.st_blksize);
|
||||||
if(n < 0){
|
if(n < 0){
|
||||||
free(buf);
|
free(buf);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -156,7 +159,7 @@ dirreadall(int fd, Dir **d)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
buf = nbuf;
|
buf = nbuf;
|
||||||
n = getdents(fd, (void*)(buf+ts), st.st_blksize);
|
n = mygetdents(fd, (void*)(buf+ts), st.st_blksize);
|
||||||
if(n <= 0)
|
if(n <= 0)
|
||||||
break;
|
break;
|
||||||
ts += n;
|
ts += n;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
#include <lib9.h>
|
#define NOPLAN9DEFINES
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern int __isthreaded;
|
extern int __isthreaded;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ OFILES=\
|
||||||
getuser.$O\
|
getuser.$O\
|
||||||
getwd.$O\
|
getwd.$O\
|
||||||
jmp.$O\
|
jmp.$O\
|
||||||
jmp-$SYSNAME.$O\
|
|
||||||
lock.$O\
|
lock.$O\
|
||||||
main.$O\
|
main.$O\
|
||||||
malloctag.$O\
|
malloctag.$O\
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
* r3 contains return value upon return.
|
* r3 contains return value upon return.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
_tas(void *x)
|
_tas(int *x)
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
/*
|
/*
|
||||||
|
|
@ -36,7 +36,7 @@ _tas(void *x)
|
||||||
switch(v) {
|
switch(v) {
|
||||||
case 0: return 0;
|
case 0: return 0;
|
||||||
case 0xdeaddead: return 1;
|
case 0xdeaddead: return 1;
|
||||||
default: print("tas: corrupted 0x%lux\n", v);
|
default: fprint(2, "tas: corrupted 0x%lux\n", v);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,6 @@ CFLAGS=$CFLAGS -I$X11/include
|
||||||
|
|
||||||
<$PLAN9/src/mksyslib
|
<$PLAN9/src/mksyslib
|
||||||
|
|
||||||
test: test.o $LIB
|
test: test.o $PLAN9/lib/$LIB
|
||||||
gcc -o test test.o -L$PLAN9 -ldraw -l9 -lfmt -lutf -L$X11/lib -lX11 -lm
|
gcc -o test test.o -L$PLAN9/lib -ldraw -l9 -lfmt -lutf -L$X11/lib -lX11 -lm
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ enqueue(Alt *a, Channel **c)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_threaddebug(DBGCHAN, "Queuing alt %p on channel %p", a, a->c);
|
_threaddebug(DBGCHAN, "Queueing alt %p on channel %p", a, a->c);
|
||||||
a->tag = c;
|
a->tag = c;
|
||||||
i = emptyentry(a->c);
|
i = emptyentry(a->c);
|
||||||
a->c->qentry[i] = a;
|
a->c->qentry[i] = a;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ procexec(Channel *pidc, char *prog, char *args[])
|
||||||
if(p->threads.head != t || p->threads.head->nextt != nil){
|
if(p->threads.head != t || p->threads.head->nextt != nil){
|
||||||
werrstr("not only thread in proc");
|
werrstr("not only thread in proc");
|
||||||
Bad:
|
Bad:
|
||||||
|
_threaddebug(DBGEXEC, "procexec bad %r");
|
||||||
if(pidc)
|
if(pidc)
|
||||||
sendul(pidc, ~0);
|
sendul(pidc, ~0);
|
||||||
return;
|
return;
|
||||||
|
|
@ -35,6 +36,8 @@ procexec(Channel *pidc, char *prog, char *args[])
|
||||||
*/
|
*/
|
||||||
if(pipe(p->exec.fd) < 0)
|
if(pipe(p->exec.fd) < 0)
|
||||||
goto Bad;
|
goto Bad;
|
||||||
|
if(fcntl(p->exec.fd[0], F_SETFD, 1) < 0)
|
||||||
|
goto Bad;
|
||||||
if(fcntl(p->exec.fd[1], F_SETFD, 1) < 0)
|
if(fcntl(p->exec.fd[1], F_SETFD, 1) < 0)
|
||||||
goto Bad;
|
goto Bad;
|
||||||
|
|
||||||
|
|
@ -57,6 +60,7 @@ procexec(Channel *pidc, char *prog, char *args[])
|
||||||
if(pidc)
|
if(pidc)
|
||||||
sendul(pidc, t->ret);
|
sendul(pidc, t->ret);
|
||||||
|
|
||||||
|
_threaddebug(DBGEXEC, "procexec schedexecwait");
|
||||||
/* wait for exec'ed program, then exit */
|
/* wait for exec'ed program, then exit */
|
||||||
_schedexecwait();
|
_schedexecwait();
|
||||||
}
|
}
|
||||||
|
|
@ -105,8 +109,7 @@ efork(void *ve)
|
||||||
Execargs *e;
|
Execargs *e;
|
||||||
|
|
||||||
e = ve;
|
e = ve;
|
||||||
_threaddebug(DBGEXEC, "_schedexec %s", e->prog);
|
_threaddebug(DBGEXEC, "_schedexec %s -- calling execv", e->prog);
|
||||||
close(e->fd[0]);
|
|
||||||
execv(e->prog, e->args);
|
execv(e->prog, e->args);
|
||||||
_threaddebug(DBGEXEC, "_schedexec failed: %r");
|
_threaddebug(DBGEXEC, "_schedexec failed: %r");
|
||||||
rerrstr(buf, sizeof buf);
|
rerrstr(buf, sizeof buf);
|
||||||
|
|
@ -120,5 +123,12 @@ efork(void *ve)
|
||||||
int
|
int
|
||||||
_schedexec(Execargs *e)
|
_schedexec(Execargs *e)
|
||||||
{
|
{
|
||||||
return ffork(RFFDG|RFPROC|RFMEM, efork, e);
|
int pid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
if(pid == 0){
|
||||||
|
efork(e);
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,12 @@ _threadnrendez++;
|
||||||
t->rendval = val;
|
t->rendval = val;
|
||||||
t->rendhash = *l;
|
t->rendhash = *l;
|
||||||
*l = t;
|
*l = t;
|
||||||
t->nextstate = Rendezvous;
|
|
||||||
++nrendez;
|
++nrendez;
|
||||||
if(nrendez > _threadhighnrendez)
|
if(nrendez > _threadhighnrendez)
|
||||||
_threadhighnrendez = nrendez;
|
_threadhighnrendez = nrendez;
|
||||||
_threaddebug(DBGREND, "Rendezvous for tag %lud", t->rendtag);
|
_threaddebug(DBGREND, "Rendezvous for tag %lud (m=%d)", t->rendtag, t->moribund);
|
||||||
unlock(&_threadrgrp.lock);
|
unlock(&_threadrgrp.lock);
|
||||||
|
t->nextstate = Rendezvous;
|
||||||
_sched();
|
_sched();
|
||||||
t->inrendez = 0;
|
t->inrendez = 0;
|
||||||
_threaddebug(DBGREND, "Woke after rendezvous; val is %lud", t->rendval);
|
_threaddebug(DBGREND, "Woke after rendezvous; val is %lud", t->rendval);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ _schedinit(void *arg)
|
||||||
if((t=p->thread) != nil){
|
if((t=p->thread) != nil){
|
||||||
p->thread = nil;
|
p->thread = nil;
|
||||||
if(t->moribund){
|
if(t->moribund){
|
||||||
|
if(t->moribund != 1)
|
||||||
|
fprint(2, "moribund %d\n", t->moribund);
|
||||||
assert(t->moribund == 1);
|
assert(t->moribund == 1);
|
||||||
t->state = Dead;
|
t->state = Dead;
|
||||||
if(t->prevt)
|
if(t->prevt)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ X11=/usr/X11R6
|
||||||
CC=9c
|
CC=9c
|
||||||
LD=9l
|
LD=9l
|
||||||
AS=9a
|
AS=9a
|
||||||
|
AR=9ar
|
||||||
CFLAGS=
|
CFLAGS=
|
||||||
LDFLAGS=
|
LDFLAGS=
|
||||||
AFLAGS=
|
AFLAGS=
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
default:V: $PLAN9/lib/$LIB
|
default:V: $PLAN9/lib/$LIB
|
||||||
|
|
||||||
$PLAN9/lib/$LIB:V: $OFILES # force archive even when not needed
|
$PLAN9/lib/$LIB:V: $OFILES # force archive even when not needed
|
||||||
ar rvc $PLAN9/lib/$LIB $newprereq
|
$AR rvc $PLAN9/lib/$LIB $newprereq
|
||||||
|
|
||||||
&:n: &.$O
|
&:n: &.$O
|
||||||
ar rvc $LIB $stem.$O
|
$AR rvc $PLAN9/lib/$LIB $stem.$O
|
||||||
|
|
||||||
all install:V: $PLAN9/lib/$LIB
|
all install:V: $PLAN9/lib/$LIB
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue