mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
parent
babe3439cc
commit
fc567f476a
11 changed files with 63 additions and 24 deletions
22
INSTALL
22
INSTALL
|
@ -54,14 +54,32 @@ if [ `uname` = Linux ]; then
|
||||||
if ./a.out >/dev/null
|
if ./a.out >/dev/null
|
||||||
then
|
then
|
||||||
echo " NPTL found."
|
echo " NPTL found."
|
||||||
echo "SYSVERSION=2.6.x" >$PLAN9/config
|
echo "SYSVERSION=2.6.x" >>$PLAN9/config
|
||||||
else
|
else
|
||||||
echo " NPTL not found."
|
echo " NPTL not found."
|
||||||
echo "SYSVERSION=2.4.x" >$PLAN9/config
|
echo "SYSVERSION=2.4.x" >>$PLAN9/config
|
||||||
fi
|
fi
|
||||||
rm -f ./a.out
|
rm -f ./a.out
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ `uname` = Darwin ]; then
|
||||||
|
# On Darwin, uname -m -p cannot be trusted.
|
||||||
|
echo "* Running on Darwin: checking architecture..."
|
||||||
|
rm -f ./a.out
|
||||||
|
gcc lib/darwin-main.c >/dev/null 2>&1
|
||||||
|
case "$(file ./a.out 2>/dev/null)" in
|
||||||
|
*x86_64*)
|
||||||
|
echo " x86-64 found."
|
||||||
|
echo "OBJTYPE=x86_64" >>$PLAN9/config
|
||||||
|
;;
|
||||||
|
*i386*)
|
||||||
|
echo " i386 found."
|
||||||
|
echo "OBJTYPE=386" >>$PLAN9/config
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
rm -f ./a.out
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f LOCAL.config ]; then
|
if [ -f LOCAL.config ]; then
|
||||||
echo Using LOCAL.config options:
|
echo Using LOCAL.config options:
|
||||||
sed 's/^/ /' LOCAL.config
|
sed 's/^/ /' LOCAL.config
|
||||||
|
|
12
bin/9a
12
bin/9a
|
@ -5,10 +5,16 @@ if [ $# != 1 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
test -f $PLAN9/config && . $PLAN9/config
|
||||||
|
|
||||||
aflags=""
|
aflags=""
|
||||||
case "`uname`" in
|
case "`uname`-${OBJTYPE:-`uname -m`}" in
|
||||||
Darwin)
|
Darwin-*386*)
|
||||||
aflags="-arch `arch`"
|
aflags="-arch i386"
|
||||||
|
;;
|
||||||
|
Darwin-*x86_64*)
|
||||||
|
aflags="-arch x86_64"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
out=`echo $1 | sed 's/\.s$//;s/$/.o/'`
|
out=`echo $1 | sed 's/\.s$//;s/$/.o/'`
|
||||||
|
|
2
bin/9c
2
bin/9c
|
@ -70,6 +70,8 @@ case "$tag" in
|
||||||
*FreeBSD*gcc*) usegcc ;;
|
*FreeBSD*gcc*) usegcc ;;
|
||||||
*FreeBSD*clang*) useclang ;;
|
*FreeBSD*clang*) useclang ;;
|
||||||
*BSD*) usegcc ;;
|
*BSD*) usegcc ;;
|
||||||
|
*Darwin-x86_64*) usegcc
|
||||||
|
cflags="$ngflags -g3 -no-cpp-precomp -m64" ;;
|
||||||
*Darwin*) usegcc
|
*Darwin*) usegcc
|
||||||
cflags="$ngflags -g3 -no-cpp-precomp -m32" ;;
|
cflags="$ngflags -g3 -no-cpp-precomp -m32" ;;
|
||||||
*HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
|
*HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
|
||||||
|
|
3
bin/9l
3
bin/9l
|
@ -45,6 +45,9 @@ case "$tag" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
*Darwin*x86_64*)
|
||||||
|
ld="${CC9:-gcc} -m64"
|
||||||
|
;;
|
||||||
*Darwin*)
|
*Darwin*)
|
||||||
ld="${CC9:-gcc} -m32"
|
ld="${CC9:-gcc} -m32"
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -130,7 +130,7 @@ gmtime(long tim)
|
||||||
char*
|
char*
|
||||||
asctime(Tm *t)
|
asctime(Tm *t)
|
||||||
{
|
{
|
||||||
char *ncp;
|
const char *ncp;
|
||||||
static char cbuf[30];
|
static char cbuf[30];
|
||||||
|
|
||||||
strcpy(cbuf, "Thu Jan 01 00:00:00 GMT 1970\n");
|
strcpy(cbuf, "Thu Jan 01 00:00:00 GMT 1970\n");
|
||||||
|
|
|
@ -52,6 +52,4 @@ test:V: tprimes tspawn
|
||||||
echo tspawn should take 3 seconds, not 6
|
echo tspawn should take 3 seconds, not 6
|
||||||
$PLAN9/bin/time ./tspawn sleep 3 >/dev/null
|
$PLAN9/bin/time ./tspawn sleep 3 >/dev/null
|
||||||
|
|
||||||
CLEANFILES=p1.txt p2.txt tp1.txt tp2.txt
|
CLEANFILES=p1.txt p2.txt tp1.txt tp2.txt test/*.$O
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,24 +4,18 @@ test -f $PLAN9/config && . $PLAN9/config
|
||||||
|
|
||||||
tag="$OBJTYPE-$SYSNAME-${SYSVERSION:-`uname -r`}-${CC9:-cc}"
|
tag="$OBJTYPE-$SYSNAME-${SYSVERSION:-`uname -r`}-${CC9:-cc}"
|
||||||
case "$tag" in
|
case "$tag" in
|
||||||
*-Linux-2.6.*)
|
*-Linux-2.[0-5]*)
|
||||||
echo pthread.o
|
|
||||||
;;
|
|
||||||
*-FreeBSD-[5-9].*)
|
|
||||||
echo pthread.o
|
|
||||||
;;
|
|
||||||
*-Linux-*)
|
|
||||||
# will have to fix this for linux power pc
|
# will have to fix this for linux power pc
|
||||||
echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o
|
echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o
|
||||||
;;
|
;;
|
||||||
*-FreeBSD-*)
|
*-FreeBSD-[0-4].*)
|
||||||
echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o
|
echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o
|
||||||
;;
|
;;
|
||||||
*-NetBSD-*)
|
*-NetBSD-*)
|
||||||
echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o
|
echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o
|
||||||
;;
|
;;
|
||||||
*-Darwin-*)
|
*-Darwin-10.[5-6].*)
|
||||||
echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o
|
echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME-${OBJTYPE}.o pthread.o
|
||||||
;;
|
;;
|
||||||
*-OpenBSD-*)
|
*-OpenBSD-*)
|
||||||
echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o $SYSNAME.o
|
echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o $SYSNAME.o
|
||||||
|
|
|
@ -80,6 +80,7 @@ threadmain(int argc, char **argv)
|
||||||
mk(countthread, c, STACK);
|
mk(countthread, c, STACK);
|
||||||
mk(filterthread, c, STACK);
|
mk(filterthread, c, STACK);
|
||||||
recvp(chancreate(sizeof(void*), 0));
|
recvp(chancreate(sizeof(void*), 0));
|
||||||
|
threadexitsall(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -91,7 +91,7 @@ threadstart(uint y, uint x)
|
||||||
z |= y;
|
z |= y;
|
||||||
t = (_Thread*)z;
|
t = (_Thread*)z;
|
||||||
|
|
||||||
/*print("threadstart %p\n", v); */
|
//print("threadstart sp=%p arg=%p startfn=%p t=%p\n", &t, t, t->startfn, t->startarg);
|
||||||
t->startfn(t->startarg);
|
t->startfn(t->startarg);
|
||||||
/*print("threadexits %p\n", v); */
|
/*print("threadexits %p\n", v); */
|
||||||
threadexits(nil);
|
threadexits(nil);
|
||||||
|
@ -114,17 +114,21 @@ threadalloc(void (*fn)(void*), void *arg, uint stack)
|
||||||
t->stk = (uchar*)(t+1);
|
t->stk = (uchar*)(t+1);
|
||||||
t->stksize = stack;
|
t->stksize = stack;
|
||||||
t->id = incref(&threadidref);
|
t->id = incref(&threadidref);
|
||||||
|
//print("fn=%p arg=%p\n", fn, arg);
|
||||||
t->startfn = fn;
|
t->startfn = fn;
|
||||||
t->startarg = arg;
|
t->startarg = arg;
|
||||||
|
//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn);
|
||||||
|
|
||||||
/* do a reasonable initialization */
|
/* do a reasonable initialization */
|
||||||
memset(&t->context.uc, 0, sizeof t->context.uc);
|
memset(&t->context.uc, 0, sizeof t->context.uc);
|
||||||
sigemptyset(&zero);
|
sigemptyset(&zero);
|
||||||
sigprocmask(SIG_BLOCK, &zero, &t->context.uc.uc_sigmask);
|
sigprocmask(SIG_BLOCK, &zero, &t->context.uc.uc_sigmask);
|
||||||
|
//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn);
|
||||||
|
|
||||||
/* must initialize with current context */
|
/* must initialize with current context */
|
||||||
if(getcontext(&t->context.uc) < 0)
|
if(getcontext(&t->context.uc) < 0)
|
||||||
sysfatal("threadalloc getcontext: %r");
|
sysfatal("threadalloc getcontext: %r");
|
||||||
|
//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn);
|
||||||
|
|
||||||
/* call makecontext to do the real work. */
|
/* call makecontext to do the real work. */
|
||||||
/* leave a few words open on both ends */
|
/* leave a few words open on both ends */
|
||||||
|
@ -141,6 +145,7 @@ threadalloc(void (*fn)(void*), void *arg, uint stack)
|
||||||
* function that takes some number of word-sized variables,
|
* function that takes some number of word-sized variables,
|
||||||
* and on 64-bit machines pointers are bigger than words.
|
* and on 64-bit machines pointers are bigger than words.
|
||||||
*/
|
*/
|
||||||
|
//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn);
|
||||||
z = (ulong)t;
|
z = (ulong)t;
|
||||||
y = z;
|
y = z;
|
||||||
z >>= 16; /* hide undefined 32-bit shift from 32-bit compilers */
|
z >>= 16; /* hide undefined 32-bit shift from 32-bit compilers */
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern int swapcontext(ucontext_t*, ucontext_t*);
|
||||||
extern void makecontext(ucontext_t*, void(*)(), int, ...);
|
extern void makecontext(ucontext_t*, void(*)(), int, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__) && !defined(__x86_64__)
|
||||||
/*
|
/*
|
||||||
* OS X before 10.5 (Leopard) does not provide
|
* OS X before 10.5 (Leopard) does not provide
|
||||||
* swapcontext nor makecontext, so we have to use our own.
|
* swapcontext nor makecontext, so we have to use our own.
|
||||||
|
@ -40,8 +40,10 @@ extern void makecontext(ucontext_t*, void(*)(), int, ...);
|
||||||
# define makecontext libthread_makecontext
|
# define makecontext libthread_makecontext
|
||||||
# if defined(__i386__)
|
# if defined(__i386__)
|
||||||
# include "386-ucontext.h"
|
# include "386-ucontext.h"
|
||||||
# else
|
# elif defined(__power__)
|
||||||
# include "power-ucontext.h"
|
# include "power-ucontext.h"
|
||||||
|
# else
|
||||||
|
# error "unknown architecture"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -99,6 +101,15 @@ enum
|
||||||
struct Context
|
struct Context
|
||||||
{
|
{
|
||||||
ucontext_t uc;
|
ucontext_t uc;
|
||||||
|
#ifdef __APPLE__
|
||||||
|
/*
|
||||||
|
* On Snow Leopard, etc., the context routines exist,
|
||||||
|
* so we use them, but apparently they write past the
|
||||||
|
* end of the ucontext_t. Sigh. We put some extra
|
||||||
|
* scratch space here for them.
|
||||||
|
*/
|
||||||
|
uchar buf[512];
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Execjob
|
struct Execjob
|
||||||
|
@ -116,12 +127,12 @@ struct _Thread
|
||||||
_Thread *allnext;
|
_Thread *allnext;
|
||||||
_Thread *allprev;
|
_Thread *allprev;
|
||||||
Context context;
|
Context context;
|
||||||
|
void (*startfn)(void*);
|
||||||
|
void *startarg;
|
||||||
uint id;
|
uint id;
|
||||||
uchar *stk;
|
uchar *stk;
|
||||||
uint stksize;
|
uint stksize;
|
||||||
int exiting;
|
int exiting;
|
||||||
void (*startfn)(void*);
|
|
||||||
void *startarg;
|
|
||||||
Proc *proc;
|
Proc *proc;
|
||||||
char name[256];
|
char name[256];
|
||||||
char state[256];
|
char state[256];
|
||||||
|
|
|
@ -38,5 +38,6 @@ YFLAGS=-d
|
||||||
LIB=
|
LIB=
|
||||||
SHORTLIB=9
|
SHORTLIB=9
|
||||||
|
|
||||||
|
<|cat $PLAN9/config 2>/dev/null || true
|
||||||
<|cat $PLAN9/src/mk.$SYSNAME-$OBJTYPE 2>/dev/null || true
|
<|cat $PLAN9/src/mk.$SYSNAME-$OBJTYPE 2>/dev/null || true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue