summaryrefslogtreecommitdiff
path: root/legacy/eet/m4
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2010-07-15 06:34:32 +0000
committerVincent Torri <vincent.torri@gmail.com>2010-07-15 06:34:32 +0000
commit8351950deef456c65601b5f0cc0ab4511a67ee70 (patch)
tree96b9cd1a3aa8c2f2467a8b2c9effd5e272cb7b6b /legacy/eet/m4
parentcebe53cd3dc18d38b6df1119ab61941bd4afafd5 (diff)
Add native Windows thread support instead of using pthread
(less overhead). On other OS, pthread is still used by default. Pass --enable-win32-threads to activate thread support on Windows. SVN revision: 50262
Diffstat (limited to 'legacy/eet/m4')
-rw-r--r--legacy/eet/m4/efl_pthread.m4130
-rw-r--r--legacy/eet/m4/efl_threads.m4189
2 files changed, 189 insertions, 130 deletions
diff --git a/legacy/eet/m4/efl_pthread.m4 b/legacy/eet/m4/efl_pthread.m4
deleted file mode 100644
index b90a045618..0000000000
--- a/legacy/eet/m4/efl_pthread.m4
+++ /dev/null
@@ -1,130 +0,0 @@
1dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
2dnl That code is public domain and can be freely used or copied.
3
4dnl Macro that check if several pthread library is available or not.
5
6dnl Usage: EFL_CHECK_PTHREAD(want_pthread_spin[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
7dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
8dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
9dnl Define EFL_HAVE_PTHREAD
10dnl Define EFL_HAVE_PTHREAD_SPINLOCK
11
12AC_DEFUN([EFL_CHECK_PTHREAD],
13[
14
15dnl configure option
16
17AC_ARG_ENABLE([pthread],
18 [AC_HELP_STRING([--disable-pthread], [enable POSIX threads code @<:@default=auto@:>@])],
19 [
20 if test "x${enableval}" = "xyes" ; then
21 _efl_enable_pthread="yes"
22 else
23 _efl_enable_pthread="no"
24 fi
25 ],
26 [_efl_enable_pthread="auto"])
27
28AC_MSG_CHECKING([whether to build POSIX threads code])
29AC_MSG_RESULT([${_efl_enable_pthread}])
30
31dnl check if the compiler supports pthreads
32
33case "$host_os" in
34 mingw*)
35 _efl_pthread_cflags=""
36 _efl_pthread_libs="-lpthreadGC2"
37 ;;
38 solaris*)
39 _efl_pthread_cflags="-mt"
40 _efl_pthread_libs="-mt"
41 ;;
42 *)
43 _efl_pthread_cflags="-pthread"
44 _efl_pthread_libs="-pthread"
45 ;;
46esac
47
48_efl_have_pthread="no"
49
50if test "x${_efl_enable_pthread}" = "xyes" || test "x${_efl_enable_pthread}" = "xauto" ; then
51
52 SAVE_CFLAGS=${CFLAGS}
53 CFLAGS="${CFLAGS} ${_efl_pthread_cflags}"
54 SAVE_LIBS=${LIBS}
55 LIBS="${LIBS} ${_efl_pthread_libs}"
56 AC_LINK_IFELSE(
57 [AC_LANG_PROGRAM([[
58#include <pthread.h>
59 ]],
60 [[
61pthread_t id;
62id = pthread_self();
63 ]])],
64 [_efl_have_pthread="yes"],
65 [_efl_have_pthread="no"])
66 CFLAGS=${SAVE_CFLAGS}
67 LIBS=${SAVE_LIBS}
68
69fi
70
71AC_MSG_CHECKING([whether system support POSIX threads])
72AC_MSG_RESULT([${_efl_have_pthread}])
73if test "$x{_efl_enable_pthread}" = "xyes" && test "x${_efl_have_pthread}" = "xno"; then
74 AC_MSG_ERROR([pthread support requested but not found.])
75fi
76
77EFL_PTHREAD_CFLAGS=""
78EFL_PTHREAD_LIBS=""
79if test "x${_efl_have_pthread}" = "xyes" ; then
80 EFL_PTHREAD_CFLAGS=${_efl_pthread_cflags}
81 EFL_PTHREAD_LIBS=${_efl_pthread_libs}
82fi
83
84AC_SUBST(EFL_PTHREAD_CFLAGS)
85AC_SUBST(EFL_PTHREAD_LIBS)
86
87if test "x${_efl_have_pthread}" = "xyes" ; then
88 AC_DEFINE(EFL_HAVE_PTHREAD, 1, [Define to mention that POSIX threads are supported])
89fi
90
91dnl check if the compiler supports pthreads spinlock
92
93_efl_have_pthread_spinlock="no"
94
95if test "x${_efl_have_pthread}" = "xyes" && test "x$1" = "xyes" ; then
96
97 SAVE_CFLAGS=${CFLAGS}
98 CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
99 SAVE_LIBS=${LIBS}
100 LIBS="${LIBS} ${EFL_PTHREAD_LIBS}"
101 AC_LINK_IFELSE(
102 [AC_LANG_PROGRAM([[
103#include <pthread.h>
104 ]],
105 [[
106pthread_spinlock_t lock;
107int res;
108res = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
109 ]])],
110 [_efl_have_pthread_spinlock="yes"],
111 [_efl_have_pthread_spinlock="no"])
112 CFLAGS=${SAVE_CFLAGS}
113 LIBS=${SAVE_LIBS}
114
115fi
116
117AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
118AC_MSG_RESULT([${_efl_have_pthread_spinlock}])
119if test "x${_efl_enable_pthread}" = "xyes" && test "x${_efl_have_pthread_spinlock}" = "xno" && test "x$1" = "xyes" ; then
120 AC_MSG_WARN([pthread support requested but spinlocks are not supported])
121fi
122
123if test "x${_efl_have_pthread_spinlock}" = "xyes" ; then
124 AC_DEFINE(EFL_HAVE_PTHREAD_SPINLOCK, 1, [Define to mention that POSIX threads spinlocks are supported])
125fi
126
127AS_IF([test "x$_efl_have_pthread" = "xyes"], [$2], [$3])
128AS_IF([test "x$_efl_have_pthread_spinlock" = "xyes"], [$4], [$5])
129
130])
diff --git a/legacy/eet/m4/efl_threads.m4 b/legacy/eet/m4/efl_threads.m4
new file mode 100644
index 0000000000..8866e3720a
--- /dev/null
+++ b/legacy/eet/m4/efl_threads.m4
@@ -0,0 +1,189 @@
1dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
2dnl That code is public domain and can be freely used or copied.
3
4dnl Macro that check if POSIX or Win32 threads library is available or not.
5
6dnl Usage: EFL_CHECK_THREADS(want_pthread_spin[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
7dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
8dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
9dnl Define EFL_HAVE_POSIX_THREADS or EFL_HAVE_WIN32_THREADS, and EFL_HAVE_THREADS
10dnl Define EFL_HAVE_POSIX_THREADS_SPINLOCK
11
12AC_DEFUN([EFL_CHECK_THREADS],
13[
14
15dnl configure option
16
17AC_ARG_ENABLE([posix-threads],
18 [AC_HELP_STRING([--disable-posix-threads], [enable POSIX threads code @<:@default=auto@:>@])],
19 [
20 if test "x${enableval}" = "xyes" ; then
21 _efl_enable_posix_threads="yes"
22 else
23 _efl_enable_posix_threads="no"
24 fi
25 ],
26 [_efl_enable_posix_threads="auto"])
27
28AC_MSG_CHECKING([whether to build POSIX threads code])
29AC_MSG_RESULT([${_efl_enable_posix_threads}])
30
31AC_ARG_ENABLE([win32-threads],
32 [AC_HELP_STRING([--disable-win32-threads], [enable Win32 threads code @<:@default=no@:>@])],
33 [
34 if test "x${enableval}" = "xyes" ; then
35 _efl_enable_win32_threads="yes"
36 else
37 _efl_enable_win32_threads="no"
38 fi
39 ],
40 [_efl_enable_win32_threads="no"])
41
42AC_MSG_CHECKING([whether to build Windows threads code])
43AC_MSG_RESULT([${_efl_enable_win32_threads}])
44
45dnl
46dnl * no + no
47dnl * yes + no : win32: error, other : pthread
48dnl * yes + yes : win32 : wthread, other : pthread
49dnl * no + yes : win32 : wthread, other : error
50
51if test "x${_efl_enable_posix_threads}" = "xyes" && test "x${_efl_enable_win32_threads}" = "xyes" ; then
52 case "$host_os" in
53 mingw*)
54 _efl_enable_posix_threads=no
55 ;;
56 *)
57 _efl_enable_win32_threads=no
58 ;;
59 esac
60fi
61
62if test "x${_efl_enable_win32_threads}" = "xyes" ; then
63 case "$host_os" in
64 mingw*)
65 ;;
66 *)
67 AC_MSG_ERROR([Win32 threads support requested but non Windows system found.])
68 ;;
69 esac
70fi
71
72if test "x${_efl_enable_posix_threads}" = "xyes" ; then
73 case "$host_os" in
74 mingw*)
75 AC_MSG_ERROR([POSIX threads support requested but Windows system found.])
76 ;;
77 *)
78 ;;
79 esac
80fi
81
82dnl check if the compiler supports POSIX threads
83
84case "$host_os" in
85 mingw*)
86 ;;
87 solaris*)
88 _efl_thread_cflags="-mt"
89 _efl_thread_libs="-mt"
90 ;;
91 *)
92 _efl_thread_cflags="-pthread"
93 _efl_thread_libs="-pthread"
94 ;;
95esac
96
97_efl_have_posix_threads="no"
98_efl_have_win32_threads="no"
99
100if test "x${_efl_enable_posix_threads}" = "xyes" || test "x${_efl_enable_posix_threads}" = "xauto" ; then
101
102 SAVE_CFLAGS=${CFLAGS}
103 CFLAGS="${CFLAGS} ${_efl_threads_cflags}"
104 SAVE_LIBS=${LIBS}
105 LIBS="${LIBS} ${_efl_threads_libs}"
106 AC_LINK_IFELSE(
107 [AC_LANG_PROGRAM([[
108#include <pthread.h>
109 ]],
110 [[
111pthread_t id;
112id = pthread_self();
113 ]])],
114 [_efl_have_posix_threads="yes"],
115 [_efl_have_posix_threads="no"])
116 CFLAGS=${SAVE_CFLAGS}
117 LIBS=${SAVE_LIBS}
118
119fi
120
121AC_MSG_CHECKING([whether system support POSIX threads])
122AC_MSG_RESULT([${_efl_have_posix_threads}])
123if test "$x{_efl_enable_posix_threads}" = "xyes" && test "x${_efl_have_posix_threads}" = "xno"; then
124 AC_MSG_ERROR([POSIX threads support requested but not found.])
125fi
126
127EFL_PTHREAD_CFLAGS=""
128EFL_PTHREAD_LIBS=""
129if test "x${_efl_have_posix_threads}" = "xyes" ; then
130 EFL_PTHREAD_CFLAGS=${_efl_thread_cflags}
131 EFL_PTHREAD_LIBS=${_efl_thread_libs}
132fi
133
134AC_SUBST(EFL_PTHREAD_CFLAGS)
135AC_SUBST(EFL_PTHREAD_LIBS)
136
137if test "x${_efl_have_posix_threads}" = "xyes" ; then
138 AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
139fi
140
141dnl check if the compiler supports pthreads spinlock
142
143_efl_have_posix_threads_spinlock="no"
144
145if test "x${_efl_have_posix_threads}" = "xyes" && test "x$1" = "xyes" ; then
146
147 SAVE_CFLAGS=${CFLAGS}
148 CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
149 SAVE_LIBS=${LIBS}
150 LIBS="${LIBS} ${EFL_PTHREAD_LIBS}"
151 AC_LINK_IFELSE(
152 [AC_LANG_PROGRAM([[
153#include <pthread.h>
154 ]],
155 [[
156pthread_spinlock_t lock;
157int res;
158res = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
159 ]])],
160 [_efl_have_posix_threads_spinlock="yes"],
161 [_efl_have_posix_threads_spinlock="no"])
162 CFLAGS=${SAVE_CFLAGS}
163 LIBS=${SAVE_LIBS}
164
165fi
166
167AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
168AC_MSG_RESULT([${_efl_have_posix_threads_spinlock}])
169if test "x${_efl_enable_posix_threads}" = "xyes" && test "x${_efl_have_posix_threads_spinlock}" = "xno" && test "x$1" = "xyes" ; then
170 AC_MSG_WARN([POSIX threads support requested but spinlocks are not supported])
171fi
172
173if test "x${_efl_have_posix_threads_spinlock}" = "xyes" ; then
174 AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported])
175fi
176
177if test "x${_efl_enable_win32_threads}" = "xyes" ; then
178 _efl_have_win32_threads="yes"
179 AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
180fi
181
182if test "x${_efl_have_posix_threads}" = "xyes" || test "x${_efl_have_win32_threads}" = "xyes" ; then
183 AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
184fi
185
186AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], [$2], [$3])
187AS_IF([test "x$_efl_have_posix_threads_spinlock" = "xyes"], [$4], [$5])
188
189])