-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Haiku: Initial managed libraries support #121880
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
Merged
jkotas
merged 2 commits into
dotnet:main
from
trungnt2910:dev/trungnt2910/haiku-lib-corelib
Apr 11, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| internal static partial class Interop | ||
| { | ||
| internal static partial class OS | ||
| { | ||
| [StructLayout(LayoutKind.Sequential)] | ||
| internal unsafe struct AreaInfo | ||
| { | ||
| public nuint size; | ||
| public uint ram_size; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets information about areas owned by a team. | ||
| /// </summary> | ||
| /// <param name="team">The team ID of the areas to iterate.</param> | ||
| /// <param name="cookie">A cookie to track the iteration.</param> | ||
| /// <param name="areaInfo">The <see cref="AreaInfo"/> structure to fill in.</param> | ||
| /// <returns>Returns 0 on success. Returns an error code on failure or when there are no more areas to iterate.</returns> | ||
| [LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNextAreaInfo")] | ||
| internal static unsafe partial int GetNextAreaInfo(int team, ref nint cookie, out AreaInfo areaInfo); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/libraries/System.Private.CoreLib/src/System/Environment.Haiku.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace System | ||
| { | ||
| public static partial class Environment | ||
| { | ||
| public static unsafe long WorkingSet | ||
| { | ||
| get | ||
| { | ||
| nint cookie = 0; | ||
| long workingSet = 0; | ||
|
|
||
| Interop.OS.AreaInfo areaInfo; | ||
|
|
||
| while (Interop.OS.GetNextAreaInfo(ProcessId, ref cookie, out areaInfo) == 0) | ||
| { | ||
| workingSet += areaInfo.ram_size; | ||
| } | ||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return workingSet; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ endif () | |
|
|
||
| set(NATIVE_SOURCES | ||
| pal_errno.c | ||
| pal_getosinfo.c | ||
| pal_io.c | ||
| pal_maphardwaretype.c | ||
| pal_memory.c | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #include "pal_config.h" | ||
| #include "pal_getosinfo.h" | ||
| #include "pal_utilities.h" | ||
|
|
||
| #include <errno.h> | ||
| #include <string.h> | ||
|
|
||
| #if HAVE_OS_H | ||
| #include <OS.h> | ||
| #endif | ||
|
|
||
| int32_t SystemNative_GetNextAreaInfo(int32_t team, intptr_t* cookie, AreaInfo* areaInfo) | ||
| { | ||
| #if HAVE_OS_H | ||
trungnt2910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (cookie == NULL || areaInfo == NULL) | ||
| { | ||
| return EINVAL; | ||
| } | ||
|
|
||
| area_info nativeAreaInfo; | ||
| memset(&nativeAreaInfo, 0, sizeof(nativeAreaInfo)); | ||
|
|
||
| status_t status = get_next_area_info((team_id)team, cookie, &nativeAreaInfo); | ||
| if (status != B_OK) | ||
| { | ||
| return (int32_t)status; | ||
| } | ||
|
|
||
| areaInfo->size = (uintptr_t)nativeAreaInfo.size; | ||
| areaInfo->ram_size = (uint32_t)nativeAreaInfo.ram_size; | ||
|
|
||
| return (int32_t)status; | ||
| #else | ||
| (void)team; | ||
| (void)cookie; | ||
| (void)areaInfo; | ||
| return ENOTSUP; | ||
| #endif | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "pal_compiler.h" | ||
| #include "pal_types.h" | ||
|
|
||
| typedef struct | ||
| { | ||
| uintptr_t size; | ||
| uint32_t ram_size; | ||
| } AreaInfo; | ||
|
|
||
| PALEXPORT int32_t SystemNative_GetNextAreaInfo(int32_t team, intptr_t* cookie, AreaInfo* areaInfo); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.