Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix #91958: use mach_timebase_info to determine process time coefficient on macOS#92185
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
999d6ae4ba25eb8932990354d181d31f96c473d7fcce50c65File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // 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.Collections.Generic; | ||
| using System.ComponentModel; | ||
| using System.Diagnostics; | ||
| using System.Runtime.InteropServices; | ||
| internal static partial class Interop | ||
| { | ||
| internal static partial class libSystem | ||
| { | ||
| [LibraryImport(Interop.Libraries.libSystem)] | ||
| public static unsafe partial int mach_timebase_info(mach_timebase_info_data_t* info); | ||
| public struct mach_timebase_info_data_t | ||
| { | ||
| public uint numer; | ||
| public uint denom; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -120,4 +120,10 @@ | ||
| <data name="Argv_IncludeDoubleQuote" xml:space="preserve"> | ||
| <value>The argv[0] argument cannot include a double quote.</value> | ||
| </data> | ||
| <data name="CantGetAllPids" xml:space="preserve"> | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fix I've suggested in #92185 (comment) should just work, but I can take care of that in a separate PR to get the fix merged right now. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. | ||
| <value>Could not get all running Process IDs.</value> | ||
| </data> | ||
| <data name="RUsageFailure" xml:space="preserve"> | ||
| <value>Failed to set or retrieve rusage information. See the error code for OS-specific error information.</value> | ||
| </data> | ||
| </root> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkoritzinsky@AaronRobinsonMSFT In terms of marshaller best practices, do we need to explicitly specify sequential layout for such structs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, no. Value types in .NET default to sequential layout. However, and this is annoying, there are some Roslyn warnings that are suppressed if one does explicitly mark the type with sequential layout. The reasoning here is historical, but the gist is if Roslyn complains about unreferenced fields, which can happen for types used in interop, then placing
StructLayout(LayoutKind.Sequential)on the type will automatically suppress the warning.The interop team's general guidance here has been to accept the defaults except where there is annoying friction with C# or where the tooling requires explicit details. This falls into the C# friction bucket, but only if a warning is emitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AaronRobinsonMSFT thank you for a very detailed answer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see any related warnings in the compilation (and also we seem to have warnings as errors enabled in this part?).
Does this mean this attribute is unnecessary? I am totally okay with adding that if required. Though, yeah, we all know that sequential is the default struct layout 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.