[PATCH] Fix building for Android

Anton Lundin glance at acc.umu.se
Fri Mar 28 03:41:43 PDT 2014


On 28 March, 2014 - Jef Driesen wrote:

> On 2014-03-27 20:44, Anton Lundin wrote:
> >This makes libdivecomputer build via Android NDK. Its currently unusable
> >due to the fact that Android usually doesn't provide any kernel serial
> >drivers.
> 
> I'll apply your patch, although with a slight modification. I prefer the
> tcdrain #ifdef right where the function is being called, rather than
> redirecting one function to another. I find that confusing when debugging.
> 
> But the reason why I'm replying to you is actually the TIOCGSERIAL part. Can
> you tell me what's going wrong there? Is TIOCGSERIAL defined on Android, but
> not supported somehow? Maybe the serial_struct struct is missing in bionic?
> 

Yepp, its the serial_struct struct thats missing from bionic.

> I have just pushed some changes related to the low latency stuff.
> Those will probably need similar changes. So that's why I'm asking.                        

So, after the low latency patch this fixes it:

--- i/src/serial_posix.c
+++ w/src/serial_posix.c
@@ -523,7 +523,7 @@ serial_set_latency (serial_t *device, unsigned int milliseconds)
        if (device == NULL)
                return -1; // EINVAL (Invalid argument)
 
-#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) {


Just tell me if you would like me to redo the patch.

//Anton

-- 
Anton Lundin	+46702-161604


More information about the devel mailing list