summaryrefslogtreecommitdiffstats
path: root/common/thread.h
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-09-01 15:48:32 +0200
committerGravatar Nikias Bassen2021-09-01 15:48:32 +0200
commitce7609375646cfb1e7d490579e172c37c74a0589 (patch)
tree0e0855e3c3971fc831c1378c35169990fb21cb13 /common/thread.h
parent24abbb9450c723617e10a6843978aa04a576523e (diff)
downloadlibimobiledevice-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.h76
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>
29typedef HANDLE THREAD_T;
30typedef CRITICAL_SECTION mutex_t;
31typedef 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>
41typedef pthread_t THREAD_T;
42typedef pthread_mutex_t mutex_t;
43typedef 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
49typedef void* (*thread_func_t)(void* data);
50
51int thread_new(THREAD_T* thread, thread_func_t thread_func, void* data);
52void thread_detach(THREAD_T thread);
53void thread_free(THREAD_T thread);
54int thread_join(THREAD_T thread);
55int thread_alive(THREAD_T thread);
56
57int 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
69void mutex_init(mutex_t* mutex);
70void mutex_destroy(mutex_t* mutex);
71void mutex_lock(mutex_t* mutex);
72void mutex_unlock(mutex_t* mutex);
73
74void thread_once(thread_once_t *once_control, void (*init_routine)(void));
75
76#endif