diff options
author | 2021-09-01 15:48:32 +0200 | |
---|---|---|
committer | 2021-09-01 15:48:32 +0200 | |
commit | ce7609375646cfb1e7d490579e172c37c74a0589 (patch) | |
tree | 0e0855e3c3971fc831c1378c35169990fb21cb13 /common/thread.h | |
parent | 24abbb9450c723617e10a6843978aa04a576523e (diff) | |
download | libimobiledevice-ce7609375646cfb1e7d490579e172c37c74a0589.tar.gz libimobiledevice-ce7609375646cfb1e7d490579e172c37c74a0589.tar.bz2 |
Remove common code in favor of new libimobiledevice-glue
Diffstat (limited to 'common/thread.h')
-rw-r--r-- | common/thread.h | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/common/thread.h b/common/thread.h deleted file mode 100644 index 23e4510..0000000 --- a/common/thread.h +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | /* | ||
2 | * thread.h | ||
3 | * | ||
4 | * Copyright (c) 2012-2019 Nikias Bassen, All Rights Reserved. | ||
5 | * Copyright (c) 2012 Martin Szulecki, All Rights Reserved. | ||
6 | * | ||
7 | * This library is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | #ifndef __THREAD_H | ||
23 | #define __THREAD_H | ||
24 | |||
25 | #include <stddef.h> | ||
26 | |||
27 | #ifdef WIN32 | ||
28 | #include <windows.h> | ||
29 | typedef HANDLE THREAD_T; | ||
30 | typedef CRITICAL_SECTION mutex_t; | ||
31 | typedef volatile struct { | ||
32 | LONG lock; | ||
33 | int state; | ||
34 | } thread_once_t; | ||
35 | #define THREAD_ONCE_INIT {0, 0} | ||
36 | #define THREAD_ID GetCurrentThreadId() | ||
37 | #define THREAD_T_NULL (THREAD_T)NULL | ||
38 | #else | ||
39 | #include <pthread.h> | ||
40 | #include <signal.h> | ||
41 | typedef pthread_t THREAD_T; | ||
42 | typedef pthread_mutex_t mutex_t; | ||
43 | typedef pthread_once_t thread_once_t; | ||
44 | #define THREAD_ONCE_INIT PTHREAD_ONCE_INIT | ||
45 | #define THREAD_ID pthread_self() | ||
46 | #define THREAD_T_NULL (THREAD_T)NULL | ||
47 | #endif | ||
48 | |||
49 | typedef void* (*thread_func_t)(void* data); | ||
50 | |||
51 | int thread_new(THREAD_T* thread, thread_func_t thread_func, void* data); | ||
52 | void thread_detach(THREAD_T thread); | ||
53 | void thread_free(THREAD_T thread); | ||
54 | int thread_join(THREAD_T thread); | ||
55 | int thread_alive(THREAD_T thread); | ||
56 | |||
57 | int thread_cancel(THREAD_T thread); | ||
58 | |||
59 | #ifdef WIN32 | ||
60 | #undef HAVE_THREAD_CLEANUP | ||
61 | #else | ||
62 | #ifdef HAVE_PTHREAD_CANCEL | ||
63 | #define HAVE_THREAD_CLEANUP 1 | ||
64 | #define thread_cleanup_push(routine, arg) pthread_cleanup_push(routine, arg) | ||
65 | #define thread_cleanup_pop(execute) pthread_cleanup_pop(execute) | ||
66 | #endif | ||
67 | #endif | ||
68 | |||
69 | void mutex_init(mutex_t* mutex); | ||
70 | void mutex_destroy(mutex_t* mutex); | ||
71 | void mutex_lock(mutex_t* mutex); | ||
72 | void mutex_unlock(mutex_t* mutex); | ||
73 | |||
74 | void thread_once(thread_once_t *once_control, void (*init_routine)(void)); | ||
75 | |||
76 | #endif | ||