Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set callconv in unicodedata callback and update doc #103852

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 4 additions & 4 deletions src/native/minipal/UnicodeDataGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
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.

//
// THIS FILE IS GENERATED. DO NOT HAND EDIT.
// IF YOU NEED TO UPDATE UNICODE VERSION FOLLOW THE GUIDE AT src/libraries/System.Private.CoreLib/Tools/GenUnicodeProp/Updating-Unicode-Versions.md
//

#include <minipal/strings.h>
#include <inttypes.h>
#include <minipal/utils.h>
#include <minipal/strings.h>

typedef struct
{
Expand Down Expand Up @@ -71,7 +71,7 @@ typedef struct
#define UNICODE_DATA_SIZE {numberOfCases}");

Console.WriteLine(@"
static int UnicodeDataComp(const void *opposingCode, const void *elem)
static int LIBC_CALLBACK UnicodeDataComp(const void *opposingCode, const void *elem)
{
CHAR16_T code = ((UnicodeDataRec*)elem)->code;

Expand Down
6 changes: 3 additions & 3 deletions src/native/minipal/unicodedata.c
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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 <minipal/strings.h>
#include <inttypes.h>
#include <minipal/utils.h>
#include <minipal/strings.h>

typedef struct
{
Expand Down Expand Up @@ -2385,7 +2385,7 @@ static const UnicodeDataRec UnicodeData[] =

#define UNICODE_DATA_SIZE 2359

static int UnicodeDataComp(const void *opposingCode, const void *elem)
static int LIBC_CALLBACK UnicodeDataComp(const void *opposingCode, const void *elem)
{
CHAR16_T code = ((UnicodeDataRec*)elem)->code;

Expand Down
6 changes: 6 additions & 0 deletions src/native/minipal/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading