Enable us to include libthreads.h in a "user program".
BIN=libthreads
SOURCE=libthreads.c schedule.c
-HEADERS=libthreads.h schedule.h
+HEADERS=libthreads.h schedule.h common.h
FLAGS=
all: ${BIN}
--- /dev/null
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#include <stdio.h>
+
+//#define CONFIG_DEBUG
+
+#ifdef CONFIG_DEBUG
+#define DEBUG(fmt, ...) do { printf("*** %25s(): line %-4d *** " fmt, __func__, __LINE__, ##__VA_ARGS__); } while (0)
+#define DBG() DEBUG("\n");
+#else
+#define DEBUG(fmt, ...)
+#define DBG()
+#endif
+
+#endif /* __CONFIG_H__ */
#include <stdlib.h>
#include "libthreads.h"
+#include "common.h"
#define STACK_SIZE (1024 * 1024)
#ifndef __LIBTHREADS_H__
#define __LIBTHREADS_H__
-#include <stdio.h>
#include <ucontext.h>
-//#define CONFIG_DEBUG
-
-#ifdef CONFIG_DEBUG
-#define DEBUG(fmt, ...) do { printf("*** %25s(): line %-4d *** " fmt, __func__, __LINE__, ##__VA_ARGS__); } while (0)
-#define DBG() DEBUG("\n");
-#else
-#define DEBUG(fmt, ...)
-#define DBG()
-#endif
-
struct thread {
void (*start_routine);
void *arg;
#include "schedule.h"
+#include "common.h"
struct thread_list_node {
struct thread *this;