diff --git a/configure.ac b/configure.ac index ab50a3ad76..24fac817a6 100644 --- a/configure.ac +++ b/configure.ac @@ -338,8 +338,10 @@ dnl Check for stdio_ext.f for __fbufsize AC_CHECK_HEADERS([stdio_ext.h], [], [], [AC_INCLUDES_DEFAULT]) dnl check for pthreads -AX_PTHREAD([HAVE_PTHREAD=yes], [HAVE_PTHREAD=no]) -AM_CONDITIONAL(HAVE_PTHREAD, test "x$HAVE_PTHREAD" = "xyes") +dnl without arguments AX_PTHREAD() will do AC_DEFINE(HAVE_PTHREAD) +dnl which later checks use in their test code +AX_PTHREAD() +AM_CONDITIONAL(HAVE_PTHREAD, test "x$ax_pthread_ok" = "xyes") dnl check for sys/prctl for setting thread name on Linux AC_CHECK_HEADERS([sys/prctl.h], [], [], [AC_INCLUDES_DEFAULT]) diff --git a/libs/gst/check/gstcheck.h b/libs/gst/check/gstcheck.h index c2c34e17d8..487382df20 100644 --- a/libs/gst/check/gstcheck.h +++ b/libs/gst/check/gstcheck.h @@ -508,8 +508,9 @@ G_STMT_START { \ _gst_check_expecting_log = TRUE; \ _gst_check_raised_critical = FALSE; \ code; \ - _fail_unless (_gst_check_raised_critical, __FILE__, __LINE__, \ - "Expected g_critical, got nothing", NULL); \ + if (!_gst_check_raised_critical) \ + _ck_assert_failed (__FILE__, __LINE__, \ + "Expected g_critical, got nothing", NULL); \ _gst_check_expecting_log = FALSE; \ } G_STMT_END @@ -518,8 +519,9 @@ G_STMT_START { \ _gst_check_expecting_log = TRUE; \ _gst_check_raised_warning = FALSE; \ code; \ - _fail_unless (_gst_check_raised_warning, __FILE__, __LINE__, \ - "Expected g_warning, got nothing", NULL); \ + if (!_gst_check_raised_warning) \ + _ck_assert_failed (__FILE__, __LINE__, \ + "Expected g_warning, got nothing", NULL); \ _gst_check_expecting_log = FALSE; \ } G_STMT_END diff --git a/libs/gst/check/libcheck/Makefile.am b/libs/gst/check/libcheck/Makefile.am index e814fc8f96..870007c091 100644 --- a/libs/gst/check/libcheck/Makefile.am +++ b/libs/gst/check/libcheck/Makefile.am @@ -11,7 +11,27 @@ CFILES =\ check_pack.c \ check_print.c \ check_run.c \ - check_str.c + check_str.c \ + libcompat.c + +if !HAVE_ALARM +CFILES += alarm.c +endif + +if !HAVE_CLOCK_GETTIME +CFILES += clock_gettime.c +endif + +if !HAVE_STRSIGNAL +CFILES += strsignal.c +endif + +if !HAVE_TIMER_CREATE_SETTIME_DELETE +CFILES +=\ + timer_create.c \ + timer_settime.c \ + timer_delete.c +endif HFILES =\ check.h \ @@ -22,7 +42,8 @@ HFILES =\ check_msg.h \ check_pack.h \ check_print.h \ - check_str.h + check_str.h \ + libcompat.h noinst_HEADERS = $(HFILES) diff --git a/libs/gst/check/libcheck/check.c b/libs/gst/check/libcheck/check.c index af2f45a3b5..7b8df85984 100644 --- a/libs/gst/check/libcheck/check.c +++ b/libs/gst/check/libcheck/check.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include @@ -32,6 +32,10 @@ #include "check_impl.h" #include "check_msg.h" +#ifdef HAVE_UNISTD_H +#include /* for _POSIX_VERSION */ +#endif + #ifndef DEFAULT_TIMEOUT #define DEFAULT_TIMEOUT 4 #endif @@ -536,7 +540,7 @@ check_get_clockid () * Worse, if librt and alarm() are unavailable, this check * will result in an assert(0). */ -#ifdef HAVE_LIBRT +#if defined(HAVE_POSIX_TIMERS) && defined(HAVE_MONOTONIC_CLOCK) timer_t timerid; if (timer_create (CLOCK_MONOTONIC, NULL, &timerid) == 0) { diff --git a/libs/gst/check/libcheck/check.h.in b/libs/gst/check/libcheck/check.h.in index e8de6a6239..306bbeed24 100644 --- a/libs/gst/check/libcheck/check.h.in +++ b/libs/gst/check/libcheck/check.h.in @@ -25,7 +25,7 @@ #include #include -#include +#include "_stdint.h" /* Macros and functions starting with _ (underscore) are internal and diff --git a/libs/gst/check/libcheck/check_error.c b/libs/gst/check/libcheck/check_error.c index c4aebd0839..9ee1dd13cf 100644 --- a/libs/gst/check/libcheck/check_error.c +++ b/libs/gst/check/libcheck/check_error.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include diff --git a/libs/gst/check/libcheck/check_error.h b/libs/gst/check/libcheck/check_error.h index b3e87444f4..771a7fd3df 100644 --- a/libs/gst/check/libcheck/check_error.h +++ b/libs/gst/check/libcheck/check_error.h @@ -21,7 +21,7 @@ #ifndef ERROR_H #define ERROR_H -#include "../lib/libcompat.h" +#include "libcompat.h" #include extern jmp_buf error_jmp_buffer; diff --git a/libs/gst/check/libcheck/check_list.c b/libs/gst/check/libcheck/check_list.c index 1382cfaed5..bce19d8b5d 100644 --- a/libs/gst/check/libcheck/check_list.c +++ b/libs/gst/check/libcheck/check_list.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include diff --git a/libs/gst/check/libcheck/check_log.c b/libs/gst/check/libcheck/check_log.c index cd1e5b5b6c..9f90b9c4b6 100644 --- a/libs/gst/check/libcheck/check_log.c +++ b/libs/gst/check/libcheck/check_log.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include diff --git a/libs/gst/check/libcheck/check_msg.c b/libs/gst/check/libcheck/check_msg.c index a55b0b8383..acdd904f05 100644 --- a/libs/gst/check/libcheck/check_msg.c +++ b/libs/gst/check/libcheck/check_msg.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include diff --git a/libs/gst/check/libcheck/check_pack.c b/libs/gst/check/libcheck/check_pack.c index a3f635dd58..9fdbc5b0c0 100644 --- a/libs/gst/check/libcheck/check_pack.c +++ b/libs/gst/check/libcheck/check_pack.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include diff --git a/libs/gst/check/libcheck/check_print.c b/libs/gst/check/libcheck/check_print.c index c84e15852d..88bc16ba7b 100644 --- a/libs/gst/check/libcheck/check_print.c +++ b/libs/gst/check/libcheck/check_print.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include diff --git a/libs/gst/check/libcheck/check_run.c b/libs/gst/check/libcheck/check_run.c index bd0f637412..17abf873dc 100644 --- a/libs/gst/check/libcheck/check_run.c +++ b/libs/gst/check/libcheck/check_run.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include diff --git a/libs/gst/check/libcheck/check_str.c b/libs/gst/check/libcheck/check_str.c index 972e29ae0b..62b67233a9 100644 --- a/libs/gst/check/libcheck/check_str.c +++ b/libs/gst/check/libcheck/check_str.c @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "../lib/libcompat.h" +#include "libcompat.h" #include #include diff --git a/libs/gst/check/libcheck/libcompat.h b/libs/gst/check/libcheck/libcompat.h index f6afdf5652..32f944c92c 100644 --- a/libs/gst/check/libcheck/libcompat.h +++ b/libs/gst/check/libcheck/libcompat.h @@ -84,22 +84,10 @@ CK_DLL_EXP unsigned int alarm (unsigned int seconds); #endif /* !HAVE_DECL_ALARM */ -#if !HAVE_MALLOC -CK_DLL_EXP void *rpl_malloc (size_t n); -#endif /* !HAVE_MALLOC */ - -#if !HAVE_REALLOC -CK_DLL_EXP void *rpl_realloc (void *p, size_t n); -#endif /* !HAVE_REALLOC */ - #if !HAVE_GETPID && HAVE__GETPID #define getpid _getpid #endif /* !HAVE_GETPID && HAVE__GETPID */ -#if !HAVE_GETTIMEOFDAY -CK_DLL_EXP int gettimeofday (struct timeval *tv, void *tz); -#endif /* !HAVE_GETTIMEOFDAY */ - #if !HAVE_DECL_LOCALTIME_R #if !defined(localtime_r) CK_DLL_EXP struct tm *localtime_r (const time_t * clock, struct tm *result); @@ -170,7 +158,9 @@ struct itimerspec */ struct sigevent; +#ifndef HAVE_CLOCK_GETTIME CK_DLL_EXP int clock_gettime (clockid_t clk_id, struct timespec *ts); +#endif CK_DLL_EXP int timer_create (clockid_t clockid, struct sigevent *sevp, timer_t * timerid); CK_DLL_EXP int timer_settime (timer_t timerid, int flags, @@ -178,33 +168,6 @@ CK_DLL_EXP int timer_settime (timer_t timerid, int flags, CK_DLL_EXP int timer_delete (timer_t timerid); #endif /* HAVE_LIBRT */ -/* - * The following checks are to determine if the system's - * snprintf (or its variants) should be replaced with - * the C99 compliant version in libcompat. - */ -#if HAVE_CONFIG_H -#include -#endif -#if HAVE_STDARG_H -#include - -#if !HAVE_VSNPRINTF -CK_DLL_EXP int rpl_vsnprintf (char *, size_t, const char *, va_list); - -#define vsnprintf rpl_vsnprintf -#endif -#if !HAVE_SNPRINTF -CK_DLL_EXP int rpl_snprintf (char *, size_t, const char *, ...); - -#define snprintf rpl_snprintf -#endif -#endif /* HAVE_STDARG_H */ - -#if !HAVE_GETLINE -CK_DLL_EXP ssize_t getline (char **lineptr, size_t * n, FILE * stream); -#endif - /* silence warnings about an empty library */ CK_DLL_EXP void ck_do_nothing (void) diff --git a/m4/check-checks.m4 b/m4/check-checks.m4 index 349a1b5013..a90d5852a3 100644 --- a/m4/check-checks.m4 +++ b/m4/check-checks.m4 @@ -20,6 +20,79 @@ AC_CHECK_HEADERS([unistd.h sys/wait.h sys/time.h], [], [], [AC_INCLUDES_DEFAULT] AC_CHECK_FUNCS([localtime_r]) +dnl Check for getpid() and _getpid() +AC_CHECK_FUNCS([getpid _getpid]) + +dnl Check for strdup() and _strdup() +AC_CHECK_DECLS([strdup]) +AC_CHECK_FUNCS([_strdup]) + +dnl Check for fork +AC_CHECK_FUNCS([fork], HAVE_FORK=1, HAVE_FORK=0) +AC_SUBST(HAVE_FORK) + +dnl Check for alarm, localtime_r and strsignal +dnl First check for time.h as it might be used by localtime_r +AC_CHECK_HEADERS([time.h]) +AC_CHECK_DECLS([alarm, localtime_r, strsignal], [], [], [ + AC_INCLUDES_DEFAULT +#if HAVE_TIME_H +#include +#endif /* HAVE_TIME_H */ +]) +AC_CHECK_FUNCS([alarm setitimer strsignal]) +AM_CONDITIONAL(HAVE_ALARM, test "x$ac_cv_func_alarm" = "xyes") +AM_CONDITIONAL(HAVE_LOCALTIME_R, test "x$ac_cv_func_localtime_r" = "xyes") +AM_CONDITIONAL(HAVE_STRSIGNAL, test "x$ac_cv_func_strsignal" = "xyes") + +dnl Check if struct timespec/itimerspec are defined in time.h. If not, we need +dnl to define it in libs/gst/check/libcheck/libcompat.h. Note the optional +dnl inclusion of pthread.h. On MinGW(-w64), the pthread.h file contains the +dnl timespec/itimerspec definitions. +AC_CHECK_MEMBERS([struct timespec.tv_sec, struct timespec.tv_nsec], [], + [AC_DEFINE_UNQUOTED(STRUCT_TIMESPEC_DEFINITION_MISSING, 1, + [Need to define the timespec structure])], [ +#include +#if HAVE_PTHREAD +#include +#endif /* HAVE_PTHREAD */ +]) +AC_CHECK_MEMBERS([struct itimerspec.it_interval, struct itimerspec.it_value], + [], [AC_DEFINE_UNQUOTED(STRUCT_ITIMERSPEC_DEFINITION_MISSING, 1, + [Need to define the itimerspec structure])], [ +#include +#if HAVE_PTHREAD +#include +#endif /* HAVE_PTHREAD */ +]) + +dnl Check if types timer_t/clockid_t are defined. If not, we need to define +dnl it in libs/gst/check/libcheck/ibcompat.h. Note the optional inclusion of +dnl pthread.h. On MinGW(-w64), the pthread.h file contains the +dnl timer_t/clockid_t definitions. +AC_CHECK_TYPE(timer_t, [], [ + AC_DEFINE([timer_t], [int], [timer_t]) + ], [ + AC_INCLUDES_DEFAULT +#if HAVE_PTHREAD +#include +#endif /* HAVE_PTHREAD */ +]) +AC_CHECK_TYPE(clockid_t, [], [ + AC_DEFINE([clockid_t], [int], [clockid_t]) + ], [ + AC_INCLUDES_DEFAULT +#if HAVE_PTHREAD +#include +#endif /* HAVE_PTHREAD */ +]) + +dnl Check for POSIX timer functions in librt +AC_CHECK_LIB([rt], [timer_create, timer_settime, timer_delete]) +AM_CONDITIONAL(HAVE_TIMER_CREATE_SETTIME_DELETE, test "x$ac_cv_lib_rt_timer_create__timer_settime__timer_delete" = "xyes") + +dnl Allow for checking HAVE_CLOCK_GETTIME in automake files +AM_CONDITIONAL(HAVE_CLOCK_GETTIME, test "x$ac_cv_func_clock_gettime" = "xyes") dnl Create _stdint.h in the top-level directory AX_CREATE_STDINT_H