#ifndef EMULATOR_PROCESS_H

#include <pthread.h>
#include <stdarg.h>

#define MAX_ARGS 8

// A transputer process (more like a thread)
typedef struct {
    pthread_t thread;
    void* args[MAX_ARGS];
    void (*func)();
} Process;

// Create a new process, with entry point 'func' and given stacksize. The
// 'nargs' arguments are passed to 'func' upon startup.
Process *ProcAlloc (void (*func)(), int stacksize, int nargs, ...);

// Start the process 'p'
void ProcRun (Process *p);

// Yield the rest of the time-slice to another process
void ProcReschedule();

#define EMULATOR_PROCESS_H
#endif // EMULATOR_PROCESS_H


#ifndef EMULATOR_PROCESS_H

#include <pthread.h>
// OS X does not support pthread_yield(), only pthread_yield_np()
#if defined(__APPLE__) || defined(__MACH__)
#define pthread_yield() pthread_yield_np()
#endif

#include <stdarg.h>

#define MAX_ARGS 8

// A transputer process (more like a thread)
typedef struct {
    pthread_t thread;
    void* args[MAX_ARGS];
    void (*func)();
} Process;

// Create a new process, with entry point 'func' and given stacksize. The
// 'nargs' arguments are passed to 'func' upon startup.
Process *ProcAlloc (void (*func)(), int stacksize, int nargs, ...);

// Start the process 'p'
void ProcRun (Process *p);

// Yield the rest of the time-slice to another process
void ProcReschedule();

#define EMULATOR_PROCESS_H
#endif // EMULATOR_PROCESS_H


Fix pthread_yield() not supported by OS X
Fix pthread_yield() not supported by OS X

See here for further reference:
https://github.com/01org/ocr/issues/28

And here for the diff between pthread_yield() and pthread_yield_np():
http://www.linuxquestions.org/questions/programming-9/pthread_yield-vs-pthread_yield_np-469283/
