summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-20 05:38:06 +0100
committerGravatar Nikias Bassen2013-03-20 05:38:06 +0100
commitb2924a1549d874fb86deaad5fd2438e567c65bf4 (patch)
treeead89f885a0492cdfc228a1c25326912e7d9b973 /tools
parentefca491e4c19868a68a099638552f9ba431dca4b (diff)
downloadlibimobiledevice-b2924a1549d874fb86deaad5fd2438e567c65bf4.tar.gz
libimobiledevice-b2924a1549d874fb86deaad5fd2438e567c65bf4.tar.bz2
use new internal common code for thread, mutex, and socket operations
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am2
-rw-r--r--tools/idevicesyslog.c29
2 files changed, 7 insertions, 24 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 57445d8..e668592 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -18,7 +18,7 @@ idevicepair_LDADD = ../src/libimobiledevice.la
idevicesyslog_SOURCES = idevicesyslog.c
idevicesyslog_CFLAGS = $(AM_CFLAGS)
idevicesyslog_LDFLAGS = $(AM_LDFLAGS)
-idevicesyslog_LDADD = ../src/libimobiledevice.la
+idevicesyslog_LDADD = $(top_srcdir)/common/libinternalcommon.la ../src/libimobiledevice.la
idevice_id_SOURCES = idevice_id.c
idevice_id_CFLAGS = $(AM_CFLAGS)
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 32163e6..3dd2257 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -29,13 +29,13 @@
#ifdef WIN32
#include <windows.h>
#define sleep(x) Sleep(x*1000)
-#else
-#include <pthread.h>
#endif
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
-#include "../src/service.h"
+
+#include "src/service.h"
+#include "common/thread.h"
static int quit_flag = 0;
@@ -46,11 +46,7 @@ static char* udid = NULL;
static idevice_t device = NULL;
static service_client_t syslog = NULL;
-#ifdef WIN32
-HANDLE worker = NULL;
-#else
-pthread_t worker;
-#endif
+thread_t worker = NULL;
static int logging = 0;
@@ -100,19 +96,10 @@ static int start_logging()
/* start worker thread */
logging = 1;
-#ifdef WIN32
- worker = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)syslog_worker, NULL, 0, NULL);
- if (worker == INVALID_HANDLE_VALUE) {
+ if (thread_create(&worker, syslog_worker, NULL) != 0) {
logging = 0;
return -1;
}
-#else
- if (pthread_create(&worker, NULL, syslog_worker, NULL) != 0) {
- logging = 0;
- return -1;
- }
-#endif
-
return 0;
}
@@ -127,11 +114,7 @@ static void stop_logging()
}
/* wait for thread to complete */
-#ifdef WIN32
- WaitForSingleObject(worker, INFINITE);
-#else
- pthread_join(worker, NULL);
-#endif
+ thread_join(worker);
}
if (device) {