1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-04-28 06:33:36 +00:00

thread: pacify gcc -Wunused-value

* lib/glthread/thread.h (glthread_atfork, glthread_sigmask)
(glthread_create, glthread_join): Evaluate arguments even when
these macros are no-ops.  Type-check the arguments too.  This is
cleaner anyway, in case the args have the wrong types (or have
side effects!).
This commit is contained in:
Paul Eggert
2026-04-25 09:40:41 -07:00
parent dd1e3c7219
commit 6bce2d2f70
2 changed files with 42 additions and 9 deletions

View File

@@ -1,5 +1,12 @@
2026-04-25 Paul Eggert <eggert@cs.ucla.edu>
thread: pacify gcc -Wunused-value
* lib/glthread/thread.h (glthread_atfork, glthread_sigmask)
(glthread_create, glthread_join): Evaluate arguments even when
these macros are no-ops. Type-check the arguments too. This is
cleaner anyway, in case the args have the wrong types (or have
side effects!).
thread: pacify gcc -Wsuggest-attribute=noreturn
* lib/glthread/thread.c (gl_thread_create):
When threading is disabled, this function is _Noreturn.

View File

@@ -114,7 +114,11 @@ extern gl_thread_t gl_thread_self (void);
# define gl_thread_self_pointer() \
(void *) gl_thread_self ()
extern _Noreturn void gl_thread_exit (void *return_value);
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) \
((void) (struct { void (*prepare_func) (void); \
void (*parent_func) (void); \
void (*child_func) (void); }) \
{PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC}, 0)
# ifdef __cplusplus
}
@@ -240,7 +244,11 @@ extern const gl_thread_t gl_null_thread;
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) \
(pthread_in_use () ? pthread_atfork (PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) : 0)
# else
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) \
((void) (struct { void (*prepare_func) (void); \
void (*parent_func) (void); \
void (*child_func) (void); }) \
{PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC}, 0)
# endif
# ifdef __cplusplus
@@ -268,7 +276,9 @@ typedef glwthread_thread_t gl_thread_t;
# define glthread_create(THREADP, FUNC, ARG) \
glwthread_thread_create (THREADP, 0, FUNC, ARG)
# define glthread_sigmask(HOW, SET, OSET) \
/* unsupported */ 0
/* unsupported */ \
((void) (struct { int how; sigset_t const *set; sigset_t *oset; }) \
{HOW, SET, OSET}, 0)
# define glthread_join(THREAD, RETVALP) \
glwthread_thread_join (THREAD, RETVALP)
# define gl_thread_self() \
@@ -277,7 +287,11 @@ typedef glwthread_thread_t gl_thread_t;
gl_thread_self ()
# define gl_thread_exit(RETVAL) \
glwthread_thread_exit (RETVAL)
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) \
((void) (struct { void (*prepare_func) (void); \
void (*parent_func) (void); \
void (*child_func) (void); }) \
{PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC}, 0)
# ifdef __cplusplus
}
@@ -292,14 +306,26 @@ typedef glwthread_thread_t gl_thread_t;
/* Provide dummy implementation if threads are not supported. */
typedef int gl_thread_t;
# define glthread_create(THREADP, FUNC, ARG) ENOSYS
# define glthread_sigmask(HOW, SET, OSET) 0
# define glthread_join(THREAD, RETVALP) 0
# define glthread_create(THREADP, FUNC, ARG) \
((void) (struct { gl_thread_t *threadp; \
void *(*func) (void *); \
void *arg; }) \
{THREADP, FUNC, ARG}, ENOSYS)
# define glthread_sigmask(HOW, SET, OSET) \
((void) (struct { int how; sigset_t const *set; sigset_t *oset; }) \
{HOW, SET, OSET}, 0)
# define glthread_join(THREAD, RETVALP) \
((void) (struct { gl_thread_t thread; void **retvalp; }) \
{THREAD, RETVALP}, 0)
# define gl_thread_self() 0
# define gl_thread_self_pointer() \
((void *) gl_thread_self ())
# define gl_thread_exit(RETVAL) (void)0
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
# define gl_thread_exit(RETVAL) ((int) {RETVAL}, (void) 0)
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) \
((void) (struct { void (*prepare_func) (void); \
void (*parent_func) (void); \
void (*child_func) (void); }) \
{PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC}, 0)
#endif