From 475c9679716eec92e3508063b7486e3508c4c974 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sat, 10 Sep 2011 19:08:39 +0200 Subject: WIN32: use windows threads and mutexes instead of pthread_* --- src/sbservices.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/sbservices.c') diff --git a/src/sbservices.c b/src/sbservices.c index dd5f571..7f050bf 100644 --- a/src/sbservices.c +++ b/src/sbservices.c @@ -36,7 +36,11 @@ static void sbs_lock(sbservices_client_t client) { debug_info("SBServices: Locked"); +#ifdef WIN32 + EnterCriticalSection(&client->mutex); +#else pthread_mutex_lock(&client->mutex); +#endif } /** @@ -47,7 +51,11 @@ static void sbs_lock(sbservices_client_t client) static void sbs_unlock(sbservices_client_t client) { debug_info("SBServices: Unlocked"); +#ifdef WIN32 + LeaveCriticalSection(&client->mutex); +#else pthread_mutex_unlock(&client->mutex); +#endif } /** @@ -100,7 +108,11 @@ sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbserv sbservices_client_t client_loc = (sbservices_client_t) malloc(sizeof(struct sbservices_client_private)); client_loc->parent = plistclient; +#ifdef WIN32 + InitializeCriticalSection(&client_loc->mutex); +#else pthread_mutex_init(&client_loc->mutex, NULL); +#endif *client = client_loc; return SBSERVICES_E_SUCCESS; @@ -122,7 +134,11 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client) sbservices_error_t err = sbservices_error(property_list_service_client_free(client->parent)); client->parent = NULL; +#ifdef WIN32 + DeleteCriticalSection(&client->mutex); +#else pthread_mutex_destroy(&client->mutex); +#endif free(client); return err; -- cgit v1.1-32-gdbae