diff options
author | Cedric Bail <cedric.bail@samsung.com> | 2013-11-12 16:06:22 +0900 |
---|---|---|
committer | Cedric Bail <cedric.bail@samsung.com> | 2013-11-12 16:06:22 +0900 |
commit | 2a29732e0734af82294d7b1fccc52595f3020f15 (patch) | |
tree | 49e5fc8c9428ea8af790ac50710065d541321708 /m4/efl_threads.m4 | |
parent | d2ff8d70a5d88307a1567f92c910abc0d9c4c272 (diff) |
efl: let's try to detect in a portable way phtread around the world.
Linking to Pthread seems to be highly not portable. Look at lock.m4
macro if you want to understand the hell it is ! By following it
closely we should now have better portability than the 1.7.x release.
And of course than our alpha...
Diffstat (limited to '')
-rw-r--r-- | m4/efl_threads.m4 | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/m4/efl_threads.m4 b/m4/efl_threads.m4 index e7a84b36c0..acea5a9dc3 100644 --- a/m4/efl_threads.m4 +++ b/m4/efl_threads.m4 | |||
@@ -17,49 +17,40 @@ dnl Generic thread detection | |||
17 | EFL_PTHREAD_CFLAGS="" | 17 | EFL_PTHREAD_CFLAGS="" |
18 | EFL_PTHREAD_LIBS="" | 18 | EFL_PTHREAD_LIBS="" |
19 | 19 | ||
20 | _efl_enable_posix_threads="no" | ||
21 | _efl_have_posix_threads="no" | 20 | _efl_have_posix_threads="no" |
22 | _efl_have_win32_threads="no" | 21 | _efl_have_win32_threads="no" |
23 | 22 | ||
23 | dnl Use generic infrastructure for pthread detection (What a hell of a mess !) | ||
24 | gl_LOCK | ||
25 | |||
26 | AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported]) | ||
27 | |||
24 | case "$host_os" in | 28 | case "$host_os" in |
25 | mingw*) | 29 | mingw*) |
26 | _efl_have_win32_threads="yes" | 30 | _efl_have_win32_threads="yes" |
27 | efl_have_setaffinity="yes" | 31 | efl_have_setaffinity="yes" |
28 | AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported]) | 32 | AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported]) |
29 | AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported]) | ||
30 | ;; | 33 | ;; |
31 | *) | 34 | *) |
32 | _efl_enable_posix_threads="yes" | 35 | _efl_have_posix_threads="${gl_use_threads}" |
33 | _efl_threads_cflags="-D_REENTRANT" | 36 | AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported]) |
34 | _efl_threads_libs="-lpthread" | ||
35 | ;; | 37 | ;; |
36 | esac | 38 | esac |
37 | 39 | ||
38 | dnl check if the compiler supports POSIX threads | 40 | dnl System specific CFLAGS |
39 | 41 | if 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 | ||
47 | fi | ||
40 | 48 | ||
41 | if test "x${_efl_enable_posix_threads}" = "xyes" ; then | 49 | dnl check if the compiler supports POSIX threads |
50 | if test "x${_efl_have_posix_threads}" = "xyes" ; then | ||
42 | 51 | ||
43 | SAVE_CFLAGS=${CFLAGS} | ||
44 | CFLAGS="${CFLAGS} ${_efl_threads_cflags}" | ||
45 | SAVE_LIBS=${LIBS} | 52 | SAVE_LIBS=${LIBS} |
46 | LIBS="${LIBS} ${_efl_threads_libs}" | 53 | LIBS="${LIBS} ${LIBMULTITHREAD}" |
47 | AC_LINK_IFELSE( | ||
48 | [AC_LANG_PROGRAM([[ | ||
49 | #include <pthread.h> | ||
50 | ]], | ||
51 | [[ | ||
52 | pthread_t id; | ||
53 | id = pthread_self(); | ||
54 | ]])], | ||
55 | [ | ||
56 | _efl_have_posix_threads="yes" | ||
57 | AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported]) | ||
58 | AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported]) | ||
59 | EFL_PTHREAD_CFLAGS=${_efl_threads_cflags} | ||
60 | EFL_PTHREAD_LIBS=${_efl_threads_libs} | ||
61 | ], | ||
62 | [_efl_have_posix_threads="no"]) | ||
63 | AC_LINK_IFELSE( | 54 | AC_LINK_IFELSE( |
64 | [AC_LANG_PROGRAM([[ | 55 | [AC_LANG_PROGRAM([[ |
65 | #include <pthread.h> | 56 | #include <pthread.h> |
@@ -83,7 +74,6 @@ pthread_attr_setaffinity_np(NULL, 0, NULL); | |||
83 | [efl_have_setaffinity="no"]) | 74 | [efl_have_setaffinity="no"]) |
84 | CFLAGS=${SAVE_CFLAGS} | 75 | CFLAGS=${SAVE_CFLAGS} |
85 | LIBS=${SAVE_LIBS} | 76 | LIBS=${SAVE_LIBS} |
86 | |||
87 | fi | 77 | fi |
88 | 78 | ||
89 | AC_MSG_CHECKING([which threads API is used]) | 79 | AC_MSG_CHECKING([which threads API is used]) |
@@ -100,6 +90,8 @@ else | |||
100 | fi | 90 | fi |
101 | AC_MSG_RESULT([${efl_have_threads}]) | 91 | AC_MSG_RESULT([${efl_have_threads}]) |
102 | 92 | ||
93 | EFL_PTHREAD_LIBS="${LTLIBMULTITHREAD}" | ||
94 | |||
103 | AC_SUBST(EFL_PTHREAD_CFLAGS) | 95 | AC_SUBST(EFL_PTHREAD_CFLAGS) |
104 | AC_SUBST(EFL_PTHREAD_LIBS) | 96 | AC_SUBST(EFL_PTHREAD_LIBS) |
105 | 97 | ||
@@ -108,11 +100,8 @@ dnl check if the compiler supports pthreads spinlock | |||
108 | efl_have_posix_threads_spinlock="no" | 100 | efl_have_posix_threads_spinlock="no" |
109 | 101 | ||
110 | if test "x${_efl_have_posix_threads}" = "xyes" ; then | 102 | if test "x${_efl_have_posix_threads}" = "xyes" ; then |
111 | |||
112 | SAVE_CFLAGS=${CFLAGS} | ||
113 | CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}" | ||
114 | SAVE_LIBS=${LIBS} | 103 | SAVE_LIBS=${LIBS} |
115 | LIBS="${LIBS} ${EFL_PTHREAD_LIBS}" | 104 | LIBS="${LIBS} ${LIBMULTITHREAD}" |
116 | AC_LINK_IFELSE( | 105 | AC_LINK_IFELSE( |
117 | [AC_LANG_PROGRAM([[ | 106 | [AC_LANG_PROGRAM([[ |
118 | #include <pthread.h> | 107 | #include <pthread.h> |
@@ -138,6 +127,9 @@ if test "x${efl_have_posix_threads_spinlock}" = "xyes" ; then | |||
138 | AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported]) | 127 | AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported]) |
139 | fi | 128 | fi |
140 | 129 | ||
130 | echo "_efl_have_posix_threads: ${_efl_have_posix_threads}" | ||
131 | echo "_efl_have_win32_threads: ${_efl_have_win32_threads}" | ||
132 | |||
141 | AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], | 133 | AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], |
142 | [$1], | 134 | [$1], |
143 | [m4_if([$2], [$2], [AC_MSG_ERROR([Threads are required.])])]) | 135 | [m4_if([$2], [$2], [AC_MSG_ERROR([Threads are required.])])]) |