From f6e192a093f561e8d5872e2ebe8e727de39e090b Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Sat, 22 Jun 2024 14:39:29 +0300 Subject: [PATCH 1/4] Set callconv in unicodedata callback and update doc --- .../GenUnicodeProp/Updating-Unicode-Versions.md | 10 +++++++++- src/native/minipal/UnicodeDataGenerator/Program.cs | 8 ++++---- src/native/minipal/unicodedata.c | 6 +++--- src/native/minipal/utils.h | 14 ++++++++++---- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/Tools/GenUnicodeProp/Updating-Unicode-Versions.md b/src/libraries/System.Private.CoreLib/Tools/GenUnicodeProp/Updating-Unicode-Versions.md index 7a9087f4134e6..f545d810ccdfa 100644 --- a/src/libraries/System.Private.CoreLib/Tools/GenUnicodeProp/Updating-Unicode-Versions.md +++ b/src/libraries/System.Private.CoreLib/Tools/GenUnicodeProp/Updating-Unicode-Versions.md @@ -41,7 +41,15 @@ This should be done automatically by dependency-flow, so in theory there shouldn - System.Globalization.Tests.csproj - System.Globalization.Nls.Tests.csproj - System.Text.Encodings.Web.Tests.csproj -4. If the new Unicode data contains casing changes/updates, then we will also need to update `src/native/minipal/UnicodeDataGenerator/unicodedata.c` file. This file is used by most of the reflection stack whenever you specify the `BindingFlags.IgnoreCase`. In order to regenerate the contents of the `unicdedata.c` file, you need to run the Program located at `src/native/minipal/UnicodeDataGenerator/unicodedata.cs` and give a full path to the new UnicodeData.txt as a parameter. +4. If the new Unicode data contains casing changes/updates, then we will also need to update `src/native/minipal/unicodedata.c` file. This file is used by most of the reflection stack whenever you specify the `BindingFlags.IgnoreCase`. In order to regenerate the contents of the `unicdedata.c` file, you need to run the Program located at `src/native/minipal/UnicodeDataGenerator/unicodedata.cs` and give a full path to the new UnicodeData.txt as a parameter. e.g. in Unix shell: + ```sh + # download UnicodeData.txt + $ curl -sSLo /tmp/UnicodeData.txt https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt + + # update unicodedata.c + $ cd runtime + $ ./dotnet.sh run --project src/native/minipal/UnicodeDataGenerator /tmp/UnicodeData.txt > src/native/minipal/unicodedata.c + ``` 5. Update the Regex casing equivalence table using the UnicodeData.txt file from the new Unicode version. You can find the instructions on how to do this [here](../../../System.Text.RegularExpressions/tools/Readme.md). 6. Finally, last step is to update the license for the Unicode data into our [Third party notices](../../../../../THIRD-PARTY-NOTICES.TXT) by copying the contents located in `https://www.unicode.org/license.html` to the section that has the Unicode license in our notices. 7. That's it, now commit all of the changed files, and send a PR into dotnet/runtime with the updates. If there were any special things you had to do that are not noted on this document, PLEASE UPDATE THESE INSTRUCTIONS to facilitate future updates. diff --git a/src/native/minipal/UnicodeDataGenerator/Program.cs b/src/native/minipal/UnicodeDataGenerator/Program.cs index f4611ef26454f..3ecf9f45bbf8e 100644 --- a/src/native/minipal/UnicodeDataGenerator/Program.cs +++ b/src/native/minipal/UnicodeDataGenerator/Program.cs @@ -7,8 +7,7 @@ using System.IO; using System.Linq; -Console.WriteLine(@" -// Licensed to the .NET Foundation under one or more agreements. +Console.WriteLine(@"// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // @@ -16,8 +15,9 @@ // IF YOU NEED TO UPDATE UNICODE VERSION FOLLOW THE GUIDE AT src/libraries/System.Private.CoreLib/Tools/GenUnicodeProp/Updating-Unicode-Versions.md // -#include #include +#include +#include typedef struct { @@ -71,7 +71,7 @@ typedef struct #define UNICODE_DATA_SIZE {numberOfCases}"); Console.WriteLine(@" -static int UnicodeDataComp(const void *opposingCode, const void *elem) +static int CALLBACK_CALLCONV UnicodeDataComp(const void *opposingCode, const void *elem) { CHAR16_T code = ((UnicodeDataRec*)elem)->code; diff --git a/src/native/minipal/unicodedata.c b/src/native/minipal/unicodedata.c index 18c1d02139723..3ec43311f86f5 100644 --- a/src/native/minipal/unicodedata.c +++ b/src/native/minipal/unicodedata.c @@ -1,4 +1,3 @@ - // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. @@ -7,8 +6,9 @@ // IF YOU NEED TO UPDATE UNICODE VERSION FOLLOW THE GUIDE AT src/libraries/System.Private.CoreLib/Tools/GenUnicodeProp/Updating-Unicode-Versions.md // -#include #include +#include +#include typedef struct { @@ -2385,7 +2385,7 @@ static const UnicodeDataRec UnicodeData[] = #define UNICODE_DATA_SIZE 2359 -static int UnicodeDataComp(const void *opposingCode, const void *elem) +static int CALLBACK_CALLCONV UnicodeDataComp(const void *opposingCode, const void *elem) { CHAR16_T code = ((UnicodeDataRec*)elem)->code; diff --git a/src/native/minipal/utils.h b/src/native/minipal/utils.h index ef840a529f48f..cceb95b178dca 100644 --- a/src/native/minipal/utils.h +++ b/src/native/minipal/utils.h @@ -50,13 +50,19 @@ # define DISABLE_ASAN #endif +#if defined(_MSC_VER) +#define CALLBACK_CALLCONV _cdecl +#else +#define CALLBACK_CALLCONV +#endif + #if defined(_MSC_VER) # ifdef SANITIZER_SHARED_RUNTIME -# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) __cdecl -# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) __cdecl +# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) CALLBACK_CALLCONV +# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) CALLBACK_CALLCONV # else -# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) __cdecl -# define SANITIZER_INTERFACE_CALLCONV __cdecl +# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) CALLBACK_CALLCONV +# define SANITIZER_INTERFACE_CALLCONV CALLBACK_CALLCONV # endif #else # ifdef SANITIZER_SHARED_RUNTIME From 70f1a6ed3188fbd5b67e712131ad26bb2a6d65c2 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Sun, 23 Jun 2024 22:46:43 +0300 Subject: [PATCH 2/4] Address CR feedback --- src/native/minipal/UnicodeDataGenerator/Program.cs | 2 +- src/native/minipal/unicodedata.c | 2 +- src/native/minipal/utils.h | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/native/minipal/UnicodeDataGenerator/Program.cs b/src/native/minipal/UnicodeDataGenerator/Program.cs index 3ecf9f45bbf8e..f98c6ea31f919 100644 --- a/src/native/minipal/UnicodeDataGenerator/Program.cs +++ b/src/native/minipal/UnicodeDataGenerator/Program.cs @@ -71,7 +71,7 @@ typedef struct #define UNICODE_DATA_SIZE {numberOfCases}"); Console.WriteLine(@" -static int CALLBACK_CALLCONV UnicodeDataComp(const void *opposingCode, const void *elem) +static int LIBC_CALLBACK UnicodeDataComp(const void *opposingCode, const void *elem) { CHAR16_T code = ((UnicodeDataRec*)elem)->code; diff --git a/src/native/minipal/unicodedata.c b/src/native/minipal/unicodedata.c index 3ec43311f86f5..e38aba8f553f7 100644 --- a/src/native/minipal/unicodedata.c +++ b/src/native/minipal/unicodedata.c @@ -2385,7 +2385,7 @@ static const UnicodeDataRec UnicodeData[] = #define UNICODE_DATA_SIZE 2359 -static int CALLBACK_CALLCONV UnicodeDataComp(const void *opposingCode, const void *elem) +static int LIBC_CALLBACK UnicodeDataComp(const void *opposingCode, const void *elem) { CHAR16_T code = ((UnicodeDataRec*)elem)->code; diff --git a/src/native/minipal/utils.h b/src/native/minipal/utils.h index cceb95b178dca..84f5353aac089 100644 --- a/src/native/minipal/utils.h +++ b/src/native/minipal/utils.h @@ -51,18 +51,18 @@ #endif #if defined(_MSC_VER) -#define CALLBACK_CALLCONV _cdecl +#define LIBC_CALLBACK _cdecl #else -#define CALLBACK_CALLCONV +#define LIBC_CALLBACK #endif #if defined(_MSC_VER) # ifdef SANITIZER_SHARED_RUNTIME -# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) CALLBACK_CALLCONV -# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) CALLBACK_CALLCONV +# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) LIBC_CALLBACK +# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) LIBC_CALLBACK # else -# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) CALLBACK_CALLCONV -# define SANITIZER_INTERFACE_CALLCONV CALLBACK_CALLCONV +# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) LIBC_CALLBACK +# define SANITIZER_INTERFACE_CALLCONV LIBC_CALLBACK # endif #else # ifdef SANITIZER_SHARED_RUNTIME From 718e74143bb73181064342ef69eb9f7c6a7c600f Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:40:38 +0300 Subject: [PATCH 3/4] Update utils.h --- src/native/minipal/utils.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/native/minipal/utils.h b/src/native/minipal/utils.h index 84f5353aac089..4b4dfb5167102 100644 --- a/src/native/minipal/utils.h +++ b/src/native/minipal/utils.h @@ -32,6 +32,12 @@ # define FALLTHROUGH #endif +#if defined(_MSC_VER) +#define LIBC_CALLBACK _cdecl +#else +#define LIBC_CALLBACK +#endif + #if defined(_MSC_VER) # if defined(__SANITIZE_ADDRESS__) # define HAS_ADDRESS_SANITIZER @@ -50,19 +56,13 @@ # define DISABLE_ASAN #endif -#if defined(_MSC_VER) -#define LIBC_CALLBACK _cdecl -#else -#define LIBC_CALLBACK -#endif - #if defined(_MSC_VER) # ifdef SANITIZER_SHARED_RUNTIME -# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) LIBC_CALLBACK -# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) LIBC_CALLBACK +# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) _cdecl +# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) _cdecl # else -# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) LIBC_CALLBACK -# define SANITIZER_INTERFACE_CALLCONV LIBC_CALLBACK +# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) _cdecl +# define SANITIZER_INTERFACE_CALLCONV _cdecl # endif #else # ifdef SANITIZER_SHARED_RUNTIME From c6619c264ef9879119e36cde44fcddbebfba4804 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:41:47 +0300 Subject: [PATCH 4/4] Update utils.h --- src/native/minipal/utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/native/minipal/utils.h b/src/native/minipal/utils.h index 4b4dfb5167102..768de9e48b4b2 100644 --- a/src/native/minipal/utils.h +++ b/src/native/minipal/utils.h @@ -33,7 +33,7 @@ #endif #if defined(_MSC_VER) -#define LIBC_CALLBACK _cdecl +#define LIBC_CALLBACK __cdecl #else #define LIBC_CALLBACK #endif @@ -58,11 +58,11 @@ #if defined(_MSC_VER) # ifdef SANITIZER_SHARED_RUNTIME -# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) _cdecl -# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) _cdecl +# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) __cdecl +# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) __cdecl # else -# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) _cdecl -# define SANITIZER_INTERFACE_CALLCONV _cdecl +# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) __cdecl +# define SANITIZER_INTERFACE_CALLCONV __cdecl # endif #else # ifdef SANITIZER_SHARED_RUNTIME