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:
@ -38,12 +38,8 @@
|
||||
* - Have not tested with more recent macOS or Ftdi driver until now.
|
||||
*/
|
||||
|
||||
/* Note that this code might also work with OpenBSD, NetBSD et cetera, but I have not tested.
|
||||
* That's why I only check for `defined (__FreeBSD__)` here.
|
||||
*/
|
||||
#if (defined (__FreeBSD__) || defined(__APPLE__)) && defined(USE_CUSTOM_BAUD)
|
||||
|
||||
#include "custbaud_bsd.h"
|
||||
#ifdef HAS_CUSTOM_BAUD
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
@ -54,9 +50,10 @@
|
||||
#include "term.h"
|
||||
|
||||
/***************************************************************************/
|
||||
/* As we can see in FreeBSD and macOS termios.h all the baudrate constants are transparent,
|
||||
* like B115200=115200. There is no need for any integer <-> code translation.
|
||||
* So we can pass any baudrate we want directly to / from cfsetospeed() & co.
|
||||
/* As we can see in BSD and macOS termios.h all the baudrate constants are
|
||||
* transparent, like B115200=115200. There is no need for any integer <-> code
|
||||
* translation. So we can pass any baudrate we want directly to / from
|
||||
* cfsetospeed() & co.
|
||||
*/
|
||||
int cfsetospeed_custom(struct termios *tiop, int speed) {
|
||||
return cfsetospeed(tiop, speed);
|
||||
@ -142,4 +139,4 @@ int tcsetattr_custom(int fd, int optional_actions, const struct termios *tiop) {
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#endif /* FreeBSD || __APPLE__ && USE_CUSTOM_BAUD */
|
||||
#endif /* HAS_CUSTOM_BAUD */
|
||||
|
Reference in New Issue
Block a user