[PATCH] Fix building for Android

Anton Lundin glance at acc.umu.se
Thu Mar 27 12:44:12 PDT 2014


This makes libdivecomputer build via Android NDK. Its currently unusable
due to the fact that Android usually doesn't provide any kernel serial
drivers.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 src/serial_posix.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/serial_posix.c b/src/serial_posix.c
index 2748957..fc0e79e 100644
--- a/src/serial_posix.c
+++ b/src/serial_posix.c
@@ -53,6 +53,11 @@
 #define NOPTY 1
 #endif
 
+/* Android is missing tcdrain, so use ioctl version instead */
+#ifdef __ANDROID__
+#define tcdrain(x) ioctl(x, TCSBRK, 1)
+#endif
+
 #include "serial.h"
 #include "context-private.h"
 
@@ -433,7 +438,7 @@ serial_configure (serial_t *device, int baudrate, int databits, int parity, int
 
 	// Configure a custom baudrate if necessary.
 	if (custom) {
-#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL)
+#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL) && !defined(__ANDROID__)
 		// Get the current settings.
 		struct serial_struct ss;
 		if (ioctl (device->fd, TIOCGSERIAL, &ss) != 0 && NOPTY) {
-- 
1.8.3.2



More information about the devel mailing list