# include "native_client/src/untrusted/irt/irt_private.h"
#endif
-#define FUN_TO_VOID_PTR(a) ((void *) (uintptr_t) (a))
-
/*
- * ABI tables for underyling NaCl thread interfaces.
+ * ABI tables for underyling NaCl thread interfaces. This is declared to be
+ * global so that a user will be able to override it using the irt_ext API.
*/
-static struct nacl_irt_thread irt_thread;
+struct nacl_irt_thread __libnacl_irt_thread;
/*
* These days, the thread_create() syscall/IRT call will align the
/* Internal functions */
-static inline void nc_abort(void) {
- while (1) *(volatile int *) 0 = 0; /* Crash. */
-}
-
static inline nc_thread_descriptor_t *nc_get_tdb(void) {
/*
* Fetch the thread-specific data pointer. This is usually just
basic_data->retval = NULL;
basic_data->status = THREAD_RUNNING;
if (pthread_cond_init(&basic_data->join_condvar, NULL) != 0)
- nc_abort();
+ __builtin_trap();
basic_data->tdb = tdb;
}
/*
* Fetch the ABI tables from the IRT. If we don't have these, all is lost.
*/
- __nc_initialize_interfaces(&irt_thread);
+ __nc_initialize_interfaces();
if (pthread_mutex_init(&__nc_thread_management_lock, NULL) != 0)
- nc_abort();
+ __builtin_trap();
/*
* Tell ThreadSanitizer to not generate happens-before arcs between uses of
ANNOTATE_NOT_HAPPENS_BEFORE_MUTEX(&__nc_thread_management_lock);
if (pthread_cond_init(&__nc_last_thread_cond, NULL) != 0)
- nc_abort();
+ __builtin_trap();
STAILQ_INIT(&__nc_thread_memory_blocks[0]);
STAILQ_INIT(&__nc_thread_memory_blocks[1]);
memset(esp, 0, kStackPadBelowAlign);
/* Start the thread. */
- retval = irt_thread.thread_create(
- FUN_TO_VOID_PTR(nc_thread_starter), esp, new_tp);
+ retval = __libnacl_irt_thread.thread_create(nc_thread_starter, esp, new_tp);
if (0 != retval) {
pthread_mutex_lock(&__nc_thread_management_lock);
/* TODO(gregoryd) : replace with atomic decrement? */
}
pthread_mutex_unlock(&__nc_thread_management_lock);
- irt_thread.thread_exit(is_used);
- nc_abort();
+ __libnacl_irt_thread.thread_exit(is_used);
+ __builtin_trap();
}
int pthread_join(pthread_t thread_id, void **thread_return) {
*/
return EPERM;
}
- return irt_thread.thread_nice(prio);
+ return __libnacl_irt_thread.thread_nice(prio);
}
int pthread_attr_init(pthread_attr_t *attr) {
return 0;
}
-int pthread_attr_getdetachstate(pthread_attr_t *attr,
+int pthread_attr_getdetachstate(const pthread_attr_t *attr,
int *detachstate) {
if (NULL == attr) {
return EINVAL;
return 0;
}
-int pthread_attr_getstacksize(pthread_attr_t *attr,
+int pthread_attr_getstacksize(const pthread_attr_t *attr,
size_t *stacksize) {
if (NULL == attr) {
return EINVAL;
* on one symbol. So if these functions are in another file in a library
* archive, they might not be linked in by static linking.
*/
+/* @IGNORE_LINES_FOR_CODE_HYGIENE[1] */
#include "native_client/src/untrusted/pthread/nc_tsd.c"