From: Tobias Brunner Date: Tue, 10 Jan 2012 17:31:33 +0000 (+0100) Subject: Use native gettid() if available (which is the case on Android). X-Git-Tag: 4.6.2~62 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=66f16d9629b08fb2af4f2eac8ca18c1b95b07877;p=thirdparty%2Fstrongswan.git Use native gettid() if available (which is the case on Android). --- diff --git a/configure.in b/configure.in index 23223b0d90..59dc86f04b 100644 --- a/configure.in +++ b/configure.in @@ -380,15 +380,19 @@ dnl check if native rwlocks are available AC_CHECK_FUNCS(pthread_rwlock_init) LIBS=$saved_LIBS -AC_MSG_CHECKING([for gettid]) -AC_TRY_COMPILE( - [#define _GNU_SOURCE - #include - #include ], - [int main() { - return syscall(SYS_gettid);}], - [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_GETTID])], - [AC_MSG_RESULT([no])] +AC_CHECK_FUNC( + [gettid], + [AC_DEFINE(HAVE_GETTID)], + [AC_MSG_CHECKING([for SYS_gettid]) + AC_TRY_COMPILE( + [#define _GNU_SOURCE + #include + #include ], + [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) diff --git a/src/libstrongswan/threading/thread.c b/src/libstrongswan/threading/thread.c index 9092bf7b74..0cbd97c3f9 100644 --- a/src/libstrongswan/threading/thread.c +++ b/src/libstrongswan/threading/thread.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 Tobias Brunner + * Copyright (C) 2009-2012 Tobias Brunner * Hochschule fuer Technik Rapperswil * * This program is free software; you can redistribute it and/or modify it @@ -17,10 +17,18 @@ #include #include #include + #ifdef HAVE_GETTID +#include +#elif defined(HAVE_SYS_GETTID) #include #include -#endif +static inline pid_t gettid() +{ + return syscall(SYS_gettid); +} +#define HAVE_GETTID +#endif /* HAVE_SYS_GETTID */ #include #include @@ -287,7 +295,7 @@ static void *thread_main(private_thread_t *this) * could be of any size, or even a struct) */ #ifdef HAVE_GETTID DBG2(DBG_LIB, "created thread %.2d [%u]", - this->id, syscall(SYS_gettid)); + this->id, gettid()); #else DBG2(DBG_LIB, "created thread %.2d [%lx]", this->id, (u_long)this->thread_id);