libwinpr-synch: stubbed more

This commit is contained in:
Marc-André Moreau 2012-09-18 15:51:33 -04:00
parent deec68be19
commit 78723f019f
21 changed files with 788 additions and 148 deletions

View File

@ -29,9 +29,10 @@
#define HANDLE_TYPE_NONE 0
#define HANDLE_TYPE_THREAD 1
#define HANDLE_TYPE_MUTEX 2
#define HANDLE_TYPE_SEMAPHORE 3
#define HANDLE_TYPE_EVENT 4
#define HANDLE_TYPE_EVENT 2
#define HANDLE_TYPE_MUTEX 3
#define HANDLE_TYPE_SEMAPHORE 4
#define HANDLE_TYPE_TIMER 5
WINPR_API HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object);
WINPR_API BOOL winpr_Handle_Remove(HANDLE handle);

View File

@ -0,0 +1,91 @@
/**
* WinPR: Windows Portable Runtime
* Interlocked Singly-Linked Lists
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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_INTERLOCKED_H
#define WINPR_INTERLOCKED_H
#include <winpr/spec.h>
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
#ifndef _WIN32
#ifdef _AMD64_
typedef struct _SLIST_ENTRY *PSLIST_ENTRY;
typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY
{
PSLIST_ENTRY Next;
} SLIST_ENTRY;
#else /* _AMD64_ */
#define SLIST_ENTRY SINGLE_LIST_ENTRY
#define _SLIST_ENTRY _SINGLE_LIST_ENTRY
#define PSLIST_ENTRY PSINGLE_LIST_ENTRY
#endif /* _AMD64_ */
#if defined(_AMD64_)
typedef struct DECLSPEC_ALIGN(16) _SLIST_HEADER
{
ULONGLONG Alignment;
ULONGLONG Region;
} SLIST_HEADER;
typedef struct _SLIST_HEADER *PSLIST_HEADER;
#else /* _AMD64_ */
typedef union _SLIST_HEADER
{
ULONGLONG Alignment;
struct
{
SLIST_ENTRY Next;
WORD Depth;
WORD Sequence;
} DUMMYSTRUCTNAME;
} SLIST_HEADER, *PSLIST_HEADER;
#endif /* _AMD64_ */
WINPR_API VOID InitializeSListHead(PSLIST_HEADER ListHead);
WINPR_API PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead);
WINPR_API PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry);
WINPR_API PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count);
WINPR_API PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead);
WINPR_API USHORT QueryDepthSList(PSLIST_HEADER ListHead);
WINPR_API LONG InterlockedIncrement(LONG volatile *Addend);
WINPR_API LONG InterlockedDecrement(LONG volatile *Addend);
WINPR_API LONG InterlockedExchange(LONG volatile *Target, LONG Value);
WINPR_API LONG InterlockedExchangeAdd(LONG volatile *Addend, LONG Value);
WINPR_API LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange, LONG Comperand);
WINPR_API LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 ExChange, LONG64 Comperand);
#endif /* _WIN32 */
#endif /* WINPR_INTERLOCKED_H */

View File

@ -0,0 +1,41 @@
/**
* WinPR: Windows Portable Runtime
* Compiler Specification Strings
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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_SPEC_H
#define WINPR_SPEC_H
#if defined(__x86_64) && \
!(defined(_X86_) || defined(__i386__) || defined(_IA64_))
#if !defined(_AMD64_)
#define _AMD64_
#endif
#endif /* _AMD64_ */
#ifndef DECLSPEC_ALIGN
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
#define DECLSPEC_ALIGN(x) __declspec(align(x))
#elif defined(__GNUC__)
#define DECLSPEC_ALIGN(x) __attribute__ ((__aligned__ (x)))
#else
#define DECLSPEC_ALIGN(x)
#endif
#endif /* DECLSPEC_ALIGN */
#endif /* WINPR_SPEC_H */

View File

