feat: rename static main thread to 'main_thread'

This commit is contained in:
Nemo D'ACREMONT 2025-04-24 13:29:36 +02:00
parent 81abd5113a
commit d709f4eb6a
No known key found for this signature in database
GPG Key ID: 85F245EC3BB1E022

View File

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