]> granicus.if.org Git - check/commitdiff
autotools: include pthread.h when checking for clockid_t/timer_t
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Tue, 31 Dec 2013 20:39:31 +0000 (20:39 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Tue, 31 Dec 2013 20:39:31 +0000 (20:39 +0000)
Must include pthread.h to check for clockid_t and timer_t. This is
because MinGW and MinGW-w64 both put the time related definitions
in pthread headers and not in sys/types.h. Without optionally
including pthread.h, the check for these types may mistakenly fail.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@981 64e312b2-a51f-0410-8e61-82d0ca0eb02a

configure.ac

index 6043ddb9889de131cb41d6a11e4b53ddfcf34cf1..46a72ec39d6ff3babaf75399833ae4ea96aa6191 100644 (file)
@@ -239,8 +239,23 @@ AC_CHECK_SIZEOF(int, 4)
 AC_CHECK_SIZEOF(short, 2)
 AC_CHECK_SIZEOF(long, 4)
 
-AC_CHECK_TYPE(clockid_t, int)
-AC_CHECK_TYPE(timer_t, int)
+# The following two checks will attempt to include pthread.h. The
+# reason is MinGW and MinGW-w64 have been known to put the time
+# related definitions in the pthread headers. Without include
+# pthread.h, these checks may mistakenly fail to find the
+# definitions.
+AC_CHECK_TYPE(clockid_t, [], [AC_DEFINE([clockid_t], [int], [clockid_t])], [
+AC_INCLUDES_DEFAULT
+#if defined(HAVE_PTHREAD)
+#include <pthread.h>
+#endif /* HAVE_PTHREAD */
+])
+AC_CHECK_TYPE(timer_t, [], [AC_DEFINE([timer_t], [int], [timer_t])], [
+AC_INCLUDES_DEFAULT
+#if defined(HAVE_PTHREAD)
+#include <pthread.h>
+#endif /* HAVE_PTHREAD */
+])
 
 # Checks for library functions.
 AC_FUNC_MALLOC