os x changes

This commit is contained in:
rsc 2005-01-11 17:43:53 +00:00
parent 530d001641
commit b8f742db85
18 changed files with 92 additions and 44 deletions

View file

@ -120,7 +120,7 @@ typedef short s16int;
/*
* Gcc 3 is too smart for its own good.
*/
#if defined(__GNUC__)
#if defined(__GNUC__) && !defined(__APPLE_CC__)
# if __GNUC__ >= 3
# undef AUTOLIB
# define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));

View file

@ -465,6 +465,9 @@ enum
#define WIN(q) ((((ulong)(q).path)>>8) & 0xFFFFFF)
#define FILE(q) ((q).path & 0xFF)
#undef FALSE
#undef TRUE
enum
{
FALSE,

View file

@ -105,6 +105,8 @@ double diddle(struct place *, double, double);
void dobounds(double, double, double, double, int);
void dogrid(double, double, double, double);
int duple(struct place *, double);
#define fmax map_fmax
#define fmin map_fmin
double fmax(double, double);
double fmin(double, double);
void getdata(char *);

View file

@ -5,7 +5,6 @@ LIB=libmap/libmap.a
OFILES=map.$O\
symbol.$O\
index.$O\
sqrt.$O\
HFILES=map.h\
iplot.h\

View file

@ -8,6 +8,7 @@
* 2+head+2+page[56]+5
*/
#define err pr_err
#define ISPRINT(c) ((c) >= ' ')
#define ESC '\033'
#define LENGTH 66

View file

@ -10,6 +10,8 @@
#define ONES ~0
#define devname proof_devname
#define getc proof_getc
#define ungetc proof_ungetc
extern char devname[];
extern double mag;

View file

@ -1,3 +1,8 @@
/*
* Somehow <errno.h> has been included on Mac OS X
*/
#undef EIO
extern char ENoDir[];
extern char EBadDir[];
extern char EBadMeta[];

View file

@ -56,7 +56,6 @@ CFsys*
fsmount(int fd, char *aname)
{
int n;
char *user;
CFsys *fs;
CFid *fid;
@ -72,7 +71,6 @@ fsmount(int fd, char *aname)
}
fs->msize = n;
user = getuser();
if((fid = fsattach(fs, nil, getuser(), aname)) == nil)
goto Error;
fssetroot(fs, fid);

1
src/libmach/OpenBSD.c Normal file
View file

@ -0,0 +1 @@
#include "nosys.c"

View file

@ -4,6 +4,9 @@
#include "elf.h"
#include "ureg386.h"
#undef errno
#define errno uregerrno
typedef struct Lreg Lreg;
typedef struct Status Status;
typedef struct Psinfo Psinfo;

View file

@ -570,7 +570,7 @@ sub(Opcode *o, Instr *i)
bprint(i, "\tR%d,$%d,R%d", i->ra, i->simm, i->rd);
}
#define div qdiv
#define div power_div
static void
div(Opcode *o, Instr *i)

View file

@ -43,7 +43,7 @@
#define S43 15
#define S44 21
#define PAYME(x) $##x
#define PAYME(x) $ ## x
/*
* SI is data

View file

@ -4,9 +4,9 @@
.text
.align 2
.globl __setlabel
.globl __getmcontext
__setlabel: /* xxx: instruction scheduling */
__getmcontext: /* xxx: instruction scheduling */
mflr r0
mfcr r5
mfctr r6
@ -18,35 +18,35 @@ __setlabel: /* xxx: instruction scheduling */
stw r1, 4*4(r3)
stw r2, 5*4(r3)
li r5, 1 /* return value for gotolabel */
li r5, 1 /* return value for setmcontext */
stw r5, 6*4(r3)
stw r13, (0+6)*4(r3) /* callee-save GPRs */
stw r14, (1+6)*4(r3) /* xxx: block move */
stw r15, (2+6)*4(r3)
stw r16, (3+6)*4(r3)
stw r17, (4+6)*4(r3)
stw r18, (5+6)*4(r3)
stw r19, (6+6)*4(r3)
stw r20, (7+6)*4(r3)
stw r21, (8+6)*4(r3)
stw r22, (9+6)*4(r3)
stw r23, (10+6)*4(r3)
stw r24, (11+6)*4(r3)
stw r25, (12+6)*4(r3)
stw r26, (13+6)*4(r3)
stw r27, (14+6)*4(r3)
stw r28, (15+6)*4(r3)
stw r29, (16+6)*4(r3)
stw r30, (17+6)*4(r3)
stw r31, (18+6)*4(r3)
stw r13, (0+7)*4(r3) /* callee-save GPRs */
stw r14, (1+7)*4(r3) /* xxx: block move */
stw r15, (2+7)*4(r3)
stw r16, (3+7)*4(r3)
stw r17, (4+7)*4(r3)
stw r18, (5+7)*4(r3)
stw r19, (6+7)*4(r3)
stw r20, (7+7)*4(r3)
stw r21, (8+7)*4(r3)
stw r22, (9+7)*4(r3)
stw r23, (10+7)*4(r3)
stw r24, (11+7)*4(r3)
stw r25, (12+7)*4(r3)
stw r26, (13+7)*4(r3)
stw r27, (14+7)*4(r3)
stw r28, (15+7)*4(r3)
stw r29, (16+7)*4(r3)
stw r30, (17+7)*4(r3)
stw r31, (18+7)*4(r3)
li r3, 0 /* return */
blr
.globl __gotolabel
.globl __setmcontext
__gotolabel:
__setmcontext:
lwz r13, (0+7)*4(r3) /* callee-save GPRs */
lwz r14, (1+7)*4(r3) /* xxx: block move */
lwz r15, (2+7)*4(r3)
@ -79,5 +79,5 @@ __gotolabel:
lwz r0, 3*4(r3)
mtxer r0
lwz r3, 6*4(r4)
lwz r3, 6*4(r3)
blr

