kernelbase: Move FlsFree() implementation to ntdll.RtlFlsFree().

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2020-09-29 23:15:30 +03:00 committed by Alexandre Julliard
parent c955eee9e8
commit 0627fa9d92
5 changed files with 32 additions and 17 deletions

View File

@ -38,7 +38,7 @@ static BOOL (WINAPI *pFlsFree)(DWORD);
static PVOID (WINAPI *pFlsGetValue)(DWORD); static PVOID (WINAPI *pFlsGetValue)(DWORD);
static BOOL (WINAPI *pFlsSetValue)(DWORD,PVOID); static BOOL (WINAPI *pFlsSetValue)(DWORD,PVOID);
static NTSTATUS (WINAPI *pRtlFlsAlloc)(PFLS_CALLBACK_FUNCTION,DWORD*); static NTSTATUS (WINAPI *pRtlFlsAlloc)(PFLS_CALLBACK_FUNCTION,DWORD*);
static NTSTATUS (WINAPI *pRtlFlsFree)(ULONG);
static void *fibers[3]; static void *fibers[3];
static BYTE testparam = 185; static BYTE testparam = 185;
static DWORD fls_index_to_set = FLS_OUT_OF_INDEXES; static DWORD fls_index_to_set = FLS_OUT_OF_INDEXES;
@ -69,6 +69,7 @@ static VOID init_funcs(void)
#define X(f) p##f = (void*)GetProcAddress(hntdll, #f); #define X(f) p##f = (void*)GetProcAddress(hntdll, #f);
X(RtlFlsAlloc); X(RtlFlsAlloc);
X(RtlFlsFree);
#undef X #undef X
} }
@ -218,7 +219,10 @@ static void test_FiberLocalStorage(void)
ok(count && (count <= 127 || (count > 4000 && count < 4096)), "Got unexpected count %u.\n", count); ok(count && (count <= 127 || (count > 4000 && count < 4096)), "Got unexpected count %u.\n", count);
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
pFlsFree(fls_indices[i]); {
status = pRtlFlsFree(fls_indices[i]);
ok(!status, "Got unexpected status %#x.\n", status);
}
} }
else else
{ {

View File

@ -1077,20 +1077,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH FlsAlloc( PFLS_CALLBACK_FUNCTION callback )
*/ */
BOOL WINAPI DECLSPEC_HOTPATCH FlsFree( DWORD index ) BOOL WINAPI DECLSPEC_HOTPATCH FlsFree( DWORD index )
{ {
BOOL ret; return set_ntstatus( RtlFlsFree( index ));
RtlAcquirePebLock();
ret = RtlAreBitsSet( NtCurrentTeb()->Peb->FlsBitmap, index, 1 );
if (ret) RtlClearBits( NtCurrentTeb()->Peb->FlsBitmap, index, 1 );
if (ret)
{
/* FIXME: call Fls callback */
/* FIXME: add equivalent of ThreadZeroTlsCell here */
if (NtCurrentTeb()->FlsSlots) NtCurrentTeb()->FlsSlots[index] = 0;
}
else SetLastError( ERROR_INVALID_PARAMETER );
RtlReleasePebLock();
return ret;
} }

View File

@ -667,6 +667,7 @@
@ stdcall RtlFirstEntrySList(ptr) @ stdcall RtlFirstEntrySList(ptr)
@ stdcall RtlFirstFreeAce(ptr ptr) @ stdcall RtlFirstFreeAce(ptr ptr)
@ stdcall RtlFlsAlloc(ptr ptr) @ stdcall RtlFlsAlloc(ptr ptr)
@ stdcall RtlFlsFree(long)
@ stub RtlFlushPropertySet @ stub RtlFlushPropertySet
# @ stub RtlFlushSecureMemoryCache # @ stub RtlFlushSecureMemoryCache
@ stdcall RtlFormatCurrentUserKeyPath(ptr) @ stdcall RtlFormatCurrentUserKeyPath(ptr)

View File

@ -256,7 +256,7 @@ TEB_ACTIVE_FRAME * WINAPI RtlGetFrame(void)
/*********************************************************************** /***********************************************************************
* RtlFlsAlloc (NTDLL.@) * RtlFlsAlloc (NTDLL.@)
*/ */
NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsAlloc( PFLS_CALLBACK_FUNCTION callback, DWORD *ret_index ) NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsAlloc( PFLS_CALLBACK_FUNCTION callback, ULONG *ret_index )
{ {
PEB * const peb = NtCurrentTeb()->Peb; PEB * const peb = NtCurrentTeb()->Peb;
NTSTATUS status = STATUS_NO_MEMORY; NTSTATUS status = STATUS_NO_MEMORY;
@ -289,3 +289,25 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsAlloc( PFLS_CALLBACK_FUNCTION callback,
*ret_index = index; *ret_index = index;
return status; return status;
} }
/***********************************************************************
* RtlFlsFree (NTDLL.@)
*/
NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsFree( ULONG index )
{
NTSTATUS status;
RtlAcquirePebLock();
if (RtlAreBitsSet( NtCurrentTeb()->Peb->FlsBitmap, index, 1 ))
{
RtlClearBits( NtCurrentTeb()->Peb->FlsBitmap, index, 1 );
/* FIXME: call Fls callback */
/* FIXME: add equivalent of ThreadZeroTlsCell here */
if (NtCurrentTeb()->FlsSlots) NtCurrentTeb()->FlsSlots[index] = 0;
status = STATUS_SUCCESS;
}
else status = STATUS_INVALID_PARAMETER;
RtlReleasePebLock();
return status;
}

View File

@ -3372,6 +3372,7 @@ NTSYSAPI ULONG WINAPI RtlFindSetBitsAndClear(PRTL_BITMAP,ULONG,ULONG);
NTSYSAPI ULONG WINAPI RtlFindSetRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN); NTSYSAPI ULONG WINAPI RtlFindSetRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
NTSYSAPI BOOLEAN WINAPI RtlFirstFreeAce(PACL,PACE_HEADER *); NTSYSAPI BOOLEAN WINAPI RtlFirstFreeAce(PACL,PACE_HEADER *);
NTSYSAPI NTSTATUS WINAPI RtlFlsAlloc(PFLS_CALLBACK_FUNCTION,ULONG *); NTSYSAPI NTSTATUS WINAPI RtlFlsAlloc(PFLS_CALLBACK_FUNCTION,ULONG *);
NTSYSAPI NTSTATUS WINAPI RtlFlsFree(ULONG);
NTSYSAPI NTSTATUS WINAPI RtlFormatCurrentUserKeyPath(PUNICODE_STRING); NTSYSAPI NTSTATUS WINAPI RtlFormatCurrentUserKeyPath(PUNICODE_STRING);
NTSYSAPI NTSTATUS WINAPI RtlFormatMessage(LPCWSTR,ULONG,BOOLEAN,BOOLEAN,BOOLEAN,__ms_va_list *,LPWSTR,ULONG,ULONG*); NTSYSAPI NTSTATUS WINAPI RtlFormatMessage(LPCWSTR,ULONG,BOOLEAN,BOOLEAN,BOOLEAN,__ms_va_list *,LPWSTR,ULONG,ULONG*);
NTSYSAPI NTSTATUS WINAPI RtlFormatMessageEx(LPCWSTR,ULONG,BOOLEAN,BOOLEAN,BOOLEAN,__ms_va_list *,LPWSTR,ULONG,ULONG*,ULONG); NTSYSAPI NTSTATUS WINAPI RtlFormatMessageEx(LPCWSTR,ULONG,BOOLEAN,BOOLEAN,BOOLEAN,__ms_va_list *,LPWSTR,ULONG,ULONG*,ULONG);