Skip to contentSkip to conversation

testsuite/smokey/y2038: replace gettid() function with a wrapper of __NR_gettid system call

PATCH In review Ethan 2 participants 2 messages Mar 27, 2025

lore
Share & tools
lore

Ethan

author
#0 lore raw

PATCH v2 1/1 testsuite/smokey/y2038: replace gettid() function with a wrapper of __NR_gettid system call

It fails to build testsuite/smokey/y2038 because there is no gettid() function in earlier glibc than 2.30. The commit that added gettid() function to glibc can be found at [1].

The following build failure is detected when using glibc 2.27 on Ubuntu 18.04.6 LTS (Bionic Beaver):

syscall-tests.c: In function ‘test_sc_cobalt_timer_settime64’:
syscall-tests.c:1211:31: error: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Werror=implicit-function-declaration]

  sev.sigev_notify_thread_id = gettid();
                               ^~~~~~
                               getgid

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92

---
 testsuite/smokey/y2038/syscall-tests.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testsuite/smokey/y2038/syscall-tests.c +3 -2
index 29e9c66c0..bb1bf0686 100644
@@ -12,6 +12,7 @@
 #include <smokey/smokey.h>
 #include <sys/timerfd.h>
 #include <sys/utsname.h>
+#include <sys/syscall.h> /* For __NR_gettid definitions */
 #include <mqueue.h>
 #include <rtdm/ipc.h>
 
@@ -1208,7 +1209,7 @@ static int test_sc_cobalt_timer_settime64(void)
 
 	sev.sigev_signo = sig;
 	sev.sigev_notify = SIGEV_THREAD_ID | SIGEV_SIGNAL;
-	sev.sigev_notify_thread_id = gettid();
+	sev.sigev_notify_thread_id = syscall(__NR_gettid);
 
 	ret = smokey_check_errno(timer_create(CLOCK_REALTIME, &sev, &t));
 	if (ret)
@@ -1271,7 +1272,7 @@ static int test_sc_cobalt_timer_gettime64(void)
 
 	sev.sigev_signo = sig;
 	sev.sigev_notify = SIGEV_THREAD_ID | SIGEV_SIGNAL;
-	sev.sigev_notify_thread_id = gettid();
+	sev.sigev_notify_thread_id = syscall(__NR_gettid);
 
 	ret = smokey_check_errno(timer_create(CLOCK_REALTIME, &sev, &t));
 	if (ret)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 42 lines · Ethan

It fails to build testsuite/smokey/y2038 because there is no gettid() function in earlier glibc than 2.30. The commit that added gettid() function to glibc can be found at [1].

The following build failure is detected when using glibc 2.27 on Ubuntu 18.04.6 LTS (Bionic Beaver):

syscall-tests.c: In function ‘test_sc_cobalt_timer_settime64’:
syscall-tests.c:1211:31: error: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Werror=implicit-function-declaration]

  sev.sigev_notify_thread_id = gettid();
                               ^~~~~~
                               getgid

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92

---
 testsuite/smokey/y2038/syscall-tests.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
testsuite/smokey/y2038/syscall-tests.c +2 -1
index 29e9c66c0..bb1bf0686 100644
@@ -12,6 +12,7 @@
 #include <smokey/smokey.h>
 #include <sys/timerfd.h>
 #include <sys/utsname.h>
+#include <sys/syscall.h> /* For __NR_gettid definitions */
 #include <mqueue.h>
 #include <rtdm/ipc.h>
 
@@ -1208,7 +1209,7 @@ static int test_sc_cobalt_timer_settime64(void)
 
 	sev.sigev_signo = sig;
 	sev.sigev_notify = SIGEV_THREAD_ID | SIGEV_SIGNAL;
-	sev.sigev_notify_thread_id = gettid();
+	sev.sigev_notify_thread_id = syscall(__NR_gettid);
 
 	ret = smokey_check_errno(timer_create(CLOCK_REALTIME, &sev, &t));
 	if (ret)

testsuite/smokey/y2038/syscall-tests.c static int test_sc_cobalt_timer_gettime64(void) · line 1278

Quoted 8 lines
testsuite/smokey/y2038/syscall-tests.c +1 -1
@@ -1271,7 +1272,7 @@ static int test_sc_cobalt_timer_gettime64(void)
 
 	sev.sigev_signo = sig;
 	sev.sigev_notify = SIGEV_THREAD_ID | SIGEV_SIGNAL;
-	sev.sigev_notify_thread_id = gettid();
+	sev.sigev_notify_thread_id = syscall(__NR_gettid);
 
 	ret = smokey_check_errno(timer_create(CLOCK_REALTIME, &sev, &t));
 	if (ret)

Thanks, merged on top of next (please use next as basis in the future).

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center