summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2010-11-21 04:37:52 +0000
committerCarsten Haitzler <raster@rasterman.com>2010-11-21 04:37:52 +0000
commit6ce323eaa01bf147bf2d4a71e150b52a7a11bd7b (patch)
treede2fe4d9466b30596925eec4ef2f94d89d9adcfb /legacy
parent4e3e9cface48686fc0c44b12b5950657da6183f1 (diff)
make thread support windows friendly. i hope.
SVN revision: 54754
Diffstat (limited to 'legacy')
-rw-r--r--legacy/elementary/configure.ac17
-rw-r--r--legacy/elementary/m4/efl_threads.m4206
-rw-r--r--legacy/elementary/src/lib/Makefile.am27
-rw-r--r--legacy/elementary/src/lib/elm_store.c28
4 files changed, 258 insertions, 20 deletions
diff --git a/legacy/elementary/configure.ac b/legacy/elementary/configure.ac
index b6c6e50227..2df23eff58 100644
--- a/legacy/elementary/configure.ac
+++ b/legacy/elementary/configure.ac
@@ -1,4 +1,4 @@
1##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## 1=-------##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
2##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## 2##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
3m4_define([v_maj], [0]) 3m4_define([v_maj], [0])
4m4_define([v_min], [7]) 4m4_define([v_min], [7])
@@ -446,17 +446,16 @@ ELM_LIBINTL_H_DEF="#undef"
446AC_CHECK_HEADER(libintl.h, [ELM_LIBINTL_H_DEF="#define"]) 446AC_CHECK_HEADER(libintl.h, [ELM_LIBINTL_H_DEF="#define"])
447AC_SUBST(ELM_LIBINTL_H_DEF) 447AC_SUBST(ELM_LIBINTL_H_DEF)
448 448
449AC_CHECK_HEADER(pthread.h, [ 449EFL_CHECK_THREADS([
450 AC_CHECK_LIB(pthread, pthread_mutex_lock, , [ 450
451 AC_MSG_ERROR(pthread not found) 451] , [
452 ]) 452 AC_MSG_ERROR(no thread support found. required.)
453
454], [
455 AC_MSG_ERROR(pthreads headers or not found)
456 exit 1 453 exit 1
457]) 454])
455AC_SUBST(EFL_PTHREAD_CFLAGS)
456AC_SUBST(EFL_PTHREAD_LIBS)
458 457
459my_libs="-lm -lpthread" 458my_libs="-lm"
460AC_SUBST(my_libs) 459AC_SUBST(my_libs)
461AC_SUBST(requirement_elm) 460AC_SUBST(requirement_elm)
462 461
diff --git a/legacy/elementary/m4/efl_threads.m4 b/legacy/elementary/m4/efl_threads.m4
new file mode 100644
index 0000000000..33d15a39b4
--- /dev/null
+++ b/legacy/elementary/m4/efl_threads.m4
@@ -0,0 +1,206 @@
1dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
2dnl rwlock code added by Mike Blumenkrantz <mike at zentific dot com>
3dnl This code is public domain and can be freely used or copied.
4
5dnl Macro that check if POSIX or Win32 threads library is available or not.
6
7dnl Usage: EFL_CHECK_THREADS(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
8dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
9dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
10dnl Defines EFL_HAVE_POSIX_THREADS or EFL_HAVE_WIN32_THREADS, and EFL_HAVE_THREADS
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_threads_cflags="-mt"
89 _efl_threads_libs="-mt"
90 ;;
91 *)
92 _efl_threads_cflags="-pthread"
93 _efl_threads_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_threads_cflags}
131 EFL_PTHREAD_LIBS=${_efl_threads_libs}
132fi
133
134AC_SUBST(EFL_PTHREAD_CFLAGS)
135AC_SUBST(EFL_PTHREAD_LIBS)
136
137_efl_enable_debug_threads="no"
138AC_ARG_ENABLE([debug-threads],
139 [AC_HELP_STRING([--enable-debug-threads], [disable assert when you forgot to call eina_threads_init])],
140 [_efl_enable_debug_threads="${enableval}"])
141
142have_debug_threads="no"
143if test "x${_efl_have_posix_threads}" = "xyes" -a "x${_efl_enable_debug_threads}" = "xyes"; then
144 have_debug_threads="yes"
145 AC_DEFINE([EFL_DEBUG_THREADS], [1], [Assert when forgot to call eina_threads_init])
146fi
147
148if test "x${_efl_have_posix_threads}" = "xyes" ; then
149 AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
150fi
151
152if test "x${_efl_enable_win32_threads}" = "xyes" ; then
153 _efl_have_win32_threads="yes"
154 AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
155fi
156
157if test "x${_efl_have_posix_threads}" = "xyes" || test "x${_efl_have_win32_threads}" = "xyes" ; then
158 AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
159fi
160
161AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], [$1], [$2])
162])
163
164dnl Usage: EFL_CHECK_SPINLOCK(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
165dnl Defines EFL_HAVE_POSIX_THREADS_SPINLOCK
166AC_DEFUN([EFL_CHECK_SPINLOCK],
167[
168
169dnl check if the compiler supports pthreads spinlock
170
171_efl_have_posix_threads_spinlock="no"
172
173if test "x${_efl_have_posix_threads}" = "xyes" ; then
174
175 SAVE_CFLAGS=${CFLAGS}
176 CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
177 SAVE_LIBS=${LIBS}
178 LIBS="${LIBS} ${EFL_PTHREAD_LIBS}"
179 AC_LINK_IFELSE(
180 [AC_LANG_PROGRAM([[
181#include <pthread.h>
182 ]],
183 [[
184pthread_spinlock_t lock;
185int res;
186res = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
187 ]])],
188 [_efl_have_posix_threads_spinlock="yes"],
189 [_efl_have_posix_threads_spinlock="no"])
190 CFLAGS=${SAVE_CFLAGS}
191 LIBS=${SAVE_LIBS}
192
193fi
194
195AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
196AC_MSG_RESULT([${_efl_have_posix_threads_spinlock}])
197if test "x${_efl_enable_posix_threads}" = "xyes" && test "x${_efl_have_posix_threads_spinlock}" = "xno" ; then
198 AC_MSG_WARN([POSIX threads support requested but spinlocks are not supported])
199fi
200
201if test "x${_efl_have_posix_threads_spinlock}" = "xyes" ; then
202 AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported])
203fi
204AS_IF([test "x$_efl_have_posix_threads_spinlock" = "xyes"], [$1], [$2])
205])
206
diff --git a/legacy/elementary/src/lib/Makefile.am b/legacy/elementary/src/lib/Makefile.am
index 84149f3a31..03ef98812d 100644
--- a/legacy/elementary/src/lib/Makefile.am
+++ b/legacy/elementary/src/lib/Makefile.am
@@ -19,7 +19,8 @@ AM_CPPFLAGS = \
19@ELEMENTARY_EDBUS_CFLAGS@ \ 19@ELEMENTARY_EDBUS_CFLAGS@ \
20@ELEMENTARY_EFREET_CFLAGS@ \ 20@ELEMENTARY_EFREET_CFLAGS@ \
21@ELEMENTARY_ETHUMB_CFLAGS@ \ 21@ELEMENTARY_ETHUMB_CFLAGS@ \
22@EVIL_CFLAGS@ 22@EVIL_CFLAGS@ \
23@EFL_PTHREAD_CFLAGS@
23 24
24if ELEMENTARY_WINDOWS_BUILD 25if ELEMENTARY_WINDOWS_BUILD
25AM_CPPFLAGS += -DELEMENTARY_BUILD 26AM_CPPFLAGS += -DELEMENTARY_BUILD
@@ -27,7 +28,10 @@ endif
27 28
28lib_LTLIBRARIES = libelementary.la 29lib_LTLIBRARIES = libelementary.la
29 30
30includes_HEADERS = Elementary.h Elementary_Cursor.h elm_widget.h 31includes_HEADERS = \
32Elementary.h \
33Elementary_Cursor.h \
34elm_widget.h
31includesdir = $(includedir)/elementary-@VMAJ@ 35includesdir = $(includedir)/elementary-@VMAJ@
32 36
33libelementary_la_SOURCES = \ 37libelementary_la_SOURCES = \
@@ -113,5 +117,20 @@ elm_cnp_helper.c
113 117
114 118
115libelementary_la_CFLAGS = 119libelementary_la_CFLAGS =
116libelementary_la_LIBADD = @my_libs@ @dlopen_libs@ @ELEMENTARY_LIBS@ @ELEMENTARY_X_LIBS@ @ELEMENTARY_FB_LIBS@ @ELEMENTARY_SDL_LIBS@ @ELEMENTARY_WIN32_LIBS@ @ELEMENTARY_WINCE_LIBS@ @ELEMENTARY_EDBUS_LIBS@ @ELEMENTARY_EFREET_LIBS@ @ELEMENTARY_ETHUMB_LIBS@ @EVIL_LIBS@ 120libelementary_la_LIBADD = \
117libelementary_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ 121@my_libs@ \
122@dlopen_libs@ \
123@ELEMENTARY_LIBS@ \
124@ELEMENTARY_X_LIBS@ \
125@ELEMENTARY_FB_LIBS@ \
126@ELEMENTARY_SDL_LIBS@ \
127@ELEMENTARY_WIN32_LIBS@ \
128@ELEMENTARY_WINCE_LIBS@ \
129@ELEMENTARY_EDBUS_LIBS@ \
130@ELEMENTARY_EFREET_LIBS@ \
131@ELEMENTARY_ETHUMB_LIBS@ \
132@EVIL_LIBS@ \
133@EFL_PTHREAD_LIBS@
134libelementary_la_LDFLAGS = \
135-no-undefined @lt_enable_auto_import@ \
136-version-info @version_info@ @release_info@
diff --git a/legacy/elementary/src/lib/elm_store.c b/legacy/elementary/src/lib/elm_store.c
index 933ea6cafe..dba552bc1c 100644
--- a/legacy/elementary/src/lib/elm_store.c
+++ b/legacy/elementary/src/lib/elm_store.c
@@ -2,13 +2,27 @@
2#include <Elementary_Cursor.h> 2#include <Elementary_Cursor.h>
3#include "elm_priv.h" 3#include "elm_priv.h"
4 4
5#include <pthread.h> 5#ifndef EFL_HAVE_THREADS
6#define LK(x) pthread_mutex_t x 6# error "No thread support. Required."
7#define LKI(x) pthread_mutex_init(&(x), NULL); 7#endif
8#define LKD(x) pthread_mutex_destroy(&(x)); 8
9#define LKL(x) pthread_mutex_lock(&(x)); 9#ifdef EFL_HAVE_POSIX_THREADS
10#define LKT(x) pthread_mutex_trylock(&(x)); 10# include <pthread.h>
11#define LKU(x) pthread_mutex_unlock(&(x)); 11# define LK(x) pthread_mutex_t x
12# define LKI(x) pthread_mutex_init(&(x), NULL);
13# define LKD(x) pthread_mutex_destroy(&(x));
14# define LKL(x) pthread_mutex_lock(&(x));
15# define LKU(x) pthread_mutex_unlock(&(x));
16#else /* EFL_HAVE_WIN32_THREADS */
17# define WIN32_LEAN_AND_MEAN
18# include <windows.h>
19# undef WIN32_LEAN_AND_MEAN
20# define LK(x) HANDLE x
21# define LKI(x) x = CreateMutex(NULL, FALSE, NULL)
22# define LKD(x) CloseHandle(x)
23# define LKL(x) WaitForSingleObject(x, INFINITE)
24# define LKU(x) ReleaseMutex(x)
25#endif
12 26
13#define ELM_STORE_MAGIC 0x3f89ea56 27#define ELM_STORE_MAGIC 0x3f89ea56
14#define ELM_STORE_FILESYSTEM_MAGIC 0x3f89ea57 28#define ELM_STORE_FILESYSTEM_MAGIC 0x3f89ea57