Martin Ling
9a7945af84
Abstract all time handling operations.
2020-01-20 04:31:59 +00:00
Martin Ling
abd31fd9f9
android: Fix build compatibility with NDK platform 21 and up.
...
In platforms 21 and higher of the NDK, linux/serial.h is available,
which it was not before. This broke the build, because the configure
script would detect the availability of 'struct serial_struct' in that
header and set HAVE_STRUCT_SERIAL_STRUCT, but the #ifndef __ANDROID__
in libserialport_internal.h stopped us actually including the header.
This change fixes things to build with all versions of the NDK, and is
tested with builds for arm from versions 9 to 24.
Version 21 also added availability of tcdrain(), so we also use that
where available, and only use the direct ioctl() method on NDK < 21.
Fixes #1078 .
2020-01-04 23:00:17 +00:00
Martin Ling
277f832a6a
Define _POSIX_C_SOURCE to 199309L to get clock_gettime().
2020-01-04 18:27:25 +01:00
Christian Seiler
fa106ef155
Use O_CLOEXEC where available
...
Ensures that the file descriptor is (by default) not passed to
subprocesses spawned by applications using libserialport.
This fixes bug #1051 .
2020-01-04 18:21:35 +01:00
Martin Ling
192e77492a
Use mach_absolute_time() on OSX without clock_gettime().
...
This should fix #759 for OSX versions below 10.12.
2019-12-28 22:02:19 +01:00
Martin Ling
f40ea9d461
Use clock_gettime(CLOCK_MONOTONIC) if available.
...
Should fix #759 except on OSX versions below 10.12, which don't
have clock_gettime.
2019-12-28 22:02:19 +01:00
Martin Ling
b457865b8f
windows: Use architecture-specific size limit for WriteFile calls.
2019-12-28 20:43:22 +01:00
Martin Ling
39df7833f7
windows: Use an adaptively sized buffer for nonblocking writes.
2019-12-28 20:43:22 +01:00
Stefan Tauner
15541ebd78
Remove redundant inclusions of limits.h
...
The first one would be included for Windows too which seems to be
an error. The second one is obviously redundant.
2017-09-13 19:27:50 +02:00
Stefan Tauner
95bad38c5b
Canonicalize symlinks in portnames
...
This allows users to supply symlinks created e.g. by udev rules instead
of the actual device names.
2017-09-13 19:27:50 +02:00
Martin Ling
6c8115820d
Linux: fix for alpha where BOTHER is not defined.
...
Fixes bug #363 .
2017-03-19 12:16:49 +00:00
Wolfram Sang
4d8195fe3f
libserialport_internal: use new macro to enable timeradd, etc.
...
Since glibc 2.20, the usage of _BSD_SOURCE is deprecated. Fix it like
described here:
https://sourceware.org/glibc/wiki/Release/2.20#Deprecation_of__BSD_SOURCE_and__SVID_SOURCE_feature_macros
This fixes bug #716 .
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2015-12-29 01:16:28 +01:00
Martin Ling
127d8d0ce7
sp_wait: Avoid overflow of timeout parameter to poll().
2015-10-13 15:04:03 +01:00
Daniel Elstner
1a584c45b0
Build: Include config.h first in all source files
2015-09-13 20:04:31 +02:00
Daniel Elstner
f1c916ede1
Build: Clean up configure.ac and Makefile.am
...
Among other things, rename some config defines so we can take
advantage of standard Autoconf macros.
2015-08-26 21:55:10 +02:00
Uwe Hermann
613c48f191
Fix a compiler warning when -Wshadow is used.
...
CC serialport.lo
In file included from ../serialport.c:25:0:
../serialport.c: In function 'get_config':
../libserialport_internal.h:227:25: warning: declaration of 'ret' shadows a previous local [-Wshadow]
#define TRY(x) do { int ret = x; if (ret != SP_OK) RETURN_CODEVAL(ret); } while (0)
^
../serialport.c:1566:3: note: in expansion of macro 'TRY'
TRY(get_baudrate(port->fd, &config->baudrate));
^
../serialport.c:1543:6: warning: shadowed declaration is here [-Wshadow]
int ret = get_flow(port->fd, data);
^
Also, add -Wshadow to the list of default compiler options.
2015-04-18 21:54:42 +02:00
Uwe Hermann
e019e72ec0
Fix a compiler warning.
...
This fixes the following scan-build warning:
serialport.c: In function 'sp_list_ports':
serialport.c:354:1: warning: control reaches end of non-void function [-Wreturn-type]
2015-04-03 20:50:22 +02:00
Uwe Hermann
b344a40bb2
Fix indentation of a switch().
2015-04-03 17:51:47 +02:00
Martin Ling
47fcf8ec85
windows: Revise management of WaitCommEvent() operations.
...
This fixes (at least parts of) bug #341 .
2015-03-29 22:18:46 +02:00
Uwe Hermann
6c6aebe78c
Make std_baudrates[] static (only used in one file).
2015-03-26 23:57:56 +01:00
Uwe Hermann
dc422c04af
Various cosmetic and consistency fixes.
2015-03-26 23:57:56 +01:00
Uwe Hermann
2b40f81454
libserialport_internal.h: Add #include guard.
2015-03-26 23:57:56 +01:00
Martin Ling
7c081505e5
Generate a config.h rather than passing defines on command line.
...
Fixes bug #553 .
2015-03-24 23:15:32 +00:00
Martin Ling
59182fbbbf
linux: Check for BOTHER macro at configure time.
...
This fixes bug #363 .
2014-11-01 18:36:09 +01:00
Martin Ling
78940e6921
windows: Fix compile issues with multiply or not defined GUIDs.
...
This fixes bug #416 .
2014-09-25 23:04:06 +02:00
Michael B. Trausch
d179da05c0
windows: Include proper GUID defining header to fix build.
...
The initguid.h header must appear early or it does not have
an effect, at least on cross-build from Linux.
2014-09-07 18:51:04 +02:00
Aurelien Jacobs
653cef3ab1
linux: remove readlinkat() dependency
2014-09-04 20:13:55 +02:00
Martin Ling
c51b846eee
linux: Define feature macros to get required functions.
...
This is needed to build with -std=c99.
2014-08-24 14:06:21 +01:00
Martin Ling
7890cef6cf
Revise debug macros to work in strict C99.
2014-08-24 14:06:21 +01:00
Martin Ling
9caa2e86aa
Specialise RETURN_VALUE macro into RETURN_{INT,STRING,POINTER}.
...
This avoids the need to pass the required format string on every
call and also eliminates the need for the non-standard typeof() call.
2014-08-24 13:31:20 +01:00
Aurelien Jacobs
970f279ae4
Introduce SP_API/SP_PRIV to mark visibility of functions.
2014-07-02 14:43:32 +02:00
Aurelien Jacobs
48a4076f69
Move list_ports() implementations to OS-specific files.
2014-06-14 01:28:49 +02:00
Martin Ling
e33dcf90a0
Tidy up and split most OS-specific code to separate files.
2014-06-11 15:10:29 +01:00