Change in osmo-trx[master]: Replace my_gettid with libosmocore osmo_gettid API

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Feb 18 17:48:42 UTC 2021


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/22950 )

Change subject: Replace my_gettid with libosmocore osmo_gettid API
......................................................................

Replace my_gettid with libosmocore osmo_gettid API

The API was moved to libosmocore, let's use it instead of defining our
own here with all the complexity in build system involved.

Depends: libosmocore.git Change-Id Id7534beeb22fcd50813dab76dd68818e2ff87ec2
Related: OS#5027
Change-Id: I19e32fbc47bd88a668e0c912e89b001b0f8831dd
---
M CommonLibs/Threads.cpp
M CommonLibs/debug.c
M CommonLibs/debug.h
M TODO-RELEASE
M configure.ac
5 files changed, 7 insertions(+), 39 deletions(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/CommonLibs/Threads.cpp b/CommonLibs/Threads.cpp
index d8dab57..b3ff52f 100644
--- a/CommonLibs/Threads.cpp
+++ b/CommonLibs/Threads.cpp
@@ -32,6 +32,8 @@
 #include "Timeval.h"
 #include "Logger.h"
 
+#include <osmocom/core/thread.h>
+
 using namespace std;
 
 #ifndef HAVE_ATOMIC_OPS
@@ -108,7 +110,7 @@
 void set_selfthread_name(const char *name)
 {
 	pthread_t selfid = pthread_self();
-	pid_t tid = my_gettid();
+	pid_t tid = osmo_gettid();
 	if (pthread_setname_np(selfid, name) == 0) {
 		LOG(INFO) << "Thread "<< selfid << " (task " << tid << ") set name: " << name;
 	} else {
diff --git a/CommonLibs/debug.c b/CommonLibs/debug.c
index 7ee8184..08954f5 100644
--- a/CommonLibs/debug.c
+++ b/CommonLibs/debug.c
@@ -21,18 +21,6 @@
  * See the COPYING file in the main directory for details.
  */
 
-#include "config.h"
-
-/* If HAVE_GETTID, then "_GNU_SOURCE" may need to be defined to use gettid() */
-#if HAVE_GETTID
-#define _GNU_SOURCE
-#endif
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#include "config.h"
-
 #include <osmocom/core/logging.h>
 #include <osmocom/core/utils.h>
 #include "debug.h"
@@ -93,15 +81,3 @@
 	.cat = default_categories,
 	.num_cat = ARRAY_SIZE(default_categories),
 };
-
-pid_t my_gettid(void)
-{
-#if HAVE_GETTID
-	return gettid();
-#elif defined(LINUX) && defined(__NR_gettid)
-	return (pid_t) syscall(__NR_gettid);
-#else
-	#pragma message ("use pid as tid")
-	return getpid();
-#endif
-}
diff --git a/CommonLibs/debug.h b/CommonLibs/debug.h
index dd78168..ddb5c75 100644
--- a/CommonLibs/debug.h
+++ b/CommonLibs/debug.h
@@ -1,9 +1,9 @@
 #pragma once
 
 #include <stdbool.h>
-#include <sys/types.h>
 
 #include <osmocom/core/logging.h>
+#include <osmocom/core/thread.h>
 
 extern const struct log_info log_info;
 
@@ -19,12 +19,10 @@
 	DCTR,
 };
 
-pid_t my_gettid(void);
-
 #define CLOGC(category, level, fmt, args...) do { \
-	LOGP(category, level, "[tid=%ld] " fmt, (long int) my_gettid(), ##args);  \
+	LOGP(category, level, "[tid=%ld] " fmt, (long int) osmo_gettid(), ##args);  \
 } while(0)
 
 #define CLOGCHAN(chan, category, level, fmt, args...) do { \
-	LOGP(category, level, "[tid=%ld][chan=%zu] " fmt, (long int) my_gettid(), chan, ##args);  \
+	LOGP(category, level, "[tid=%ld][chan=%zu] " fmt, (long int) osmo_gettid(), chan, ##args);  \
 } while(0)
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 84ecf22..c916fb1 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -1,3 +1,4 @@
 * update libosmocore dependency to > 1.3.x for osmo_sched_vty_init(), osmo_sched_vty_apply_localthread()
 * update osmo-gsm-manuals dependency to > 0.3.0 for vty_cpu_sched.adoc include.
 * update libosmocore dependency to > 1.4.x for osmo_fd_{read,write}_{enable,disable}()
+* update libosmocore dependency to > 1.4.2 for osmo_gettid()
diff --git a/configure.ac b/configure.ac
index 7f6aef7..8067fa7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,15 +82,6 @@
 AC_HEADER_TIME
 AC_C_BIGENDIAN
 
-# Check if gettid is available (despite not being documented in glibc doc, it requires __USE_GNU on some systems)
-# C compiler is used since __USE_GNU seems to be always defined for g++.
-save_CPPFLAGS=$CPPFLAGS
-AC_LANG_PUSH(C)
-CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
-AC_CHECK_FUNCS([gettid])
-AC_LANG_POP(C)
-CPPFLAGS=$save_CPPFLAGS
-
 PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.3.0)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.3.0)
 PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.3.0)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/22950
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I19e32fbc47bd88a668e0c912e89b001b0f8831dd
Gerrit-Change-Number: 22950
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210218/ca4f36c1/attachment.htm>


More information about the gerrit-log mailing list