ソースを参照

compat.h: Fix clockid_t & its members replacement

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Hugo Beauzée-Luyssen 9 年 前
コミット
321e1785bf
2 ファイル変更6 行追加5 行削除
  1. 3 5
      compat/compat.h
  2. 3 0
      configure.ac

+ 3 - 5
compat/compat.h

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

+ 3 - 0
configure.ac

@@ -91,6 +91,9 @@ AC_SEARCH_LIBS([clock_gettime], [rt pthread])
 AC_CHECK_TYPES([clockid_t],,,[
                #include <time.h>
                #include <pthread.h>])
+AC_CHECK_DECLS([CLOCK_MONOTONIC],,,[
+               #include <time.h>
+               #include <pthread_time.h>])
 AC_REPLACE_FUNCS([strlcpy])
 AC_REPLACE_FUNCS([strndup])
 AC_REPLACE_FUNCS([clock_gettime])