提交 a437ffbf 编写于 作者: B bernard

[libc] code cleanup for termios.

上级 41f3d1f9
...@@ -7,7 +7,7 @@ src = Glob('*.c') + Glob('*.cpp') ...@@ -7,7 +7,7 @@ src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd] CPPPATH = [cwd]
group = DefineGroup('libc', src, group = DefineGroup('libc', src,
depend = ['RT_USING_LIBC', 'RT_USING_POSIX_TERMIOS'], depend = ['RT_USING_LIBC', 'RT_USING_POSIX', 'RT_USING_POSIX_TERMIOS'],
CPPPATH = CPPPATH) CPPPATH = CPPPATH)
Return('group') Return('group')
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
int tcgetattr(int fd, struct termios *tio) int tcgetattr(int fd, struct termios *tio)
{ {
/* Get the current serial port settings. */ /* Get the current serial port settings. */
if (ioctl(fd, TCGETA, tio)) if (ioctl(fd, TCGETA, tio))
return -1; return -1;
...@@ -41,27 +41,27 @@ int tcgetattr(int fd, struct termios *tio) ...@@ -41,27 +41,27 @@ int tcgetattr(int fd, struct termios *tio)
int tcsetattr(int fd, int act, const struct termios *tio) int tcsetattr(int fd, int act, const struct termios *tio)
{ {
switch (act) switch (act)
{ {
case TCSANOW: case TCSANOW:
/* make the change immediately */ /* make the change immediately */
return (ioctl(fd, TCSETA, (void*)tio)); return (ioctl(fd, TCSETA, (void*)tio));
case TCSADRAIN: case TCSADRAIN:
/* /*
* Don't make the change until all currently written data * Don't make the change until all currently written data
* has been transmitted. * has been transmitted.
*/ */
return (ioctl(fd, TCSETAW, (void*)tio)); return (ioctl(fd, TCSETAW, (void*)tio));
case TCSAFLUSH: case TCSAFLUSH:
/* Don't make the change until all currently written data /* Don't make the change until all currently written data
* has been transmitted, at which point any received but * has been transmitted, at which point any received but
* unread data is also discarded. * unread data is also discarded.
*/ */
return (ioctl(fd, TCSETAF, (void*)tio)); return (ioctl(fd, TCSETAF, (void*)tio));
default: default:
errno = EINVAL; errno = EINVAL;
return (-1); return (-1);
} }
} }
/** /**
...@@ -106,7 +106,7 @@ int cfsetispeed(struct termios *tio, speed_t speed) ...@@ -106,7 +106,7 @@ int cfsetispeed(struct termios *tio, speed_t speed)
int tcsendbreak(int fd, int dur) int tcsendbreak(int fd, int dur)
{ {
/* nonzero duration is implementation-defined, so ignore it */ /* nonzero duration is implementation-defined, so ignore it */
return 0; return 0;
} }
int tcflush(int fd, int queue) int tcflush(int fd, int queue)
...@@ -124,14 +124,14 @@ int tcflow(int fd, int action) ...@@ -124,14 +124,14 @@ int tcflow(int fd, int action)
*/ */
int tcdrain(int fd) int tcdrain(int fd)
{ {
return 0; return 0;
} }
int isatty (int fd) int isatty (int fd)
{ {
struct termios term; struct termios term;
return tcgetattr (fd, &term) == 0; return tcgetattr (fd, &term) == 0;
} }
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册