aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-02-17 18:25:45 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2021-02-17 18:27:41 +0100
commit5738940535e86bcfb0520342a15971d645e6a54a (patch)
tree1c6cfae49a1038859a0e496cb85d180408fd93e9
parentcec9eda227487ee2f5947e9ed5135fbe9578e013 (diff)
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
-rw-r--r--CommonLibs/Threads.cpp4
-rw-r--r--CommonLibs/debug.c24
-rw-r--r--CommonLibs/debug.h8
-rw-r--r--TODO-RELEASE1
-rw-r--r--configure.ac9
5 files changed, 7 insertions, 39 deletions
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 Signal::wait(Mutex& wMutex, unsigned timeout) const
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 @@ const struct log_info log_info = {
.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 @@ enum {
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_TYPE_SIZE_T
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)