ucrtbase: Add __std_type_info_name implementation.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2016-08-04 16:28:38 +02:00 committed by Alexandre Julliard
parent 0707164543
commit 2487168b75
4 changed files with 52 additions and 3 deletions

View File

@ -47,7 +47,7 @@
@ cdecl __std_type_info_compare(ptr ptr) ucrtbase.__std_type_info_compare
@ stub __std_type_info_destroy_list
@ stub __std_type_info_hash
@ stub __std_type_info_name
@ cdecl __std_type_info_name(ptr ptr) ucrtbase.__std_type_info_name
@ cdecl __unDName(ptr str long ptr ptr long) ucrtbase.__unDName
@ cdecl __unDNameEx(ptr str long ptr ptr ptr long) ucrtbase.__unDNameEx
@ cdecl __uncaught_exception() ucrtbase.__uncaught_exception

View File

@ -1511,6 +1511,24 @@ typedef struct
char mangled[1];
} type_info140;
typedef struct
{
SLIST_ENTRY entry;
char name[1];
} type_info_entry;
static void* CDECL type_info_entry_malloc(MSVCRT_size_t size)
{
type_info_entry *ret = MSVCRT_malloc(FIELD_OFFSET(type_info_entry, name) + size);
return ret->name;
}
static void CDECL type_info_entry_free(void *ptr)
{
ptr = (char*)ptr - FIELD_OFFSET(type_info_entry, name);
MSVCRT_free(ptr);
}
/******************************************************************
* __std_type_info_compare (UCRTBASE.@)
*/
@ -1523,4 +1541,35 @@ int CDECL MSVCRT_type_info_compare(const type_info140 *l, const type_info140 *r)
TRACE("(%p %p) returning %d\n", l, r, ret);
return ret;
}
/******************************************************************
* __std_type_info_name (UCRTBASE.@)
*/
const char* CDECL MSVCRT_type_info_name_list(type_info140 *ti, SLIST_HEADER *header)
{
if (!ti->name)
{
char* name = __unDName(0, ti->mangled + 1, 0,
type_info_entry_malloc, type_info_entry_free, UNDNAME_NO_ARGUMENTS | UNDNAME_32_BIT_DECODE);
if (name)
{
unsigned int len = strlen(name);
while (len && name[--len] == ' ')
name[len] = '\0';
if (InterlockedCompareExchangePointer((void**)&ti->name, name, NULL))
{
type_info_entry_free(name);
}
else
{
type_info_entry *entry = (type_info_entry*)(name-FIELD_OFFSET(type_info_entry, name));
InterlockedPushEntrySList(header, &entry->entry);
}
}
}
TRACE("(%p) returning %s\n", ti, ti->name);
return ti->name;
}
#endif

View File

@ -145,7 +145,7 @@
@ cdecl __std_type_info_compare(ptr ptr) MSVCRT_type_info_compare
@ stub __std_type_info_destroy_list
@ stub __std_type_info_hash
@ stub __std_type_info_name
@ cdecl __std_type_info_name(ptr ptr) MSVCRT_type_info_name_list
@ cdecl __stdio_common_vfprintf(int64 ptr str ptr ptr) MSVCRT__stdio_common_vfprintf
@ stub __stdio_common_vfprintf_p
@ stub __stdio_common_vfprintf_s

View File

@ -42,7 +42,7 @@
@ cdecl __std_type_info_compare(ptr ptr) ucrtbase.__std_type_info_compare
@ stub __std_type_info_destroy_list
@ stub __std_type_info_hash
@ stub __std_type_info_name
@ cdecl __std_type_info_name(ptr ptr) ucrtbase.__std_type_info_name
@ cdecl __telemetry_main_invoke_trigger(ptr)
@ cdecl __telemetry_main_return_trigger(ptr)
@ cdecl __unDName(ptr str long ptr ptr long) ucrtbase.__unDName