]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Tidy bits of libgcc/config/gthr-vxworks
authorOlivier Hainque <hainque@adacore.com>
Wed, 9 Jul 2025 10:48:34 +0000 (10:48 +0000)
committerOlivier Hainque <hainque@adacore.com>
Mon, 20 Oct 2025 16:56:08 +0000 (16:56 +0000)
This addresses a variety of warnings about missing prototypes
or suspicious ptr-to-function conversions.

libgcc/
* config/gthr-vxworks-thread.c (__init_gthread_tcb): Make static.
(__delete_gthread_tcb): Likewise.
(__task_wrapper): Likewise.
(__gthread_create): Convert __task_wrapper to (void *) before going
to (FUNCPTR).
* config/gthr-vxworks-tls.c (tls_delete_hook): Accommodate prototype
variations between kernel and rtp. Return STATUS.

libgcc/config/gthr-vxworks-thread.c
libgcc/config/gthr-vxworks-tls.c

index 31f291aca67e3176c704df74dcecc86523e0b473..1d630e95fd2e64552bf116b21782e79ec9c69403 100644 (file)
@@ -29,6 +29,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #include "gthr.h"
 
+typedef STATUS (* ENTRYPTR) (int);
+
 #if __GTHREADS_CXX0X
 
 #include <taskLib.h>
@@ -189,7 +191,7 @@ __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *mutex,
 
 /* Task control block initialization and destruction functions.  */
 
-int
+static int
 __init_gthread_tcb (__gthread_t __tcb)
 {
   if (!__tcb)
@@ -222,7 +224,7 @@ return_sem_delete:
 
 /* 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);
@@ -256,8 +258,8 @@ __gthread_self (void)
   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;
@@ -322,7 +324,7 @@ __gthread_create (__gthread_t * __threadid, void *(*__func) (void *),
 
   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,
index 8ff9f2fd1d3a30216c4409f19e0932abef96c8f2..336d8cb1129394ce2d52e52f0ed4620688cb8204 100644 (file)
@@ -168,7 +168,22 @@ static __gthread_once_t tls_init_guard = __GTHREAD_ONCE_INIT;
 
 /* 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.
 
@@ -176,8 +191,8 @@ static __gthread_once_t tls_init_guard = __GTHREAD_ONCE_INIT;
    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;
@@ -202,6 +217,8 @@ tls_delete_hook (void *tcb ATTRIBUTE_UNUSED)
       VX_LEAVE_TLS_DTOR();
       VX_SET_TLS_DATA(NULL);
     }
+
+  return OK;
 }
 
 /* Initialize global data used by the TLS system.  */
@@ -217,11 +234,11 @@ tls_destructor (void)
 {
 #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);
@@ -343,7 +360,7 @@ __gthread_setspecific (__gthread_key_t key, void *value)
            return ENOMEM;
          if (!delete_hook_installed)
            {
-             taskDeleteHookAdd ((FUNCPTR)tls_delete_hook);
+             taskDeleteHookAdd (tls_delete_hook);
              delete_hook_installed = 1;
            }
          __gthread_mutex_unlock (&tls_lock);