@ -58,19 +58,15 @@ WINPR_API BOOL ReleaseMutex(HANDLE hMutex);
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
#define CreateSemaphore CreateSemaphoreW
#define OpenSemaphore OpenSemaphoreW
#else
#define OpenSemaphore OpenSemaphoreA
#define CreateSemaphore CreateSemaphoreA
#define OpenSemaphore OpenSemaphoreA
#endif
WINPR_API BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount);
@ -94,6 +90,24 @@ WINPR_API HANDLE OpenEventW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR
WINPR_API BOOL SetEvent(HANDLE hEvent);
WINPR_API BOOL ResetEvent(HANDLE hEvent);
/* One-Time Initialization */
#define CALLBACK
typedef union _RTL_RUN_ONCE
{
PVOID Ptr;
} RTL_RUN_ONCE, *PRTL_RUN_ONCE;
typedef PRTL_RUN_ONCE PINIT_ONCE;
typedef PRTL_RUN_ONCE LPINIT_ONCE;
typedef BOOL CALLBACK (*PINIT_ONCE_FN) (PINIT_ONCE InitOnce, PVOID Parameter, PVOID* Context);
WINPR_API BOOL InitOnceBeginInitialize(LPINIT_ONCE lpInitOnce, DWORD dwFlags, PBOOL fPending, LPVOID* lpContext);
WINPR_API BOOL InitOnceComplete(LPINIT_ONCE lpInitOnce, DWORD dwFlags, LPVOID lpContext);
WINPR_API BOOL InitOnceExecuteOnce(PINIT_ONCE InitOnce, PINIT_ONCE_FN InitFn, PVOID Parameter, LPVOID* Context);
WINPR_API VOID InitOnceInitialize(PINIT_ONCE InitOnce);
/* Slim Reader/Writer (SRW) Lock */
typedef PVOID RTL_SRWLOCK;
@ -131,6 +145,7 @@ typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION;
typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;
WINPR_API VOID InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
WINPR_API BOOL InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags);
WINPR_API BOOL InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount);
WINPR_API DWORD SetCriticalSectionSpinCount(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount);
@ -156,12 +171,66 @@ WINPR_API BOOL DeleteSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrier)
WINPR_API VOID Sleep(DWORD dwMilliseconds);
WINPR_API DWORD SleepEx(DWORD dwMilliseconds, BOOL bAlertable);
/* Address */
WINPR_API VOID WakeByAddressAll(PVOID Address);
WINPR_API VOID WakeByAddressSingle(PVOID Address);
WINPR_API BOOL WaitOnAddress(VOID volatile *Address, PVOID CompareAddress, SIZE_T AddressSize, DWORD dwMilliseconds);
/* Wait */
WINPR_API DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
WINPR_API DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds);
WINPR_API DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds, BOOL bAlertable);
WINPR_API DWORD SignalObjectAndWait(HANDLE hObjectToSignal, HANDLE hObjectToWaitOn, DWORD dwMilliseconds, BOOL bAlertable);
/* Waitable Timer */
typedef struct _REASON_CONTEXT
{
ULONG Version;
DWORD Flags;
union
{
struct
{
HMODULE LocalizedReasonModule;
ULONG LocalizedReasonId;
ULONG ReasonStringCount;
LPWSTR* ReasonStrings;
} Detailed;
LPWSTR SimpleReasonString;
} Reason;
} REASON_CONTEXT, *PREASON_CONTEXT;
typedef VOID (*PTIMERAPCROUTINE)(LPVOID lpArgToCompletionRoutine, DWORD dwTimerLowValue, DWORD dwTimerHighValue);
WINPR_API HANDLE CreateWaitableTimerExA(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess);
WINPR_API HANDLE CreateWaitableTimerExW(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess);
WINPR_API BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPeriod,
PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, BOOL fResume);
WINPR_API BOOL SetWaitableTimerEx(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPeriod,
PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay);
WINPR_API HANDLE OpenWaitableTimerA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpTimerName);
WINPR_API HANDLE OpenWaitableTimerW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpTimerName);
WINPR_API BOOL CancelWaitableTimer(HANDLE hTimer);
#ifdef UNICODE
#define CreateWaitableTimerEx CreateWaitableTimerExW
#define OpenWaitableTimer OpenWaitableTimerW
#else
#define CreateWaitableTimerEx CreateWaitableTimerExA
#define OpenWaitableTimer OpenWaitableTimerA
#endif
#endif
#endif /* WINPR_SYNCH_H */

