summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-20 05:34:51 +0100
committerGravatar Nikias Bassen2013-03-20 05:34:51 +0100
commitefca491e4c19868a68a099638552f9ba431dca4b (patch)
tree4ed04996837945ca172da485b5aa507ca9b988c2
parenta49c508bc489199f1f352be1f5aaaafb07c10506 (diff)
downloadlibimobiledevice-efca491e4c19868a68a099638552f9ba431dca4b.tar.gz
libimobiledevice-efca491e4c19868a68a099638552f9ba431dca4b.tar.bz2
move thread and socket code to "common" subdir
-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 @@
AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = src include $(CYTHON_SUB) $(DEV_SUB) tools docs
+SUBDIRS = common src include $(CYTHON_SUB) $(DEV_SUB) tools docs
DISTCHECK_CONFIGURE_FLAGS = --enable-dev-tools
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 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+AM_CFLAGS = $(GLOBAL_CFLAGS) $(libplist_CFLAGS) $(LFS_CFLAGS)
+AM_LDFLAGS = $(libplist_LIBS) ${libpthread_LIBS}
+
+noinst_LTLIBRARIES = libinternalcommon.la
+libinternalcommon_la_LIBADD =
+libinternalcommon_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined
+libinternalcommon_la_SOURCES = \
+ socket.c socket.h \
+ thread.c thread.h
+
+if WIN32
+libinternalcommon_la_LIBADD += -lole32
+endif
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)
pthread_join(thread, NULL);
#endif
}
+
+void mutex_init(mutex_t* mutex)
+{
+#ifdef WIN32
+ InitializeCriticalSection(mutex);
+#else
+ pthread_mutex_init(mutex, NULL);
+#endif
+}
+
+void mutex_destroy(mutex_t* mutex)
+{
+#ifdef WIN32
+ DeleteCriticalSection(mutex);
+#else
+ pthread_mutex_destroy(mutex);
+#endif
+}
+
+void mutex_lock(mutex_t* mutex)
+{
+#ifdef WIN32
+ EnterCriticalSection(mutex);
+#else
+ pthread_mutex_lock(mutex);
+#endif
+}
+
+void mutex_unlock(mutex_t* mutex)
+{
+#ifdef WIN32
+ LeaveCriticalSection(mutex);
+#else
+ pthread_mutex_unlock(mutex);
+#endif
+}
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 @@
#ifdef WIN32
#include <windows.h>
typedef HANDLE thread_t;
+typedef CRITICAL_SECTION mutex_t;
#else
#include <pthread.h>
typedef pthread_t thread_t;
+typedef pthread_mutex_t mutex_t;
#endif
typedef void* (*thread_func_t)(void* data);
@@ -35,4 +37,9 @@ typedef void* (*thread_func_t)(void* data);
int thread_create(thread_t* thread, thread_func_t thread_func, void* data);
void thread_join(thread_t thread);
+void mutex_init(mutex_t* mutex);
+void mutex_destroy(mutex_t* mutex);
+void mutex_lock(mutex_t* mutex);
+void mutex_unlock(mutex_t* mutex);
+
#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])])
AC_OUTPUT([
Makefile
+common/Makefile
src/Makefile
include/Makefile
dev/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)
ideviceprovision_LDFLAGS = $(AM_LDFLAGS)
ideviceprovision_LDADD = ../src/libimobiledevice.la
-idevicedebugserverproxy_SOURCES = idevicedebugserverproxy.c socket.c thread.c
+idevicedebugserverproxy_SOURCES = idevicedebugserverproxy.c
idevicedebugserverproxy_CFLAGS = $(AM_CFLAGS)
idevicedebugserverproxy_LDFLAGS = $(AM_LDFLAGS)
-idevicedebugserverproxy_LDADD = ../src/libimobiledevice.la
+idevicedebugserverproxy_LDADD = $(top_srcdir)/common/libinternalcommon.la ../src/libimobiledevice.la
idevicediagnostics_SOURCES = idevicediagnostics.c
idevicediagnostics_CFLAGS = $(AM_CFLAGS)
idevicediagnostics_LDFLAGS = $(AM_LDFLAGS)
idevicediagnostics_LDADD = ../src/libimobiledevice.la
-
-EXTRA_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 @@
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
-#include "socket.h"
-#include "thread.h"
+#include "common/socket.h"
+#include "common/thread.h"
#define info(...) fprintf(stdout, __VA_ARGS__); fflush(stdout)
#define debug(...) if(debug_mode) fprintf(stdout, __VA_ARGS__)