@@ -104,7 +104,7 @@ import Network.Socket.ReadShow
104104-----------------------------------------------------------------------------
105105
106106-- | Basic type for a socket.
107- data Socket = Socket ! (IORef CInt ) ! CInt {- for Show -}
107+ data Socket = Socket (IORef CInt ) CInt {- for Show -}
108108
109109instance Show Socket where
110110 show (Socket _ ofd) = " <socket: " ++ show ofd ++ " >"
@@ -982,8 +982,8 @@ foreign import CALLCONV unsafe "ntohl" ntohl :: Word32 -> Word32
982982{-# DEPRECATED ntohl "Use getAddrInfo instead" #-}
983983
984984instance Storable PortNumber where
985- sizeOf _ = sizeOf (0 :: Word16 )
986- alignment _ = alignment (0 :: Word16 )
985+ sizeOf ~ _ = sizeOf (0 :: Word16 )
986+ alignment ~ _ = alignment (0 :: Word16 )
987987 poke p (PortNum po) = poke (castPtr p) (htons po)
988988 peek p = PortNum . ntohs <$> peek (castPtr p)
989989
@@ -1007,6 +1007,7 @@ class SocketAddress sa where
10071007sockaddrStorageLen :: Int
10081008sockaddrStorageLen = 128
10091009
1010+ {-# NOINLINE withSocketAddress #-}
10101011withSocketAddress :: SocketAddress sa => sa -> (Ptr sa -> Int -> IO a ) -> IO a
10111012withSocketAddress addr f = do
10121013 let sz = sizeOfSocketAddress addr
@@ -1051,13 +1052,13 @@ type ScopeID = Word32
10511052-- 'isSupportedSockAddr'.
10521053data SockAddr
10531054 = SockAddrInet
1054- ! PortNumber -- sin_port
1055- ! HostAddress -- sin_addr (ditto)
1055+ PortNumber -- sin_port
1056+ HostAddress -- sin_addr (ditto)
10561057 | SockAddrInet6
1057- ! PortNumber -- sin6_port
1058- ! FlowInfo -- sin6_flowinfo (ditto)
1059- ! HostAddress6 -- sin6_addr (ditto)
1060- ! ScopeID -- sin6_scope_id (ditto)
1058+ PortNumber -- sin6_port
1059+ FlowInfo -- sin6_flowinfo (ditto)
1060+ HostAddress6 -- sin6_addr (ditto)
1061+ ScopeID -- sin6_scope_id (ditto)
10611062 -- | The path must have fewer than 104 characters. All of these characters must have code points less than 256.
10621063 | SockAddrUnix
10631064 String -- sun_path
@@ -1114,6 +1115,9 @@ sizeOfSockAddr SockAddrUnix{} = #const sizeof(struct sockaddr_un)
11141115sizeOfSockAddr SockAddrInet {} = # const sizeof(struct sockaddr_in)
11151116sizeOfSockAddr SockAddrInet6 {} = # const sizeof(struct sockaddr_in6)
11161117
1118+ -- The combination of "-XString" and inlining results in a bug where
1119+ -- "sz" is always 0.
1120+ {-# NOINLINE withSockAddr #-}
11171121-- | Use a 'SockAddr' with a function requiring a pointer to a
11181122-- 'SockAddr' and the length of that 'SockAddr'.
11191123withSockAddr :: SockAddr -> (Ptr SockAddr -> Int -> IO a ) -> IO a
@@ -1279,8 +1283,8 @@ newtype In6Addr = In6Addr HostAddress6
12791283#endif
12801284
12811285instance Storable In6Addr where
1282- sizeOf _ = # const sizeof(struct in6_addr)
1283- alignment _ = # alignment struct in6_addr
1286+ sizeOf ~ _ = # const sizeof(struct in6_addr)
1287+ alignment ~ _ = # alignment struct in6_addr
12841288
12851289 peek p = do
12861290 a <- peek32 p 0
0 commit comments