diff --git a/include/winpr/handle.h b/include/winpr/handle.h new file mode 100644 index 000000000..284677ffa --- /dev/null +++ b/include/winpr/handle.h @@ -0,0 +1,45 @@ +/** + * WinPR: Windows Portable Runtime + * Handle Management + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_HANDLE_H +#define WINPR_HANDLE_H + +#include +#include +#include +#include +#include + +#ifndef _WIN32 + +#define HANDLE_FLAG_INHERIT 0x00000001 +#define HANDLE_FLAG_PROTECT_FROM_CLOSE 0x00000002 + +WINPR_API BOOL CloseHandle(HANDLE hObject); + +WINPR_API BOOL DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle, HANDLE hTargetProcessHandle, + LPHANDLE lpTargetHandle, DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwOptions); + +WINPR_API BOOL GetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags); +WINPR_API BOOL SetHandleInformation(HANDLE hObject, DWORD dwMask, DWORD dwFlags); + +#endif + +#endif /* WINPR_HANDLE_H */ + diff --git a/include/winpr/heap.h b/include/winpr/heap.h new file mode 100644 index 000000000..2d5d256cd --- /dev/null +++ b/include/winpr/heap.h @@ -0,0 +1,44 @@ +/** + * WinPR: Windows Portable Runtime + * Heap Memory Allocation + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_HEAP_H +#define WINPR_HEAP_H + +#include +#include +#include +#include +#include + +#ifndef _WIN32 + +#define HEAP_GENERATE_EXCEPTIONS 0x00000004 +#define HEAP_NO_SERIALIZE 0x00000001 +#define HEAP_ZERO_MEMORY 0x00000008 +#define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010 + +WINPR_API HANDLE GetProcessHeap(void); +WINPR_API LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes); +WINPR_API LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes); +WINPR_API BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem); + +#endif + +#endif /* WINPR_HEAP_H */ + diff --git a/include/winpr/memory.h b/include/winpr/memory.h index 32b7c1467..c1a9aa6a6 100644 --- a/include/winpr/memory.h +++ b/include/winpr/memory.h @@ -38,16 +38,9 @@ #define RtlFillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length)) #define RtlZeroMemory(Destination, Length) memset((Destination), 0, (Length)) -#define HEAP_GENERATE_EXCEPTIONS 0x00000004 -#define HEAP_NO_SERIALIZE 0x00000001 -#define HEAP_ZERO_MEMORY 0x00000008 -#define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010 - -WINPR_API HANDLE GetProcessHeap(void); -WINPR_API LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes); -WINPR_API LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes); -WINPR_API BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem); - #endif +#include + #endif /* WINPR_CRT_MEMORY_H */ + diff --git a/include/winpr/registry.h b/include/winpr/registry.h index 6cadc8c32..f1069f16b 100644 --- a/include/winpr/registry.h +++ b/include/winpr/registry.h @@ -148,13 +148,6 @@ typedef ACCESS_MASK REGSAM; #define RRF_NOEXPAND 0x10000000 #define RRF_ZEROONFAILURE 0x20000000 -typedef struct _SECURITY_ATTRIBUTES -{ - DWORD nLength; - LPVOID lpSecurityDescriptor; - BOOL bInheritHandle; -} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; - struct val_context { int valuelen; diff --git a/include/winpr/synch.h b/include/winpr/synch.h new file mode 100644 index 000000000..859289f23 --- /dev/null +++ b/include/winpr/synch.h @@ -0,0 +1,64 @@ +/** + * WinPR: Windows Portable Runtime + * Synchronization Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SYNCH_H +#define WINPR_SYNCH_H + +#include +#include +#include +#include +#include + +#include + +#ifndef _WIN32 + +WINPR_API HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCSTR lpName); +WINPR_API HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCWSTR lpName); + +#ifdef UNICODE +#define CreateSemaphore CreateSemaphoreW +#else +#define CreateSemaphore CreateSemaphoreA +#endif + +WINPR_API HANDLE OpenSemaphoreA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName); +WINPR_API HANDLE OpenSemaphoreW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName); + +#ifdef UNICODE +#define OpenSemaphore OpenSemaphoreW +#else +#define OpenSemaphore OpenSemaphoreA +#endif + +WINPR_API BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount); + +#define WAIT_OBJECT_0 0x00000000L +#define WAIT_ABANDONED 0x00000080L +#define WAIT_TIMEOUT 0x00000102L +#define WAIT_FAILED ((DWORD) 0xFFFFFFFF) + +WINPR_API DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds); +WINPR_API DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds); + +#endif + +#endif /* WINPR_SYNCH_H */ + diff --git a/include/winpr/wtypes.h b/include/winpr/wtypes.h index a8a9b0ad9..d0afe9277 100644 --- a/include/winpr/wtypes.h +++ b/include/winpr/wtypes.h @@ -54,7 +54,7 @@ typedef float FLOAT; typedef unsigned char UCHAR, *PUCHAR; typedef short SHORT; -typedef void* HANDLE; +typedef void* HANDLE, *LPHANDLE; typedef DWORD HCALL; typedef int INT, *LPINT; typedef signed char INT8; @@ -176,6 +176,13 @@ typedef struct _SECURITY_DESCRIPTOR PACL Dacl; } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR; +typedef struct _SECURITY_ATTRIBUTES +{ + DWORD nLength; + LPVOID lpSecurityDescriptor; + BOOL bInheritHandle; +} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; + #endif typedef BYTE byte; diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index e06e66934..77611e022 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -19,6 +19,9 @@ add_subdirectory(crt) add_subdirectory(utils) +add_subdirectory(heap) +add_subdirectory(handle) +add_subdirectory(synch) add_subdirectory(bcrypt) add_subdirectory(rpc) add_subdirectory(sspi) diff --git a/winpr/crt/memory.c b/winpr/crt/memory.c index cb859e056..0f9b16f39 100644 --- a/winpr/crt/memory.c +++ b/winpr/crt/memory.c @@ -24,36 +24,6 @@ #ifndef _WIN32 -HANDLE GetProcessHeap(void) -{ - return NULL; -} -LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes) -{ - LPVOID lpMem = NULL; - - if (dwFlags & HEAP_ZERO_MEMORY) - lpMem = calloc(1, dwBytes); - else - lpMem = malloc(dwBytes); - - return lpMem; -} - -LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes) -{ - LPVOID lpNewMem; - - lpNewMem = realloc(lpMem, dwBytes); - - return lpNewMem; -} - -BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) -{ - free(lpMem); - return 1; -} #endif diff --git a/winpr/handle/CMakeLists.txt b/winpr/handle/CMakeLists.txt new file mode 100644 index 000000000..16edeb710 --- /dev/null +++ b/winpr/handle/CMakeLists.txt @@ -0,0 +1,28 @@ +# WinPR: Windows Portable Runtime +# libwinpr-handle cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(WINPR_HANDLE_SRCS + handle.c) + +add_library(winpr-handle ${WINPR_HANDLE_SRCS}) + +set_target_properties(winpr-handle PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") + +install(TARGETS winpr-handle DESTINATION ${CMAKE_INSTALL_LIBDIR}) + diff --git a/winpr/handle/handle.c b/winpr/handle/handle.c new file mode 100644 index 000000000..098f2e331 --- /dev/null +++ b/winpr/handle/handle.c @@ -0,0 +1,66 @@ +/** + * WinPR: Windows Portable Runtime + * Handle Management + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef _WIN32 + +#if defined __APPLE__ +#include +#include +#include +#include +#include +#define winpr_sem_t semaphore_td +#else +#include +#include +#define winpr_sem_t sem_t +#endif + +BOOL CloseHandle(HANDLE hObject) +{ +#if defined __APPLE__ + semaphore_destroy(mach_task_self(), *((winpr_sem_t*) hObject)); +#else + sem_destroy((winpr_sem_t*) hObject); +#endif + + free(hObject); + + return 1; +} + +BOOL DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle, HANDLE hTargetProcessHandle, + LPHANDLE lpTargetHandle, DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwOptions) +{ + return 1; +} + +BOOL GetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags) +{ + return 1; +} + +BOOL SetHandleInformation(HANDLE hObject, DWORD dwMask, DWORD dwFlags) +{ + return 1; +} + +#endif diff --git a/winpr/heap/CMakeLists.txt b/winpr/heap/CMakeLists.txt new file mode 100644 index 000000000..4f708b521 --- /dev/null +++ b/winpr/heap/CMakeLists.txt @@ -0,0 +1,28 @@ +# WinPR: Windows Portable Runtime +# libwinpr-heap cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(WINPR_HEAP_SRCS + heap.c) + +add_library(winpr-heap ${WINPR_HEAP_SRCS}) + +set_target_properties(winpr-heap PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") + +install(TARGETS winpr-heap DESTINATION ${CMAKE_INSTALL_LIBDIR}) + diff --git a/winpr/heap/heap.c b/winpr/heap/heap.c new file mode 100644 index 000000000..cb859e056 --- /dev/null +++ b/winpr/heap/heap.c @@ -0,0 +1,59 @@ +/** + * WinPR: Windows Portable Runtime + * Memory Allocation + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +/* Memory Allocation: http://msdn.microsoft.com/en-us/library/hk1k7x6x.aspx */ +/* Memory Management Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366781/ */ + +#ifndef _WIN32 + +HANDLE GetProcessHeap(void) +{ + return NULL; +} + +LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes) +{ + LPVOID lpMem = NULL; + + if (dwFlags & HEAP_ZERO_MEMORY) + lpMem = calloc(1, dwBytes); + else + lpMem = malloc(dwBytes); + + return lpMem; +} + +LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes) +{ + LPVOID lpNewMem; + + lpNewMem = realloc(lpMem, dwBytes); + + return lpNewMem; +} + +BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) +{ + free(lpMem); + return 1; +} + +#endif diff --git a/winpr/sspi/sspi.c b/winpr/sspi/sspi.c index 40a1bb9f8..1df13c3e7 100644 --- a/winpr/sspi/sspi.c +++ b/winpr/sspi/sspi.c @@ -122,8 +122,8 @@ void sspi_ContextBufferAllocTableGrow() size = sizeof(CONTEXT_BUFFER_ALLOC_ENTRY) * ContextBufferAllocTable.cMaxEntries; - ContextBufferAllocTable.entries = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ContextBufferAllocTable.entries, size); - memset((void*) &ContextBufferAllocTable.entries[ContextBufferAllocTable.cMaxEntries / 2], 0, size / 2); + ContextBufferAllocTable.entries = realloc(ContextBufferAllocTable.entries, size); + ZeroMemory((void*) &ContextBufferAllocTable.entries[ContextBufferAllocTable.cMaxEntries / 2], size / 2); } void sspi_ContextBufferAllocTableFree() diff --git a/winpr/synch/CMakeLists.txt b/winpr/synch/CMakeLists.txt new file mode 100644 index 000000000..d60f73c40 --- /dev/null +++ b/winpr/synch/CMakeLists.txt @@ -0,0 +1,34 @@ +# WinPR: Windows Portable Runtime +# libwinpr-synch cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(WINPR_SYNCH_SRCS + critical.c + event.c + mutex.c + semaphore.c + sleep.c) + +add_library(winpr-synch ${WINPR_SYNCH_SRCS}) + +set_target_properties(winpr-synch PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") + +target_link_libraries(winpr-synch winpr-handle) + +install(TARGETS winpr-synch DESTINATION ${CMAKE_INSTALL_LIBDIR}) + diff --git a/winpr/synch/critical.c b/winpr/synch/critical.c new file mode 100644 index 000000000..b929ef678 --- /dev/null +++ b/winpr/synch/critical.c @@ -0,0 +1,23 @@ +/** + * WinPR: Windows Portable Runtime + * Synchronization Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + + diff --git a/winpr/synch/event.c b/winpr/synch/event.c new file mode 100644 index 000000000..b929ef678 --- /dev/null +++ b/winpr/synch/event.c @@ -0,0 +1,23 @@ +/** + * WinPR: Windows Portable Runtime + * Synchronization Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + + diff --git a/winpr/synch/mutex.c b/winpr/synch/mutex.c new file mode 100644 index 000000000..b929ef678 --- /dev/null +++ b/winpr/synch/mutex.c @@ -0,0 +1,23 @@ +/** + * WinPR: Windows Portable Runtime + * Synchronization Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + + diff --git a/winpr/synch/semaphore.c b/winpr/synch/semaphore.c new file mode 100644 index 000000000..93175148a --- /dev/null +++ b/winpr/synch/semaphore.c @@ -0,0 +1,104 @@ +/** + * WinPR: Windows Portable Runtime + * Synchronization Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef _WIN32 + +#if defined __APPLE__ +#include +#include +#include +#include +#include +#define winpr_sem_t semaphore_td +#else +#include +#include +#define winpr_sem_t sem_t +#endif + +HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCSTR lpName) +{ + winpr_sem_t* hSemaphore; + + hSemaphore = malloc(sizeof(winpr_sem_t)); + +#if defined __APPLE__ + semaphore_create(mach_task_self(), hSemaphore, SYNC_POLICY_FIFO, lMaximumCount); +#else + sem_init(hSemaphore, 0, lMaximumCount); +#endif + + return (HANDLE) hSemaphore; +} + +HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCWSTR lpName) +{ + winpr_sem_t* hSemaphore; + + hSemaphore = malloc(sizeof(winpr_sem_t)); + +#if defined __APPLE__ + semaphore_create(mach_task_self(), hSemaphore, SYNC_POLICY_FIFO, lMaximumCount); +#else + sem_init(hSemaphore, 0, lMaximumCount); +#endif + + return (HANDLE) hSemaphore; +} + +HANDLE OpenSemaphoreA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName) +{ + return NULL; +} + +HANDLE OpenSemaphoreW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName) +{ + return NULL; +} + +BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount) +{ +#if defined __APPLE__ + semaphore_signal(*((winpr_sem_t*) hSemaphore)); +#else + sem_post((winpr_sem_t*) hSemaphore); +#endif + + return 1; +} + +DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) +{ +#if defined __APPLE__ + semaphore_wait(*((winpr_sem_t*) hHandle)); +#else + sem_wait((winpr_sem_t*) hHandle); +#endif + + return WAIT_OBJECT_0; +} + +DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds) +{ + return 0; +} + +#endif diff --git a/winpr/synch/sleep.c b/winpr/synch/sleep.c new file mode 100644 index 000000000..b929ef678 --- /dev/null +++ b/winpr/synch/sleep.c @@ -0,0 +1,23 @@ +/** + * WinPR: Windows Portable Runtime + * Synchronization Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +