#ifndef __SYSTHREAD_H__
#define __SYSTHREAD_H__
#include <NetInfo/config.h>
#include <rpc/types.h>
#ifdef _THREAD_TYPE_PTHREAD_
#include <stdlib.h>
#include <pthread.h>
#define thread_type pthread_t
#else
#ifndef _CTHREADS_
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
#include <mach/cthreads.h>
#endif
#define thread_type cthread_t
#endif
#define ThreadStateTerminal -1
#define ThreadStateInitial 0
#define ThreadStateIdle 1
#define ThreadStateActive 2
#define ThreadStateSleeping 3
typedef struct
{
thread_type thread;
char *name;
bool_t should_terminate;
bool_t is_running;
void *data;
unsigned long state;
} systhread;
systhread *systhread_new(void);
void systhread_free(systhread *);
systhread *systhread_current(void);
unsigned int systhread_count(void);
systhread *systhread_with_name(char *);
systhread *systhread_at_index(unsigned int);
unsigned long systhread_state(systhread *t);
void systhread_set_state(systhread *, unsigned long);
char *systhread_name(systhread *);
void systhread_set_name(systhread *, char *);
void *systhread_data(systhread *);
void systhread_set_data(systhread *, void *);
void systhread_run(systhread *, void(*)(void *), void *);
bool_t systhread_is_running(systhread *);
void systhread_set_should_terminate(systhread *, bool_t);
bool_t systhread_should_terminate(systhread *);
void systhread_exit(void);
void systhread_yield(void);
void systhread_sleep(unsigned long);
void systhread_usleep(unsigned long);
#endif __SYSTHREAD_H__