Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Backport the inlines for cfsetspeed and tcdrain.
Browse files Browse the repository at this point in the history
This fixes some issues with using boost's asio (which wrongly assumes
_BSD_SOURCE implies that these things are available) following our
change from -isystem to --sysroot.

Test: Manual, check that we can build when using cfsetspeed on ICS.
Bug: android/ndk#302
Change-Id: Iab50221e4864f9a09a8fb00691252170eb6e8d09
(cherry picked from commit 3b59037)
  • Loading branch information
DanAlbert committed Feb 23, 2017
1 parent 7c90e2b commit 40b0d6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ndk/platforms/android-9/include/sys/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
#define __static_cast(x,y) (x)y
#endif

#if defined(__cplusplus)
#define __BIONIC_CAST(_k,_t,_v) (_k<_t>(_v))
#else
#define __BIONIC_CAST(_k,_t,_v) ((_t) (_v))
#endif

/*
* The __CONCAT macro is used to concatenate parts of symbol names, e.g.
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
Expand Down
12 changes: 12 additions & 0 deletions ndk/platforms/android-9/include/termios.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ static __inline__ void cfmakeraw(struct termios *s)
s->c_cflag |= CS8;
}

static __inline int cfsetspeed(struct termios* s, speed_t speed) {
// TODO: check 'speed' is valid.
s->c_cflag = (s->c_cflag & ~CBAUD) | (speed & CBAUD);
return 0;
}

static __inline int tcdrain(int fd) {
// A non-zero argument to TCSBRK means "don't send a break".
// The drain is a side-effect of the ioctl!
return ioctl(fd, TCSBRK, __BIONIC_CAST(static_cast, unsigned long, 1));
}

__END_DECLS

#endif /* _TERMIOS_H_ */

0 comments on commit 40b0d6c

Please sign in to comment.