summaryrefslogtreecommitdiff
path: root/legacy/ecore
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2010-11-26 15:34:30 +0000
committerVincent Torri <vincent.torri@gmail.com>2010-11-26 15:34:30 +0000
commit95f36c0e180807addeb9c2721b05d127ac31d7b5 (patch)
tree8903c0fecd92ccf0f0c628c5955e38c8cc66b94e /legacy/ecore
parenta90e2e4aff365fee7ccad5188b1fe056ba34536f (diff)
more fixes, but needs to remove Windows 7 code, now...
SVN revision: 55019
Diffstat (limited to 'legacy/ecore')
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_thread.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/legacy/ecore/src/lib/ecore/ecore_thread.c b/legacy/ecore/src/lib/ecore/ecore_thread.c
index e6c1da93c6..ef7c225e6f 100644
--- a/legacy/ecore/src/lib/ecore/ecore_thread.c
+++ b/legacy/ecore/src/lib/ecore/ecore_thread.c
@@ -54,19 +54,50 @@
54# include <windows.h> 54# include <windows.h>
55# undef WIN32_LEAN_AND_MEAN 55# undef WIN32_LEAN_AND_MEAN
56 56
57# define PH(x) HANDLE x 57typedef struct
58{
59 HANDLE thread;
60 void *val;
61} win32_thread;
62
63# define PH(x) win32_thread *x
58# define PHE(x, y) ((x) == (y)) 64# define PHE(x, y) ((x) == (y))
59# define PHS() (HANDLE)GetCurrentThreadId() 65# define PHS() (HANDLE)GetCurrentThreadId()
60# define PHC(x, f, d) ((x = CreateThread(NULL, 0, f, d, 0, NULL)) == NULL) 66
61# define PHJ(x, p) \ 67int _ecore_thread_win32_create(win32_thread **x, LPTHREAD_START_ROUTINE f, void *d)
62 do { \ 68{
63 if (!PHE(x, PHS())) \ 69 win32_thread *t;
64 { \ 70 t = (win32_thread *)calloc(1, sizeof(win32_thread));
65 WaitForSingleObject(x, INFINITE); \ 71 if (!t)
66 CloseHandle(x); \ 72 return -1;
67 } \ 73
68 } while (0) 74 (t)->thread = CreateThread(NULL, 0, f, d, 0, NULL);
69# define PHA(x) TerminateThread(x) 75 if (!t->thread)
76 {
77 free(t);
78 return -1;
79 }
80 t->val = d;
81 *x = t;
82
83 return 0;
84}
85# define PHC(x, f, d) _ecore_thread_win32_create(&(x), (LPTHREAD_START_ROUTINE)f, d)
86
87int _ecore_thread_win32_join(win32_thread *x, void **res)
88{
89 if (!PHE(x, PHS()))
90 {
91 WaitForSingleObject(x->thread, INFINITE);
92 CloseHandle(x->thread);
93 }
94 if (res) *res = x->val;
95
96 return 0;
97}
98
99# define PHJ(x, p) _ecore_thread_win32_join(x, (void**)(&(p)))
100# define PHA(x) TerminateThread(x->thread, 0)
70 101
71typedef struct 102typedef struct
72{ 103{
@@ -84,7 +115,7 @@ typedef struct
84 { \ 115 { \
85 x->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); \ 116 x->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); \
86 if (x->semaphore) \ 117 if (x->semaphore) \
87 InitializeCriticalSection(&_c->threads_count_lock_); \ 118 InitializeCriticalSection(&x->threads_count_lock); \
88 else \ 119 else \
89 { \ 120 { \
90 free(x); \ 121 free(x); \