From 0c4a65929c8b63280498a3f9b1952ad42cd0b846 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 8 Jul 2021 08:24:09 +0200 Subject: [PATCH] glib-aux: use nm_utils_gettid() instead of gettid() I missed that we already have a gettid() wrapper. Drop the duplicated again and use nm_utils_gettid(). Fixes: e874c5bf6b78 ('random: Provide missing gettid() declaration') --- Makefile.am | 2 ++ src/core/tests/meson.build | 2 ++ src/libnm-glib-aux/nm-random-utils.c | 2 +- src/libnm-glib-aux/nm-shared-utils.h | 10 ---------- .../sd-adapt-shared/nm-sd-adapt-shared.h | 2 ++ 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8897d70d88..054a574ffa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4436,7 +4436,9 @@ src_core_tests_test_systemd_LDFLAGS = \ src_core_tests_test_systemd_LDADD = \ src/libnm-systemd-core/libnm-systemd-core.la \ src/libnm-systemd-shared/libnm-systemd-shared.la \ + src/libnm-glib-aux/libnm-glib-aux.la \ src/libnm-log-null/libnm-log-null.la \ + src/libnm-std-aux/libnm-std-aux.la \ src/c-siphash/libc-siphash.la \ $(GLIB_LIBS) \ $(CODE_COVERAGE_LDFLAGS) \ diff --git a/src/core/tests/meson.build b/src/core/tests/meson.build index 316f20ccb8..99fa0ae9a1 100644 --- a/src/core/tests/meson.build +++ b/src/core/tests/meson.build @@ -44,7 +44,9 @@ exe = executable( link_with: [ libnm_systemd_shared, libnm_systemd_core, + libnm_glib_aux, libnm_log_null, + libnm_std_aux, libc_siphash, ], ) diff --git a/src/libnm-glib-aux/nm-random-utils.c b/src/libnm-glib-aux/nm-random-utils.c index f622b28411..4f861be055 100644 --- a/src/libnm-glib-aux/nm-random-utils.c +++ b/src/libnm-glib-aux/nm-random-utils.c @@ -61,7 +61,7 @@ _rand_init_seed(guint32 seed_array[static SEED_ARRAY_SIZE], GRand *rand) seed_array[seed_idx++] = ((guint64) now_nsec); seed_array[seed_idx++] = _pid_hash(getpid()); seed_array[seed_idx++] = _pid_hash(getppid()); - seed_array[seed_idx++] = _pid_hash(gettid()); + seed_array[seed_idx++] = _pid_hash(nm_utils_gettid()); nm_assert(seed_idx == SEED_ARRAY_SIZE); } diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index 1c59dcaae9..06b7e164fa 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -30,16 +30,6 @@ nm_is_ascii(char ch) /*****************************************************************************/ -#include -static inline pid_t -_nm_gettid(void) -{ - return (pid_t) syscall(SYS_gettid); -} -#define gettid() _nm_gettid() - -/*****************************************************************************/ - pid_t nm_utils_gettid(void); gboolean _nm_assert_on_main_thread(void); diff --git a/src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h b/src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h index fb31962295..e88ff9b1ca 100644 --- a/src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h +++ b/src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h @@ -75,6 +75,8 @@ raw_getpid(void) #endif } +#define gettid() nm_utils_gettid() + /* we build with C11 and thus provides char32_t,char16_t. */ #define HAVE_CHAR32_T 1 #define HAVE_CHAR16_T 1