#include "gthr.h"
+typedef STATUS (* ENTRYPTR) (int);
+
#if __GTHREADS_CXX0X
#include <taskLib.h>
/* Task control block initialization and destruction functions. */
-int
+static int
__init_gthread_tcb (__gthread_t __tcb)
{
if (!__tcb)
/* Here, we pass a pointer to a tcb to allow calls from
cleanup attributes. */
-void
+static void
__delete_gthread_tcb (__gthread_t* __tcb)
{
semDelete ((*__tcb)->return_value_available);
return __local_tcb;
}
-int
-__task_wrapper (__gthread_t tcb, FUNCPTR __func, _Vx_usr_arg_t __args)
+static int
+__task_wrapper (__gthread_t tcb, ENTRYPTR __func, _Vx_usr_arg_t __args)
{
if (!tcb)
return ERROR;
TASK_ID task_id = taskCreate (NULL,
priority, options, stacksize,
- (FUNCPTR) & __task_wrapper,
+ (FUNCPTR) (void *) __task_wrapper,
(_Vx_usr_arg_t) tcb,
(_Vx_usr_arg_t) __func,
(_Vx_usr_arg_t) __args,
/* Internal routines. */
-/* The task TCB has just been deleted. Call the destructor
+/* The task deletion hooks for TLS handling have different prototypes
+ for kernel or rtp modes. The RTP variant expects a TCB argument, which,
+ fortunately, we don't need to use. */
+
+#ifdef __RTP__
+#define TLS_DELETE_HOOK_ARG_DECL TASK_ID tcb ATTRIBUTE_UNUSED
+#define TLS_DELETE_HOOK_ARG NULL
+#else
+#define TLS_DELETE_HOOK_ARG_DECL void
+#define TLS_DELETE_HOOK_ARG
+#endif
+
+STATUS tls_delete_hook (TLS_DELETE_HOOK_ARG_DECL);
+
+
+/* A task has just been deleted. Call the destructor
function for each TLS key that has both a destructor and
a non-NULL specific value in this thread.
count protects us from calling a stale destructor. It does
need to read tls_keys.dtor[key] atomically. */
-void
-tls_delete_hook (void *tcb ATTRIBUTE_UNUSED)
+STATUS
+tls_delete_hook (TLS_DELETE_HOOK_ARG_DECL)
{
struct tls_data *data;
__gthread_key_t key;
VX_LEAVE_TLS_DTOR();
VX_SET_TLS_DATA(NULL);
}
+
+ return OK;
}
/* Initialize global data used by the TLS system. */
{
#ifdef __RTP__
/* All threads but this one should have exited by now. */
- tls_delete_hook (NULL);
+ tls_delete_hook (TLS_DELETE_HOOK_ARG);
#endif
/* Unregister the hook. */
if (delete_hook_installed)
- taskDeleteHookDelete ((FUNCPTR)tls_delete_hook);
+ taskDeleteHookDelete (tls_delete_hook);
if (tls_init_guard.done && __gthread_mutex_lock (&tls_lock) != ERROR)
semDelete (tls_lock);
return ENOMEM;
if (!delete_hook_installed)
{
- taskDeleteHookAdd ((FUNCPTR)tls_delete_hook);
+ taskDeleteHookAdd (tls_delete_hook);
delete_hook_installed = 1;
}
__gthread_mutex_unlock (&tls_lock);