From: Santiago Fernandez Madero Date: Wed, 5 Aug 2020 22:22:51 +0000 (-0700) Subject: Build Globalization native shim as C++ and don't define __typeof (#40352) X-Git-Tag: submit/tizen/20210909.063632~6198 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8140826a72663ed8c2724d2099dd65d5ef689f18;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Build Globalization native shim as C++ and don't define __typeof (#40352) * Build Globalization native shim as C++ and don't define __typeof intrinsic * PR Feedback, use TYPEOF in all shims --- diff --git a/src/libraries/Native/Unix/Common/pal_compiler.h b/src/libraries/Native/Unix/Common/pal_compiler.h index 42e638c..c53dc39 100644 --- a/src/libraries/Native/Unix/Common/pal_compiler.h +++ b/src/libraries/Native/Unix/Common/pal_compiler.h @@ -33,3 +33,11 @@ #define EXTERN_C extern #endif // __cplusplus #endif // EXTERN_C + +#ifndef TYPEOF +#ifdef __cplusplus +#define TYPEOF decltype +#else +#define TYPEOF __typeof +#endif // __cplusplus +#endif // TYPEOF diff --git a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt index b08f49e..b4262529 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt @@ -59,6 +59,10 @@ set(NATIVEGLOBALIZATION_SOURCES entrypoints.c ) +if (MSVC) + set_source_files_properties(${NATIVEGLOBALIZATION_SOURCES} PROPERTIES LANGUAGE CXX) +endif() + include_directories("../Common") if (GEN_SHARED_LIB) diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c index d4780a2..43e1d4f 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c @@ -19,7 +19,7 @@ #include "pal_icushim.h" // Define pointers to all the used ICU functions -#define PER_FUNCTION_BLOCK(fn, lib) __typeof(fn)* fn##_ptr; +#define PER_FUNCTION_BLOCK(fn, lib) TYPEOF(fn)* fn##_ptr; FOR_ALL_ICU_FUNCTIONS #undef PER_FUNCTION_BLOCK @@ -43,7 +43,7 @@ static void* libicui18n = NULL; #define PER_FUNCTION_BLOCK(fn, lib) \ c_static_assert_msg((sizeof(#fn) + MaxICUVersionStringWithSuffixLength + 1) <= sizeof(symbolName), "The symbolName is too small for symbol " #fn); \ sprintf(symbolName, #fn "%s", symbolVersion); \ - fn##_ptr = (__typeof(fn)*)dlsym(lib, symbolName); \ + fn##_ptr = (TYPEOF(fn)*)dlsym(lib, symbolName); \ if (fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol %s from " #lib "\nError: %s\n", symbolName, dlerror()); abort(); } static int FindSymbolVersion(int majorVer, int minorVer, int subVer, char* symbolName, char* symbolVersion, char* suffix) @@ -90,7 +90,7 @@ static int FindSymbolVersion(int majorVer, int minorVer, int subVer, char* symbo #define PER_FUNCTION_BLOCK(fn, lib) \ sprintf_s(symbolName, SYMBOL_NAME_SIZE, #fn "%s", symbolVersion); \ - fn##_ptr = (__typeof(fn)*)GetProcAddress((HMODULE)lib, symbolName); \ + fn##_ptr = (TYPEOF(fn)*)GetProcAddress((HMODULE)lib, symbolName); \ if (fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol %s from " #lib "\nError: %u\n", symbolName, GetLastError()); abort(); } static int FindICULibs() diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_internal.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_internal.h index fcb669e..46d8064 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_internal.h +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_internal.h @@ -46,10 +46,6 @@ #include "icu.h" -#ifndef __typeof -#define __typeof decltype -#endif - #define HAVE_SET_MAX_VARIABLE 1 #define UDAT_STANDALONE_SHORTER_WEEKDAYS 1 @@ -180,7 +176,7 @@ FOR_ALL_OS_CONDITIONAL_ICU_FUNCTIONS // Declare pointers to all the used ICU functions -#define PER_FUNCTION_BLOCK(fn, lib) EXTERN_C __typeof(fn)* fn##_ptr; +#define PER_FUNCTION_BLOCK(fn, lib) EXTERN_C TYPEOF(fn)* fn##_ptr; FOR_ALL_ICU_FUNCTIONS #undef PER_FUNCTION_BLOCK diff --git a/src/libraries/Native/Unix/System.Native/pal_networkstatistics.c b/src/libraries/Native/Unix/System.Native/pal_networkstatistics.c index 1422032..4a7c394 100644 --- a/src/libraries/Native/Unix/System.Native/pal_networkstatistics.c +++ b/src/libraries/Native/Unix/System.Native/pal_networkstatistics.c @@ -193,8 +193,8 @@ int32_t SystemNative_GetIcmpv4GlobalStatistics(Icmpv4GlobalStatistics* retStats) return -1; } - __typeof(systemStats.icps_inhist[0])* inHist = systemStats.icps_inhist; - __typeof(systemStats.icps_outhist[0])* outHist = systemStats.icps_outhist; + TYPEOF(systemStats.icps_inhist[0])* inHist = systemStats.icps_inhist; + TYPEOF(systemStats.icps_outhist[0])* outHist = systemStats.icps_outhist; retStats->AddressMaskRepliesReceived = inHist[ICMP_MASKREPLY]; retStats->AddressMaskRepliesSent = outHist[ICMP_MASKREPLY]; diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.c b/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.c index 03e2c59..8085b02 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.c +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.c @@ -11,12 +11,12 @@ #include "opensslshim.h" // Define pointers to all the used OpenSSL functions -#define REQUIRED_FUNCTION(fn) __typeof(fn) fn##_ptr; -#define NEW_REQUIRED_FUNCTION(fn) __typeof(fn) fn##_ptr; -#define LIGHTUP_FUNCTION(fn) __typeof(fn) fn##_ptr; -#define FALLBACK_FUNCTION(fn) __typeof(fn) fn##_ptr; -#define RENAMED_FUNCTION(fn,oldfn) __typeof(fn) fn##_ptr; -#define LEGACY_FUNCTION(fn) __typeof(fn) fn##_ptr; +#define REQUIRED_FUNCTION(fn) TYPEOF(fn) fn##_ptr; +#define NEW_REQUIRED_FUNCTION(fn) TYPEOF(fn) fn##_ptr; +#define LIGHTUP_FUNCTION(fn) TYPEOF(fn) fn##_ptr; +#define FALLBACK_FUNCTION(fn) TYPEOF(fn) fn##_ptr; +#define RENAMED_FUNCTION(fn,oldfn) TYPEOF(fn) fn##_ptr; +#define LEGACY_FUNCTION(fn) TYPEOF(fn) fn##_ptr; FOR_ALL_OPENSSL_FUNCTIONS #undef LEGACY_FUNCTION #undef RENAMED_FUNCTION @@ -131,23 +131,23 @@ static void InitializeOpenSSLShim() // Get pointers to all the functions that are needed #define REQUIRED_FUNCTION(fn) \ - if (!(fn##_ptr = (__typeof(fn))(dlsym(libssl, #fn)))) { fprintf(stderr, "Cannot get required symbol " #fn " from libssl\n"); abort(); } + if (!(fn##_ptr = (TYPEOF(fn))(dlsym(libssl, #fn)))) { fprintf(stderr, "Cannot get required symbol " #fn " from libssl\n"); abort(); } #define NEW_REQUIRED_FUNCTION(fn) \ - if (!v1_0_sentinel && !(fn##_ptr = (__typeof(fn))(dlsym(libssl, #fn)))) { fprintf(stderr, "Cannot get required symbol " #fn " from libssl\n"); abort(); } + if (!v1_0_sentinel && !(fn##_ptr = (TYPEOF(fn))(dlsym(libssl, #fn)))) { fprintf(stderr, "Cannot get required symbol " #fn " from libssl\n"); abort(); } #define LIGHTUP_FUNCTION(fn) \ - fn##_ptr = (__typeof(fn))(dlsym(libssl, #fn)); + fn##_ptr = (TYPEOF(fn))(dlsym(libssl, #fn)); #define FALLBACK_FUNCTION(fn) \ - if (!(fn##_ptr = (__typeof(fn))(dlsym(libssl, #fn)))) { fn##_ptr = (__typeof(fn))local_##fn; } + if (!(fn##_ptr = (TYPEOF(fn))(dlsym(libssl, #fn)))) { fn##_ptr = (TYPEOF(fn))local_##fn; } #define RENAMED_FUNCTION(fn,oldfn) \ - if (!v1_0_sentinel && !(fn##_ptr = (__typeof(fn))(dlsym(libssl, #fn)))) { fprintf(stderr, "Cannot get required symbol " #fn " from libssl\n"); abort(); } \ - if (v1_0_sentinel && !(fn##_ptr = (__typeof(fn))(dlsym(libssl, #oldfn)))) { fprintf(stderr, "Cannot get required symbol " #oldfn " from libssl\n"); abort(); } + if (!v1_0_sentinel && !(fn##_ptr = (TYPEOF(fn))(dlsym(libssl, #fn)))) { fprintf(stderr, "Cannot get required symbol " #fn " from libssl\n"); abort(); } \ + if (v1_0_sentinel && !(fn##_ptr = (TYPEOF(fn))(dlsym(libssl, #oldfn)))) { fprintf(stderr, "Cannot get required symbol " #oldfn " from libssl\n"); abort(); } #define LEGACY_FUNCTION(fn) \ - if (v1_0_sentinel && !(fn##_ptr = (__typeof(fn))(dlsym(libssl, #fn)))) { fprintf(stderr, "Cannot get required symbol " #fn " from libssl\n"); abort(); } + if (v1_0_sentinel && !(fn##_ptr = (TYPEOF(fn))(dlsym(libssl, #fn)))) { fprintf(stderr, "Cannot get required symbol " #fn " from libssl\n"); abort(); } FOR_ALL_OPENSSL_FUNCTIONS #undef LEGACY_FUNCTION diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.h b/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.h index d595332..825c884 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.h +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.h @@ -35,6 +35,7 @@ #include #include "pal_crypto_config.h" +#include "pal_compiler.h" #define OPENSSL_VERSION_1_1_1_RTM 0x10101000L #define OPENSSL_VERSION_1_1_0_RTM 0x10100000L #define OPENSSL_VERSION_1_0_2_RTM 0x10002000L @@ -579,12 +580,12 @@ void SSL_get0_alpn_selected(const SSL* ssl, const unsigned char** protocol, unsi LIGHTUP_FUNCTION(EC_POINT_set_affine_coordinates_GF2m) \ // Declare pointers to all the used OpenSSL functions -#define REQUIRED_FUNCTION(fn) extern __typeof(fn)* fn##_ptr; -#define NEW_REQUIRED_FUNCTION(fn) extern __typeof(fn)* fn##_ptr; -#define LIGHTUP_FUNCTION(fn) extern __typeof(fn)* fn##_ptr; -#define FALLBACK_FUNCTION(fn) extern __typeof(fn)* fn##_ptr; -#define RENAMED_FUNCTION(fn,oldfn) extern __typeof(fn)* fn##_ptr; -#define LEGACY_FUNCTION(fn) extern __typeof(fn)* fn##_ptr; +#define REQUIRED_FUNCTION(fn) extern TYPEOF(fn)* fn##_ptr; +#define NEW_REQUIRED_FUNCTION(fn) extern TYPEOF(fn)* fn##_ptr; +#define LIGHTUP_FUNCTION(fn) extern TYPEOF(fn)* fn##_ptr; +#define FALLBACK_FUNCTION(fn) extern TYPEOF(fn)* fn##_ptr; +#define RENAMED_FUNCTION(fn,oldfn) extern TYPEOF(fn)* fn##_ptr; +#define LEGACY_FUNCTION(fn) extern TYPEOF(fn)* fn##_ptr; FOR_ALL_OPENSSL_FUNCTIONS #undef LEGACY_FUNCTION #undef RENAMED_FUNCTION