Commit 74631bbc authored by Adam Sandberg Eriksson's avatar Adam Sandberg Eriksson Committed by Marge Bot
Browse files

base: add newtypes for socklen_t and ndfs_t to System.Posix.Types #16568

Metric Increase:
    haddock.base
    T4029
parent 0e478407
Pipeline #10483 passed with stages
in 421 minutes and 12 seconds
......@@ -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) */
......@@ -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)
......
......@@ -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>
])
......
......@@ -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*
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment