2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2003-05-29 00:36:41 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/kernel32/thread/fls.c
|
|
|
|
* PURPOSE: Fiber local storage functions
|
|
|
|
* PROGRAMMER: KJK::Hyperion <noog@libero.it>
|
|
|
|
*
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* 28/05/2003 - created. Stubs only
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <k32.h>
|
|
|
|
|
2007-09-02 19:42:22 +00:00
|
|
|
#include <debug.h>
|
2003-05-29 00:36:41 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2010-01-09 20:51:33 +00:00
|
|
|
DWORD
|
|
|
|
WINAPI
|
|
|
|
FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback)
|
2003-05-29 00:36:41 +00:00
|
|
|
{
|
2010-01-09 20:51:33 +00:00
|
|
|
(void)lpCallback;
|
2003-05-29 00:36:41 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FLS_OUT_OF_INDEXES;
|
2003-05-29 00:36:41 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2010-01-09 20:51:33 +00:00
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
FlsFree(DWORD dwFlsIndex)
|
2003-05-29 00:36:41 +00:00
|
|
|
{
|
2010-01-09 20:51:33 +00:00
|
|
|
(void)dwFlsIndex;
|
2003-05-29 00:36:41 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
2003-05-29 00:36:41 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2010-01-09 20:51:33 +00:00
|
|
|
PVOID
|
|
|
|
WINAPI
|
|
|
|
FlsGetValue(DWORD dwFlsIndex)
|
2003-05-29 00:36:41 +00:00
|
|
|
{
|
2010-01-09 20:51:33 +00:00
|
|
|
PVOID *ppFlsSlots;
|
|
|
|
PVOID pRetVal;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2010-01-09 21:57:00 +00:00
|
|
|
if(dwFlsIndex >= 128) goto l_InvalidParam;
|
2003-05-29 00:36:41 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
ppFlsSlots = NtCurrentTeb()->FlsData;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2010-01-09 21:57:00 +00:00
|
|
|
if(ppFlsSlots == NULL) goto l_InvalidParam;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
SetLastError(0);
|
|
|
|
pRetVal = ppFlsSlots[dwFlsIndex + 2];
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
return pRetVal;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
|
|
|
l_InvalidParam:
|
2010-01-09 20:51:33 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return NULL;
|
2003-05-29 00:36:41 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2010-01-09 20:51:33 +00:00
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
FlsSetValue(DWORD dwFlsIndex, PVOID lpFlsData)
|
2003-05-29 00:36:41 +00:00
|
|
|
{
|
2010-01-09 20:51:33 +00:00
|
|
|
PVOID *ppFlsSlots;
|
|
|
|
TEB *pTeb = NtCurrentTeb();
|
2003-05-29 00:36:41 +00:00
|
|
|
|
2010-01-09 21:57:00 +00:00
|
|
|
if(dwFlsIndex >= 128) goto l_InvalidParam;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
ppFlsSlots = pTeb->FlsData;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
if (ppFlsSlots == NULL)
|
|
|
|
{
|
|
|
|
PEB *pPeb = pTeb->ProcessEnvironmentBlock;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
ppFlsSlots = RtlAllocateHeap(pPeb->ProcessHeap,
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
(128 + 2) * sizeof(PVOID));
|
2010-01-09 21:57:00 +00:00
|
|
|
if(ppFlsSlots == NULL) goto l_OutOfMemory;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
pTeb->FlsData = ppFlsSlots;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
RtlAcquirePebLock();
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
/* TODO: initialization */
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
RtlReleasePebLock();
|
|
|
|
}
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
ppFlsSlots[dwFlsIndex + 2] = lpFlsData;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
2010-01-09 20:51:33 +00:00
|
|
|
return TRUE;
|
2003-07-06 23:04:19 +00:00
|
|
|
|
|
|
|
l_OutOfMemory:
|
2010-01-09 20:51:33 +00:00
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
goto l_Fail;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2003-07-06 23:04:19 +00:00
|
|
|
l_InvalidParam:
|
2010-01-09 20:51:33 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2003-07-06 23:04:19 +00:00
|
|
|
|
|
|
|
l_Fail:
|
2010-01-09 20:51:33 +00:00
|
|
|
return FALSE;
|
2003-05-29 00:36:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|