From b2924a1549d874fb86deaad5fd2438e567c65bf4 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 20 Mar 2013 05:38:06 +0100 Subject: use new internal common code for thread, mutex, and socket operations --- tools/Makefile.am | 2 +- tools/idevicesyslog.c | 29 ++++++----------------------- 2 files changed, 7 insertions(+), 24 deletions(-) (limited to 'tools') 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 #define sleep(x) Sleep(x*1000) -#else -#include #endif #include #include -#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) { -- cgit v1.1-32-gdbae