Skip to content

Commit

Permalink
win32: Remove windows.h from public headers
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Dec 11, 2023
1 parent e314faa commit 6096480
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
7 changes: 4 additions & 3 deletions include/libimobiledevice-glue/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
#include <stddef.h>

#ifdef WIN32
#include <windows.h>
typedef void* HANDLE;
typedef HANDLE THREAD_T;
typedef CRITICAL_SECTION mutex_t;
struct _RTL_CRITICAL_SECTION;
typedef struct _RTL_CRITICAL_SECTION mutex_t;
typedef struct {
HANDLE sem;
} cond_t;
typedef volatile struct {
LONG lock;
long lock;
int state;
} thread_once_t;
#define THREAD_ONCE_INIT {0, 0}
Expand Down
4 changes: 0 additions & 4 deletions include/libimobiledevice-glue/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
#include <config.h>
#endif

#ifdef WIN32
#include <windows.h>
#endif

#include <stdio.h>
#include <stdint.h>

Expand Down
13 changes: 8 additions & 5 deletions src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef WIN32
#include <windows.h>
#endif
#include "common.h"
#include "libimobiledevice-glue/thread.h"

LIBIMOBILEDEVICE_GLUE_API int thread_new(THREAD_T *thread, thread_func_t thread_func, void* data)
{
#ifdef WIN32
HANDLE th = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_func, data, 0, NULL);
HANDLE th = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)(void*)thread_func, data, 0, NULL);
if (th == NULL) {
return -1;
}
Expand Down Expand Up @@ -93,7 +96,7 @@ LIBIMOBILEDEVICE_GLUE_API int thread_cancel(THREAD_T thread)
LIBIMOBILEDEVICE_GLUE_API void mutex_init(mutex_t* mutex)
{
#ifdef WIN32
InitializeCriticalSection(mutex);
InitializeCriticalSection((LPCRITICAL_SECTION)mutex);
#else
pthread_mutex_init(mutex, NULL);
#endif
Expand All @@ -102,7 +105,7 @@ LIBIMOBILEDEVICE_GLUE_API void mutex_init(mutex_t* mutex)
LIBIMOBILEDEVICE_GLUE_API void mutex_destroy(mutex_t* mutex)
{
#ifdef WIN32
DeleteCriticalSection(mutex);
DeleteCriticalSection((LPCRITICAL_SECTION)mutex);
#else
pthread_mutex_destroy(mutex);
#endif
Expand All @@ -111,7 +114,7 @@ LIBIMOBILEDEVICE_GLUE_API void mutex_destroy(mutex_t* mutex)
LIBIMOBILEDEVICE_GLUE_API void mutex_lock(mutex_t* mutex)
{
#ifdef WIN32
EnterCriticalSection(mutex);
EnterCriticalSection((LPCRITICAL_SECTION)mutex);
#else
pthread_mutex_lock(mutex);
#endif
Expand All @@ -120,7 +123,7 @@ LIBIMOBILEDEVICE_GLUE_API void mutex_lock(mutex_t* mutex)
LIBIMOBILEDEVICE_GLUE_API void mutex_unlock(mutex_t* mutex)
{
#ifdef WIN32
LeaveCriticalSection(mutex);
LeaveCriticalSection((LPCRITICAL_SECTION)mutex);
#else
pthread_mutex_unlock(mutex);
#endif
Expand Down

0 comments on commit 6096480

Please sign in to comment.