View File

@ -79,6 +79,8 @@ typedef STARTUPINFOA STARTUPINFO;
typedef LPSTARTUPINFOA LPSTARTUPINFO;
#endif
/* Process */
WINPR_API BOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
@ -87,12 +89,6 @@ WINPR_API BOOL CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, L
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
#ifdef UNICODE
#define CreateProcess CreateProcessW
#else
#define CreateProcess CreateProcessA
#endif
WINPR_API BOOL CreateProcessAsUserA(HANDLE hToken, LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
@ -102,24 +98,30 @@ WINPR_API BOOL CreateProcessAsUserW(HANDLE hToken, LPCWSTR lpApplicationName, LP
LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
#ifdef UNICODE
#define CreateProcess CreateProcessW
#define CreateProcessAsUser CreateProcessAsUserW
#else
#define CreateProcess CreateProcessA
#define CreateProcessAsUser CreateProcessAsUserA
#endif
WINPR_API VOID ExitProcess(UINT uExitCode);
WINPR_API HANDLE GetCurrentProcess(VOID);
WINPR_API DWORD GetCurrentProcessId(VOID);
WINPR_API BOOL TerminateProcess(HANDLE hProcess, UINT uExitCode);
/* Thread */
WINPR_API HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,LPVOID lpParameter,DWORD dwCreationFlags,LPDWORD lpThreadId);
WINPR_API HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
WINPR_API VOID ExitProcess(UINT uExitCode);
WINPR_API VOID ExitThread(DWORD dwExitCode);
WINPR_API HANDLE GetCurrentProcess(VOID);
WINPR_API DWORD GetCurrentProcessId(VOID);
WINPR_API DWORD GetCurrentProcessorNumber(VOID);
WINPR_API HANDLE GetCurrentThread(VOID);
WINPR_API DWORD GetCurrentThreadId(VOID);
@ -127,9 +129,14 @@ WINPR_API DWORD ResumeThread(HANDLE hThread);
WINPR_API DWORD SuspendThread(HANDLE hThread);
WINPR_API BOOL SwitchToThread(VOID);
WINPR_API BOOL TerminateProcess(HANDLE hProcess, UINT uExitCode);
WINPR_API BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode);
/* Processor */
WINPR_API DWORD GetCurrentProcessorNumber(VOID);
/* Thread-Local Storage */
WINPR_API DWORD TlsAlloc(VOID);
WINPR_API LPVOID TlsGetValue(DWORD dwTlsIndex);
WINPR_API BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue);

View File

