summaryrefslogtreecommitdiffstats
path: root/src/thread.h
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-09-13 20:28:16 +0200
committerGravatar Nikias Bassen2021-09-13 20:28:16 +0200
commit40b25fd572bf94d65e880a216bba5e825e5bbf2d (patch)
treeb6df709be2dbdec2186df1c7e2bec211b8d0dec5 /src/thread.h
parentbcf56b30fea3b841ee11a9b4f3ac74f6de465f3d (diff)
downloadlibirecovery-40b25fd572bf94d65e880a216bba5e825e5bbf2d.tar.gz
libirecovery-40b25fd572bf94d65e880a216bba5e825e5bbf2d.tar.bz2
Remove duplicated thread/collection code and use new libimobiledevice-glue instead
Diffstat (limited to 'src/thread.h')
-rw-r--r--src/thread.h87
1 files changed, 0 insertions, 87 deletions
diff --git a/src/thread.h b/src/thread.h
deleted file mode 100644
index 2aadc6e..0000000
--- a/src/thread.h
+++ /dev/null
@@ -1,87 +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>
29typedef HANDLE THREAD_T;
30typedef CRITICAL_SECTION mutex_t;
31typedef struct {
32 HANDLE sem;
33} cond_t;
34typedef volatile struct {
35 LONG lock;
36 int state;
37} thread_once_t;
38#define THREAD_ONCE_INIT {0, 0}
39#define THREAD_ID GetCurrentThreadId()
40#define THREAD_T_NULL (THREAD_T)NULL
41#else
42#include <pthread.h>
43#include <signal.h>
44#include <sys/time.h>
45typedef pthread_t THREAD_T;
46typedef pthread_mutex_t mutex_t;
47typedef pthread_cond_t cond_t;
48typedef pthread_once_t thread_once_t;
49#define THREAD_ONCE_INIT PTHREAD_ONCE_INIT
50#define THREAD_ID pthread_self()
51#define THREAD_T_NULL (THREAD_T)NULL
52#endif
53
54typedef void* (*thread_func_t)(void* data);
55
56int thread_new(THREAD_T* thread, thread_func_t thread_func, void* data);
57void thread_detach(THREAD_T thread);
58void thread_free(THREAD_T thread);
59int thread_join(THREAD_T thread);
60int thread_alive(THREAD_T thread);
61
62int thread_cancel(THREAD_T thread);
63
64#ifdef WIN32
65#undef HAVE_THREAD_CLEANUP
66#else
67#ifdef HAVE_PTHREAD_CANCEL
68#define HAVE_THREAD_CLEANUP 1
69#define thread_cleanup_push(routine, arg) pthread_cleanup_push(routine, arg)
70#define thread_cleanup_pop(execute) pthread_cleanup_pop(execute)
71#endif
72#endif
73
74void mutex_init(mutex_t* mutex);
75void mutex_destroy(mutex_t* mutex);
76void mutex_lock(mutex_t* mutex);
77void mutex_unlock(mutex_t* mutex);
78
79void thread_once(thread_once_t *once_control, void (*init_routine)(void));
80
81void cond_init(cond_t* cond);
82void cond_destroy(cond_t* cond);
83int cond_signal(cond_t* cond);
84int cond_wait(cond_t* cond, mutex_t* mutex);
85int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms);
86
87#endif