Skip to content

Commit bc2f1c4

Browse files
committed
Fix build on Android where bionic does have termios2.
1 parent 4af0789 commit bc2f1c4

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,15 @@ else()
396396
message(AUTHOR_WARNING "backtrace(3) not present in execinfo.h. Automatic backtraces for failures in rr are disabled.")
397397
endif()
398398

399+
include(CheckTypeSize)
400+
set(SAVE_CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES}")
401+
list(APPEND CMAKE_EXTRA_INCLUDE_FILES "termios.h")
402+
check_type_size("struct termios2" SIZEOF_TERMIOS2)
403+
if(HAVE_SIZEOF_TERMIOS2)
404+
add_definitions(-DHAVE_TERMIOS2)
405+
endif()
406+
set(CMAKE_EXTRA_INCLUDE_FILES "${SAVE_CMAKE_EXTRA_INCLUDE_FILES}")
407+
399408
# Test only symbols
400409
check_symbol_exists(pthread_mutexattr_setrobust "pthread.h" HAVE_ROBUST_MUTEX)
401410

src/record_syscall.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@
103103

104104
using namespace std;
105105

106+
#ifndef HAVE_TERMIOS2
106107
// The kernel header that defines this conflicts badly with glibc headers
107-
// so we define it ourselves.
108+
// (but not bionic, which does define this) so we define it ourselves.
108109
// NB: We need this struct defined so that the preprocessor macro for
109110
// TCGETS2 will evaluate. But we use IOCTL_MASK_SIZE on it and we use
110111
// the size from the tracee to determine how many bytes to record, so
@@ -119,6 +120,7 @@ struct termios2 {
119120
speed_t c_ispeed;
120121
speed_t c_ospeed;
121122
};
123+
#endif
122124

123125
namespace rr {
124126

src/test/ioctl_tty.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
#include "util.h"
44

5-
/* We have to define termios2 ourselves. See
5+
#ifndef HAVE_TERMIOS2
6+
/* We have to define termios2 ourselves with glibc. See
67
* https://github.com/npat-efault/picocom/blob/1acf1ddabaf3576b4023c4f6f09c5a3e4b086fb8/termios2.txt
78
* for the long explanation.
89
*/
@@ -16,6 +17,7 @@ struct termios2 {
1617
speed_t c_ispeed;
1718
speed_t c_ospeed;
1819
};
20+
#endif
1921

2022
int main(void) {
2123
int fd;

0 commit comments

Comments
 (0)