summaryrefslogtreecommitdiff
path: root/m4/efl_threads.m4
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2014-02-18 12:24:19 +0900
committerCedric BAIL <cedric.bail@samsung.com>2014-02-18 12:24:19 +0900
commit14c6378fc41906db14464e17aadc7d94a825fafd (patch)
treee1432e8d61c09150b874562e3fc63cb44a84236f /m4/efl_threads.m4
parent54129dfcaab5fb7674808f9202dfb5a2ea5bd609 (diff)
autotools: try improving thread detection.
As already stated before reliably detecting CC, LIBS and CFLAGS parameters for use with threads is still a pain in 2014. With this patch I am trying to solve T880 and use ax_pthread.m4. Note that I do not trust this macro more than the previous one, so if there is any build issue on any system regarding thread, I may just rollback to the previous code. Still I hope it is an improvement and that our build system detect thread more reliably.
Diffstat (limited to '')
-rw-r--r--m4/efl_threads.m439
1 files changed, 19 insertions, 20 deletions
diff --git a/m4/efl_threads.m4 b/m4/efl_threads.m4
index 04b3e64..f1b0cb3 100644
--- a/m4/efl_threads.m4
+++ b/m4/efl_threads.m4
@@ -14,15 +14,18 @@ AC_DEFUN([EFL_CHECK_THREADS],
14 14
15dnl Generic thread detection 15dnl Generic thread detection
16 16
17EFL_PTHREAD_CFLAGS="-D_REENTRANT" 17dnl Use generic infrastructure for pthread detection (What a hell of a mess !)
18EFL_PTHREAD_LIBS="" 18_efl_have_ax_threads="no"
19AX_PTHREAD([
20 EFL_PTHREAD_CFLAGS="${PTHREAD_CFLAGS}"
21 EFL_PTHREAD_LIBS="${PTHREAD_LIBS}"
22 CC="${PTHREAD_CC}"
23 _efl_have_ax_threads="yes"
24 ])
19 25
20_efl_have_posix_threads="no" 26_efl_have_posix_threads="no"
21_efl_have_win32_threads="no" 27_efl_have_win32_threads="no"
22 28
23dnl Use generic infrastructure for pthread detection (What a hell of a mess !)
24gl_LOCK
25
26AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported]) 29AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
27 30
28case "$host_os" in 31case "$host_os" in
@@ -32,25 +35,18 @@ case "$host_os" in
32 AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported]) 35 AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
33 ;; 36 ;;
34 *) 37 *)
35 _efl_have_posix_threads="${gl_use_threads}" 38 _efl_have_posix_threads="${_efl_have_ax_threads}"
36 AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported]) 39 AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
37 ;; 40 ;;
38esac 41esac
39 42
40dnl System specific CFLAGS 43dnl check if the compiler supports POSIX thread barrier and setaffinity
41if test "x${_efl_have_posix_threads}" = "xyes"; then
42 case "$host_os" in
43 osf*) EFL_PTHREAD_CFLAGS="-D_REENTRANT" ;;
44 aix* | freebsd*) EFL_PTHREAD_CFLAGS="-D_THREAD_SAFE" ;;
45 solaris*) EFL_PTHREAD_CFLAGS="-D_REENTRANT" ;;
46 esac
47fi
48
49dnl check if the compiler supports POSIX threads
50if test "x${_efl_have_posix_threads}" = "xyes" ; then 44if test "x${_efl_have_posix_threads}" = "xyes" ; then
51 45
52 SAVE_LIBS=${LIBS} 46 SAVE_LIBS=${LIBS}
53 LIBS="${LIBS} ${LIBMULTITHREAD}" 47 SAVE_CFLAGS=${CFLAGS}
48 LIBS="${LIBS} ${PTHREAD_LIBS}"
49 CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
54 AC_LINK_IFELSE( 50 AC_LINK_IFELSE(
55 [AC_LANG_PROGRAM([[ 51 [AC_LANG_PROGRAM([[
56#include <pthread.h> 52#include <pthread.h>
@@ -73,6 +69,7 @@ pthread_attr_setaffinity_np(NULL, 0, NULL);
73 [efl_have_setaffinity="yes"], 69 [efl_have_setaffinity="yes"],
74 [efl_have_setaffinity="no"]) 70 [efl_have_setaffinity="no"])
75 LIBS=${SAVE_LIBS} 71 LIBS=${SAVE_LIBS}
72 CFLAGS=${SAVE_CFLAGS}
76fi 73fi
77 74
78AC_MSG_CHECKING([which threads API is used]) 75AC_MSG_CHECKING([which threads API is used])
@@ -89,8 +86,6 @@ else
89fi 86fi
90AC_MSG_RESULT([${efl_have_threads}]) 87AC_MSG_RESULT([${efl_have_threads}])
91 88
92EFL_PTHREAD_LIBS="${LTLIBMULTITHREAD}"
93
94AC_SUBST(EFL_PTHREAD_CFLAGS) 89AC_SUBST(EFL_PTHREAD_CFLAGS)
95AC_SUBST(EFL_PTHREAD_LIBS) 90AC_SUBST(EFL_PTHREAD_LIBS)
96 91
@@ -99,8 +94,11 @@ dnl check if the compiler supports pthreads spinlock
99efl_have_posix_threads_spinlock="no" 94efl_have_posix_threads_spinlock="no"
100 95
101if test "x${_efl_have_posix_threads}" = "xyes" ; then 96if test "x${_efl_have_posix_threads}" = "xyes" ; then
97
102 SAVE_LIBS=${LIBS} 98 SAVE_LIBS=${LIBS}
103 LIBS="${LIBS} ${LIBMULTITHREAD}" 99 SAVE_CFLAGS=${CFLAGS}
100 LIBS="${LIBS} ${PTHREAD_LIBS}"
101 CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
104 AC_LINK_IFELSE( 102 AC_LINK_IFELSE(
105 [AC_LANG_PROGRAM([[ 103 [AC_LANG_PROGRAM([[
106#include <pthread.h> 104#include <pthread.h>
@@ -115,6 +113,7 @@ sched_yield();
115 [efl_have_posix_threads_spinlock="yes"], 113 [efl_have_posix_threads_spinlock="yes"],
116 [efl_have_posix_threads_spinlock="no"]) 114 [efl_have_posix_threads_spinlock="no"])
117 LIBS=${SAVE_LIBS} 115 LIBS=${SAVE_LIBS}
116 CFLAGS=${SAVE_CFLAGS}
118 117
119fi 118fi
120 119