]> Savannah Git Hosting - gnulib.git/commitdiff
tls tests: Small improvements.
authorBruno Haible <bruno@clisp.org>
Thu, 20 Jun 2019 01:53:51 +0000 (03:53 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 20 Jun 2019 01:53:51 +0000 (03:53 +0200)
* tests/test-tls.c: Include <stdint.h>.
(worker_thread): Avoid gcc warning on 64-bit mingw.
(test_tls): Pass a different id to each thread.
* modules/tls-tests (Depends-on): Add stdint.

ChangeLog
modules/tls-tests
tests/test-tls.c

index 9472275f44dae8c4eb4e1f1c10ee97f626f2b3f9..b8ff877c14dd5386ff47f08e103b477c6c0c7999 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-06-20  Bruno Haible  <bruno@clisp.org>
+
+       tls tests: Small improvements.
+       * tests/test-tls.c: Include <stdint.h>.
+       (worker_thread): Avoid gcc warning on 64-bit mingw.
+       (test_tls): Pass a different id to each thread.
+       * modules/tls-tests (Depends-on): Add stdint.
+
 2019-06-20  Bruno Haible  <bruno@clisp.org>
 
        cond tests: Simplify.
index 562e36b21d623951a0c207b45e0b4c4645ae2f61..b93f6735dd0cc25af9416683f4a4ed1713724d9f 100644 (file)
@@ -3,6 +3,7 @@ tests/test-tls.c
 
 Depends-on:
 thread
+stdint
 yield
 
 configure.ac:
index 6bfa6ff4b1520540dde0d5e6b7ae0e042261b929..0cd6b1d94793358902de42dad402e34449f2478f 100644 (file)
@@ -46,6 +46,7 @@
 /* Number of operations performed in each thread.  */
 #define REPEAT_COUNT 50000
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -90,7 +91,7 @@ static gl_tls_key_t mykeys[KEYS_COUNT];
 static void *
 worker_thread (void *arg)
 {
-  unsigned int id = (unsigned int) (unsigned long) arg;
+  unsigned int id = (unsigned int) (uintptr_t) arg;
   int i, j, repeat;
   unsigned int values[KEYS_COUNT];
 
@@ -172,7 +173,7 @@ test_tls (void)
 
       /* Spawn the threads.  */
       for (i = 0; i < THREAD_COUNT; i++)
-        threads[i] = gl_thread_create (worker_thread, NULL);
+        threads[i] = gl_thread_create (worker_thread, (void *) (uintptr_t) i);
 
       /* Wait for the threads to terminate.  */
       for (i = 0; i < THREAD_COUNT; i++)