[commit: packages/unix] master: Replace `__hsunix_nanosleep` wrapper with CApiFFI (4c25a0d)

git at git.haskell.org git at git.haskell.org
Tue Apr 19 21:37:57 UTC 2016


Repository : ssh://git@git.haskell.org/unix

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/4c25a0d4af899b43d557a6d2dc1b4291e5f75659/unix

>---------------------------------------------------------------

commit 4c25a0d4af899b43d557a6d2dc1b4291e5f75659
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sat Jan 30 22:42:23 2016 +0100

    Replace `__hsunix_nanosleep` wrapper with CApiFFI


>---------------------------------------------------------------

4c25a0d4af899b43d557a6d2dc1b4291e5f75659
 System/Posix/Unistd.hsc | 4 ++--
 cbits/HsUnix.c          | 8 --------
 include/HsUnix.h        | 5 -----
 3 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/System/Posix/Unistd.hsc b/System/Posix/Unistd.hsc
index 3f2d115..7f79113 100644
--- a/System/Posix/Unistd.hsc
+++ b/System/Posix/Unistd.hsc
@@ -181,9 +181,9 @@ nanosleep nsecs = do
                        else throwErrno "nanosleep"
      loop (fromIntegral tv_sec0 :: CTime) (fromIntegral tv_nsec0 :: CTime)
 
-data CTimeSpec
+data {-# CTYPE "struct timespec" #-} CTimeSpec
 
-foreign import ccall safe "__hsunix_nanosleep"
+foreign import capi safe "HsUnix.h nanosleep"
   c_nanosleep :: Ptr CTimeSpec -> Ptr CTimeSpec -> IO CInt
 #endif
 
diff --git a/cbits/HsUnix.c b/cbits/HsUnix.c
index 49f90e8..e54bccf 100644
--- a/cbits/HsUnix.c
+++ b/cbits/HsUnix.c
@@ -34,14 +34,6 @@ int __hsunix_getpwuid_r(uid_t uid, struct passwd *pw, char *buffer,
 }
 #endif
 
-#ifdef HAVE_NANOSLEEP
-// nanosleep is a macro on some platforms, so we need a wrapper:
-int __hsunix_nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
-{
-    return nanosleep(rqtp, rmtp);
-}
-#endif
-
 #ifdef HAVE_PTSNAME
 // I cannot figure out how to make the definitions of the following
 // functions visible in <stdlib.h> on Linux.  But these definitions
diff --git a/include/HsUnix.h b/include/HsUnix.h
index e276726..7b404fc 100644
--- a/include/HsUnix.h
+++ b/include/HsUnix.h
@@ -125,11 +125,6 @@ int __hsunix_getpwuid_r(uid_t, struct passwd *, char *, size_t,
                         struct passwd **);
 #endif
 
-#ifdef HAVE_NANOSLEEP
-// nanosleep is a macro on some platforms, so we need a wrapper:
-int __hsunix_nanosleep(const struct timespec *, struct timespec *);
-#endif
-
 #ifdef HAVE_PTSNAME
 // I cannot figure out how to make the definitions of the following
 // functions visible in <stdlib.h> on Linux.  But these definitions



More information about the ghc-commits mailing list