[PATCH v2 0/3] MR5915: include: Tweak atexit and cpuid declarations, guard DECLSPEC_UUID definition.
IIUC atexit isn't exported by ucrtbase, but still exists (maybe as a builtin) and is resolved to a module-local symbol which can be used to register functions executed on module process detach. It is called implicitly by C++ compilers to register static destructors. -- v2: include: Define __cpuid(ex) as intrinsics when _MSC_VER is defined. include: Don't import atexit when building with ucrtbase. include: Guard rpcndr.h DECLSPEC_UUID definition. https://gitlab.winehq.org/wine/wine/-/merge_requests/5915
From: Rémi Bernon <rbernon(a)codeweavers.com> --- include/rpcndr.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/rpcndr.h b/include/rpcndr.h index 93ebb0a4aa7..551768d7786 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -112,7 +112,10 @@ typedef void (__RPC_USER *NDR_RUNDOWN)(void *context); typedef void (__RPC_USER *NDR_NOTIFY_ROUTINE)(void); typedef void (__RPC_USER *NDR_NOTIFY2_ROUTINE)(boolean flag); +#ifndef DECLSPEC_UUID #define DECLSPEC_UUID(x) +#endif + #define MIDL_INTERFACE(x) struct struct _MIDL_STUB_MESSAGE; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5915
From: Rémi Bernon <rbernon(a)codeweavers.com> --- include/msvcrt/stdlib.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h index f3df662528a..fe23567e851 100644 --- a/include/msvcrt/stdlib.h +++ b/include/msvcrt/stdlib.h @@ -203,7 +203,11 @@ _ACRTIMP DECLSPEC_NORETURN void __cdecl _Exit(int); _ACRTIMP DECLSPEC_NORETURN void __cdecl _exit(int); _ACRTIMP DECLSPEC_NORETURN void __cdecl abort(void); _ACRTIMP int __cdecl abs(int); +#ifndef _UCRT _ACRTIMP int __cdecl atexit(void (__cdecl *)(void)); +#else +extern int __cdecl atexit(void (__cdecl *)(void)); +#endif _ACRTIMP double __cdecl atof(const char*); _ACRTIMP int __cdecl atoi(const char*); _ACRTIMP int __cdecl _atoi_l(const char*,_locale_t); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5915
From: Rémi Bernon <rbernon(a)codeweavers.com> --- include/msvcrt/intrin.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/msvcrt/intrin.h b/include/msvcrt/intrin.h index 7981e2798ba..0da964ed30a 100644 --- a/include/msvcrt/intrin.h +++ b/include/msvcrt/intrin.h @@ -16,14 +16,27 @@ extern "C" { #endif #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) + +#if defined(_MSC_VER) && (!defined(__has_builtin) || __has_builtin(__cpuidex)) +void __cpuidex(int info[4], int ax, int cx); +#pragma intrinsic(__cpuidex) +#else static inline void __cpuidex(int info[4], int ax, int cx) { __asm__ ("cpuid" : "=a"(info[0]), "=b" (info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(ax), "c"(cx)); } +#endif /* _MSC_VER */ + +#if defined(_MSC_VER) && (!defined(__has_builtin) || __has_builtin(__cpuid)) +void __cpuid(int info[4], int ax); +#pragma intrinsic(__cpuid) +#else static inline void __cpuid(int info[4], int ax) { return __cpuidex(info, ax, 0); } +#endif /* _MSC_VER */ + #endif #if defined(__aarch64__) || defined(__arm64ec__) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5915
v2: Add conditions for older Clang which don't have __cpuid(ex) builtins yet. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5915#note_74221
Alexandre Julliard (@julliard) commented about include/msvcrt/intrin.h:
#endif
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) + +#if defined(_MSC_VER) && (!defined(__has_builtin) || __has_builtin(__cpuidex)) You can't use __has_builtin if it's not defined.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/5915#note_74386
On Tue Jun 25 16:24:56 2024 +0000, Alexandre Julliard wrote:
You can't use __has_builtin if it's not defined. Shall we copy
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif
from include/msvcrt/setjmp.h or include/winnt.h? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5915#note_74387
participants (3)
-
Alexandre Julliard (@julliard) -
Jinoh Kang (@iamahuman) -
Rémi Bernon