Skip to content

Commit

Permalink
Use GeneratedDllImport for blittable p/invokes in System.Console, Sys…
Browse files Browse the repository at this point in the history
…tem.IO.FileSystem.Watcher, System.IO.Pipes (#61996)
  • Loading branch information
elinor-fung authored Nov 24, 2021
1 parent 3bfce3b commit 2307418
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ internal static partial void FSEventStreamScheduleWithRunLoop(
/// Stops receiving events on the specified stream. The stream can be restarted and not miss any events.
/// </summary>
/// <param name="streamRef">The stream to stop receiving events on.</param>
[DllImport(Interop.Libraries.CoreServicesLibrary)]
internal static extern void FSEventStreamStop(IntPtr streamRef);
[GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)]
internal static partial void FSEventStreamStop(IntPtr streamRef);

/// <summary>
/// Invalidates an EventStream and removes it from any RunLoops.
/// </summary>
/// <param name="streamRef">The FSEventStream to invalidate</param>
/// <remarks>This can only be called after FSEventStreamScheduleWithRunLoop has be called</remarks>
[DllImport(Interop.Libraries.CoreServicesLibrary)]
internal static extern void FSEventStreamInvalidate(IntPtr streamRef);
[GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)]
internal static partial void FSEventStreamInvalidate(IntPtr streamRef);

/// <summary>
/// Removes the event stream from the RunLoop.
Expand All @@ -167,7 +167,7 @@ internal static partial void FSEventStreamUnscheduleFromRunLoop(
/// Releases a reference count on the specified EventStream and, if necessary, cleans the stream up.
/// </summary>
/// <param name="streamRef">The stream on which to decrement the reference count.</param>
[DllImport(Interop.Libraries.CoreServicesLibrary)]
internal static extern void FSEventStreamRelease(IntPtr streamRef);
[GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)]
internal static partial void FSEventStreamRelease(IntPtr streamRef);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ private static partial int AppleCryptoNative_SecKeychainCreate(
byte[] utf8Passphrase,
out SafeKeychainHandle keychain);

[DllImport(Libraries.AppleCryptoNative)]
private static extern int AppleCryptoNative_SecKeychainDelete(IntPtr keychain);
[GeneratedDllImport(Libraries.AppleCryptoNative)]
private static partial int AppleCryptoNative_SecKeychainDelete(IntPtr keychain);

[GeneratedDllImport(Libraries.AppleCryptoNative)]
private static partial int AppleCryptoNative_SecKeychainCopyDefault(out SafeKeychainHandle keychain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ internal static partial class Fcntl
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetPipeSz", SetLastError=true)]
internal static partial int SetPipeSz(SafePipeHandle fd, int size);

[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlCanGetSetPipeSz")]
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlCanGetSetPipeSz")]
[SuppressGCTransition]
private static extern int FcntlCanGetSetPipeSz();
private static partial int FcntlCanGetSetPipeSz();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ internal static partial class Sys
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadStdin", SetLastError = true)]
internal static unsafe partial int ReadStdin(byte* buffer, int bufferSize);

[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InitializeConsoleBeforeRead")]
internal static extern void InitializeConsoleBeforeRead(byte minChars = 1, byte decisecondsTimeout = 0);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InitializeConsoleBeforeRead")]
internal static partial void InitializeConsoleBeforeRead(byte minChars = 1, byte decisecondsTimeout = 0);

[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UninitializeConsoleAfterRead")]
internal static extern void UninitializeConsoleAfterRead();
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UninitializeConsoleAfterRead")]
internal static partial void UninitializeConsoleAfterRead();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetEUid")]
internal static extern int SetEUid(uint euid);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetEUid")]
internal static partial int SetEUid(uint euid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ internal static partial class Interop
{
internal static partial class Sys
{
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSignalForBreak")]
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSignalForBreak")]
[SuppressGCTransition]
internal static extern int GetSignalForBreak();
internal static partial int GetSignalForBreak();

[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSignalForBreak")]
internal static extern int SetSignalForBreak(int signalForBreak);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSignalForBreak")]
internal static partial int SetSignalForBreak(int signalForBreak);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Sys
{
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetTerminalInvalidationHandler")]
internal static extern unsafe void SetTerminalInvalidationHandler(delegate* unmanaged<void> handler);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetTerminalInvalidationHandler")]
internal static unsafe partial void SetTerminalInvalidationHandler(delegate* unmanaged<void> handler);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal static partial class Sys
/// <summary>
/// Forces a write of all modified I/O buffers to their storage mediums.
/// </summary>
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Sync")]
internal static extern void Sync();
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Sync")]
internal static partial void Sync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ internal static partial class Interop
{
internal static partial class Crypto
{
[DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspRequestDestroy")]
internal static extern void OcspRequestDestroy(IntPtr ocspReq);
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspRequestDestroy")]
internal static partial void OcspRequestDestroy(IntPtr ocspReq);

[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetOcspRequestDerSize")]
internal static partial int GetOcspRequestDerSize(SafeOcspRequestHandle req);
Expand All @@ -31,8 +31,8 @@ ref MemoryMarshal.GetReference(buf),
buf.Length);
}

[DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspResponseDestroy")]
internal static extern void OcspResponseDestroy(IntPtr ocspReq);
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspResponseDestroy")]
internal static partial void OcspResponseDestroy(IntPtr ocspReq);

[GeneratedDllImport(Libraries.CryptoNative, CharSet = CharSet.Ansi)]
private static partial int CryptoNative_X509ChainGetCachedOcspStatus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ internal static SafePkcs7Handle DecodePkcs7(ReadOnlySpan<byte> buf) =>
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7CreateCertificateCollection")]
internal static partial SafePkcs7Handle Pkcs7CreateCertificateCollection(SafeX509StackHandle certs);

[DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7Destroy")]
internal static extern void Pkcs7Destroy(IntPtr p7);
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7Destroy")]
internal static partial void Pkcs7Destroy(IntPtr p7);

[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetPkcs7Certificates")]
private static partial int GetPkcs7Certificates(SafePkcs7Handle p7, out SafeSharedX509StackHandle certs);
Expand Down

0 comments on commit 2307418

Please sign in to comment.