Add wrappers around fcntl
authorIan Lynagh <igloo@earth.li>
Wed, 20 May 2009 17:53:58 +0000 (17:53 +0000)
committerIan Lynagh <igloo@earth.li>
Wed, 20 May 2009 17:53:58 +0000 (17:53 +0000)
We need to do this as it has a (, ...) type, which we aren't allowed to
directly call with the FFI.

System/Posix/Internals.hs
include/HsBase.h

index 5bbdf9c..fbac648 100644 (file)
@@ -424,13 +424,13 @@ foreign import ccall unsafe "HsBase.h getpid"
    c_getpid :: IO CPid
 
 #if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
-foreign import ccall unsafe "HsBase.h fcntl"
+foreign import ccall unsafe "HsBase.h fcntl_read"
    c_fcntl_read  :: CInt -> CInt -> IO CInt
 
-foreign import ccall unsafe "HsBase.h fcntl"
+foreign import ccall unsafe "HsBase.h fcntl_write"
    c_fcntl_write :: CInt -> CInt -> CLong -> IO CInt
 
-foreign import ccall unsafe "HsBase.h fcntl"
+foreign import ccall unsafe "HsBase.h fcntl_lock"
    c_fcntl_lock  :: CInt -> CInt -> Ptr CFLock -> IO CInt
 
 foreign import ccall unsafe "HsBase.h fork"
index 9bbbdc8..b749c58 100644 (file)
@@ -765,5 +765,19 @@ INLINE intptr_t  __hscore_to_intptr   (void *p)     { return (intptr_t)p; }
 void errorBelch2(const char*s, char *t);
 void debugBelch2(const char*s, char *t);
 
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
+
+INLINE int fcntl_read(int fd, int cmd) {
+    fcntl(fd, cmd);
+}
+INLINE int fcntl_write(int fd, int cmd, long arg) {
+    fcntl(fd, cmd, arg);
+}
+INLINE int fcntl_lock(int fd, int cmd, struct flock *lock) {
+    fcntl(fd, cmd, lock);
+}
+
+#endif
+
 #endif /* __HSBASE_H__ */