diff options
| author | 2013-03-20 05:34:51 +0100 | |
|---|---|---|
| committer | 2013-03-20 05:34:51 +0100 | |
| commit | efca491e4c19868a68a099638552f9ba431dca4b (patch) | |
| tree | 4ed04996837945ca172da485b5aa507ca9b988c2 | |
| parent | a49c508bc489199f1f352be1f5aaaafb07c10506 (diff) | |
| download | libimobiledevice-efca491e4c19868a68a099638552f9ba431dca4b.tar.gz libimobiledevice-efca491e4c19868a68a099638552f9ba431dca4b.tar.bz2 | |
move thread and socket code to "common" subdir
| -rw-r--r-- | Makefile.am | 2 | ||||
| -rw-r--r-- | common/Makefile.am | 15 | ||||
| -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.ac | 1 | ||||
| -rw-r--r-- | tools/Makefile.am | 6 | ||||
| -rw-r--r-- | tools/idevicedebugserverproxy.c | 4 |
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 @@ | |||
| 1 | AUTOMAKE_OPTIONS = foreign | 1 | AUTOMAKE_OPTIONS = foreign |
| 2 | ACLOCAL_AMFLAGS = -I m4 | 2 | ACLOCAL_AMFLAGS = -I m4 |
| 3 | SUBDIRS = src include $(CYTHON_SUB) $(DEV_SUB) tools docs | 3 | SUBDIRS = common src include $(CYTHON_SUB) $(DEV_SUB) tools docs |
| 4 | 4 | ||
| 5 | DISTCHECK_CONFIGURE_FLAGS = --enable-dev-tools | 5 | DISTCHECK_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 @@ | |||
| 1 | AM_CPPFLAGS = -I$(top_srcdir)/include | ||
| 2 | |||
| 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libplist_CFLAGS) $(LFS_CFLAGS) | ||
| 4 | AM_LDFLAGS = $(libplist_LIBS) ${libpthread_LIBS} | ||
| 5 | |||
| 6 | noinst_LTLIBRARIES = libinternalcommon.la | ||
| 7 | libinternalcommon_la_LIBADD = | ||
| 8 | libinternalcommon_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined | ||
| 9 | libinternalcommon_la_SOURCES = \ | ||
| 10 | socket.c socket.h \ | ||
| 11 | thread.c thread.h | ||
| 12 | |||
| 13 | if WIN32 | ||
| 14 | libinternalcommon_la_LIBADD += -lole32 | ||
| 15 | 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) | |||
| 45 | pthread_join(thread, NULL); | 45 | pthread_join(thread, NULL); |
| 46 | #endif | 46 | #endif |
| 47 | } | 47 | } |
| 48 | |||
| 49 | void mutex_init(mutex_t* mutex) | ||
| 50 | { | ||
| 51 | #ifdef WIN32 | ||
| 52 | InitializeCriticalSection(mutex); | ||
| 53 | #else | ||
| 54 | pthread_mutex_init(mutex, NULL); | ||
| 55 | #endif | ||
| 56 | } | ||
| 57 | |||
| 58 | void mutex_destroy(mutex_t* mutex) | ||
| 59 | { | ||
| 60 | #ifdef WIN32 | ||
| 61 | DeleteCriticalSection(mutex); | ||
| 62 | #else | ||
| 63 | pthread_mutex_destroy(mutex); | ||
| 64 | #endif | ||
| 65 | } | ||
| 66 | |||
| 67 | void mutex_lock(mutex_t* mutex) | ||
| 68 | { | ||
| 69 | #ifdef WIN32 | ||
| 70 | EnterCriticalSection(mutex); | ||
| 71 | #else | ||
| 72 | pthread_mutex_lock(mutex); | ||
| 73 | #endif | ||
| 74 | } | ||
| 75 | |||
| 76 | void 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> |
| 27 | typedef HANDLE thread_t; | 27 | typedef HANDLE thread_t; |
| 28 | typedef CRITICAL_SECTION mutex_t; | ||
| 28 | #else | 29 | #else |
| 29 | #include <pthread.h> | 30 | #include <pthread.h> |
| 30 | typedef pthread_t thread_t; | 31 | typedef pthread_t thread_t; |
| 32 | typedef pthread_mutex_t mutex_t; | ||
| 31 | #endif | 33 | #endif |
| 32 | 34 | ||
| 33 | typedef void* (*thread_func_t)(void* data); | 35 | typedef void* (*thread_func_t)(void* data); |
| @@ -35,4 +37,9 @@ typedef void* (*thread_func_t)(void* data); | |||
| 35 | int thread_create(thread_t* thread, thread_func_t thread_func, void* data); | 37 | int thread_create(thread_t* thread, thread_func_t thread_func, void* data); |
| 36 | void thread_join(thread_t thread); | 38 | void thread_join(thread_t thread); |
| 37 | 39 | ||
| 40 | void mutex_init(mutex_t* mutex); | ||
| 41 | void mutex_destroy(mutex_t* mutex); | ||
| 42 | void mutex_lock(mutex_t* mutex); | ||
| 43 | void 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 | ||
| 224 | AC_OUTPUT([ | 224 | AC_OUTPUT([ |
| 225 | Makefile | 225 | Makefile |
| 226 | common/Makefile | ||
| 226 | src/Makefile | 227 | src/Makefile |
| 227 | include/Makefile | 228 | include/Makefile |
| 228 | dev/Makefile | 229 | 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) | |||
| 60 | ideviceprovision_LDFLAGS = $(AM_LDFLAGS) | 60 | ideviceprovision_LDFLAGS = $(AM_LDFLAGS) |
| 61 | ideviceprovision_LDADD = ../src/libimobiledevice.la | 61 | ideviceprovision_LDADD = ../src/libimobiledevice.la |
| 62 | 62 | ||
| 63 | idevicedebugserverproxy_SOURCES = idevicedebugserverproxy.c socket.c thread.c | 63 | idevicedebugserverproxy_SOURCES = idevicedebugserverproxy.c |
| 64 | idevicedebugserverproxy_CFLAGS = $(AM_CFLAGS) | 64 | idevicedebugserverproxy_CFLAGS = $(AM_CFLAGS) |
| 65 | idevicedebugserverproxy_LDFLAGS = $(AM_LDFLAGS) | 65 | idevicedebugserverproxy_LDFLAGS = $(AM_LDFLAGS) |
| 66 | idevicedebugserverproxy_LDADD = ../src/libimobiledevice.la | 66 | idevicedebugserverproxy_LDADD = $(top_srcdir)/common/libinternalcommon.la ../src/libimobiledevice.la |
| 67 | 67 | ||
| 68 | idevicediagnostics_SOURCES = idevicediagnostics.c | 68 | idevicediagnostics_SOURCES = idevicediagnostics.c |
| 69 | idevicediagnostics_CFLAGS = $(AM_CFLAGS) | 69 | idevicediagnostics_CFLAGS = $(AM_CFLAGS) |
| 70 | idevicediagnostics_LDFLAGS = $(AM_LDFLAGS) | 70 | idevicediagnostics_LDFLAGS = $(AM_LDFLAGS) |
| 71 | idevicediagnostics_LDADD = ../src/libimobiledevice.la | 71 | idevicediagnostics_LDADD = ../src/libimobiledevice.la |
| 72 | |||
| 73 | 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 @@ | |||
| 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__) |
