Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
safern committed Mar 19, 2020
1 parent c1216d2 commit f2e22b4
Show file tree
Hide file tree
Showing 102 changed files with 207 additions and 213 deletions.
1 change: 1 addition & 0 deletions src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ set(CORECLR_LIBRARIES
gcinfo # Condition="'$(TargetCpu)'=='amd64' or '$(TargetCpu)' == 'arm' or '$(TargetCpu)' == 'arm64'"
ildbsymlib
utilcode
v3binder
System.Globalization.Native-Static
libraries-native
interop
Expand Down
10 changes: 3 additions & 7 deletions src/coreclr/src/libraries-native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(GLOBALIZATION_NATIVE_DIR ${CLR_REPO_ROOT_DIR}/src/libraries/Native/AnyOS/System.Globalization.Native)
set(GLOBALIZATION_NATIVE_DIR ${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Globalization.Native)

# Suppress exporting of the PAL APIs
add_definitions(-DPALEXPORT=)
add_definitions(-DPALEXPORT=EXTERN_C)

include_directories("${GLOBALIZATION_NATIVE_DIR}")
include_directories("${CLR_REPO_ROOT_DIR}/src/libraries/Native/AnyOS/Common")
include_directories("${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/Common")

add_subdirectory(${GLOBALIZATION_NATIVE_DIR} System.Globalization.Native)

if(CLR_CMAKE_HOST_UNIX)
include_directories("${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/Common")
endif()

add_library(libraries-native
STATIC
entrypoints.c
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/libraries/Native/AnyOS/zlib/pal_zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define FUNCTIONCALLINGCONVENCTION WINAPI
#else
#include "pal_types.h"
#include "compiler.h"
#include "pal_compiler.h"
#define FUNCTIONEXPORT PALEXPORT
#define FUNCTIONCALLINGCONVENCTION
#endif
Expand Down
4 changes: 1 addition & 3 deletions src/libraries/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ endfunction()

include(configure.cmake)

include_directories(../AnyOS/Common)

add_subdirectory(System.IO.Compression.Native)

if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
Expand All @@ -224,7 +222,7 @@ add_subdirectory(System.Native)

if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
if (NOT CLR_CMAKE_TARGET_IOS) # TODO: reenable
add_subdirectory(../AnyOS/System.Globalization.Native System.Globalization.Native)
add_subdirectory(System.Globalization.Native)
add_subdirectory(System.Net.Security.Native)
endif()
if (NOT CLR_CMAKE_TARGET_IOS)
Expand Down
19 changes: 19 additions & 0 deletions src/libraries/Native/Unix/Common/pal_atomic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//

#if defined(TARGET_UNIX)
#include <stdatomic.h>
#elif defined(TARGET_WINDOWS)
#include "windows.h"
#endif

static int pal_atomic_cas_ptr(void* volatile *dest, void* exchange, void* comperand)
{
#if defined(TARGET_UNIX)
return atomic_compare_exchange_strong_explicit((_Atomic(void*)volatile*)dest, exchange, comperand, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
#elif defined(TARGET_WINDOWS)
return InterlockedCompareExchangePointer(dest, exchange, comperand) == comperand;
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#define EXTERN_C extern
#endif // __cplusplus
#endif // EXTERN_C
2 changes: 1 addition & 1 deletion src/libraries/Native/Unix/Common/pal_safecrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "compiler.h"
#include "pal_compiler.h"
#include "pal_config.h"

#include <string.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#ifdef TARGET_UNIX
#include <strings.h>
#endif

#include "pal_locale_internal.h"
#include "pal_errors_internal.h"
#include "pal_calendarData.h"

#ifndef TARGET_UNIX
#if defined(TARGET_UNIX)
#include <strings.h>

#define STRING_COPY(localeNamePtr, size, locale, capacity) \
strncpy(localeNamePtr, locale, capacity); \
localeNamePtr[capacity - 1] = 0;

#elif defined(TARGET_WINDOWS)
#define strcasecmp _stricmp
#define STRING_COPY(localeNamePtr, size, locale, capacity) strncpy_s(localeNamePtr, size, locale, _TRUNCATE);
#endif

#define GREGORIAN_NAME "gregorian"
Expand Down Expand Up @@ -313,12 +316,7 @@ static int32_t EnumSymbols(const char* locale,
return FALSE;

char localeWithCalendarName[ULOC_FULLNAME_CAPACITY];
#ifdef TARGET_UNIX
strncpy(localeWithCalendarName, locale, ULOC_FULLNAME_CAPACITY);
#else
strncpy_s(localeWithCalendarName, sizeof(locale), locale, ULOC_FULLNAME_CAPACITY);
#endif
localeWithCalendarName[ULOC_FULLNAME_CAPACITY - 1] = 0;
STRING_COPY(localeWithCalendarName, sizeof(locale), locale, ULOC_FULLNAME_CAPACITY);

uloc_setKeywordValue("calendar", GetCalendarName(calendarId), localeWithCalendarName, ULOC_FULLNAME_CAPACITY, &err);

Expand Down Expand Up @@ -425,12 +423,7 @@ static int32_t EnumAbbrevEraNames(const char* locale,

char* localeNamePtr = localeNameBuf;
char* parentNamePtr = parentNameBuf;
#ifdef TARGET_UNIX
strncpy(localeNamePtr, locale, ULOC_FULLNAME_CAPACITY);
#else
strncpy_s(localeNamePtr, sizeof(locale), locale, ULOC_FULLNAME_CAPACITY);
#endif
localeNamePtr[ULOC_FULLNAME_CAPACITY - 1] = 0;
STRING_COPY(localeNamePtr, sizeof(locale), locale, ULOC_FULLNAME_CAPACITY);

while (TRUE)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdlib.h>

#include "pal_locale.h"
#include "compiler.h"
#include "pal_compiler.h"
#include "pal_errors.h"

/*
Expand Down Expand Up @@ -70,25 +70,25 @@ typedef enum
// the function pointer definition for the callback used in EnumCalendarInfo
typedef void (*EnumCalendarInfoCallback)(const UChar*, const void*);

EXTERN_C PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName,
PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName,
CalendarId* calendars,
int32_t calendarsCapacity);

EXTERN_C PALEXPORT ResultCode GlobalizationNative_GetCalendarInfo(const UChar* localeName,
PALEXPORT ResultCode GlobalizationNative_GetCalendarInfo(const UChar* localeName,
CalendarId calendarId,
CalendarDataType dataType,
UChar* result,
int32_t resultCapacity);

EXTERN_C PALEXPORT int32_t GlobalizationNative_EnumCalendarInfo(EnumCalendarInfoCallback callback,
PALEXPORT int32_t GlobalizationNative_EnumCalendarInfo(EnumCalendarInfoCallback callback,
const UChar* localeName,
CalendarId calendarId,
CalendarDataType dataType,
const void* context);

EXTERN_C PALEXPORT int32_t GlobalizationNative_GetLatestJapaneseEra(void);
PALEXPORT int32_t GlobalizationNative_GetLatestJapaneseEra(void);

EXTERN_C PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era,
PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era,
int32_t* startYear,
int32_t* startMonth,
int32_t* startDay);
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
// See the LICENSE file in the project root for more information.

#include "pal_locale.h"
#include "compiler.h"
#include "pal_compiler.h"

EXTERN_C PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc,
PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc,
int32_t cwSrcLength,
UChar* lpDst,
int32_t cwDstLength,
int32_t bToUpper);

EXTERN_C PALEXPORT void GlobalizationNative_ChangeCaseInvariant(const UChar* lpSrc,
PALEXPORT void GlobalizationNative_ChangeCaseInvariant(const UChar* lpSrc,
int32_t cwSrcLength,
UChar* lpDst,
int32_t cwDstLength,
int32_t bToUpper);

EXTERN_C PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc,
PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc,
int32_t cwSrcLength,
UChar* lpDst,
int32_t cwDstLength,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

#include "pal_errors_internal.h"
#include "pal_collation.h"

#ifndef TARGET_UNIX
#include <atomic>
#endif
#include "pal_atomic.h"

c_static_assert_msg(UCOL_EQUAL == 0, "managed side requires 0 for equal strings");
c_static_assert_msg(UCOL_LESS < 0, "managed side requires less than zero for a < b");
Expand Down Expand Up @@ -407,12 +404,7 @@ static const UCollator* GetCollatorFromSortHandle(SortHandle* pSortHandle, int32
pCollator = CloneCollatorWithOptions(pSortHandle->collatorsPerOption[0], options, pErr);
UCollator* pNull = NULL;

#ifdef TARGET_UNIX
// we are not using the standard atomic_compare_exchange_strong to workaround bugs in clang 5.0 (https://bugs.llvm.org/show_bug.cgi?id=37457)
if (!__atomic_compare_exchange_n(&pSortHandle->collatorsPerOption[options], &pNull, pCollator, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
#else
if (!::std::atomic_compare_exchange_strong_explicit((volatile ::std::atomic<UCollator*> *const)&pSortHandle->collatorsPerOption[options], &pNull, pCollator, ::std::memory_order_seq_cst, ::std::memory_order_seq_cst))
#endif
if (!pal_atomic_cas_ptr((void* volatile*)&pSortHandle->collatorsPerOption[options], &pNull, pCollator))
{
ucol_close(pCollator);
pCollator = pSortHandle->collatorsPerOption[options];
Expand All @@ -427,7 +419,7 @@ int32_t GlobalizationNative_GetSortVersion(SortHandle* pSortHandle)
{
UErrorCode err = U_ZERO_ERROR;
const UCollator* pColl = GetCollatorFromSortHandle(pSortHandle, 0, &err);
int32_t result = 0xFFFFFFFF;
int32_t result = -1;

if (U_SUCCESS(err))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,68 @@
#pragma once

#include "pal_locale.h"
#include "compiler.h"
#include "pal_compiler.h"
#include "pal_errors.h"

typedef struct SortHandle SortHandle;

EXTERN_C PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle);
PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle);

EXTERN_C PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle);
PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle);

// If we fail to get the sort version we will fallback to 0xFFFFFFFF as the sort version.
EXTERN_C PALEXPORT int32_t GlobalizationNative_GetSortVersion(SortHandle* pSortHandle);
// If we fail to get the sort version we will fallback to -1 as the sort version.
PALEXPORT int32_t GlobalizationNative_GetSortVersion(SortHandle* pSortHandle);

EXTERN_C PALEXPORT int32_t GlobalizationNative_CompareString(SortHandle* pSortHandle,
PALEXPORT int32_t GlobalizationNative_CompareString(SortHandle* pSortHandle,
const UChar* lpStr1,
int32_t cwStr1Length,
const UChar* lpStr2,
int32_t cwStr2Length,
int32_t options);

EXTERN_C PALEXPORT int32_t GlobalizationNative_IndexOf(SortHandle* pSortHandle,
PALEXPORT int32_t GlobalizationNative_IndexOf(SortHandle* pSortHandle,
const UChar* lpTarget,
int32_t cwTargetLength,
const UChar* lpSource,
int32_t cwSourceLength,
int32_t options,
int32_t* pMatchedLength);

EXTERN_C PALEXPORT int32_t GlobalizationNative_LastIndexOf(SortHandle* pSortHandle,
PALEXPORT int32_t GlobalizationNative_LastIndexOf(SortHandle* pSortHandle,
const UChar* lpTarget,
int32_t cwTargetLength,
const UChar* lpSource,
int32_t cwSourceLength,
int32_t options);

EXTERN_C PALEXPORT int32_t GlobalizationNative_IndexOfOrdinalIgnoreCase(const UChar* lpTarget,
PALEXPORT int32_t GlobalizationNative_IndexOfOrdinalIgnoreCase(const UChar* lpTarget,
int32_t cwTargetLength,
const UChar* lpSource,
int32_t cwSourceLength,
int32_t findLast);

EXTERN_C PALEXPORT int32_t GlobalizationNative_StartsWith(SortHandle* pSortHandle,
PALEXPORT int32_t GlobalizationNative_StartsWith(SortHandle* pSortHandle,
const UChar* lpTarget,
int32_t cwTargetLength,
const UChar* lpSource,
int32_t cwSourceLength,
int32_t options);

EXTERN_C PALEXPORT int32_t GlobalizationNative_EndsWith(SortHandle* pSortHandle,
PALEXPORT int32_t GlobalizationNative_EndsWith(SortHandle* pSortHandle,
const UChar* lpTarget,
int32_t cwTargetLength,
const UChar* lpSource,
int32_t cwSourceLength,
int32_t options);

EXTERN_C PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle,
PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle,
const UChar* lpStr,
int32_t cwStrLength,
uint8_t* sortKey,
int32_t cbSortKeyLength,
int32_t options);

EXTERN_C PALEXPORT int32_t GlobalizationNative_CompareStringOrdinalIgnoreCase(const UChar* lpStr1,
PALEXPORT int32_t GlobalizationNative_CompareStringOrdinalIgnoreCase(const UChar* lpStr1,
int32_t cwStr1Length,
const UChar* lpStr2,
int32_t cwStr2Length);
Loading

0 comments on commit f2e22b4

Please sign in to comment.