[lttng-ust] Add config time check for new gettid API
diff mbox series

Message ID 20190726170731.16080-1-raj.khem@gmail.com
State Superseded, archived
Headers show
Series
  • [lttng-ust] Add config time check for new gettid API
Related show

Commit Message

Khem Raj July 26, 2019, 5:07 p.m. UTC
glibc 2.30 introdoced this function see [1]
so its best to detect it
and provide fallbacks only if its not present

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

Signed-off-by: Khem Raj <raj.khem at gmail.com>
---
 configure.ac            | 1 +
 include/lttng/ust-tid.h | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

Comments

Sebastien Boisvert July 26, 2019, 6:01 p.m. UTC | #1
On 2019-07-26 1:07 p.m., Khem Raj wrote:
> glibc 2.30 introdoced this function see [1]

introduced

> so its best to detect it

it's

> and provide fallbacks only if its not present

fallback

it's

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

That's interesting for the thread identifier context field.

Thanks

> Signed-off-by: Khem Raj <raj.khem at gmail.com>
> ---
>  configure.ac            | 1 +
>  include/lttng/ust-tid.h | 7 +++++--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 7fa059a..b1099c1 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -137,6 +137,7 @@ AC_CHECK_FUNCS([ \
>  	clock_gettime \
>  	ftruncate \
>  	getpagesize \
> +	gettid \
>  	gettimeofday \
>  	localeconv \
>  	memchr \
> diff --git a/include/lttng/ust-tid.h b/include/lttng/ust-tid.h
> index e669d7e..7995c78 100644
> --- a/include/lttng/ust-tid.h
> +++ b/include/lttng/ust-tid.h
> @@ -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 */
>

Patch
diff mbox series

diff --git a/configure.ac b/configure.ac
index 7fa059a..b1099c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -137,6 +137,7 @@  AC_CHECK_FUNCS([ \
 	clock_gettime \
 	ftruncate \
 	getpagesize \
+	gettid \
 	gettimeofday \
 	localeconv \
 	memchr \
diff --git a/include/lttng/ust-tid.h b/include/lttng/ust-tid.h
index e669d7e..7995c78 100644
--- a/include/lttng/ust-tid.h
+++ b/include/lttng/ust-tid.h
@@ -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 */