int main(int argc, const char *argv[]) { #if 1 CIRCLEQ_HEAD(circleq, _Data) head = CIRCLEQ_HEAD_INITIALIZER(head); #else CIRCLEQ_HEAD(circleq, _Data) head; CIRCLEQ_INIT(&head); #endif exit(EXIT_SUCCESS); }
#include <errno.h> #include <pthread.h> #include <sys/queue.h> static pthread_mutex_t handler_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; struct atfork_t { CIRCLEQ_ENTRY(atfork_t) entries; void (*prepare)(void); void (*child)(void); void (*parent)(void); }; static CIRCLEQ_HEAD(atfork_head_t, atfork_t) atfork_head = \ CIRCLEQ_HEAD_INITIALIZER(atfork_head); void __bionic_atfork_run_prepare() { struct atfork_t *cursor; /* We will lock this here, and unlock it in the parent and child functions. * This ensures that nobody can modify the handler array between the calls * to the prepare and parent/child handlers. * * TODO: If a handler mucks with the list, it could cause problems. Right * now it's ok because all they can do is add new items to the end * of the list, but if/when we implement cleanup in dlclose() things * will get more interesting... */ pthread_mutex_lock(&handler_mutex);
#include <sys/wait.h> #include "recorder.h" #include "../share/config.h" #include "../share/dbg.h" #include "../share/hpc.h" #include "../share/sys.h" #include "../share/task.h" struct tasklist_entry { struct task t; CIRCLEQ_ENTRY(tasklist_entry) entries; }; CIRCLEQ_HEAD(tasklist, tasklist_entry) head = CIRCLEQ_HEAD_INITIALIZER(head); static struct tasklist_entry* tid_to_entry[MAX_TID]; static struct tasklist_entry* current_entry; static int num_active_threads; static struct tasklist_entry* get_entry(pid_t tid) { return tid_to_entry[tid]; } static struct task* get_task(pid_t tid) { struct tasklist_entry* entry = get_entry(tid); return entry ? &entry->t : NULL; }