Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
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
1 change: 1 addition & 0 deletions src/Common/src/Interop/Unix/Interop.Libraries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal static partial class Libraries
internal const string NetSecurityNative = "System.Net.Security.Native";
internal const string CryptoNative = "System.Security.Cryptography.Native.OpenSsl";
internal const string CompressionNative = "System.IO.Compression.Native";
internal const string IOPortsNative = "System.IO.Ports.Native";
internal const string Libdl = "libdl";
}
}
1 change: 1 addition & 0 deletions src/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ endfunction()
include(configure.cmake)

add_subdirectory(System.IO.Compression.Native)
add_subdirectory(System.IO.Ports.Native)

add_compile_options(-Weverything)
add_compile_options(-Wno-c++98-compat-pedantic)
Expand Down
22 changes: 22 additions & 0 deletions src/Native/Unix/System.IO.Ports.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
project(System.IO.Ports.Native C)

add_library(System.IO.Ports.Native
SHARED
pal_termios.c
pal_serial.c
${VERSION_FILE_PATH}
)

add_library(System.IO.Ports.Native-Static
STATIC
pal_termios.c
pal_serial.c
${VERSION_FILE_PATH}
)

# Disable the "lib" prefix and override default name
set_target_properties(System.IO.Ports.Native-Static PROPERTIES PREFIX "")
set_target_properties(System.IO.Ports.Native-Static PROPERTIES OUTPUT_NAME System.IO.Ports.Native CLEAN_DIRECT_OUTPUT 1)

install_library_and_symbols (System.IO.Ports.Native)
install (TARGETS System.IO.Ports.Native-Static DESTINATION .)
16 changes: 16 additions & 0 deletions src/Native/Unix/System.IO.Ports.Native/pal_serial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#include "pal_types.h"
#include <fcntl.h>
#include <errno.h>
#include <pal_serial.h>

/* Open device file in non-blocking mode and without controlling terminal */
intptr_t SystemIoPortsNative_SerialPortOpen(const char * name)
{
intptr_t result;
while ((result = open(name, O_RDWR | O_NOCTTY | O_CLOEXEC | O_NONBLOCK)) < 0 && errno == EINTR);
return result;
}
9 changes: 9 additions & 0 deletions src/Native/Unix/System.IO.Ports.Native/pal_serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#include "pal_types.h"
#include "pal_compiler.h"

DLLEXPORT intptr_t SystemIoPortsNative_SerialPortOpen(const char * name);

Loading