diff options
author | Adam Sandberg Eriksson <adam@sandbergericsson.se> | 2019-08-02 16:04:28 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-09-23 17:52:32 -0400 |
commit | 74631bbcc9cd7926d75e3cd0ed2b8d766de2868c (patch) | |
tree | 428110a3cde5ea52b8877564a804608ccd58878c /libraries | |
parent | 0e478407f3aa03425011f6ab5081d39eeca7df05 (diff) | |
download | haskell-74631bbcc9cd7926d75e3cd0ed2b8d766de2868c.tar.gz |
base: add newtypes for socklen_t and ndfs_t to System.Posix.Types #16568
Metric Increase:
haddock.base
T4029
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/GHC/Event/Poll.hsc | 9 | ||||
-rw-r--r-- | libraries/base/System/Posix/Types.hs | 15 | ||||
-rw-r--r-- | libraries/base/aclocal.m4 | 8 | ||||
-rw-r--r-- | libraries/base/changelog.md | 3 | ||||
-rw-r--r-- | libraries/base/configure.ac | 4 |
5 files changed, 33 insertions, 6 deletions
diff --git a/libraries/base/GHC/Event/Poll.hsc b/libraries/base/GHC/Event/Poll.hsc index 61315b370c..370dd4a365 100644 --- a/libraries/base/GHC/Event/Poll.hsc +++ b/libraries/base/GHC/Event/Poll.hsc @@ -27,7 +27,6 @@ available = False import Control.Concurrent.MVar (MVar, newMVar, swapMVar) import Data.Bits (Bits, FiniteBits, (.|.), (.&.)) -import Data.Word import Foreign.C.Types (CInt(..), CShort(..)) import Foreign.Ptr (Ptr) import Foreign.Storable (Storable(..)) @@ -37,7 +36,7 @@ import GHC.Enum (maxBound) import GHC.Num (Num(..)) import GHC.Real (fromIntegral, div) import GHC.Show (Show) -import System.Posix.Types (Fd(..)) +import System.Posix.Types (Fd(..), CNfds(..)) import qualified GHC.Event.Array as A import qualified GHC.Event.Internal as E @@ -110,7 +109,7 @@ poll p mtout f = do -- This function deals with timeouts greater than maxBound :: CInt, by -- looping until c_poll returns a non-zero value (0 indicates timeout -- expired) OR the full timeout has passed. - c_pollLoop :: Ptr PollFd -> (#type nfds_t) -> Int -> IO CInt + c_pollLoop :: Ptr PollFd -> CNfds -> Int -> IO CInt c_pollLoop ptr len tout | isShortTimeout = c_poll ptr len (fromIntegral tout) | otherwise = do @@ -201,8 +200,8 @@ instance Storable PollFd where #{poke struct pollfd, revents} ptr (pfdRevents p) foreign import ccall safe "poll.h poll" - c_poll :: Ptr PollFd -> (#type nfds_t) -> CInt -> IO CInt + c_poll :: Ptr PollFd -> CNfds -> CInt -> IO CInt foreign import ccall unsafe "poll.h poll" - c_poll_unsafe :: Ptr PollFd -> (#type nfds_t) -> CInt -> IO CInt + c_poll_unsafe :: Ptr PollFd -> CNfds -> CInt -> IO CInt #endif /* defined(HAVE_POLL_H) */ diff --git a/libraries/base/System/Posix/Types.hs b/libraries/base/System/Posix/Types.hs index a02a5b94e4..ed1d14f2b5 100644 --- a/libraries/base/System/Posix/Types.hs +++ b/libraries/base/System/Posix/Types.hs @@ -95,6 +95,12 @@ module System.Posix.Types ( #if defined(HTYPE_TIMER_T) CTimer(..), #endif +#if defined(HTYPE_SOCKLEN_T) + CSocklen(..), +#endif +#if defined(HTYPE_NFDS_T) + CNfds(..), +#endif Fd(..), @@ -214,6 +220,15 @@ INTEGRAL_TYPE_WITH_CTYPE(CKey,key_t,HTYPE_KEY_T) OPAQUE_TYPE_WITH_CTYPE(CTimer,timer_t,HTYPE_TIMER_T) #endif +#if defined(HTYPE_SOCKLEN_T) +-- | @since 4.14.0.0 +INTEGRAL_TYPE(CSocklen,HTYPE_SOCKLEN_T) +#endif +#if defined(HTYPE_NFDS_T) +-- | @since 4.14.0.0 +INTEGRAL_TYPE(CNfds,HTYPE_NFDS_T) +#endif + -- Make an Fd type rather than using CInt everywhere INTEGRAL_TYPE(Fd,CInt) diff --git a/libraries/base/aclocal.m4 b/libraries/base/aclocal.m4 index ece0c6f05e..528eac5d21 100644 --- a/libraries/base/aclocal.m4 +++ b/libraries/base/aclocal.m4 @@ -106,6 +106,14 @@ AC_DEFUN([FPTOOLS_HTYPE_INCLUDES], # include <sys/resource.h> #endif +#if HAVE_POLL_H +# include <poll.h> +#endif + +#if HAVE_SYS_SOCKET_H +# include <sys/socket.h> +#endif + #include <stdlib.h> ]) diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 0f2c72a9ac..b97ed78ced 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -33,6 +33,9 @@ * Add `isResourceVanishedError`, `resourceVanishedErrorType`, and `isResourceVanishedErrorType` to `System.IO.Error`. + * Add newtypes for `CSocklen` (`socklen_t`) and `CNfds` (`nfds_t`) to + `System.Posix.Types`. + ## 4.13.0.0 *TBA* * Bundled with GHC *TBA* diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac index 0fe2ca52c2..631e921423 100644 --- a/libraries/base/configure.ac +++ b/libraries/base/configure.ac @@ -30,7 +30,7 @@ dnl ** check for full ANSI header (.h) files AC_HEADER_STDC # check for specific header (.h) files that we are interested in -AC_CHECK_HEADERS([ctype.h errno.h fcntl.h inttypes.h limits.h signal.h sys/file.h sys/resource.h sys/select.h sys/stat.h sys/syscall.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/types.h sys/utsname.h sys/wait.h termios.h time.h unistd.h utime.h windows.h winsock.h langinfo.h poll.h sys/epoll.h sys/event.h sys/eventfd.h]) +AC_CHECK_HEADERS([ctype.h errno.h fcntl.h inttypes.h limits.h signal.h sys/file.h sys/resource.h sys/select.h sys/stat.h sys/syscall.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/types.h sys/utsname.h sys/wait.h termios.h time.h unistd.h utime.h windows.h winsock.h langinfo.h poll.h sys/epoll.h sys/event.h sys/eventfd.h sys/socket.h]) # Enable large file support. Do this before testing the types ino_t, off_t, and # rlim_t, because it will affect the result of that test. @@ -168,6 +168,8 @@ FPTOOLS_CHECK_HTYPE(fsfilcnt_t) FPTOOLS_CHECK_HTYPE(id_t) FPTOOLS_CHECK_HTYPE(key_t) FPTOOLS_CHECK_HTYPE(timer_t) +FPTOOLS_CHECK_HTYPE(socklen_t) +FPTOOLS_CHECK_HTYPE(nfds_t) FPTOOLS_CHECK_HTYPE(intptr_t) FPTOOLS_CHECK_HTYPE(uintptr_t) |