View file

@ -8,23 +8,24 @@ makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
tos = (ulong*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/sizeof(ulong);
sp = tos - 16;
ucp->label.pc = (long)func;
ucp->label.sp = (long)sp;
ucp->mc.pc = (long)func;
ucp->mc.sp = (long)sp;
va_start(arg, argc);
ucp->label.r3 = va_arg(arg, long);
ucp->mc.r3 = va_arg(arg, long);
va_end(arg);
}
void
int
getcontext(ucontext_t *uc)
{
return __setlabel(uc);
return _getmcontext(&uc->mc);
}
int
setcontext(ucontext_t *uc)
{
return __gotolabel(uc);
_setmcontext(&uc->mc);
return 0;
}
int

View file

@ -1,5 +1,6 @@
typedef struct mcontext mcontext_t;
typedef struct ucontext ucontext_t;
struct ucontext
struct mcontext
{
ulong pc; /* lr */
ulong cr; /* mfcr */
@ -15,10 +16,20 @@ struct ucontext
// ulong vr[4*12]; /* callee saved: v20-v31, 256-bits each */
};
struct ucontext
{
struct {
void *ss_sp;
uint ss_size;
} uc_stack;
sigset_t uc_sigmask;
mcontext_t mc;
};
void makecontext(ucontext_t*, void(*)(void), int, ...);
void getcontext(ucontext_t*);
int getcontext(ucontext_t*);
int setcontext(ucontext_t*);
int swapcontext(ucontext_t*, ucontext_t*);
int __setlabel(ucontext_t*);
void __gotolabel(ucontext_t*);
int _getmcontext(mcontext_t*);
void _setmcontext(mcontext_t*);

View file

@ -27,6 +27,11 @@ _threaddebug(char *fmt, ...)
static int fd = -1;
return;
va_start(arg, fmt);
vfprint(1, fmt, arg);
va_end(arg);
return;
if(fd < 0){
p = strrchr(argv0, '/');
if(p)
@ -77,9 +82,11 @@ threadstart(void *v)
_Thread *t;
t = v;
//print("threadstart %p\n", v);
t->startfn(t->startarg);
memset(&v, 0xff, 32); /* try to cut off stack traces */
//print("threadexits %p\n", v);
threadexits(nil);
//print("not reacehd\n");
}
static _Thread*
@ -156,6 +163,7 @@ _threadswitch(void)
Proc *p;
p = proc();
//print("threadswtch %p\n", p);
contextswitch(&p->thread->context, &p->schedcontext);
}
@ -217,7 +225,7 @@ scheduler(Proc *p)
setproc(p);
_threaddebug("scheduler enter");
// print("s %p %d\n", p, gettid());
// print("s %p\n", p);
lock(&p->lock);
for(;;){
while((t = p->runqueue.head) == nil){
@ -234,11 +242,13 @@ scheduler(Proc *p)
p->nswitch++;
_threaddebug("run %d (%s)", t->id, t->name);
contextswitch(&p->schedcontext, &t->context);
//print("back in scheduler\n");
p->thread = nil;
lock(&p->lock);
if(t->exiting){
delthreadinproc(p, t);
p->nthread--;
//print("ntrhead %d\n", p->nthread);
free(t);
}
}
@ -313,6 +323,7 @@ threadsetstate(char *fmt, ...)
static int
threadqlock(QLock *l, int block, ulong pc)
{
//print("threadqlock %p\n", l);
lock(&l->l);
if(l->owner == nil){
l->owner = (*threadnow)();

View file

@ -17,6 +17,10 @@ extern void makecontext(ucontext_t*, void(*)(), int, ...);
#endif
#if defined(__APPLE__)
# define mcontext libthread_mcontext
# define mcontext_t libthread_mcontext_t
# define ucontext libthread_ucontext
# define ucontext_t libthread_ucontext_t
# include "Darwin-ucontext.h"
#endif

View file

@ -1,5 +1,12 @@
SYSNAME=`uname`
OBJTYPE=`uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g' | sed 's/ppc64/power/g' | sed 's/ppc/power/g'`
OBJTYPE=`uname -m | sed '
s;i.86;386;;
s;/.*;;;
s; ;;g;
s;PowerMacintosh;power;g;
s;ppc64;power;g;
s;ppc;power;g'`
SYSVERSION=`uname -r`
BIN=$PLAN9/bin