[PATCH] Wrap mkfifo, tcsetattr and tcgetattr on android because they are inline and cause linker failer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Wrap mkfifo, tcsetattr and tcgetattr on android because they are inline and cause linker failer

Nathan Hüsken
---
 System/Posix/Internals.hs |   13 +++++++++++++
 include/HsBase.h          |    7 +++++++
 2 files changed, 20 insertions(+)

diff --git a/System/Posix/Internals.hs b/System/Posix/Internals.hs
index 1633a3e..cf7b6b7 100644
--- a/System/Posix/Internals.hs
+++ b/System/Posix/Internals.hs
@@ -488,8 +488,13 @@ foreign import ccall unsafe "HsBase.h fork"
 foreign import ccall unsafe "HsBase.h link"
    c_link :: CString -> CString -> IO CInt
 
+#ifndef linux_android_HOST_OS
 foreign import ccall unsafe "HsBase.h mkfifo"
    c_mkfifo :: CString -> CMode -> IO CInt
+#else
+foreign import ccall unsafe "HsBase.h __mkfifo"
+   c_mkfifo :: CString -> CMode -> IO CInt
+#endif
 
 foreign import ccall unsafe "HsBase.h pipe"
    c_pipe :: Ptr CInt -> IO CInt
@@ -503,11 +508,19 @@ foreign import capi unsafe "signal.h sigaddset"
 foreign import capi unsafe "signal.h sigprocmask"
    c_sigprocmask :: CInt -> Ptr CSigset -> Ptr CSigset -> IO CInt
 
+#ifndef linux_android_HOST_OS
 foreign import ccall unsafe "HsBase.h tcgetattr"
    c_tcgetattr :: CInt -> Ptr CTermios -> IO CInt
 
 foreign import ccall unsafe "HsBase.h tcsetattr"
    c_tcsetattr :: CInt -> CInt -> Ptr CTermios -> IO CInt
+#else
+foreign import ccall unsafe "HsBase.h __tcgetattr"
+   c_tcgetattr :: CInt -> Ptr CTermios -> IO CInt
+
+foreign import ccall unsafe "HsBase.h __tcsetattr"
+   c_tcsetattr :: CInt -> CInt -> Ptr CTermios -> IO CInt
+#endif
 
 foreign import capi unsafe "HsBase.h utime"
    c_utime :: CString -> Ptr CUtimbuf -> IO CInt
diff --git a/include/HsBase.h b/include/HsBase.h
index b1a62fd..698a9ab 100644
--- a/include/HsBase.h
+++ b/include/HsBase.h
@@ -175,6 +175,13 @@ extern int fdReady(int fd, int write, int msecs, int isSock);
 # endif
 #endif
 
+#ifdef linux_android_HOST_OS
+// On android these functions are inline, so need to wrap them to be able to link them
+INLINE int __mkfifo(const char *__p, mode_t __m) {return mkfifo(__p,__m);}
+INLINE int __tcgetattr(int fd, struct termios *s) {return tcgetattr(fd,s);}
+INLINE int __tcsetattr(int fd, int __opt, const struct termios *s) {return tcsetattr(fd,__opt,s);}
+#endif
+
 INLINE int __hscore_get_errno(void) { return errno; }
 INLINE void __hscore_set_errno(int e) { errno = e; }
 
--
1.7.10.4


--------------080308010200080804060704--