-
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
| } | ||
| } | ||
| 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; | ||
| } | ||
|
Comment on lines
+14
to
+22
|
||
|
|
||
| return workingSet; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| 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 | ||
|
|
||
| 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 | ||
| } | ||
| 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); |
Uh oh!
There was an error while loading. Please reload this page.