libcheck: Just move libcompat files to a subdir
authorNirbheek Chauhan <nirbheek@centricular.com>
Fri, 9 Dec 2016 09:48:11 +0000 (15:18 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Fri, 9 Dec 2016 10:01:01 +0000 (15:31 +0530)
Makes it clearer which files are actually used in libcheck and which are used
for cross-platform compatibility. This is going to be especially useful when we
add all the libcompat fallback code that upstream libcheck has which will add
about 6 new files.

https://bugzilla.gnome.org/show_bug.cgi?id=775870

20 files changed:
libs/gst/check/libcheck/Makefile.am
libs/gst/check/libcheck/alarm.c [deleted file]
libs/gst/check/libcheck/clock_gettime.c [deleted file]
libs/gst/check/libcheck/libcompat.c [deleted file]
libs/gst/check/libcheck/libcompat.h [deleted file]
libs/gst/check/libcheck/libcompat/alarm.c [new file with mode: 0644]
libs/gst/check/libcheck/libcompat/clock_gettime.c [new file with mode: 0644]
libs/gst/check/libcheck/libcompat/libcompat.c [new file with mode: 0644]
libs/gst/check/libcheck/libcompat/libcompat.h [new file with mode: 0644]
libs/gst/check/libcheck/libcompat/localtime_r.c [new file with mode: 0644]
libs/gst/check/libcheck/libcompat/strsignal.c [new file with mode: 0644]
libs/gst/check/libcheck/libcompat/timer_create.c [new file with mode: 0644]
libs/gst/check/libcheck/libcompat/timer_delete.c [new file with mode: 0644]
libs/gst/check/libcheck/libcompat/timer_settime.c [new file with mode: 0644]
libs/gst/check/libcheck/localtime_r.c [deleted file]
libs/gst/check/libcheck/meson.build
libs/gst/check/libcheck/strsignal.c [deleted file]
libs/gst/check/libcheck/timer_create.c [deleted file]
libs/gst/check/libcheck/timer_delete.c [deleted file]
libs/gst/check/libcheck/timer_settime.c [deleted file]

index dfa2062ad663e060aa2efbfd65750be5c923c9df..9a00bdc812efd8840b7a5e5b09eed93a54bf6f37 100644 (file)
@@ -12,25 +12,25 @@ CFILES =\
        check_print.c   \
        check_run.c     \
        check_str.c     \
-       libcompat.c
+       libcompat/libcompat.c
 
 if !HAVE_ALARM
-CFILES += alarm.c
+CFILES += libcompat/alarm.c
 endif
 
 if !HAVE_CLOCK_GETTIME
-CFILES += clock_gettime.c
+CFILES += libcompat/clock_gettime.c
 endif
 
 if !HAVE_STRSIGNAL
-CFILES += strsignal.c
+CFILES += libcompat/strsignal.c
 endif
 
 if !HAVE_TIMER_CREATE_SETTIME_DELETE
 CFILES +=\
-       timer_create.c  \
-       timer_settime.c \
-       timer_delete.c
+       libcompat/timer_create.c        \
+       libcompat/timer_settime.c       \
+       libcompat/timer_delete.c
 endif
 
 HFILES =\
@@ -42,7 +42,7 @@ HFILES =\
        check_pack.h    \
        check_print.h   \
        check_str.h     \
-       libcompat.h
+       libcompat/libcompat.h
 
 noinst_HEADERS = $(HFILES)
 
diff --git a/libs/gst/check/libcheck/alarm.c b/libs/gst/check/libcheck/alarm.c
deleted file mode 100644 (file)
index 9f87019..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "libcompat.h"
-
-unsigned int
-alarm (unsigned int seconds CK_ATTRIBUTE_UNUSED)
-{
-  assert (0);
-  return 0;
-}
diff --git a/libs/gst/check/libcheck/clock_gettime.c b/libs/gst/check/libcheck/clock_gettime.c
deleted file mode 100644 (file)
index cc27e73..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "libcompat.h"
-
-#ifdef __APPLE__
-#include <mach/clock.h>
-#include <mach/mach.h>
-#include <mach/mach_time.h>
-#include <unistd.h>
-#endif
-
-#define NANOSECONDS_PER_SECOND 1000000000
-
-
-
-int
-clock_gettime (clockid_t clk_id CK_ATTRIBUTE_UNUSED, struct timespec *ts)
-{
-
-#ifdef __APPLE__
-  /* OS X does not have clock_gettime, use mach_absolute_time */
-
-  static mach_timebase_info_data_t sTimebaseInfo;
-  uint64_t rawTime;
-  uint64_t nanos;
-
-  rawTime = mach_absolute_time ();
-
-  /*
-   * OS X has a function to convert abs time to nano seconds: AbsoluteToNanoseconds
-   * However, the function may not be available as we may not have
-   * access to CoreServices. Because of this, we convert the abs time
-   * to nano seconds manually.
-   */
-
-  /*
-   * First grab the time base used on the system, if this is the first
-   * time we are being called. We can check if the value is uninitialized,
-   * as the denominator will be zero. 
-   */
-  if (sTimebaseInfo.denom == 0) {
-    (void) mach_timebase_info (&sTimebaseInfo);
-  }
-
-  /* 
-   * Do the conversion. We hope that the multiplication doesn't 
-   * overflow; the price you pay for working in fixed point.
-   */
-  nanos = rawTime * sTimebaseInfo.numer / sTimebaseInfo.denom;
-
-  /* 
-   * Fill in the timespec container 
-   */
-  ts->tv_sec = nanos / NANOSECONDS_PER_SECOND;
-  ts->tv_nsec = nanos - (ts->tv_sec * NANOSECONDS_PER_SECOND);
-#else
-  /* 
-   * As there is no function to fall back onto to get the current
-   * time, zero out the time so the caller will have a sane value. 
-   */
-  ts->tv_sec = 0;
-  ts->tv_nsec = 0;
-#endif
-
-  return 0;
-}
diff --git a/libs/gst/check/libcheck/libcompat.c b/libs/gst/check/libcheck/libcompat.c
deleted file mode 100644 (file)
index f550d1d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "libcompat.h"
-
-/* silence warnings about an empty library */
-void
-ck_do_nothing (void)
-{
-  assert (0);
-
-  /*
-   * to silence warning about this function actually
-   * returning, but being marked as noreturn. assert()
-   * must be marked as a function that returns.
-   */
-  exit (1);
-}
diff --git a/libs/gst/check/libcheck/libcompat.h b/libs/gst/check/libcheck/libcompat.h
deleted file mode 100644 (file)
index f09289b..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-#ifndef LIBCOMPAT_H
-#define LIBCOMPAT_H
-
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-#define GCC_VERSION_AT_LEAST(major, minor) \
-((__GNUC__ > (major)) || \
- (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
-#else
-#define GCC_VERSION_AT_LEAST(major, minor) 0
-#endif
-
-#if GCC_VERSION_AT_LEAST(2,95)
-#define CK_ATTRIBUTE_UNUSED __attribute__ ((unused))
-#else
-#define CK_ATTRIBUTE_UNUSED
-#endif /* GCC 2.95 */
-
-#if GCC_VERSION_AT_LEAST(2,5)
-#define CK_ATTRIBUTE_NORETURN __attribute__ ((noreturn))
-#else
-#define CK_ATTRIBUTE_NORETURN
-#endif /* GCC 2.5 */
-
-/*
- * Used for MSVC to create the export attribute
- * CK_DLL_EXP is defined during the compilation of the library
- * on the command line.
- */
-#ifndef CK_DLL_EXP
-#define CK_DLL_EXP
-#endif
-
-#if _MSC_VER
-#include <WinSock2.h>           /* struct timeval, API used in gettimeofday implementation */
-#include <io.h>                 /* read, write */
-#include <process.h>            /* getpid */
-#endif /* _MSC_VER */
-
-/* defines size_t */
-#include <sys/types.h>
-
-/* provides assert */
-#include <assert.h>
-
-/* defines FILE */
-#include <stdio.h>
-
-/* defines exit() */
-#include <stdlib.h>
-
-/* provides localtime and struct tm */
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif /* !HAVE_SYS_TIME_H */
-#include <time.h>
-
-/* declares fork(), _POSIX_VERSION.  according to Autoconf.info,
-   unistd.h defines _POSIX_VERSION if the system is POSIX-compliant,
-   so we will use this as a test for all things uniquely provided by
-   POSIX like sigaction() and fork() */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-/* declares pthread_create and friends */
-#ifdef HAVE_PTHREAD
-#include <pthread.h>
-#endif
-
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-
-/* replacement functions for broken originals */
-#if !HAVE_DECL_ALARM
-CK_DLL_EXP unsigned int alarm (unsigned int seconds);
-#endif /* !HAVE_DECL_ALARM */
-
-#if !HAVE_GETPID && HAVE__GETPID
-#define getpid _getpid
-#endif /* !HAVE_GETPID && HAVE__GETPID */
-
-#if !HAVE_DECL_LOCALTIME_R
-#if !defined(localtime_r)
-CK_DLL_EXP struct tm *localtime_r (const time_t * clock, struct tm *result);
-#endif
-#endif /* !HAVE_DECL_LOCALTIME_R */
-
-#if !HAVE_DECL_STRDUP && !HAVE__STRDUP
-CK_DLL_EXP char *strdup (const char *str);
-#elif !HAVE_DECL_STRDUP && HAVE__STRDUP
-#define strdup _strdup
-#endif /* !HAVE_DECL_STRDUP && HAVE__STRDUP */
-
-#if !HAVE_DECL_STRSIGNAL
-CK_DLL_EXP char *strsignal (int sig);
-#endif /* !HAVE_DECL_STRSIGNAL */
-
-/*
- * On systems where clock_gettime() is not available, or
- * on systems where some clocks may not be supported, the
- * definition for CLOCK_MONOTONIC and CLOCK_REALTIME may not
- * be available. These should define which type of clock
- * clock_gettime() should use. We define it here if it is
- * not defined simply so the reimplementation can ignore it.
- *
- * We set the values of these clocks to some (hopefully)
- * invalid value, to avoid the case where we define a
- * clock with a valid value, and unintentionally use
- * an actual good clock by accident.
- */
-#ifndef CLOCK_MONOTONIC
-#define CLOCK_MONOTONIC -1
-#endif
-#ifndef CLOCK_REALTIME
-#define CLOCK_REALTIME -1
-#endif
-
-#ifndef HAVE_LIBRT
-
-#ifdef STRUCT_TIMESPEC_DEFINITION_MISSING
-/*
- * The following structure is defined in POSIX 1003.1 for times
- * specified in seconds and nanoseconds. If it is not defined in
- * time.g, then we need to define it here
- */
-struct timespec
-{
-  time_t tv_sec;
-  long tv_nsec;
-};
-#endif /* STRUCT_TIMESPEC_DEFINITION_MISSING */
-
-#ifdef STRUCT_ITIMERSPEC_DEFINITION_MISSING
-/* 
- * The following structure is defined in POSIX.1b for timer start values and intervals.
- * If it is not defined in time.h, then we need to define it here.
- */
-struct itimerspec
-{
-  struct timespec it_interval;
-  struct timespec it_value;
-};
-#endif /* STRUCT_ITIMERSPEC_DEFINITION_MISSING */
-
-/* 
- * Do a simple forward declaration in case the struct is not defined.
- * In the versions of timer_create in libcompat, sigevent is never
- * used.
- */
-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,
-    const struct itimerspec *new_value, struct itimerspec *old_value);
-CK_DLL_EXP int timer_delete (timer_t timerid);
-#endif /* HAVE_LIBRT */
-
-/* silence warnings about an empty library */
-CK_DLL_EXP void
-ck_do_nothing (void)
-    CK_ATTRIBUTE_NORETURN;
-
-#endif /* !LIBCOMPAT_H */
diff --git a/libs/gst/check/libcheck/libcompat/alarm.c b/libs/gst/check/libcheck/libcompat/alarm.c
new file mode 100644 (file)
index 0000000..9f87019
--- /dev/null
@@ -0,0 +1,8 @@
+#include "libcompat.h"
+
+unsigned int
+alarm (unsigned int seconds CK_ATTRIBUTE_UNUSED)
+{
+  assert (0);
+  return 0;
+}
diff --git a/libs/gst/check/libcheck/libcompat/clock_gettime.c b/libs/gst/check/libcheck/libcompat/clock_gettime.c
new file mode 100644 (file)
index 0000000..cc27e73
--- /dev/null
@@ -0,0 +1,64 @@
+#include "libcompat.h"
+
+#ifdef __APPLE__
+#include <mach/clock.h>
+#include <mach/mach.h>
+#include <mach/mach_time.h>
+#include <unistd.h>
+#endif
+
+#define NANOSECONDS_PER_SECOND 1000000000
+
+
+
+int
+clock_gettime (clockid_t clk_id CK_ATTRIBUTE_UNUSED, struct timespec *ts)
+{
+
+#ifdef __APPLE__
+  /* OS X does not have clock_gettime, use mach_absolute_time */
+
+  static mach_timebase_info_data_t sTimebaseInfo;
+  uint64_t rawTime;
+  uint64_t nanos;
+
+  rawTime = mach_absolute_time ();
+
+  /*
+   * OS X has a function to convert abs time to nano seconds: AbsoluteToNanoseconds
+   * However, the function may not be available as we may not have
+   * access to CoreServices. Because of this, we convert the abs time
+   * to nano seconds manually.
+   */
+
+  /*
+   * First grab the time base used on the system, if this is the first
+   * time we are being called. We can check if the value is uninitialized,
+   * as the denominator will be zero. 
+   */
+  if (sTimebaseInfo.denom == 0) {
+    (void) mach_timebase_info (&sTimebaseInfo);
+  }
+
+  /* 
+   * Do the conversion. We hope that the multiplication doesn't 
+   * overflow; the price you pay for working in fixed point.
+   */
+  nanos = rawTime * sTimebaseInfo.numer / sTimebaseInfo.denom;
+
+  /* 
+   * Fill in the timespec container 
+   */
+  ts->tv_sec = nanos / NANOSECONDS_PER_SECOND;
+  ts->tv_nsec = nanos - (ts->tv_sec * NANOSECONDS_PER_SECOND);
+#else
+  /* 
+   * As there is no function to fall back onto to get the current
+   * time, zero out the time so the caller will have a sane value. 
+   */
+  ts->tv_sec = 0;
+  ts->tv_nsec = 0;
+#endif
+
+  return 0;
+}
diff --git a/libs/gst/check/libcheck/libcompat/libcompat.c b/libs/gst/check/libcheck/libcompat/libcompat.c
new file mode 100644 (file)
index 0000000..f550d1d
--- /dev/null
@@ -0,0 +1,15 @@
+#include "libcompat.h"
+
+/* silence warnings about an empty library */
+void
+ck_do_nothing (void)
+{
+  assert (0);
+
+  /*
+   * to silence warning about this function actually
+   * returning, but being marked as noreturn. assert()
+   * must be marked as a function that returns.
+   */
+  exit (1);
+}
diff --git a/libs/gst/check/libcheck/libcompat/libcompat.h b/libs/gst/check/libcheck/libcompat/libcompat.h
new file mode 100644 (file)
index 0000000..f09289b
--- /dev/null
@@ -0,0 +1,176 @@
+#ifndef LIBCOMPAT_H
+#define LIBCOMPAT_H
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
+#define GCC_VERSION_AT_LEAST(major, minor) \
+((__GNUC__ > (major)) || \
+ (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
+#else
+#define GCC_VERSION_AT_LEAST(major, minor) 0
+#endif
+
+#if GCC_VERSION_AT_LEAST(2,95)
+#define CK_ATTRIBUTE_UNUSED __attribute__ ((unused))
+#else
+#define CK_ATTRIBUTE_UNUSED
+#endif /* GCC 2.95 */
+
+#if GCC_VERSION_AT_LEAST(2,5)
+#define CK_ATTRIBUTE_NORETURN __attribute__ ((noreturn))
+#else
+#define CK_ATTRIBUTE_NORETURN
+#endif /* GCC 2.5 */
+
+/*
+ * Used for MSVC to create the export attribute
+ * CK_DLL_EXP is defined during the compilation of the library
+ * on the command line.
+ */
+#ifndef CK_DLL_EXP
+#define CK_DLL_EXP
+#endif
+
+#if _MSC_VER
+#include <WinSock2.h>           /* struct timeval, API used in gettimeofday implementation */
+#include <io.h>                 /* read, write */
+#include <process.h>            /* getpid */
+#endif /* _MSC_VER */
+
+/* defines size_t */
+#include <sys/types.h>
+
+/* provides assert */
+#include <assert.h>
+
+/* defines FILE */
+#include <stdio.h>
+
+/* defines exit() */
+#include <stdlib.h>
+
+/* provides localtime and struct tm */
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif /* !HAVE_SYS_TIME_H */
+#include <time.h>
+
+/* declares fork(), _POSIX_VERSION.  according to Autoconf.info,
+   unistd.h defines _POSIX_VERSION if the system is POSIX-compliant,
+   so we will use this as a test for all things uniquely provided by
+   POSIX like sigaction() and fork() */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+/* declares pthread_create and friends */
+#ifdef HAVE_PTHREAD
+#include <pthread.h>
+#endif
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+/* replacement functions for broken originals */
+#if !HAVE_DECL_ALARM
+CK_DLL_EXP unsigned int alarm (unsigned int seconds);
+#endif /* !HAVE_DECL_ALARM */
+
+#if !HAVE_GETPID && HAVE__GETPID
+#define getpid _getpid
+#endif /* !HAVE_GETPID && HAVE__GETPID */
+
+#if !HAVE_DECL_LOCALTIME_R
+#if !defined(localtime_r)
+CK_DLL_EXP struct tm *localtime_r (const time_t * clock, struct tm *result);
+#endif
+#endif /* !HAVE_DECL_LOCALTIME_R */
+
+#if !HAVE_DECL_STRDUP && !HAVE__STRDUP
+CK_DLL_EXP char *strdup (const char *str);
+#elif !HAVE_DECL_STRDUP && HAVE__STRDUP
+#define strdup _strdup
+#endif /* !HAVE_DECL_STRDUP && HAVE__STRDUP */
+
+#if !HAVE_DECL_STRSIGNAL
+CK_DLL_EXP char *strsignal (int sig);
+#endif /* !HAVE_DECL_STRSIGNAL */
+
+/*
+ * On systems where clock_gettime() is not available, or
+ * on systems where some clocks may not be supported, the
+ * definition for CLOCK_MONOTONIC and CLOCK_REALTIME may not
+ * be available. These should define which type of clock
+ * clock_gettime() should use. We define it here if it is
+ * not defined simply so the reimplementation can ignore it.
+ *
+ * We set the values of these clocks to some (hopefully)
+ * invalid value, to avoid the case where we define a
+ * clock with a valid value, and unintentionally use
+ * an actual good clock by accident.
+ */
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC -1
+#endif
+#ifndef CLOCK_REALTIME
+#define CLOCK_REALTIME -1
+#endif
+
+#ifndef HAVE_LIBRT
+
+#ifdef STRUCT_TIMESPEC_DEFINITION_MISSING
+/*
+ * The following structure is defined in POSIX 1003.1 for times
+ * specified in seconds and nanoseconds. If it is not defined in
+ * time.g, then we need to define it here
+ */
+struct timespec
+{
+  time_t tv_sec;
+  long tv_nsec;
+};
+#endif /* STRUCT_TIMESPEC_DEFINITION_MISSING */
+
+#ifdef STRUCT_ITIMERSPEC_DEFINITION_MISSING
+/* 
+ * The following structure is defined in POSIX.1b for timer start values and intervals.
+ * If it is not defined in time.h, then we need to define it here.
+ */
+struct itimerspec
+{
+  struct timespec it_interval;
+  struct timespec it_value;
+};
+#endif /* STRUCT_ITIMERSPEC_DEFINITION_MISSING */
+
+/* 
+ * Do a simple forward declaration in case the struct is not defined.
+ * In the versions of timer_create in libcompat, sigevent is never
+ * used.
+ */
+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,
+    const struct itimerspec *new_value, struct itimerspec *old_value);
+CK_DLL_EXP int timer_delete (timer_t timerid);
+#endif /* HAVE_LIBRT */
+
+/* silence warnings about an empty library */
+CK_DLL_EXP void
+ck_do_nothing (void)
+    CK_ATTRIBUTE_NORETURN;
+
+#endif /* !LIBCOMPAT_H */
diff --git a/libs/gst/check/libcheck/libcompat/localtime_r.c b/libs/gst/check/libcheck/libcompat/localtime_r.c
new file mode 100644 (file)
index 0000000..682a1b4
--- /dev/null
@@ -0,0 +1,19 @@
+#include "libcompat.h"
+
+#if !defined(localtime_r)
+
+struct tm *
+localtime_r (const time_t * clock, struct tm *result)
+{
+  struct tm *now = localtime (clock);
+
+  if (now == NULL) {
+    return NULL;
+  } else {
+    *result = *now;
+  }
+
+  return result;
+}
+
+#endif /* !defined(localtime_r) */
diff --git a/libs/gst/check/libcheck/libcompat/strsignal.c b/libs/gst/check/libcheck/libcompat/strsignal.c
new file mode 100644 (file)
index 0000000..57e71cd
--- /dev/null
@@ -0,0 +1,10 @@
+#include "libcompat.h"
+
+char *
+strsignal (int sig)
+{
+  static char signame[40];
+
+  sprintf (signame, "SIG #%d", sig);
+  return signame;
+}
diff --git a/libs/gst/check/libcheck/libcompat/timer_create.c b/libs/gst/check/libcheck/libcompat/timer_create.c
new file mode 100644 (file)
index 0000000..a701781
--- /dev/null
@@ -0,0 +1,15 @@
+#include "libcompat.h"
+
+int
+timer_create (clockid_t clockid CK_ATTRIBUTE_UNUSED,
+    struct sigevent *sevp CK_ATTRIBUTE_UNUSED,
+    timer_t * timerid CK_ATTRIBUTE_UNUSED)
+{
+  /* 
+   * The create function does nothing. timer_settime will use
+   * alarm to set the timer, and timer_delete will stop the
+   * alarm
+   */
+
+  return 0;
+}
diff --git a/libs/gst/check/libcheck/libcompat/timer_delete.c b/libs/gst/check/libcheck/libcompat/timer_delete.c
new file mode 100644 (file)
index 0000000..cc3ae29
--- /dev/null
@@ -0,0 +1,33 @@
+#include "libcompat.h"
+
+int
+timer_delete (timer_t timerid CK_ATTRIBUTE_UNUSED)
+{
+#ifdef HAVE_SETITIMER
+  /*
+   * If the system does not have timer_settime() but does have
+   * setitimer() use that instead of alarm().
+   */
+  struct itimerval interval;
+
+  /*
+   * Setting values to '0' results in disabling the running timer.
+   */
+  interval.it_value.tv_sec = 0;
+  interval.it_value.tv_usec = 0;
+  interval.it_interval.tv_sec = 0;
+  interval.it_interval.tv_usec = 0;
+
+  return setitimer (ITIMER_REAL, &interval, NULL);
+#else
+  /*
+   * There is only one timer, that used by alarm.
+   * Setting alarm(0) will not set a new alarm, and
+   * will kill the previous timer.
+   */
+
+  alarm (0);
+
+  return 0;
+#endif
+}
diff --git a/libs/gst/check/libcheck/libcompat/timer_settime.c b/libs/gst/check/libcheck/libcompat/timer_settime.c
new file mode 100644 (file)
index 0000000..d09ba27
--- /dev/null
@@ -0,0 +1,37 @@
+#include "libcompat.h"
+
+int
+timer_settime (timer_t timerid CK_ATTRIBUTE_UNUSED,
+    int flags CK_ATTRIBUTE_UNUSED,
+    const struct itimerspec *new_value,
+    struct itimerspec *old_value CK_ATTRIBUTE_UNUSED)
+{
+#ifdef HAVE_SETITIMER
+  /*
+   * If the system does not have timer_settime() but does have
+   * setitimer() use that instead of alarm().
+   */
+  struct itimerval interval;
+
+  interval.it_value.tv_sec = new_value->it_value.tv_sec;
+  interval.it_value.tv_usec = new_value->it_value.tv_nsec / 1000;
+  interval.it_interval.tv_sec = new_value->it_interval.tv_sec;
+  interval.it_interval.tv_usec = new_value->it_interval.tv_nsec / 1000;
+
+  return setitimer (ITIMER_REAL, &interval, NULL);
+#else
+  int seconds = new_value->it_value.tv_sec;
+
+  /* 
+   * As the alarm() call has only second precision, if the caller
+   * specifies partial seconds, we round up to the nearest second.
+   */
+  if (new_value->it_value.tv_nsec > 0) {
+    seconds += 1;
+  }
+
+  alarm (seconds);
+
+  return 0;
+#endif
+}
diff --git a/libs/gst/check/libcheck/localtime_r.c b/libs/gst/check/libcheck/localtime_r.c
deleted file mode 100644 (file)
index 682a1b4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "libcompat.h"
-
-#if !defined(localtime_r)
-
-struct tm *
-localtime_r (const time_t * clock, struct tm *result)
-{
-  struct tm *now = localtime (clock);
-
-  if (now == NULL) {
-    return NULL;
-  } else {
-    *result = *now;
-  }
-
-  return result;
-}
-
-#endif /* !defined(localtime_r) */
index f86c187bc695735c7f19dc72873ad0a5863bb6ea..90f4ba190e0ff2da4e98238f72bce648ad0ab7d9 100644 (file)
@@ -8,24 +8,28 @@ libcheck_files = [
   'check_print.c',
   'check_run.c',
   'check_str.c',
-  'libcompat.c'
+  'libcompat/libcompat.c'
 ]
 
 if not cdata.has('HAVE_ALARM')
-  libcheck_files += [ 'alarm.c' ]
+  libcheck_files += ['libcompat/alarm.c']
 endif
 
 if not cdata.has('HAVE_CLOCK_GETTIME')
-  libcheck_files += [ 'clock_gettime.c' ]
+  libcheck_files += ['libcompat/clock_gettime.c']
 endif
 
 if not cdata.has('HAVE_DECL_STRSIGNAL')
-  libcheck_files += [ 'strsignal.c' ]
+  libcheck_files += ['libcompat/strsignal.c']
 endif
 
 # FIXME: check for symbols timer_create, timer_settime, timer_delete as well
 if not rt_lib.found()
-  libcheck_files += [ 'timer_create.c', 'timer_settime.c', 'timer_delete.c' ]
+  libcheck_files += [
+    'libcompat/timer_create.c',
+    'libcompat/timer_settime.c',
+    'libcompat/timer_delete.c'
+  ]
 endif
 
 configure_file(input : 'check.h.in',
@@ -36,7 +40,7 @@ internal_check_h_inc = include_directories('..')
 
 libcheck = static_library('check',
   libcheck_files,
-  include_directories : [ configinc, internal_check_h_inc ],
+  include_directories : [configinc, internal_check_h_inc],
   dependencies : [rt_lib, mathlib],
   c_args: gst_c_args,
   pic: true)
diff --git a/libs/gst/check/libcheck/strsignal.c b/libs/gst/check/libcheck/strsignal.c
deleted file mode 100644 (file)
index 57e71cd..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "libcompat.h"
-
-char *
-strsignal (int sig)
-{
-  static char signame[40];
-
-  sprintf (signame, "SIG #%d", sig);
-  return signame;
-}
diff --git a/libs/gst/check/libcheck/timer_create.c b/libs/gst/check/libcheck/timer_create.c
deleted file mode 100644 (file)
index a701781..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "libcompat.h"
-
-int
-timer_create (clockid_t clockid CK_ATTRIBUTE_UNUSED,
-    struct sigevent *sevp CK_ATTRIBUTE_UNUSED,
-    timer_t * timerid CK_ATTRIBUTE_UNUSED)
-{
-  /* 
-   * The create function does nothing. timer_settime will use
-   * alarm to set the timer, and timer_delete will stop the
-   * alarm
-   */
-
-  return 0;
-}
diff --git a/libs/gst/check/libcheck/timer_delete.c b/libs/gst/check/libcheck/timer_delete.c
deleted file mode 100644 (file)
index cc3ae29..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "libcompat.h"
-
-int
-timer_delete (timer_t timerid CK_ATTRIBUTE_UNUSED)
-{
-#ifdef HAVE_SETITIMER
-  /*
-   * If the system does not have timer_settime() but does have
-   * setitimer() use that instead of alarm().
-   */
-  struct itimerval interval;
-
-  /*
-   * Setting values to '0' results in disabling the running timer.
-   */
-  interval.it_value.tv_sec = 0;
-  interval.it_value.tv_usec = 0;
-  interval.it_interval.tv_sec = 0;
-  interval.it_interval.tv_usec = 0;
-
-  return setitimer (ITIMER_REAL, &interval, NULL);
-#else
-  /*
-   * There is only one timer, that used by alarm.
-   * Setting alarm(0) will not set a new alarm, and
-   * will kill the previous timer.
-   */
-
-  alarm (0);
-
-  return 0;
-#endif
-}
diff --git a/libs/gst/check/libcheck/timer_settime.c b/libs/gst/check/libcheck/timer_settime.c
deleted file mode 100644 (file)
index d09ba27..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "libcompat.h"
-
-int
-timer_settime (timer_t timerid CK_ATTRIBUTE_UNUSED,
-    int flags CK_ATTRIBUTE_UNUSED,
-    const struct itimerspec *new_value,
-    struct itimerspec *old_value CK_ATTRIBUTE_UNUSED)
-{
-#ifdef HAVE_SETITIMER
-  /*
-   * If the system does not have timer_settime() but does have
-   * setitimer() use that instead of alarm().
-   */
-  struct itimerval interval;
-
-  interval.it_value.tv_sec = new_value->it_value.tv_sec;
-  interval.it_value.tv_usec = new_value->it_value.tv_nsec / 1000;
-  interval.it_interval.tv_sec = new_value->it_interval.tv_sec;
-  interval.it_interval.tv_usec = new_value->it_interval.tv_nsec / 1000;
-
-  return setitimer (ITIMER_REAL, &interval, NULL);
-#else
-  int seconds = new_value->it_value.tv_sec;
-
-  /* 
-   * As the alarm() call has only second precision, if the caller
-   * specifies partial seconds, we round up to the nearest second.
-   */
-  if (new_value->it_value.tv_nsec > 0) {
-    seconds += 1;
-  }
-
-  alarm (seconds);
-
-  return 0;
-#endif
-}