On Solaris 11, I see many warnings: gllib/glthread/thread.h:236:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] I wouldn't care much about 1 warning, but these are many.
This patch fixes them. 2023-06-25 Bruno Haible <br...@clisp.org> thread: Avoid compiler warnings on Solaris. * lib/glthread/thread.h: Include <stdint.h>. (gl_thread_self_pointer): Do the cast from pthread_t to 'void *' via intptr_t. * modules/thread (Depends-on): Add stdint. diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h index 88bc53ee7f..942ce70b5c 100644 --- a/lib/glthread/thread.h +++ b/lib/glthread/thread.h @@ -130,6 +130,9 @@ extern _Noreturn void gl_thread_exit (void *return_value); # include <pthread.h> +/* Get intptr_t. */ +# include <stdint.h> + /* On IRIX, pthread_atfork is declared in <unistd.h>, not in <pthread.h>. */ # if defined __sgi # include <unistd.h> @@ -233,7 +236,7 @@ extern const gl_thread_t gl_null_thread; # define gl_thread_self() \ (pthread_in_use () ? pthread_self () : (pthread_t) 0) # define gl_thread_self_pointer() \ - (pthread_in_use () ? (void *) (pthread_t) pthread_self () : NULL) + (pthread_in_use () ? (void *) (intptr_t) (pthread_t) pthread_self () : NULL) # endif # define gl_thread_exit(RETVAL) \ (void) (pthread_in_use () ? (pthread_exit (RETVAL), 0) : 0) diff --git a/modules/thread b/modules/thread index 1d530b0d3a..f416807b63 100644 --- a/modules/thread +++ b/modules/thread @@ -8,6 +8,7 @@ m4/thread.m4 Depends-on: threadlib +stdint extern-inline lock windows-thread [test $gl_threads_api = windows]