summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--common/Makefile.am15
-rw-r--r--common/socket.c (renamed from tools/socket.c)0
-rw-r--r--common/socket.h (renamed from tools/socket.h)0
-rw-r--r--common/thread.c (renamed from tools/thread.c)36
-rw-r--r--common/thread.h (renamed from tools/thread.h)7
-rw-r--r--configure.ac1
-rw-r--r--tools/Makefile.am6
-rw-r--r--tools/idevicedebugserverproxy.c4
9 files changed, 64 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am
index d342323..c2644e4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
1AUTOMAKE_OPTIONS = foreign 1AUTOMAKE_OPTIONS = foreign
2ACLOCAL_AMFLAGS = -I m4 2ACLOCAL_AMFLAGS = -I m4
3SUBDIRS = src include $(CYTHON_SUB) $(DEV_SUB) tools docs 3SUBDIRS = common src include $(CYTHON_SUB) $(DEV_SUB) tools docs
4 4
5DISTCHECK_CONFIGURE_FLAGS = --enable-dev-tools 5DISTCHECK_CONFIGURE_FLAGS = --enable-dev-tools
6 6
diff --git a/common/Makefile.am b/common/Makefile.am
new file mode 100644
index 0000000..dfa6852
--- /dev/null
+++ b/common/Makefile.am
@@ -0,0 +1,15 @@
1AM_CPPFLAGS = -I$(top_srcdir)/include
2
3AM_CFLAGS = $(GLOBAL_CFLAGS) $(libplist_CFLAGS) $(LFS_CFLAGS)
4AM_LDFLAGS = $(libplist_LIBS) ${libpthread_LIBS}
5
6noinst_LTLIBRARIES = libinternalcommon.la
7libinternalcommon_la_LIBADD =
8libinternalcommon_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined
9libinternalcommon_la_SOURCES = \
10 socket.c socket.h \
11 thread.c thread.h
12
13if WIN32
14libinternalcommon_la_LIBADD += -lole32
15endif
diff --git a/tools/socket.c b/common/socket.c
index c35de33..c35de33 100644
--- a/tools/socket.c
+++ b/common/socket.c
diff --git a/tools/socket.h b/common/socket.h
index c2b2599..c2b2599 100644
--- a/tools/socket.h
+++ b/common/socket.h
diff --git a/tools/thread.c b/common/thread.c
index f077243..2cf4321 100644
--- a/tools/thread.c
+++ b/common/thread.c
@@ -45,3 +45,39 @@ void thread_join(thread_t thread)
45 pthread_join(thread, NULL); 45 pthread_join(thread, NULL);
46#endif 46#endif
47} 47}
48
49void mutex_init(mutex_t* mutex)
50{
51#ifdef WIN32
52 InitializeCriticalSection(mutex);
53#else
54 pthread_mutex_init(mutex, NULL);
55#endif
56}
57
58void mutex_destroy(mutex_t* mutex)
59{
60#ifdef WIN32
61 DeleteCriticalSection(mutex);
62#else
63 pthread_mutex_destroy(mutex);
64#endif
65}
66
67void mutex_lock(mutex_t* mutex)
68{
69#ifdef WIN32
70 EnterCriticalSection(mutex);
71#else
72 pthread_mutex_lock(mutex);
73#endif
74}
75
76void mutex_unlock(mutex_t* mutex)
77{
78#ifdef WIN32
79 LeaveCriticalSection(mutex);
80#else
81 pthread_mutex_unlock(mutex);
82#endif
83}
diff --git a/tools/thread.h b/common/thread.h
index 983eeb5..e74ee74 100644
--- a/tools/thread.h
+++ b/common/thread.h
@@ -25,9 +25,11 @@
25#ifdef WIN32 25#ifdef WIN32
26#include <windows.h> 26#include <windows.h>
27typedef HANDLE thread_t; 27typedef HANDLE thread_t;
28typedef CRITICAL_SECTION mutex_t;
28#else 29#else
29#include <pthread.h> 30#include <pthread.h>
30typedef pthread_t thread_t; 31typedef pthread_t thread_t;
32typedef pthread_mutex_t mutex_t;
31#endif 33#endif
32 34
33typedef void* (*thread_func_t)(void* data); 35typedef void* (*thread_func_t)(void* data);
@@ -35,4 +37,9 @@ typedef void* (*thread_func_t)(void* data);
35int thread_create(thread_t* thread, thread_func_t thread_func, void* data); 37int thread_create(thread_t* thread, thread_func_t thread_func, void* data);
36void thread_join(thread_t thread); 38void thread_join(thread_t thread);
37 39
40void mutex_init(mutex_t* mutex);
41void mutex_destroy(mutex_t* mutex);
42void mutex_lock(mutex_t* mutex);
43void mutex_unlock(mutex_t* mutex);
44
38#endif 45#endif
diff --git a/configure.ac b/configure.ac
index cf644a8..57cd233 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,6 +223,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
223 223
224AC_OUTPUT([ 224AC_OUTPUT([
225Makefile 225Makefile
226common/Makefile
226src/Makefile 227src/Makefile
227include/Makefile 228include/Makefile
228dev/Makefile 229dev/Makefile
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 5b07a5e..57445d8 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -60,14 +60,12 @@ ideviceprovision_CFLAGS = $(AM_CFLAGS)
60ideviceprovision_LDFLAGS = $(AM_LDFLAGS) 60ideviceprovision_LDFLAGS = $(AM_LDFLAGS)
61ideviceprovision_LDADD = ../src/libimobiledevice.la 61ideviceprovision_LDADD = ../src/libimobiledevice.la
62 62
63idevicedebugserverproxy_SOURCES = idevicedebugserverproxy.c socket.c thread.c 63idevicedebugserverproxy_SOURCES = idevicedebugserverproxy.c
64idevicedebugserverproxy_CFLAGS = $(AM_CFLAGS) 64idevicedebugserverproxy_CFLAGS = $(AM_CFLAGS)
65idevicedebugserverproxy_LDFLAGS = $(AM_LDFLAGS) 65idevicedebugserverproxy_LDFLAGS = $(AM_LDFLAGS)
66idevicedebugserverproxy_LDADD = ../src/libimobiledevice.la 66idevicedebugserverproxy_LDADD = $(top_srcdir)/common/libinternalcommon.la ../src/libimobiledevice.la
67 67
68idevicediagnostics_SOURCES = idevicediagnostics.c 68idevicediagnostics_SOURCES = idevicediagnostics.c
69idevicediagnostics_CFLAGS = $(AM_CFLAGS) 69idevicediagnostics_CFLAGS = $(AM_CFLAGS)
70idevicediagnostics_LDFLAGS = $(AM_LDFLAGS) 70idevicediagnostics_LDFLAGS = $(AM_LDFLAGS)
71idevicediagnostics_LDADD = ../src/libimobiledevice.la 71idevicediagnostics_LDADD = ../src/libimobiledevice.la
72
73EXTRA_DIST = socket.h thread.h
diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c
index 3a25ebc..baf3cd7 100644
--- a/tools/idevicedebugserverproxy.c
+++ b/tools/idevicedebugserverproxy.c
@@ -28,8 +28,8 @@
28#include <libimobiledevice/libimobiledevice.h> 28#include <libimobiledevice/libimobiledevice.h>
29#include <libimobiledevice/lockdown.h> 29#include <libimobiledevice/lockdown.h>
30 30
31#include "socket.h" 31#include "common/socket.h"
32#include "thread.h" 32#include "common/thread.h"
33 33
34#define info(...) fprintf(stdout, __VA_ARGS__); fflush(stdout) 34#define info(...) fprintf(stdout, __VA_ARGS__); fflush(stdout)
35#define debug(...) if(debug_mode) fprintf(stdout, __VA_ARGS__) 35#define debug(...) if(debug_mode) fprintf(stdout, __VA_ARGS__)