@ -160,6 +160,23 @@ typedef union _ULARGE_INTEGER
ULONGLONG QuadPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;
typedef union _LARGE_INTEGER
{
struct
{
DWORD LowPart;
LONG HighPart;
};
struct
{
DWORD LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} LARGE_INTEGER, *PLARGE_INTEGER;
typedef struct _FILETIME
{
DWORD dwLowDateTime;

View File

@ -28,6 +28,7 @@ endif()
add_subdirectory(crt)
add_subdirectory(utils)
add_subdirectory(heap)
add_subdirectory(interlocked)
add_subdirectory(handle)
add_subdirectory(synch)
add_subdirectory(thread)
@ -46,6 +47,7 @@ if(WITH_MONOLITHIC_BUILD)
$<TARGET_OBJECTS:winpr-crt>
$<TARGET_OBJECTS:winpr-utils>
$<TARGET_OBJECTS:winpr-heap>
$<TARGET_OBJECTS:winpr-interlocked>
$<TARGET_OBJECTS:winpr-handle>
$<TARGET_OBJECTS:winpr-synch>
$<TARGET_OBJECTS:winpr-thread>

View File

@ -0,0 +1,34 @@
# WinPR: Windows Portable Runtime
# libwinpr-interlocked cmake build script
#
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# 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_INTERLOCKED_SRCS
interlocked.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-interlocked OBJECT ${WINPR_INTERLOCKED_SRCS})
else()
add_library(winpr-interlocked ${WINPR_INTERLOCKED_SRCS})
endif()
set_target_properties(winpr-interlocked PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
if(WITH_MONOLITHIC_BUILD)
else()
install(TARGETS winpr-interlocked DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

View File

@ -0,0 +1,105 @@
/**
* WinPR: Windows Portable Runtime
* Interlocked Singly-Linked Lists
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/interlocked.h>
/**
* api-ms-win-core-interlocked-l1-2-0.dll:
*
* InitializeSListHead
* InterlockedPopEntrySList
* InterlockedPushEntrySList
* InterlockedPushListSListEx
* InterlockedFlushSList
* QueryDepthSList
* InterlockedIncrement
* InterlockedDecrement
* InterlockedExchange
* InterlockedExchangeAdd
* InterlockedCompareExchange
* InterlockedCompareExchange64
*/
#ifndef _WIN32
VOID InitializeSListHead(PSLIST_HEADER ListHead)
{
}
PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead)
{
return NULL;
}
PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry)
{
return NULL;
}
PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count)
{
return NULL;
}
PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead)
{
return NULL;
}
USHORT QueryDepthSList(PSLIST_HEADER ListHead)
{
return 0;
}
LONG InterlockedIncrement(LONG volatile *Addend)
{
return 0;
}
LONG InterlockedDecrement(LONG volatile *Addend)
{
return 0;
}
LONG InterlockedExchange(LONG volatile *Target, LONG Value)
{
return 0;
}
LONG InterlockedExchangeAdd(LONG volatile *Addend, LONG Value)
{
return 0;
}
LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange, LONG Comperand)
{
return 0;
}
LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 ExChange, LONG64 Comperand)
{
return 0;
}
#endif

View File

@ -19,16 +19,19 @@ set(CMAKE_THREAD_PREFER_PTHREAD)
find_required_package(Threads)
set(WINPR_SYNCH_SRCS
address.c
barrier.c
condition.c
critical.c
event.c
init.c
mutex.c
semaphore.c
sleep.c
srw.c
synch.c
synch.h
timer.c
wait.c)
if(WITH_MONOLITHIC_BUILD)
@ -57,3 +60,4 @@ else()
target_link_libraries(winpr-synch ${WINPR_SYNCH_LIBS})
install(TARGETS winpr-synch DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

View File

@ -0,0 +1,45 @@
/**
* WinPR: Windows Portable Runtime
* Synchronization Functions
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/synch.h>
/**
* WakeByAddressAll
* WakeByAddressSingle
* WaitOnAddress
*/
VOID WakeByAddressAll(PVOID Address)
{
}
VOID WakeByAddressSingle(PVOID Address)
{
}
BOOL WaitOnAddress(VOID volatile *Address, PVOID CompareAddress, SIZE_T AddressSize, DWORD dwMilliseconds)
{
return TRUE;
}

View File

@ -39,6 +39,11 @@ VOID InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
}
BOOL InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags)
{
return TRUE;
}
BOOL InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount)
{
return TRUE;

View File

@ -0,0 +1,51 @@
/**
* WinPR: Windows Portable Runtime
* Synchronization Functions
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/synch.h>
/**
* InitOnceBeginInitialize
* InitOnceComplete
* InitOnceExecuteOnce
* InitOnceInitialize
*/
BOOL InitOnceBeginInitialize(LPINIT_ONCE lpInitOnce, DWORD dwFlags, PBOOL fPending, LPVOID* lpContext)
{
return TRUE;
}
BOOL InitOnceComplete(LPINIT_ONCE lpInitOnce, DWORD dwFlags, LPVOID lpContext)
{
return TRUE;
}
BOOL InitOnceExecuteOnce(PINIT_ONCE InitOnce, PINIT_ONCE_FN InitFn, PVOID Parameter, LPVOID* Context)
{
return TRUE;
}
VOID InitOnceInitialize(PINIT_ONCE InitOnce)
{
}

View File

@ -23,21 +23,3 @@
#include <winpr/synch.h>
/**
* api-ms-win-core-synch-l1-2-0.dll:
*
* CancelWaitableTimer
* CreateWaitableTimerExW
* InitOnceBeginInitialize
* InitOnceComplete
* InitOnceExecuteOnce
* InitOnceInitialize
* OpenWaitableTimerW
* SetWaitableTimer
* SetWaitableTimerEx
* SignalObjectAndWait
* WaitOnAddress
* WakeByAddressAll
* WakeByAddressSingle
*/

View File

@ -0,0 +1,69 @@
/**
* WinPR: Windows Portable Runtime
* Synchronization Functions
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/synch.h>
/**
* CreateWaitableTimerExW
* OpenWaitableTimerW
* SetWaitableTimer
* SetWaitableTimerEx
* CancelWaitableTimer
*/
HANDLE CreateWaitableTimerExA(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess)
{
return NULL;
}
HANDLE CreateWaitableTimerExW(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess)
{
return NULL;
}
BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPeriod,
PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, BOOL fResume)
{
return TRUE;
}
BOOL SetWaitableTimerEx(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPeriod,
PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay)
{
return TRUE;
}
HANDLE OpenWaitableTimerA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpTimerName)
{
return NULL;
}
HANDLE OpenWaitableTimerW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpTimerName)
{
return NULL;
}
BOOL CancelWaitableTimer(HANDLE hTimer)
{
return TRUE;
}

