File: _generated\0\LibraryImports.g.cs
Web Access
Project: src\runtime\src\libraries\System.IO.Ports\src\System.IO.Ports.csproj (System.IO.Ports)
// <auto-generated/>
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosReset(global::System.IO.Ports.SafeSerialDeviceHandle handle, int speed, int data, global::System.IO.Ports.StopBits stop, global::System.IO.Ports.Parity parity, global::System.IO.Ports.Handshake flow)
        {
            int __lastError;
            nint __handle_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native, speed, data, stop, parity, flow);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosReset", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native, int __speed_native, int __data_native, global::System.IO.Ports.StopBits __stop_native, global::System.IO.Ports.Parity __parity_native, global::System.IO.Ports.Handshake __flow_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosGetSignal(global::System.IO.Ports.SafeSerialDeviceHandle handle, global::Interop.Termios.Signals signal)
        {
            int __lastError;
            nint __handle_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native, signal);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosGetSignal", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native, global::Interop.Termios.Signals __signal_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosGetSignal(global::System.IO.Ports.SafeSerialDeviceHandle handle, global::Interop.Termios.Signals signal, int set)
        {
            int __lastError;
            nint __handle_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native, signal, set);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosSetSignal", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native, global::Interop.Termios.Signals __signal_native, int __set_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial global::Interop.Termios.Signals TermiosGetAllSignals(global::System.IO.Ports.SafeSerialDeviceHandle handle)
        {
            nint __handle_native = default;
            global::Interop.Termios.Signals __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    __retVal = __PInvoke(__handle_native);
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosGetAllSignals", ExactSpelling = true)]
            static extern unsafe global::Interop.Termios.Signals __PInvoke(nint __handle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosSetSpeed(global::System.IO.Ports.SafeSerialDeviceHandle handle, int speed)
        {
            int __lastError;
            nint __handle_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native, speed);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosSetSpeed", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native, int __speed_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosGetSpeed(global::System.IO.Ports.SafeSerialDeviceHandle handle)
        {
            int __lastError;
            nint __handle_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosGetSpeed", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosGetAvailableBytes(global::System.IO.Ports.SafeSerialDeviceHandle handle, bool fromReadBuffer)
        {
            int __lastError;
            nint __handle_native = default;
            int __fromReadBuffer_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __fromReadBuffer_native = (int)(fromReadBuffer ? 1 : 0);
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native, __fromReadBuffer_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosAvailableBytes", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native, int __fromReadBuffer_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosDiscard(global::System.IO.Ports.SafeSerialDeviceHandle handle, global::Interop.Termios.Queue input)
        {
            int __lastError;
            nint __handle_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native, input);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosDiscard", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native, global::Interop.Termios.Queue __input_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosDrain(global::System.IO.Ports.SafeSerialDeviceHandle handle)
        {
            int __lastError;
            nint __handle_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosDrain", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Termios
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int TermiosSendBreak(global::System.IO.Ports.SafeSerialDeviceHandle handle, int duration)
        {
            int __lastError;
            nint __handle_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedIn __handle_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __handle_native__marshaller.FromManaged(handle);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __handle_native = __handle_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__handle_native, duration);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __handle_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_TermiosSendBreak", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native, int __duration_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Serial
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial global::System.IO.Ports.SafeSerialDeviceHandle SerialPortOpen(string name)
        {
            int __lastError;
            bool __invokeSucceeded = default;
            byte* __name_native = default;
            global::System.IO.Ports.SafeSerialDeviceHandle __retVal = default;
            nint __retVal_native = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.IO.Ports.SafeSerialDeviceHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
            scoped global::System.Runtime.InteropServices.Marshalling.Utf8StringMarshaller.ManagedToUnmanagedIn __name_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __name_native__marshaller.FromManaged(name, stackalloc byte[global::System.Runtime.InteropServices.Marshalling.Utf8StringMarshaller.ManagedToUnmanagedIn.BufferSize]);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __name_native = __name_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal_native = __PInvoke(__name_native);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
 
                __invokeSucceeded = true;
                // UnmarshalCapture - Capture the native data into marshaller instances in case conversion to managed data throws an exception.
                __retVal_native__marshaller.FromUnmanaged(__retVal_native);
                // Unmarshal - Convert native data to managed data.
                __retVal = __retVal_native__marshaller.ToManaged();
            }
            finally
            {
                if (__invokeSucceeded)
                {
                    // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
                    __retVal_native__marshaller.Free();
                }
 
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __name_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_SerialPortOpen", ExactSpelling = true)]
            static extern unsafe nint __PInvoke(byte* __name_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Serial
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static partial int SerialPortClose(nint handle)
        {
            int __lastError;
            int __retVal;
            {
                global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                __retVal = __PInvoke(handle);
                __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_SerialPortClose", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __handle_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Serial
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_Shutdown", ExactSpelling = true)]
        internal static extern partial global::Interop.Error Shutdown(nint socket, global::System.Net.Sockets.SocketShutdown how);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Serial
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static unsafe partial int Read(global::System.Runtime.InteropServices.SafeHandle fd, byte* buffer, int count)
        {
            int __lastError;
            nint __fd_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Runtime.InteropServices.SafeHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __fd_native__marshaller.FromManaged(fd);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __fd_native = __fd_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__fd_native, buffer, count);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __fd_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_Read", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __fd_native, byte* __buffer_native, int __count_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Serial
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "11.0.14.27912")]
        [global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
        internal static unsafe partial int Write(global::System.Runtime.InteropServices.SafeHandle fd, byte* buffer, int bufferSize)
        {
            int __lastError;
            nint __fd_native = default;
            int __retVal = default;
            // Setup - Perform required setup.
            global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::System.Runtime.InteropServices.SafeHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
            try
            {
                // Marshal - Convert managed data to native data.
                __fd_native__marshaller.FromManaged(fd);
                {
                    // PinnedMarshal - Convert managed data to native data that requires the managed data to be pinned.
                    __fd_native = __fd_native__marshaller.ToUnmanaged();
                    global::System.Runtime.InteropServices.Marshal.SetLastSystemError(0);
                    __retVal = __PInvoke(__fd_native, buffer, bufferSize);
                    __lastError = global::System.Runtime.InteropServices.Marshal.GetLastSystemError();
                }
            }
            finally
            {
                // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
                __fd_native__marshaller.Free();
            }
 
            global::System.Runtime.InteropServices.Marshal.SetLastPInvokeError(__lastError);
            return __retVal;
            // Local P/Invoke
            [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_Write", ExactSpelling = true)]
            static extern unsafe int __PInvoke(nint __fd_native, byte* __buffer_native, int __bufferSize_native);
        }
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Serial
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_Poll", ExactSpelling = true)]
        private static unsafe extern partial global::Interop.Error Poll(global::Interop.PollEvent* pollEvents, uint eventCount, int timeout, uint* triggered);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Sys
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal", ExactSpelling = true)]
        internal static extern partial global::Interop.Error ConvertErrorPlatformToPal(int platformErrno);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Sys
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform", ExactSpelling = true)]
        internal static extern partial int ConvertErrorPalToPlatform(global::Interop.Error error);
    }
}
internal static unsafe partial class Interop
{
    internal static unsafe partial class Sys
    {
        [global::System.Runtime.InteropServices.DllImportAttribute("libSystem.IO.Ports.Native", EntryPoint = "SystemIoPortsNative_StrErrorR", ExactSpelling = true)]
        private static unsafe extern partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize);
    }
}