From: Brian Norris Date: Thu, 8 Mar 2012 23:41:34 +0000 (-0800) Subject: libthreads: create header file X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=8090a361f8800cfced794c0adbf8a91778d3cec6;hp=0b930bb715fcfc231ee297ac2294c7f9402337b7 libthreads: create header file --- diff --git a/Makefile b/Makefile index 25b9459a..1867a444 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ BIN=libthreads SOURCE=libthreads.c +HEADERS=libthreads.h FLAGS= all: ${BIN} -${BIN}: ${SOURCE} +${BIN}: ${SOURCE} ${HEADERS} gcc -o ${BIN} ${SOURCE} ${FLAGS} clean: diff --git a/libthreads.c b/libthreads.c index 4545ee36..5ede8d7e 100644 --- a/libthreads.c +++ b/libthreads.c @@ -1,28 +1,13 @@ #include #include #include -#include //#define CONFIG_DEBUG -#ifdef CONFIG_DEBUG -#define DBG() do { printf("Here: %s, L%d\n", __func__, __LINE__); } while (0) -#define DEBUG(fmt, ...) printf(fmt, ##__VA_ARGS__) -#else -#define DBG() -#define DEBUG(fmt, ...) -#endif +#include "libthreads.h" #define STACK_SIZE (1024 * 1024) -struct thread { - void (*start_routine); - void *arg; - ucontext_t context; - void *stack; - int index; -}; - static struct thread *current; static ucontext_t *cleanup; diff --git a/libthreads.h b/libthreads.h new file mode 100644 index 00000000..85228717 --- /dev/null +++ b/libthreads.h @@ -0,0 +1,20 @@ +#include + +#ifdef CONFIG_DEBUG +#define DBG() do { printf("Here: %s, L%d\n", __func__, __LINE__); } while (0) +#define DEBUG(fmt, ...) printf(fmt, ##__VA_ARGS__) +#else +#define DBG() +#define DEBUG(fmt, ...) +#endif + +struct thread { + void (*start_routine); + void *arg; + ucontext_t context; + void *stack; + int index; +}; + +int thread_create(struct thread *t, void (*start_routine), void *arg); +void thread_start(struct thread *t);