View File

@ -29,6 +29,7 @@
* WaitForSingleObject
* WaitForSingleObjectEx
* WaitForMultipleObjectsEx
* SignalObjectAndWait
*/
DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
@ -51,3 +52,8 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait
{
return 0;
}
DWORD SignalObjectAndWait(HANDLE hObjectToSignal, HANDLE hObjectToWaitOn, DWORD dwMilliseconds, BOOL bAlertable)
{
return 0;
}

View File

@ -19,7 +19,10 @@ set(CMAKE_THREAD_PREFER_PTHREAD)
find_required_package(Threads)
set(WINPR_THREAD_SRCS
thread.c)
process.c
processor.c
thread.c
tls.c)
if(WITH_MONOLITHIC_BUILD)
add_library(winpr-thread OBJECT ${WINPR_THREAD_SRCS})

View File

@ -0,0 +1,112 @@
/**
* WinPR: Windows Portable Runtime
* Process Thread Functions
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/handle.h>
#include <winpr/thread.h>
/**
* CreateProcessA
* CreateProcessW
* CreateProcessAsUserA
* CreateProcessAsUserW
* ExitProcess
* GetCurrentProcess
* GetCurrentProcessId
* GetExitCodeProcess
* GetProcessHandleCount
* GetProcessId
* GetProcessIdOfThread
* GetProcessMitigationPolicy
* GetProcessTimes
* GetProcessVersion
* OpenProcess
* OpenProcessToken
* ProcessIdToSessionId
* SetProcessAffinityUpdateMode
* SetProcessMitigationPolicy
* SetProcessShutdownParameters
* TerminateProcess
*/
#ifndef _WIN32
#include <pthread.h>
typedef void *(*pthread_start_routine)(void*);
BOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
return TRUE;
}
BOOL CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
return TRUE;
}
BOOL CreateProcessAsUserA(HANDLE hToken, LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
return TRUE;
}
BOOL CreateProcessAsUserW(HANDLE hToken, LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
return TRUE;
}
VOID ExitProcess(UINT uExitCode)
{
}
HANDLE GetCurrentProcess(VOID)
{
return NULL;
}
DWORD GetCurrentProcessId(VOID)
{
return 0;
}
DWORD GetProcessId(HANDLE Process)
{
return 0;
}
BOOL TerminateProcess(HANDLE hProcess, UINT uExitCode)
{
return TRUE;
}
#endif

View File

@ -0,0 +1,44 @@
/**
* WinPR: Windows Portable Runtime
* Process Thread Functions
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/handle.h>
#include <winpr/thread.h>
/**
* GetCurrentProcessorNumber
* GetCurrentProcessorNumberEx
* GetThreadIdealProcessorEx
* SetThreadIdealProcessorEx
* IsProcessorFeaturePresent
*/
#ifndef _WIN32
DWORD GetCurrentProcessorNumber(VOID)
{
return 0;
}
#endif

View File

