-
Notifications
You must be signed in to change notification settings - Fork 5k
bottom part of serial port support on Unix #29033
Changes from 9 commits
bea5e41
cbb5838
03c57c1
5ec3a0f
04e0b1f
8abfee1
d8565ec
176d786
f3fa5b9
36b4a41
c04b26e
File filter
Filter by extension
Conversations
Jump to
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 @@ | ||
project(System.IO.Ports.Native) | ||
|
||
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 .) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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> | ||
|
||
|
||
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. nit: we have one blank line elsewhere |
||
/* Open device file in non-blocking mode and without controlling terminal */ | ||
int SerialPortOpen(const char * name) | ||
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. As noted in another comment, we should represent file descriptors at the interop layer as intptr_t. As it's currently written, on a 64-bit platform there's potentially going to be corruption here, as this is going to return a 32-bit value and the managed code is expected a 64-bit value. |
||
{ | ||
int result; | ||
while ((result = open(name, O_RDWR | O_NOCTTY | O_CLOEXEC | O_NONBLOCK)) < 0 && errno == EINTR); | ||
return result; | ||
} | ||
|
||
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. nit: there are two extra blank lines at the end of this file, reduce it to one blank line? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// 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" | ||
|
||
BEGIN_EXTERN_C | ||
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. This macro and its END_ counterpart are not defined anymore and can be removed. Now we are pure C. |
||
|
||
int SerialPortOpen(const char * name); | ||
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. We've generally prefixed all exports with the name of the library, e.g. SystemIoPortsNative_SerialPortOpen. |
||
|
||
END_EXTERN_C |
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.
Please add
C
project(System.IO.Ports.Native C)