Skip to contentSkip to conversation

Add config time check for new gettid API

PATCH Sebastien Boisvert 1 participant 1 message Jul 26, 2019 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 1 line · Khem Raj

glibc 2.30 introdoced this function see [1]

introduced

Quoted 1 line

so its best to detect it

it's

Quoted 1 line

and provide fallbacks only if its not present

fallback

it's

Quoted 3 lines

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=6399

That's interesting for the thread identifier context field.

Thanks

Quoted 42 lines
---
 configure.ac            | 1 +
 include/lttng/ust-tid.h | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
configure.ac +1 -0
index 7fa059a..b1099c1 100644
@@ -137,6 +137,7 @@ AC_CHECK_FUNCS([ \
 	clock_gettime \
 	ftruncate \
 	getpagesize \
+	gettid \
 	gettimeofday \
 	localeconv \
 	memchr \
include/lttng/ust-tid.h +5 -2
index e669d7e..7995c78 100644
@@ -26,7 +26,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-
+#include <config.h>
+#if HAVE_GETTID
+#include <unistd.h>
+#else
 #ifdef __linux__
 #include <syscall.h>
 #endif
@@ -49,5 +52,5 @@ static inline pid_t gettid(void)
 	return getpid();
 }
 #endif
-
+#endif /* HAVE_GETTID */
 #endif /* _LTTNG_UST_TID_H */