@ -28,33 +28,18 @@
/**
* api-ms-win-core-processthreads-l1-1-1.dll
*
* CreateProcessA
* CreateProcessAsUserW
* CreateProcessW
* CreateRemoteThread
* CreateRemoteThreadEx
* CreateThread
* DeleteProcThreadAttributeList
* ExitProcess
* ExitThread
* FlushInstructionCache
* FlushProcessWriteBuffers
* GetCurrentProcess
* GetCurrentProcessId
* GetCurrentProcessorNumber
* GetCurrentProcessorNumberEx
* GetCurrentThread
* GetCurrentThreadId
* GetCurrentThreadStackLimits
* GetExitCodeProcess
* GetExitCodeThread
* GetPriorityClass
* GetProcessHandleCount
* GetProcessId
* GetProcessIdOfThread
* GetProcessMitigationPolicy
* GetProcessTimes
* GetProcessVersion
* GetStartupInfoW
* GetThreadContext
* GetThreadId
@ -63,33 +48,20 @@
* GetThreadPriorityBoost
* GetThreadTimes
* InitializeProcThreadAttributeList
* IsProcessorFeaturePresent
* OpenProcess
* OpenProcessToken
* OpenThread
* OpenThreadToken
* ProcessIdToSessionId
* QueryProcessAffinityUpdateMode
* QueueUserAPC
* ResumeThread
* SetPriorityClass
* SetProcessAffinityUpdateMode
* SetProcessMitigationPolicy
* SetProcessShutdownParameters
* SetThreadContext
* SetThreadIdealProcessorEx
* SetThreadPriority
* SetThreadPriorityBoost
* SetThreadStackGuarantee
* SetThreadToken
* SuspendThread
* SwitchToThread
* TerminateProcess
* TerminateThread
* TlsAlloc
* TlsFree
* TlsGetValue
* TlsSetValue
* UpdateProcThreadAttribute
*/
@ -99,34 +71,6 @@
typedef void *(*pthread_start_routine)(void*);
BOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
return TRUE;
}
BOOL CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
return TRUE;
}
BOOL CreateProcessAsUserA(HANDLE hToken, LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
return TRUE;
}
BOOL CreateProcessAsUserW(HANDLE hToken, LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
return TRUE;
}
HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,LPVOID lpParameter,DWORD dwCreationFlags,LPDWORD lpThreadId)
{
@ -144,31 +88,11 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
return winpr_Handle_Insert(HANDLE_TYPE_THREAD, (void*) thread);
}
VOID ExitProcess(UINT uExitCode)
{
}
VOID ExitThread(DWORD dwExitCode)
{
}
HANDLE GetCurrentProcess(VOID)
{
return NULL;
}
DWORD GetCurrentProcessId(VOID)
{
return 0;
}
DWORD GetCurrentProcessorNumber(VOID)
{
return 0;
}
HANDLE GetCurrentThread(VOID)
{
return NULL;
@ -179,11 +103,6 @@ DWORD GetCurrentThreadId(VOID)
return 0;
}
DWORD GetProcessId(HANDLE Process)
{
return 0;
}
DWORD ResumeThread(HANDLE hThread)
{
return 0;
@ -199,35 +118,10 @@ BOOL SwitchToThread(VOID)
return TRUE;
}
BOOL TerminateProcess(HANDLE hProcess, UINT uExitCode)
{
return TRUE;
}
BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode)
{
return TRUE;
}
DWORD TlsAlloc(VOID)
{
return 0;
}
LPVOID TlsGetValue(DWORD dwTlsIndex)
{
return NULL;
}
BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
{
return TRUE;
}
BOOL TlsFree(DWORD dwTlsIndex)
{
return TRUE;
}
#endif

View File

@ -0,0 +1,58 @@
/**
* WinPR: Windows Portable Runtime
* Process Thread Functions
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/handle.h>
#include <winpr/thread.h>
/**
* TlsAlloc
* TlsFree
* TlsGetValue
* TlsSetValue
*/
#ifndef _WIN32
DWORD TlsAlloc(VOID)
{
return 0;
}
LPVOID TlsGetValue(DWORD dwTlsIndex)
{
return NULL;
}
BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
{
return TRUE;
}
BOOL TlsFree(DWORD dwTlsIndex)
{
return TRUE;
}
#endif