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

Use collection expressions for UnmanagedCallConv.CallConvs #97017

Merged
merged 1 commit into from
Jan 16, 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 @@ -66,7 +66,7 @@ internal static void RhCollect(int generation, InternalGCCollectionMode mode, bo
}

[DllImport(Redhawk.BaseName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static extern void RhpCollect(int generation, InternalGCCollectionMode mode, Interop.BOOL lowMemoryP);

[RuntimeExport("RhGetGcTotalMemory")]
Expand All @@ -76,7 +76,7 @@ internal static long RhGetGcTotalMemory()
}

[DllImport(Redhawk.BaseName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static extern long RhpGetGcTotalMemory();

[RuntimeExport("RhStartNoGCRegion")]
Expand Down Expand Up @@ -278,28 +278,28 @@ internal static extern unsafe IntPtr RhpCallPropagateExceptionCallback(
// Block the current thread until at least one object needs to be finalized (returns true) or
// memory is low (returns false and the finalizer thread should initiate a garbage collection).
[DllImport(Redhawk.BaseName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static extern uint RhpWaitForFinalizerRequest();

// Indicate that the current round of finalizations is complete.
[DllImport(Redhawk.BaseName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static extern void RhpSignalFinalizationComplete(uint fCount);

[DllImport(Redhawk.BaseName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static extern ulong RhpGetTickCount64();

// Enters a no GC region, possibly doing a blocking GC if there is not enough
// memory available to satisfy the caller's request.
[DllImport(Redhawk.BaseName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static extern int RhpStartNoGCRegion(long totalSize, Interop.BOOL hasLohSize, long lohSize, Interop.BOOL disallowFullBlockingGC);

// Exits a no GC region, possibly doing a GC to clean up the garbage that
// the caller allocated.
[DllImport(Redhawk.BaseName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static extern int RhpEndNoGCRegion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static unsafe int RhGetCurrentThreadStackTrace(IntPtr[] outputBuffer)

#pragma warning disable SYSLIB1054 // Use DllImport here instead of LibraryImport because this file is used by Test.CoreLib.
[DllImport(Redhawk.BaseName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static extern unsafe int RhpGetCurrentThreadStackTrace(IntPtr* pOutputBuffer, uint outputBufferLength, UIntPtr addressInCurrentFrame);
#pragma warning restore SYSLIB1054

Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/libraries/Common/src/Interop/Interop.HostPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ internal delegate void corehost_resolve_component_dependencies_result_fn(IntPtr
#else
[LibraryImport(Libraries.HostPolicy, StringMarshalling = StringMarshalling.Utf8)]
#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
internal static partial int corehost_resolve_component_dependencies(string componentMainAssemblyPath,
corehost_resolve_component_dependencies_result_fn result);

[LibraryImport(Libraries.HostPolicy)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
internal static partial IntPtr corehost_set_error_writer(IntPtr errorWriter);
#pragma warning restore CS3016 // Arrays as attribute arguments is not CLS-compliant
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,39 @@

using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

internal static partial class Interop
{
internal static unsafe partial class Ucrtbase
{
#pragma warning disable CS3016 // Arrays as attribute arguments is not CLS-compliant
[LibraryImport(Libraries.Ucrtbase)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial void* _aligned_malloc(nuint size, nuint alignment);

[LibraryImport(Libraries.Ucrtbase)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial void _aligned_free(void* ptr);

[LibraryImport(Libraries.Ucrtbase)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial void* _aligned_realloc(void* ptr, nuint size, nuint alignment);

[LibraryImport(Libraries.Ucrtbase)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial void* calloc(nuint num, nuint size);

[LibraryImport(Libraries.Ucrtbase)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial void free(void* ptr);

[LibraryImport(Libraries.Ucrtbase)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial void* malloc(nuint size);

[LibraryImport(Libraries.Ucrtbase)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial void* realloc(void* ptr, nuint new_size);
#pragma warning restore CS3016 // Arrays as attribute arguments is not CLS-compliant
}
Expand Down
31 changes: 16 additions & 15 deletions src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,71 @@

using System;
using System.DirectoryServices.Protocols;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Ldap
{
[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_free", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial IntPtr ber_free(IntPtr berelement, int option);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_alloc_t", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial IntPtr ber_alloc(int option);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_printf(SafeBerHandle berElement, string format, IntPtr value);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_printf(SafeBerHandle berElement, string format, HGlobalMemHandle value, uint length);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_printf(SafeBerHandle berElement, string format);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_printf(SafeBerHandle berElement, string format, int value);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_printf(SafeBerHandle berElement, string format, uint tag);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_flatten", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_flatten(SafeBerHandle berElement, ref IntPtr value);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_init", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial IntPtr ber_init(BerVal value);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_scanf(SafeBerHandle berElement, string format);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_scanf(SafeBerHandle berElement, string format, ref IntPtr ptrResult, ref uint bitLength);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_scanf(SafeBerHandle berElement, string format, ref int result);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_scanf(SafeBerHandle berElement, string format, ref IntPtr value);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_bvfree", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_bvfree(IntPtr value);

[LibraryImport(Libraries.Wldap32, EntryPoint = "ber_bvecfree", StringMarshalling = StringMarshalling.Utf16)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int ber_bvecfree(IntPtr value);
}
}
Loading
Loading