mirror of
https://github.com/UzixLS/picocom.git
synced 2025-07-19 07:21:18 +03:00
Small refactoring in term.c for bsd improvements
Introduced `#define HAS_CUSTOM_BAUD` for platforms which have appropriate implementation. Moving that `#if defined(__linux__) && defined(USE_CUSTOM_BAUD)` ... stuff out of `term.c`and put it to `termios2.h` / `custbaud_bsd.h` headers. Moving that platform specific `#ifdefs` to the platform specific headers helps removing duplicate complex `#ifdef` constructs. The both platform specific headers then do `#define HAS_CUSTOM_BAUD` to signal that custom baudrate support is implemented for the target platform. I'd tested all above mentioned platforms with both USE_CUSTOM_BAUD unset and set to check if that refactoring don't raises unexpected issues.
This commit is contained in:
@ -6,6 +6,8 @@
|
||||
* by Joe Merten (https://github.com/JoeMerten www.jme.de)
|
||||
*
|
||||
* ATTENTION: BSD and macOS specific stuff!
|
||||
* This header will `#define HAS_CUSTOM_BAUD` in case of custom baud rate
|
||||
* implementation is available for the current target platform.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
@ -26,6 +28,13 @@
|
||||
#ifndef CUSTBAUD_BSD_H
|
||||
#define CUSTBAUD_BSD_H
|
||||
|
||||
/* Note that this code might also work other BSD variants, but I have only
|
||||
* tested with those listed below.
|
||||
*/
|
||||
#if (defined (__FreeBSD__) || defined(__APPLE__)) && defined(USE_CUSTOM_BAUD)
|
||||
|
||||
#define HAS_CUSTOM_BAUD
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
/***************************************************************************/
|
||||
@ -36,7 +45,7 @@
|
||||
* tcsetattr_custom()), we want to provide the values here to have them
|
||||
* available for term_baud_up()/down().
|
||||
*
|
||||
* FreeBSD termios.h has 460k and 921k but misses e.g. 500k and >=1M.
|
||||
* FreeBSD 11.0 termios.h has 460k and 921k but misses e.g. 500k and >=1M.
|
||||
*/
|
||||
|
||||
#if defined(HIGH_BAUD)
|
||||
@ -97,4 +106,5 @@ int tcsetattr_custom(int fd, int optional_actions, const struct termios *tiop);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#endif /* __FreeBSD__ || __APPLE__ && USE_CUSTOM_BAUD */
|
||||
#endif /* CUSTBAUD_BSD_H */
|
||||
|
Reference in New Issue
Block a user