Various tweaks to make things run on Mac OS.

The main change is the use of pthread to implement ffork.
This commit is contained in:
rsc 2003-10-01 02:50:57 +00:00
parent e182749a98
commit a995e477ff
12 changed files with 84 additions and 12 deletions

View file

@ -1,8 +1,7 @@
#include "threadimpl.h"
#include <unistd.h>
extern int getfforkid(void);
int
_threadgetpid(void)
{
return getpid();
return getfforkid();
}

View file

@ -17,6 +17,21 @@ struct Label
ulong si;
ulong di;
};
#elif defined(__APPLE__)
struct Label
{
ulong pc; /* lr */
ulong cr; /* mfcr */
ulong ctr; /* mfcr */
ulong xer; /* mfcr */
ulong sp; /* callee saved: r1 */
ulong toc; /* callee saved: r2 */
ulong gpr[19]; /* callee saved: r13-r31 */
// XXX: currently do not save vector registers or floating-point state
// ulong pad;
// uvlong fpr[18]; /* callee saved: f14-f31 */
// ulong vr[4*12]; /* callee saved: v20-v31, 256-bits each */
};
#else
#error "Unknown or unsupported architecture"
#endif

View file

@ -25,7 +25,7 @@ threadmain(int argc, char **argv)
c[1] = chancreate(sizeof(ulong), 1);
c[2] = c[0];
threadcreate(pingpong, c, 16384);
proccreate(pingpong, c, 16384);
threadcreate(pingpong, c+1, 16384);
sendul(c[0], atoi(argv[1]));
}