Use native gettid() if available (which is the case on Android).
This commit is contained in:
+13
-9
@@ -380,15 +380,19 @@ dnl check if native rwlocks are available
|
|||||||
AC_CHECK_FUNCS(pthread_rwlock_init)
|
AC_CHECK_FUNCS(pthread_rwlock_init)
|
||||||
LIBS=$saved_LIBS
|
LIBS=$saved_LIBS
|
||||||
|
|
||||||
AC_MSG_CHECKING([for gettid])
|
AC_CHECK_FUNC(
|
||||||
AC_TRY_COMPILE(
|
[gettid],
|
||||||
[#define _GNU_SOURCE
|
[AC_DEFINE(HAVE_GETTID)],
|
||||||
#include <unistd.h>
|
[AC_MSG_CHECKING([for SYS_gettid])
|
||||||
#include <sys/syscall.h>],
|
AC_TRY_COMPILE(
|
||||||
[int main() {
|
[#define _GNU_SOURCE
|
||||||
return syscall(SYS_gettid);}],
|
#include <unistd.h>
|
||||||
[AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_GETTID])],
|
#include <sys/syscall.h>],
|
||||||
[AC_MSG_RESULT([no])]
|
[int main() {
|
||||||
|
return syscall(SYS_gettid);}],
|
||||||
|
[AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_SYS_GETTID])],
|
||||||
|
[AC_MSG_RESULT([no])]
|
||||||
|
)]
|
||||||
)
|
)
|
||||||
|
|
||||||
AC_CHECK_FUNCS(prctl mallinfo getpass closefrom)
|
AC_CHECK_FUNCS(prctl mallinfo getpass closefrom)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2011 Tobias Brunner
|
* Copyright (C) 2009-2012 Tobias Brunner
|
||||||
* Hochschule fuer Technik Rapperswil
|
* Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
@@ -17,10 +17,18 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
#ifdef HAVE_GETTID
|
#ifdef HAVE_GETTID
|
||||||
|
#include <sys/types.h>
|
||||||
|
#elif defined(HAVE_SYS_GETTID)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#endif
|
static inline pid_t gettid()
|
||||||
|
{
|
||||||
|
return syscall(SYS_gettid);
|
||||||
|
}
|
||||||
|
#define HAVE_GETTID
|
||||||
|
#endif /* HAVE_SYS_GETTID */
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
@@ -287,7 +295,7 @@ static void *thread_main(private_thread_t *this)
|
|||||||
* could be of any size, or even a struct) */
|
* could be of any size, or even a struct) */
|
||||||
#ifdef HAVE_GETTID
|
#ifdef HAVE_GETTID
|
||||||
DBG2(DBG_LIB, "created thread %.2d [%u]",
|
DBG2(DBG_LIB, "created thread %.2d [%u]",
|
||||||
this->id, syscall(SYS_gettid));
|
this->id, gettid());
|
||||||
#else
|
#else
|
||||||
DBG2(DBG_LIB, "created thread %.2d [%lx]",
|
DBG2(DBG_LIB, "created thread %.2d [%lx]",
|
||||||
this->id, (u_long)this->thread_id);
|
this->id, (u_long)this->thread_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user