From 8ddbf76626a48420306869db1d171f854cc25310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 7 Oct 2015 11:11:30 +0100 Subject: [PATCH] tracers: Only build getrusage() tracer if RUSAGE_THREAD is available --- configure.ac | 19 ++++++++++++++++++- plugins/tracers/Makefile.am | 2 +- plugins/tracers/gstrusage.c | 2 -- plugins/tracers/gsttracers.c | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 0ffc9f1bec..ec26d5406d 100644 --- a/configure.ac +++ b/configure.ac @@ -605,8 +605,25 @@ AC_CHECK_FUNCS([gmtime_r]) AC_CHECK_FUNCS([localtime_r]) AC_CHECK_FUNCS([sigaction]) AC_CHECK_FUNCS([getrusage]) -AM_CONDITIONAL(HAVE_GETRUSAGE, test "x$ac_cv_func_getrusage" = "xyes") AC_CHECK_HEADERS([sys/resource.h]) +AC_CACHE_CHECK(for RUSAGE_THREAD, gst_cv_rusage_thread, + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#ifndef __USE_GNU +# define __USE_GNU /* RUSAGE_THREAD */ +#endif +#include + ]], [[ +struct rusage ru; +getrusage (RUSAGE_THREAD, &ru); + ]])],[ + gst_cv_rusage_thread=yes + AC_DEFINE(HAVE_RUSAGE_THREAD, 1, [RUSAGE_THREAD is available]) + ],[ + gst_cv_rusage_thread=no + ]) +) +AM_CONDITIONAL(HAVE_RUSAGE_THREAD, test "x$gst_cv_rusage_thread" = "xyes") dnl check for fseeko() AC_FUNC_FSEEKO diff --git a/plugins/tracers/Makefile.am b/plugins/tracers/Makefile.am index 0a30538a50..9f4f86dfe3 100644 --- a/plugins/tracers/Makefile.am +++ b/plugins/tracers/Makefile.am @@ -1,7 +1,7 @@ plugin_LTLIBRARIES = libgstcoretracers.la -if HAVE_GETRUSAGE +if HAVE_RUSAGE_THREAD RUSAGE_SOURCES = gstrusage.c else RUSAGE_SOURCES = diff --git a/plugins/tracers/gstrusage.c b/plugins/tracers/gstrusage.c index ee9f7e5928..26ebeba551 100644 --- a/plugins/tracers/gstrusage.c +++ b/plugins/tracers/gstrusage.c @@ -32,12 +32,10 @@ #include #include "gstrusage.h" -#ifdef HAVE_SYS_RESOURCE_H #ifndef __USE_GNU # define __USE_GNU /* RUSAGE_THREAD */ #endif #include -#endif GST_DEBUG_CATEGORY_STATIC (gst_rusage_debug); #define GST_CAT_DEFAULT gst_rusage_debug diff --git a/plugins/tracers/gsttracers.c b/plugins/tracers/gsttracers.c index 010c185aaa..2840f074e4 100644 --- a/plugins/tracers/gsttracers.c +++ b/plugins/tracers/gsttracers.c @@ -38,7 +38,7 @@ plugin_init (GstPlugin * plugin) if (!gst_tracer_register (plugin, "log", gst_log_tracer_get_type ())) return FALSE; #endif -#ifdef HAVE_GETRUSAGE +#ifdef HAVE_RUSAGE_THREAD if (!gst_tracer_register (plugin, "rusage", gst_rusage_tracer_get_type ())) return FALSE; #endif