diff --git a/src/thread/thread.c b/src/thread/thread.c index 657c7eb..b2192a7 100644 --- a/src/thread/thread.c +++ b/src/thread/thread.c @@ -15,7 +15,7 @@ #define UNSET_STATUS(entry, value) ((entry->status) &= ~(value)) #define FINISHED (1 << 0) #define IS_FINISHED(entry) (HAS_STATUS(entry, FINISHED)) -#define IS_MAIN(entry) (entry == main) +#define IS_MAIN(entry) (entry == main_thread) #define WAITING (1 << 2) #define IS_WAITING(entry) (HAS_STATUS(entry, WAITING)) #define WAITED (1 << 3) @@ -40,7 +40,7 @@ static char stack_for_freeing[STACK_SIZE] = {0}; static int stack_valgrind_id = 0; static ucontext_t context_for_freeing; -static struct context_entry_t* main = NULL; +static struct context_entry_t* main_thread = NULL; struct mutex_fifo_entry_t; @@ -315,14 +315,14 @@ void __attribute__((constructor)) setup_main_thread() TAILQ_INSERT_TAIL(&available_threads, new_entry, link); } - main = malloc(sizeof(*main)); - // memset(main, 0, sizeof(*main)); - getcontext(&main->context); - main->status = 0; - main->valgrind_id = 0; - main->retvalue = NULL; - ufd__init(&main->waited_threads, main); - running = main; + main_thread = malloc(sizeof(*main_thread)); + // memset(main_thread, 0, sizeof(*main)); + getcontext(&main_thread->context); + main_thread->status = 0; + main_thread->valgrind_id = 0; + main_thread->retvalue = NULL; + ufd__init(&main_thread->waited_threads, main_thread); + running = main_thread; // Create a context with static stack to clean everything at the end. getcontext(&context_for_freeing); @@ -342,7 +342,7 @@ void __attribute__((destructor)) clear_last_thread() exit(0); } - free(main); + free(main_thread); // Running's stack was allocated by us, lets switch to a static stack first. swapcontext(&running->context, &context_for_freeing); exit(0);