From 2487168b758a8133b15dea5aab4801f2d1f381db Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 4 Aug 2016 16:28:38 +0200 Subject: [PATCH] ucrtbase: Add __std_type_info_name implementation. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- .../api-ms-win-crt-private-l1-1-0.spec | 2 +- dlls/msvcrt/cpp.c | 49 +++++++++++++++++++ dlls/ucrtbase/ucrtbase.spec | 2 +- dlls/vcruntime140/vcruntime140.spec | 2 +- 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec b/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec index 1e16e5fd547..d8f4c5242f6 100644 --- a/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec +++ b/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec @@ -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 diff --git a/dlls/msvcrt/cpp.c b/dlls/msvcrt/cpp.c index 8e4496922df..ee27fc714e1 100644 --- a/dlls/msvcrt/cpp.c +++ b/dlls/msvcrt/cpp.c @@ -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 diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index 95fcc057772..d1c1553b676 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -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 diff --git a/dlls/vcruntime140/vcruntime140.spec b/dlls/vcruntime140/vcruntime140.spec index a8dc379c1f8..525a99819a8 100644 --- a/dlls/vcruntime140/vcruntime140.spec +++ b/dlls/vcruntime140/vcruntime140.spec @@ -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