diff --git a/eng/pipelines/libraries/build-job.yml b/eng/pipelines/libraries/build-job.yml index 710dfed04fcf6..32f51c907fdd7 100644 --- a/eng/pipelines/libraries/build-job.yml +++ b/eng/pipelines/libraries/build-job.yml @@ -78,7 +78,8 @@ jobs: - ${{ if eq(parameters.osGroup, 'OSX') }}: - script: | - brew install pkgconfig openssl + brew install pkgconfig icu4c openssl + brew link --force icu4c ln -s /usr/local/opt/openssl/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig/ ln -s /usr/local/opt/openssl/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig/ ln -s /usr/local/opt/openssl/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig/ diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 226f0af522b28..8b54f9b271f07 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -131,10 +131,6 @@ include(pgosupport.cmake) # - project which require platform header not clr's # - do not depend on clr's compile definitions #----------------------------------------- -if(CLR_CMAKE_PLATFORM_UNIX AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) - add_subdirectory(src/corefx) -endif() - if(CLR_CMAKE_PLATFORM_UNIX) add_subdirectory(src/pal) add_subdirectory(src/coreclr/hosts) diff --git a/src/coreclr/functions.cmake b/src/coreclr/functions.cmake index 5db138c728dc8..3d07f7fc35729 100644 --- a/src/coreclr/functions.cmake +++ b/src/coreclr/functions.cmake @@ -380,36 +380,6 @@ function(_install) endif() endfunction() -function(verify_dependencies targetName errorMessage) - set(SANITIZER_BUILD OFF) - - if (CLR_CMAKE_PLATFORM_UNIX) - if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED) - string(FIND "$ENV{DEBUG_SANITIZERS}" "asan" __ASAN_POS) - string(FIND "$ENV{DEBUG_SANITIZERS}" "ubsan" __UBSAN_POS) - if ((${__ASAN_POS} GREATER -1) OR (${__UBSAN_POS} GREATER -1)) - set(SANITIZER_BUILD ON) - endif() - endif() - endif() - - # We don't need to verify dependencies on OSX, since missing dependencies - # result in link error over there. - # Also don't verify dependencies for Asan build because in this case shared - # libraries can contain undefined symbols - if (NOT CLR_CMAKE_PLATFORM_DARWIN AND NOT CLR_CMAKE_PLATFORM_ANDROID AND NOT SANITIZER_BUILD) - add_custom_command( - TARGET ${targetName} - POST_BUILD - VERBATIM - COMMAND ${CMAKE_SOURCE_DIR}/verify-so.sh - $ - ${errorMessage} - COMMENT "Verifying ${targetName} dependencies" - ) - endif() -endfunction() - function(add_library_clr) _add_library(${ARGV}) endfunction() diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Directory.Build.props b/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Directory.Build.props deleted file mode 100644 index 85f4e6a0d340b..0000000000000 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Directory.Build.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - Linux;OSX;FreeBSD - - - diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.builds b/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.builds deleted file mode 100644 index 85918b379eada..0000000000000 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.builds +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.pkgproj b/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.pkgproj deleted file mode 100644 index 3694a635bda6e..0000000000000 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.pkgproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - true - - - - - - diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.FreeBSD.Microsoft.NETCore.Native.props b/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.FreeBSD.Microsoft.NETCore.Native.props deleted file mode 100644 index dea614a67d919..0000000000000 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.FreeBSD.Microsoft.NETCore.Native.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.Linux.Microsoft.NETCore.Native.props b/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.Linux.Microsoft.NETCore.Native.props deleted file mode 100644 index dea614a67d919..0000000000000 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.Linux.Microsoft.NETCore.Native.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.OSX.Microsoft.NETCore.Native.props b/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.OSX.Microsoft.NETCore.Native.props deleted file mode 100644 index 734ec7d9aff55..0000000000000 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Native/runtime.OSX.Microsoft.NETCore.Native.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.FreeBSD.Microsoft.NETCore.Runtime.CoreCLR.props b/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.FreeBSD.Microsoft.NETCore.Runtime.CoreCLR.props index 3219da6648cee..7751b8dfce28c 100644 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.FreeBSD.Microsoft.NETCore.Runtime.CoreCLR.props +++ b/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.FreeBSD.Microsoft.NETCore.Runtime.CoreCLR.props @@ -6,7 +6,6 @@ - runtimes\$(PackageTargetRuntime)\native diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props b/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props index a046f0ba18925..f5ea97eb0ebaf 100644 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props +++ b/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props @@ -12,7 +12,6 @@ - runtimes\$(PackageTargetRuntime)\native diff --git a/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props b/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props index 7fa9c74bf2691..fe04146322381 100644 --- a/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props +++ b/src/coreclr/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props @@ -8,7 +8,6 @@ runtimes\$(PackageTargetRuntime)\native - diff --git a/src/coreclr/src/.nuget/descriptions.json b/src/coreclr/src/.nuget/descriptions.json index 0ab63e6c4d73f..d55e8c78cb56f 100644 --- a/src/coreclr/src/.nuget/descriptions.json +++ b/src/coreclr/src/.nuget/descriptions.json @@ -44,11 +44,6 @@ "Description": "Provides support for building IL projects.", "CommonTypes": [ ] }, - { - "Name": "Microsoft.NETCore.Native", - "Description": "Native shims for .NET Core runtime", - "CommonTypes": [ ] - }, { "Name": "Microsoft.NETCore.Crossgen2", "Description": "The .NET Crossgen2 compiler.", diff --git a/src/coreclr/src/.nuget/packages.builds b/src/coreclr/src/.nuget/packages.builds index 883d9c7a9829b..fa33f6a2a88ea 100644 --- a/src/coreclr/src/.nuget/packages.builds +++ b/src/coreclr/src/.nuget/packages.builds @@ -14,7 +14,6 @@ - diff --git a/src/coreclr/src/corefx/.clang-format b/src/coreclr/src/corefx/.clang-format deleted file mode 100644 index 64f593eedebf1..0000000000000 --- a/src/coreclr/src/corefx/.clang-format +++ /dev/null @@ -1,18 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: LLVM -AlignEscapedNewlinesLeft: false -AlignAfterOpenBracket: true -AllowShortFunctionsOnASingleLine: false -AlwaysBreakTemplateDeclarations: true -BinPackArguments: false -BinPackParameters: false -BreakBeforeBraces: Allman -ColumnLimit: 120 -ConstructorInitializerAllOnOneLineOrOnePerLine: true -IndentCaseLabels: true -IndentWidth: 4 -PointerAlignment: Left -TabWidth: 4 -... - diff --git a/src/coreclr/src/corefx/CMakeLists.txt b/src/coreclr/src/corefx/CMakeLists.txt deleted file mode 100644 index 7bd522d3bf5ad..0000000000000 --- a/src/coreclr/src/corefx/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ - -# This portion of the tree is for portions of CoreFX libraries which are (1) best -# suited to having been implemented in native code and (2) need to be invoked from -# mscorlib.dll. If mscorlib.dll does not use the library, the code should go in -# the src/Native directory of dotnet/corefx. -# -# The libraries should disable the "lib" prefix, and use an assembly-style naming format, -# such as System.Security.Cryptography.Native (shared across multiple System.Security.Cryptography.* -# assemblies) or System.Diagnostics.Process.Native (a native interop library for -# System.Diagnostics.Process.dll). - -if(CLR_CMAKE_PLATFORM_UNIX) - add_subdirectory(System.Globalization.Native) -endif(CLR_CMAKE_PLATFORM_UNIX) diff --git a/src/coreclr/src/corefx/format-code.sh b/src/coreclr/src/corefx/format-code.sh deleted file mode 100755 index 843d588951157..0000000000000 --- a/src/coreclr/src/corefx/format-code.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -# OS X names clang-format as clang-format; Ubuntu uses -# clang-format-version so check for the right one -if command -v "clang-format-3.6" > /dev/null; then - export CF="$(command -v clang-format-3.6)" -elif command -v "clang-format" > /dev/null; then - export CF="$(command -v clang-format)" -else - echo "Unable to find clang-format" - exit 1 -fi - -cd $(dirname "${BASH_SOURCE[0]}") - -for D in */; do - for file in "${D}"*.cpp; do - if [ -e $file ] ; then - $CF -style=file -i "$file" - fi - done - - for file in "${D}"*.h ; do - if [ -e $file ] ; then - $CF -style=file -i "$file" - fi - done - - for file in "${D}"*.hpp ; do - if [ -e $file ] ; then - $CF -style=file -i "$file" - fi - done - - for file in "${D}"*.in ; do - if [ -e $file ] ; then - $CF -style=file -i "$file" - fi - done -done diff --git a/src/coreclr/verify-so.sh b/src/coreclr/verify-so.sh deleted file mode 100755 index 3907cf1db0b4a..0000000000000 --- a/src/coreclr/verify-so.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -# $1 contains full path to the .so to verify -# $2 contains message to print when the verification fails - -OSName=$(uname -s) -case $OSName in - Linux) - source /etc/os-release - # TODO: add support for verification on Alpine Linux - if [ "$ID" != "alpine" ]; then - ldd -r $1 | awk 'BEGIN {count=0} /undefined symbol:/ { if (count==0) {print "Undefined symbol(s) found:"} print " " $3; count++ } END {if (count>0) exit(1)}' - if [ $? != 0 ]; then - echo "$2" - exit 1 - fi - fi - ;; -esac - -# TODO: add support for verification on non-Linux Unixes (except of OSX) diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt index f4deee610aa7e..ccb64346bc01a 100644 --- a/src/libraries/Native/Unix/CMakeLists.txt +++ b/src/libraries/Native/Unix/CMakeLists.txt @@ -293,6 +293,7 @@ endif() add_subdirectory(System.Native) if (NOT CLR_CMAKE_PLATFORM_WASM) + add_subdirectory(System.Globalization.Native) add_subdirectory(System.Net.Security.Native) add_subdirectory(System.Security.Cryptography.Native) endif() diff --git a/src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt similarity index 51% rename from src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt rename to src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt index 7478bd80b747e..efe74c96cb20c 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt @@ -1,9 +1,16 @@ project(System.Globalization.Native C) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +add_compile_options(-Wno-switch-enum) +add_compile_options(-Wno-covered-switch-default) -add_definitions(-DPIC) -add_definitions(-DBIT64) +# Workaround for warnings produced by ICU headers +add_compile_options(-Wno-reserved-id-macro) +add_compile_options(-Wno-documentation) +add_compile_options(-Wno-documentation-unknown-command) + +# Workaround for https://unicode-org.atlassian.net/browse/ICU-20601 +add_compile_options(-Wno-extra-semi-stmt) +add_compile_options(-Wno-unknown-warning-option) set(ICU_HOMEBREW_INC_PATH "/usr/local/opt/icu4c/include") @@ -13,7 +20,15 @@ if(UTYPES_H STREQUAL UTYPES_H-NOTFOUND) return() endif() -if (NOT CLR_CMAKE_PLATFORM_DARWIN) +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + find_library(ICUCORE icucore) + if(ICUCORE STREQUAL ICUCORE-NOTFOUND) + message(FATAL_ERROR "Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.") + return() + endif() + add_definitions(-DOSX_ICU_LIBRARY_PATH=\"${ICUCORE}\") + add_definitions(-DU_DISABLE_RENAMING) +else() find_library(ICUUC icuuc) if(ICUUC STREQUAL ICUUC-NOTFOUND) message(FATAL_ERROR "Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform)") @@ -21,18 +36,18 @@ if (NOT CLR_CMAKE_PLATFORM_DARWIN) endif() find_library(ICUI18N icui18n) - if(ICUI18N STREQUAL ICUI18N-NOTFOUND) + if(ICUI18N STREQUAL ICUI18N-NOTFOUND) message(FATAL_ERROR "Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform)") return() endif() -else() - find_library(ICUCORE icucore) - if(ICUI18N STREQUAL ICUCORE-NOTFOUND) - message(FATAL_ERROR "Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.") - return() - endif() - add_definitions(-DOSX_ICU_LIBRARY_PATH=\"${ICUCORE}\") + add_custom_command(TARGET System.Globalization.Native POST_BUILD + COMMENT "Verifying System.Globalization.Native.so dependencies" + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-so.sh + $ + "Verification failed. System.Globalization.Native.so has undefined dependencies. These are likely ICU APIs that need to be added to icushim.h." + VERBATIM + ) endif() include(configure.cmake) @@ -52,46 +67,26 @@ set(NATIVEGLOBALIZATION_SOURCES include_directories(${UTYPES_H}) -_add_library(System.Globalization.Native +add_library(System.Globalization.Native SHARED ${NATIVEGLOBALIZATION_SOURCES} + ${VERSION_FILE_PATH} +) + +target_link_libraries(System.Globalization.Native + dl ) -_add_library(System.Globalization.Native_Static +install_library_and_symbols (System.Globalization.Native) + +add_library(System.Globalization.Native-Static STATIC ${NATIVEGLOBALIZATION_SOURCES} + ${VERSION_FILE_PATH} ) -# Disable the "lib" prefix. -set_target_properties(System.Globalization.Native PROPERTIES PREFIX "") - # Disable the "lib" prefix and override default name -set_target_properties(System.Globalization.Native_Static PROPERTIES PREFIX "") -set_target_properties(System.Globalization.Native_Static PROPERTIES OUTPUT_NAME System.Globalization.Native) - -if(NOT CLR_CMAKE_PLATFORM_DARWIN) - if (NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD) - target_link_libraries(System.Globalization.Native - dl - ) - target_link_libraries(System.Globalization.Native_Static - dl - ) - endif() -else() - target_link_libraries(System.Globalization.Native - dl - ) - - add_definitions(-DU_DISABLE_RENAMING) -endif() - -verify_dependencies( - System.Globalization.Native - "Verification failed. System.Globalization.Native.so has undefined dependencies. These are likely ICU APIs that need to be added to icushim.h." -) +set_target_properties(System.Globalization.Native-Static PROPERTIES PREFIX "") +set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) -# add the install targets -install_clr(TARGETS System.Globalization.Native) -install_clr(TARGETS System.Globalization.Native DESTINATION sharedFramework SKIP_STRIP) -install(TARGETS System.Globalization.Native_Static DESTINATION .) +install (TARGETS System.Globalization.Native-Static DESTINATION .) diff --git a/src/coreclr/src/corefx/System.Globalization.Native/config.h.in b/src/libraries/Native/Unix/System.Globalization.Native/config.h.in similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/config.h.in rename to src/libraries/Native/Unix/System.Globalization.Native/config.h.in diff --git a/src/coreclr/src/corefx/System.Globalization.Native/configure.cmake b/src/libraries/Native/Unix/System.Globalization.Native/configure.cmake similarity index 94% rename from src/coreclr/src/corefx/System.Globalization.Native/configure.cmake rename to src/libraries/Native/Unix/System.Globalization.Native/configure.cmake index 6fd506dbe25a3..28fc2dea1e67b 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/configure.cmake +++ b/src/libraries/Native/Unix/System.Globalization.Native/configure.cmake @@ -8,10 +8,10 @@ CHECK_C_SOURCE_COMPILES(" int main(void) { enum UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; } " HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS) -if(NOT CLR_CMAKE_PLATFORM_DARWIN) - set(CMAKE_REQUIRED_LIBRARIES ${ICUUC} ${ICUI18N}) -else() +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(CMAKE_REQUIRED_LIBRARIES ${ICUCORE}) +else() + set(CMAKE_REQUIRED_LIBRARIES ${ICUUC} ${ICUI18N}) endif() check_symbol_exists( diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_calendarData.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_calendarData.c similarity index 96% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_calendarData.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_calendarData.c index 96336fced7151..68005cbc8011f 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_calendarData.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_calendarData.c @@ -21,9 +21,9 @@ #define JAPANESE_LOCALE_AND_CALENDAR "ja_JP@calendar=japanese" -const UChar UDAT_MONTH_DAY_UCHAR[] = {'M', 'M', 'M', 'M', 'd', '\0'}; -const UChar UDAT_YEAR_NUM_MONTH_DAY_UCHAR[] = {'y', 'M', 'd', '\0'}; -const UChar UDAT_YEAR_MONTH_UCHAR[] = {'y', 'M', 'M', 'M', 'M', '\0'}; +static const UChar UDAT_MONTH_DAY_UCHAR[] = {'M', 'M', 'M', 'M', 'd', '\0'}; +static const UChar UDAT_YEAR_NUM_MONTH_DAY_UCHAR[] = {'y', 'M', 'd', '\0'}; +static const UChar UDAT_YEAR_MONTH_UCHAR[] = {'y', 'M', 'M', 'M', 'M', '\0'}; /* Function: @@ -224,7 +224,7 @@ static int InvokeCallbackForDatePattern(const char* locale, UErrorCode ignore = U_ZERO_ERROR; int32_t patternLen = udat_toPattern(pFormat, FALSE, NULL, 0, &ignore) + 1; - UChar* pattern = calloc(patternLen, sizeof(UChar)); + UChar* pattern = calloc((size_t)patternLen, sizeof(UChar)); if (pattern == NULL) { udat_close(pFormat); @@ -264,7 +264,7 @@ static int InvokeCallbackForDateTimePattern(const char* locale, UErrorCode ignore = U_ZERO_ERROR; int32_t patternLen = udatpg_getBestPattern(pGenerator, patternSkeleton, -1, NULL, 0, &ignore) + 1; - UChar* bestPattern = calloc(patternLen, sizeof(UChar)); + UChar* bestPattern = calloc((size_t)patternLen, sizeof(UChar)); if (bestPattern == NULL) { udatpg_close(pGenerator); @@ -328,13 +328,13 @@ static int32_t EnumSymbols(const char* locale, UErrorCode ignore = U_ZERO_ERROR; int symbolLen = udat_getSymbols(pFormat, type, i, NULL, 0, &ignore) + 1; - if (symbolLen <= sizeof(stackSymbolBuf) / sizeof(stackSymbolBuf[0])) + if ((size_t)symbolLen <= sizeof(stackSymbolBuf) / sizeof(stackSymbolBuf[0])) { symbolBuf = stackSymbolBuf; } else { - symbolBuf = calloc(symbolLen, sizeof(UChar)); + symbolBuf = calloc((size_t)symbolLen, sizeof(UChar)); if (symbolBuf == NULL) { err = U_MEMORY_ALLOCATION_ERROR; @@ -591,12 +591,12 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, ucal_set(pCal, UCAL_DATE, 1); int32_t currentEra; - for (int i = 0; U_SUCCESS(err) && i <= 12; i++) + for (int month = 0; U_SUCCESS(err) && month <= 12; month++) { currentEra = ucal_get(pCal, UCAL_ERA, &err); if (currentEra == era) { - for (int i = 0; U_SUCCESS(err) && i < 31; i++) + for (int day = 0; U_SUCCESS(err) && day < 31; day++) { // subtract 1 day at a time until we get out of the specified Era ucal_add(pCal, UCAL_DATE, -1, &err); diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_calendarData.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_calendarData.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_calendarData.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_calendarData.h diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_casing.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_casing.c similarity index 96% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_casing.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_casing.c index e6b27d3eb8a18..353542390ca7c 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_casing.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_casing.c @@ -9,6 +9,10 @@ #include "pal_casing.h" #include "pal_icushim.h" +// Workaround for warnings produced by U16_NEXT and U16_APPEND macro expansions +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wsign-conversion" + /* Function: ChangeCase @@ -141,3 +145,5 @@ void GlobalizationNative_ChangeCaseTurkish( } } } + +#pragma clang diagnostic pop diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_casing.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_casing.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_casing.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_casing.h diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_collation.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_collation.c similarity index 94% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_collation.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_collation.c index c6dc2522126e0..4b07e752dce8b 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_collation.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_collation.c @@ -18,7 +18,7 @@ c_static_assert_msg(UCOL_GREATER > 0, "managed side requires greater than zero f c_static_assert_msg(USEARCH_DONE == -1, "managed side requires -1 for not found"); #define UCOL_IGNORABLE 0 -#define UCOL_PRIMARYORDERMASK 0xFFFF0000 +#define UCOL_PRIMARYORDERMASK ((int32_t)0xFFFF0000) #define UCOL_SECONDARYORDERMASK 0x0000FF00 #define UCOL_TERTIARYORDERMASK 0x000000FF @@ -53,13 +53,13 @@ struct SortHandle typedef struct { UChar* items; size_t size; } UCharList; // Hiragana character range -const UChar hiraganaStart = 0x3041; -const UChar hiraganaEnd = 0x309e; -const UChar hiraganaToKatakanaOffset = 0x30a1 - 0x3041; +static const UChar hiraganaStart = 0x3041; +static const UChar hiraganaEnd = 0x309e; +static const UChar hiraganaToKatakanaOffset = 0x30a1 - 0x3041; // Mapping between half- and fullwidth characters. // LowerChars are the characters that should sort lower than HigherChars -const UChar g_HalfFullLowerChars[] = { +static const UChar g_HalfFullLowerChars[] = { // halfwidth characters 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, @@ -80,7 +80,7 @@ const UChar g_HalfFullLowerChars[] = { 0x315d, 0x315e, 0x315f, 0x3160, 0x3161, 0x3162, 0x3163 }; -const UChar g_HalfFullHigherChars[] = { +static const UChar g_HalfFullHigherChars[] = { // fullwidth characters 0xff01, 0xff02, 0xff03, 0xff04, 0xff05, 0xff06, 0xff07, 0xff08, 0xff09, 0xff0a, 0xff0b, 0xff0c, 0xff0d, 0xff0e, 0xff0f, 0xff10, 0xff11, 0xff12, 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0xff1a, 0xff1b, 0xff1c, 0xff1d, 0xff1e, @@ -100,7 +100,7 @@ const UChar g_HalfFullHigherChars[] = { 0xffbe, 0xffc2, 0xffc3, 0xffc4, 0xffc5, 0xffc6, 0xffc7, 0xffca, 0xffcb, 0xffcc, 0xffcd, 0xffce, 0xffcf, 0xffd2, 0xffd3, 0xffd4, 0xffd5, 0xffd6, 0xffd7, 0xffda, 0xffdb, 0xffdc }; -const int32_t g_HalfFullCharsLength = (sizeof(g_HalfFullHigherChars) / sizeof(UChar)); +static const int32_t g_HalfFullCharsLength = (sizeof(g_HalfFullHigherChars) / sizeof(UChar)); /* ICU collation rules reserve any punctuation and whitespace characters for use in the syntax. @@ -167,7 +167,7 @@ static UCharList* GetCustomRules(int32_t options, UColAttributeValue strength, i ((needsIgnoreWidthCustomRule || needsNotIgnoreWidthCustomRule) ? 5 * g_HalfFullCharsLength : 0); UChar* items; - customRules->items = items = malloc(capacity * sizeof(UChar)); + customRules->items = items = malloc((size_t)capacity * sizeof(UChar)); if (customRules->items == NULL) { free(customRules); @@ -223,7 +223,7 @@ static UCharList* GetCustomRules(int32_t options, UColAttributeValue strength, i } } - customRules->size = items - customRules->items; + customRules->size = (size_t)(items - customRules->items); return customRules; } @@ -234,7 +234,7 @@ static UCharList* GetCustomRules(int32_t options, UColAttributeValue strength, i * * On error, the return value is undefined. */ -UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t options, UErrorCode* pErr) +static UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t options, UErrorCode* pErr) { UColAttributeValue strength = ucol_getStrength(pCollator); @@ -260,13 +260,13 @@ UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t options, } else { - int32_t customRuleLength = customRules->size; + int32_t customRuleLength = (int32_t)customRules->size; int32_t localeRulesLength; const UChar* localeRules = ucol_getRules(pCollator, &localeRulesLength); int32_t completeRulesLength = localeRulesLength + customRuleLength + 1; - UChar* completeRules = calloc(completeRulesLength, sizeof(UChar)); + UChar* completeRules = calloc((size_t)completeRulesLength, sizeof(UChar)); for (int i = 0; i < localeRulesLength; i++) { @@ -336,7 +336,7 @@ static int CanIgnoreAllCollationElements(const UCollator* pColl, const UChar* lp return U_SUCCESS(err) ? result : FALSE; } -void CreateSortHandle(SortHandle** ppSortHandle) +static void CreateSortHandle(SortHandle** ppSortHandle) { *ppSortHandle = (SortHandle*)malloc(sizeof(SortHandle)); if ((*ppSortHandle) == NULL) @@ -384,7 +384,7 @@ void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle) free(pSortHandle); } -const UCollator* GetCollatorFromSortHandle(SortHandle* pSortHandle, int32_t options, UErrorCode* pErr) +static const UCollator* GetCollatorFromSortHandle(SortHandle* pSortHandle, int32_t options, UErrorCode* pErr) { if (options == 0) { @@ -562,13 +562,18 @@ int32_t GlobalizationNative_IndexOfOrdinalIgnoreCase( { int32_t srcIdx = i, trgIdx = 0; const UChar *src = lpSource, *trg = lpTarget; - UChar32 srcCodepoint, trgCodepoint; int32_t match = TRUE; while (trgIdx < cwTargetLength) { + UChar32 srcCodepoint, trgCodepoint; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wsign-conversion" U16_NEXT(src, srcIdx, cwSourceLength, srcCodepoint); U16_NEXT(trg, trgIdx, cwTargetLength, trgCodepoint); +#pragma clang diagnostic pop + if (!AreEqualOrdinalIgnoreCase(srcCodepoint, trgCodepoint)) { match = FALSE; @@ -676,10 +681,8 @@ static int32_t inline SimpleAffix_Iterators(UCollationElements* pPatternIterator } } -int32_t SimpleAffix(const UCollator* pCollator, UErrorCode* pErrorCode, const UChar* pPattern, int32_t patternLength, const UChar* pText, int32_t textLength, int32_t options, int32_t forwardSearch) +static int32_t SimpleAffix(const UCollator* pCollator, UErrorCode* pErrorCode, const UChar* pPattern, int32_t patternLength, const UChar* pText, int32_t textLength, int32_t forwardSearch) { - assert(options <= CompareOptionsIgnoreCase); - int32_t result = FALSE; UCollationElements* pPatternIterator = ucol_openElements(pCollator, pPattern, patternLength, pErrorCode); @@ -701,7 +704,7 @@ int32_t SimpleAffix(const UCollator* pCollator, UErrorCode* pErrorCode, const UC return result; } -int32_t ComplexStartsWith(const UCollator* pCollator, UErrorCode* pErrorCode, const UChar* pPattern, int32_t patternLength, const UChar* pText, int32_t textLength) +static int32_t ComplexStartsWith(const UCollator* pCollator, UErrorCode* pErrorCode, const UChar* pPattern, int32_t patternLength, const UChar* pText, int32_t textLength) { int32_t result = FALSE; @@ -752,11 +755,11 @@ int32_t GlobalizationNative_StartsWith( } else { - return SimpleAffix(pCollator, &err, lpTarget, cwTargetLength, lpSource, cwSourceLength, options, TRUE); + return SimpleAffix(pCollator, &err, lpTarget, cwTargetLength, lpSource, cwSourceLength, TRUE); } } -int32_t ComplexEndsWith(const UCollator* pCollator, UErrorCode* pErrorCode, const UChar* pPattern, int32_t patternLength, const UChar* pText, int32_t textLength) +static int32_t ComplexEndsWith(const UCollator* pCollator, UErrorCode* pErrorCode, const UChar* pPattern, int32_t patternLength, const UChar* pText, int32_t textLength) { int32_t result = FALSE; @@ -809,7 +812,7 @@ int32_t GlobalizationNative_EndsWith( } else { - return SimpleAffix(pCollator, &err, lpTarget, cwTargetLength, lpSource, cwSourceLength, options, FALSE); + return SimpleAffix(pCollator, &err, lpTarget, cwTargetLength, lpSource, cwSourceLength, FALSE); } } @@ -846,11 +849,13 @@ int32_t GlobalizationNative_CompareStringOrdinalIgnoreCase( while (str1Idx < cwStr1Length && str2Idx < cwStr2Length) { - UChar32 str1Codepoint; - UChar32 str2Codepoint; + UChar32 str1Codepoint, str2Codepoint; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wsign-conversion" U16_NEXT(lpStr1, str1Idx, cwStr1Length, str1Codepoint); U16_NEXT(lpStr2, str2Idx, cwStr2Length, str2Codepoint); +#pragma clang diagnostic pop if (str1Codepoint != str2Codepoint && u_toupper(str1Codepoint) != u_toupper(str2Codepoint)) { diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_collation.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_collation.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_collation.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_collation.h diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_compiler.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_compiler.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_compiler.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_compiler.h diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_errors.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_errors.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_errors.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_errors.h diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c similarity index 95% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_icushim.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c index 9c0614534cb02..a71c47ae0ac5f 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_icushim.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c @@ -19,15 +19,9 @@ FOR_ALL_ICU_FUNCTIONS static void* libicuuc = NULL; static void* libicui18n = NULL; -#define VERSION_PREFIX_NONE "" -#define VERSION_PREFIX_SUSE "suse" - -// .[suse]x.x.x, considering the max number of decimal digits for each component -#define MaxICUVersionStringLength (sizeof(VERSION_PREFIX_SUSE) + 33) - #ifdef __APPLE__ -static int FindICULibs(const char* versionPrefix, char* symbolName, char* symbolVersion) +static int FindICULibs() { #ifndef OSX_ICU_LIBRARY_PATH c_static_assert_msg(false, "The ICU Library path is not defined"); @@ -49,6 +43,12 @@ static int FindICULibs(const char* versionPrefix, char* symbolName, char* symbol #else // __APPLE__ +#define VERSION_PREFIX_NONE "" +#define VERSION_PREFIX_SUSE "suse" + +// .[suse]x.x.x, considering the max number of decimal digits for each component +#define MaxICUVersionStringLength (sizeof(VERSION_PREFIX_SUSE) + 33) + // Version ranges to search for each of the three version components // The rationale for major version range is that we support versions higher or // equal to the version we are built against and less or equal to that version @@ -249,14 +249,26 @@ static int FindICULibs(const char* versionPrefix, char* symbolName, char* symbol // return 0 if failed to load ICU and 1 otherwise int32_t GlobalizationNative_LoadICU() { +#ifdef __APPLE__ + + if (!FindICULibs()) + { + return FALSE; + } + + // Get pointers to all the ICU functions that are needed +#define PER_FUNCTION_BLOCK(fn, lib) \ + fn##_ptr = (__typeof(fn)*)dlsym(lib, #fn); \ + if (fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol %s from " #lib "\nError: %s\n", #fn, dlerror()); abort(); } + +#else // __APPLE__ + char symbolName[128]; char symbolVersion[MaxICUVersionStringLength + 1] = ""; if (!FindICULibs(VERSION_PREFIX_NONE, symbolName, symbolVersion)) { -#ifndef __APPLE__ if (!FindICULibs(VERSION_PREFIX_SUSE, symbolName, symbolVersion)) -#endif { return FALSE; } @@ -269,14 +281,11 @@ int32_t GlobalizationNative_LoadICU() 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(); } +#endif // __APPLE__ + FOR_ALL_ICU_FUNCTIONS #undef PER_FUNCTION_BLOCK -#ifdef __APPLE__ - // libicui18n initialized with libicuuc so we null it to avoid double closing same handle - libicui18n = NULL; -#endif // __APPLE__ - return TRUE; } @@ -288,19 +297,3 @@ int32_t GlobalizationNative_GetICUVersion() u_getVersion((uint8_t *) &version); return version; } - -__attribute__((destructor)) -void ShutdownICUShim() -{ - if (libicuuc != NULL) - { - dlclose(libicuuc); - libicuuc = NULL; - } - - if (libicui18n != NULL) - { - dlclose(libicui18n); - libicui18n = NULL; - } -} diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_icushim.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.h similarity index 99% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_icushim.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.h index 68ce33ab6f196..fff2364026c49 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_icushim.h +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.h @@ -6,8 +6,7 @@ // Enable calling ICU functions through shims to enable support for // multiple versions of ICU. -#ifndef __ICUSHIM_H__ -#define __ICUSHIM_H__ +#pragma once #include "config.h" #include "pal_compiler.h" @@ -241,8 +240,6 @@ FOR_ALL_ICU_FUNCTIONS #define usearch_last(...) usearch_last_ptr(__VA_ARGS__) #define usearch_openFromCollator(...) usearch_openFromCollator_ptr(__VA_ARGS__) -#endif // __ICUSHIM_H__ - DLLEXPORT int32_t GlobalizationNative_LoadICU(void); DLLEXPORT int32_t GlobalizationNative_GetICUVersion(void); diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_idna.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_idna.c similarity index 88% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_idna.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_idna.c index 303a2eccc5a21..6ce504d61f948 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_idna.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_idna.c @@ -8,10 +8,10 @@ #include "pal_icushim.h" #include "pal_idna.h" -const uint32_t AllowUnassigned = 0x1; -const uint32_t UseStd3AsciiRules = 0x2; +static const uint32_t AllowUnassigned = 0x1; +static const uint32_t UseStd3AsciiRules = 0x2; -uint32_t GetOptions(uint32_t flags) +static uint32_t GetOptions(uint32_t flags) { // Using Nontransitional to Unicode and Check ContextJ to match the current behavior of .NET on Windows uint32_t options = UIDNA_NONTRANSITIONAL_TO_UNICODE | UIDNA_CHECK_CONTEXTJ; @@ -51,7 +51,7 @@ int32_t GlobalizationNative_ToAscii( int32_t asciiStrLen = uidna_nameToASCII(pIdna, lpSrc, cwSrcLength, lpDst, cwDstLength, &info, &err); // To have a consistent behavior with Windows, we mask out the error when having 2 hyphens in the third and fourth place. - info.errors &= ~UIDNA_ERROR_HYPHEN_3_4; + info.errors &= (uint32_t)~UIDNA_ERROR_HYPHEN_3_4; uidna_close(pIdna); @@ -70,7 +70,7 @@ Return values: >0: the length of the converted string (not including the null terminator). */ int32_t GlobalizationNative_ToUnicode( - int32_t flags, const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength) + uint32_t flags, const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength) { UErrorCode err = U_ZERO_ERROR; UIDNAInfo info = UIDNA_INFO_INITIALIZER; diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_idna.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_idna.h similarity index 93% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_idna.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_idna.h index f9ff5e4770882..f2228cbd535fc 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_idna.h +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_idna.h @@ -12,7 +12,7 @@ DLLEXPORT int32_t GlobalizationNative_ToAscii(uint32_t flags, UChar* lpDst, int32_t cwDstLength); -DLLEXPORT int32_t GlobalizationNative_ToUnicode(int32_t flags, +DLLEXPORT int32_t GlobalizationNative_ToUnicode(uint32_t flags, const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_locale.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_locale.c similarity index 97% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_locale.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_locale.c index 9054590c36569..9508f97c8bd62 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_locale.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_locale.c @@ -96,14 +96,14 @@ void u_charsToUChars_safe(const char* str, UChar* value, int32_t valueLength, UE return; } - int len = strlen(str); - if (len >= valueLength) + size_t len = strlen(str); + if (len >= (size_t)valueLength) { *err = U_BUFFER_OVERFLOW_ERROR; return; } - u_charsToUChars(str, value, len + 1); + u_charsToUChars(str, value, (int32_t)(len + 1)); } int32_t FixupLocaleName(UChar* value, int32_t valueLength) @@ -160,7 +160,7 @@ int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength) if (pLocaleName[0] == 0) // unexpected empty name return -2; - int32_t localeNameLength = strlen(pLocaleName); + int32_t localeNameLength = (int32_t)strlen(pLocaleName); totalLength += localeNameLength + 1; // add 1 for the name length diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_locale.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_locale.h similarity index 97% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_locale.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_locale.h index 134291e4d4579..7d3992d34ba92 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_locale.h +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_locale.h @@ -49,7 +49,7 @@ DetectDefaultLocaleName Detect the default locale for the machine, defaulting to Invaraint if we can't compute one (different from uloc_getDefault()) would do. */ -const char* DetectDefaultLocaleName(); +const char* DetectDefaultLocaleName(void); DLLEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_localeNumberData.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.c similarity index 97% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_localeNumberData.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.c index 5663c63d82516..01d970a5b9991 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_localeNumberData.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.c @@ -14,7 +14,6 @@ #define UCHAR_SPACE ((UChar)0x0020) // space #define UCHAR_NBSPACE ((UChar)0x00A0) // space #define UCHAR_DIGIT ((UChar)0x0023) // '#' -#define UCHAR_SEMICOLON ((UChar)0x003B) // ';' #define UCHAR_MINUS ((UChar)0x002D) // '-' #define UCHAR_PERCENT ((UChar)0x0025) // '%' #define UCHAR_OPENPAREN ((UChar)0x0028) // '(' @@ -85,14 +84,14 @@ static char* NormalizeNumericPattern(const UChar* srcPattern, int isNegative) // minus sign if (isNegative && !minusAdded) { - size_t length = (iEnd - iStart) + 2; - destPattern = calloc(length, sizeof(char)); + int length = (iEnd - iStart) + 2; + destPattern = calloc((size_t)length, sizeof(char)); destPattern[index++] = '-'; } else { - size_t length = (iEnd - iStart) + 1; - destPattern = calloc(length, sizeof(char)); + int length = (iEnd - iStart) + 1; + destPattern = calloc((size_t)length, sizeof(char)); } for (int i = iStart; i <= iEnd; i++) @@ -164,7 +163,7 @@ static int GetNumericPattern(const UNumberFormat* pNumberFormat, UErrorCode ignore = U_ZERO_ERROR; int32_t icuPatternLength = unum_toPattern(pNumberFormat, FALSE, NULL, 0, &ignore) + 1; - UChar* icuPattern = calloc(icuPatternLength, sizeof(UChar)); + UChar* icuPattern = calloc((size_t)icuPatternLength, sizeof(UChar)); if (icuPattern == NULL) { return U_MEMORY_ALLOCATION_ERROR; @@ -200,7 +199,9 @@ static int GetNumericPattern(const UNumberFormat* pNumberFormat, } } - assert(FALSE); // should have found a valid pattern + // TODO: https://github.com/dotnet/runtime/issues/946 + // assert(FALSE); // should have found a valid pattern + free(normalizedPattern); return INVALID_FORMAT; } @@ -418,7 +419,7 @@ int32_t GlobalizationNative_GetLocaleInfoInt( switch (localeNumberData) { case LocaleNumber_LanguageId: - *value = uloc_getLCID(locale); + *value = (int32_t)uloc_getLCID(locale); break; case LocaleNumber_MeasurementSystem: status = GetMeasurementSystem(locale, value); diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_localeNumberData.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_localeNumberData.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.h diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_localeStringData.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_localeStringData.c similarity index 98% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_localeStringData.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_localeStringData.c index a38b015ad6c5b..c16b87d3af78d 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_localeStringData.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_localeStringData.c @@ -77,7 +77,7 @@ static UErrorCode GetLocaleIso639LanguageTwoLetterName(const char* locale, UChar UErrorCode status = U_ZERO_ERROR, ignore = U_ZERO_ERROR; int32_t length = uloc_getLanguage(locale, NULL, 0, &ignore) + 1; - char* buf = calloc(length, sizeof(char)); + char* buf = calloc((size_t)length, sizeof(char)); if (buf == NULL) { return U_MEMORY_ALLOCATION_ERROR; @@ -120,7 +120,7 @@ static UErrorCode GetLocaleIso3166CountryName(const char* locale, UChar* value, UErrorCode status = U_ZERO_ERROR, ignore = U_ZERO_ERROR; int32_t length = uloc_getCountry(locale, NULL, 0, &ignore) + 1; - char* buf = calloc(length, sizeof(char)); + char* buf = calloc((size_t)length, sizeof(char)); if (buf == NULL) { return U_MEMORY_ALLOCATION_ERROR; @@ -143,7 +143,7 @@ static UErrorCode GetLocaleIso3166CountryCode(const char* locale, UChar* value, { UErrorCode status = U_ZERO_ERROR; const char *pIsoCountryName = uloc_getISO3Country(locale); - int len = strlen(pIsoCountryName); + size_t len = strlen(pIsoCountryName); if (len == 0) { @@ -333,7 +333,7 @@ int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, default: status = U_UNSUPPORTED_ERROR; break; - }; + } return UErrorCodeToBool(status); } diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_localeStringData.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_localeStringData.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_localeStringData.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_localeStringData.h diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_normalization.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_normalization.c similarity index 95% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_normalization.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_normalization.c index 1fc880b6d0d03..46b41554b7d3d 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/pal_normalization.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_normalization.c @@ -8,7 +8,7 @@ #include "pal_icushim.h" #include "pal_normalization.h" -const UNormalizer2* GetNormalizerForForm(NormalizationForm normalizationForm, UErrorCode* pErrorCode) +static const UNormalizer2* GetNormalizerForForm(NormalizationForm normalizationForm, UErrorCode* pErrorCode) { switch (normalizationForm) { diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_normalization.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_normalization.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_normalization.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_normalization.h diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_timeZoneInfo.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_timeZoneInfo.c similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_timeZoneInfo.c rename to src/libraries/Native/Unix/System.Globalization.Native/pal_timeZoneInfo.c diff --git a/src/coreclr/src/corefx/System.Globalization.Native/pal_timeZoneInfo.h b/src/libraries/Native/Unix/System.Globalization.Native/pal_timeZoneInfo.h similarity index 100% rename from src/coreclr/src/corefx/System.Globalization.Native/pal_timeZoneInfo.h rename to src/libraries/Native/Unix/System.Globalization.Native/pal_timeZoneInfo.h diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt index 5f3df32a716aa..b7a822ac04d73 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt @@ -1,11 +1,7 @@ project(System.Net.Security.Native C) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) -add_definitions(-DPIC=1) - if (HAVE_GSSFW_HEADERS) find_library(LIBGSS NAMES GSS) if(LIBGSS STREQUAL LIBGSS-NOTFOUND) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt index fcb96e1a45098..6143c43e22b73 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt @@ -1,9 +1,5 @@ project(System.Security.Cryptography.Native.Apple C) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -add_definitions(-DPIC=1) - find_library(COREFOUNDATION_LIBRARY CoreFoundation) find_library(SECURITY_LIBRARY Security) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt index 056001927f1b1..bdf4772f88a3b 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt @@ -1,14 +1,12 @@ project(System.Security.Cryptography.Native C) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - # These are happening inside of OpenSSL-defined macros out of our control add_compile_options(-Wno-cast-align) add_compile_options(-Wno-reserved-id-macro) add_compile_options(-Wno-documentation) add_compile_options(-Wno-used-but-marked-unused) -add_definitions(-DPIC=1 -DOPENSSL_API_COMPAT=0x10100000L) +add_definitions(-DOPENSSL_API_COMPAT=0x10100000L) if(CMAKE_STATIC_LIB_LINK) set(CMAKE_FIND_LIBRARY_SUFFIXES .a) 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 08d73b805a08a..2d3fe03bb9021 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.c +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.c @@ -117,12 +117,3 @@ static void InitializeOpenSSLShim() #undef NEW_REQUIRED_FUNCTION #undef REQUIRED_FUNCTION } - -__attribute__((destructor)) -static void ShutdownOpenSSLShim() -{ - if (libssl != NULL) - { - dlclose(libssl); - } -} diff --git a/src/libraries/Native/Unix/verify-so.sh b/src/libraries/Native/Unix/verify-so.sh index 07a23d6cc4421..9b204add3a97f 100755 --- a/src/libraries/Native/Unix/verify-so.sh +++ b/src/libraries/Native/Unix/verify-so.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # $1 contains full path to the .so to verify # $2 contains message to print when the verification fails -ldd -r $1 | awk 'BEGIN {count=0} /undefined symbol:/ { if (count==0) {print "Undefined symbol(s) found:"} print " " $3; count++ } END {if (count>0) exit(1)}' +ldd -r $1 2>&1 | awk 'BEGIN {count=0} /undefined symbol:/ { if (count==0) {print "Undefined symbol(s) found:"} print " " $3; count++ } END {if (count>0) exit(1)}' if [ $? != 0 ]; then echo "$2" exit 1