termios: Added cfsetspeed function.
BSD extension to set both the input and output speed of a termios structure. Fixes #18220. Change-Id: I8c4a06b4be4aa55b8ce35cb7f62552fc47a8e8d0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6049 Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
8aadf2e84a
commit
ba9ce9c13b
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _BSD_TERMIOS_H_
|
||||||
|
#define _BSD_TERMIOS_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include_next <termios.h>
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _DEFAULT_SOURCE
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int cfsetspeed(struct termios *termios, speed_t speed);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _BSD_TERMIOS_H_ */
|
||||||
@@ -24,6 +24,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
signal.c
|
signal.c
|
||||||
string.cpp
|
string.cpp
|
||||||
stringlist.c
|
stringlist.c
|
||||||
|
termios.c
|
||||||
unvis.c
|
unvis.c
|
||||||
usershell.c
|
usershell.c
|
||||||
vis.c
|
vis.c
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023, Haiku, inc.
|
||||||
|
*
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
cfsetspeed(struct termios *termios, speed_t speed)
|
||||||
|
{
|
||||||
|
/* Custom speed values are stored in c_ispeed and c_ospeed.
|
||||||
|
* Standard values are inlined in c_cflag. */
|
||||||
|
if (speed > B31250) {
|
||||||
|
termios->c_cflag |= CBAUD;
|
||||||
|
termios->c_ispeed = speed;
|
||||||
|
termios->c_ospeed = speed;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
termios->c_cflag &= ~CBAUD;
|
||||||
|
termios->c_cflag |= speed;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user