瀏覽代碼

compat: Add clockid_t detection

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Hugo Beauzée-Luyssen 9 年之前
父節點
當前提交
c11d1a1fa4
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 8 1
      compat/compat.h
  2. 3 0
      configure.ac

+ 8 - 1
compat/compat.h

@@ -36,12 +36,19 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
 #endif
 
 #if !defined HAVE_CLOCK_GETTIME
-typedef enum {
+#ifndef HAVE_CLOCKID_T
+typedef
+#endif
+enum {
     CLOCK_REALTIME,
     CLOCK_MONOTONIC,
     CLOCK_PROCESS_CPUTIME_ID,
     CLOCK_THREAD_CPUTIME_ID
+#ifndef HAVE_CLOCKID_T
 } clockid_t;
+#else
+};
+#endif
 int clock_gettime(clockid_t clk_id, struct timespec *tp);
 #endif
 

+ 3 - 0
configure.ac

@@ -88,6 +88,9 @@ AC_SEARCH_LIBS([strlcpy], [bsd], [
   AC_DEFINE([HAVE_LIBBSD], [1], [Does this system have libbsd strl*** functions implementation])
 ])
 AC_SEARCH_LIBS([clock_gettime], [rt pthread])
+AC_CHECK_TYPES([clockid_t],,,[
+               #include <time.h>
+               #include <pthread.h>])
 AC_REPLACE_FUNCS([strlcpy])
 AC_REPLACE_FUNCS([strndup])
 AC_REPLACE_FUNCS([clock_gettime])