@@ -93,9 +93,7 @@ import GHC.IO (IO (..))
93
93
94
94
import qualified Text.Read as P
95
95
96
- #if defined(DOMAIN_SOCKET_SUPPORT)
97
96
import Foreign.Marshal.Array
98
- #endif
99
97
100
98
import Network.Socket.Imports
101
99
@@ -1075,11 +1073,7 @@ isSupportedSockAddr :: SockAddr -> Bool
1075
1073
isSupportedSockAddr addr = case addr of
1076
1074
SockAddrInet {} -> True
1077
1075
SockAddrInet6 {} -> True
1078
- #if defined(DOMAIN_SOCKET_SUPPORT)
1079
1076
SockAddrUnix {} -> True
1080
- #else
1081
- SockAddrUnix {} -> False
1082
- #endif
1083
1077
1084
1078
instance SocketAddress SockAddr where
1085
1079
sizeOfSocketAddress = sizeOfSockAddr
@@ -1098,7 +1092,6 @@ type CSaFamily = (#type sa_family_t)
1098
1092
-- 'SockAddr'. This function differs from 'Foreign.Storable.sizeOf'
1099
1093
-- in that the value of the argument /is/ used.
1100
1094
sizeOfSockAddr :: SockAddr -> Int
1101
- #if defined(DOMAIN_SOCKET_SUPPORT)
1102
1095
# ifdef linux_HOST_OS
1103
1096
-- http://man7.org/linux/man-pages/man7/unix.7.html says:
1104
1097
-- "an abstract socket address is distinguished (from a
@@ -1118,9 +1111,6 @@ sizeOfSockAddr (SockAddrUnix path) =
1118
1111
# else
1119
1112
sizeOfSockAddr SockAddrUnix {} = # const sizeof(struct sockaddr_un)
1120
1113
# endif
1121
- #else
1122
- sizeOfSockAddr SockAddrUnix {} = error " sizeOfSockAddr: not supported"
1123
- #endif
1124
1114
sizeOfSockAddr SockAddrInet {} = # const sizeof(struct sockaddr_in)
1125
1115
sizeOfSockAddr SockAddrInet6 {} = # const sizeof(struct sockaddr_in6)
1126
1116
@@ -1135,10 +1125,8 @@ withSockAddr addr f = do
1135
1125
-- structure, and attempting to do so could overflow the allocated storage
1136
1126
-- space. This constant holds the maximum allowable path length.
1137
1127
--
1138
- #if defined(DOMAIN_SOCKET_SUPPORT)
1139
1128
unixPathMax :: Int
1140
1129
unixPathMax = # const sizeof(((struct sockaddr_un * )NULL )-> sun_path)
1141
- #endif
1142
1130
1143
1131
-- We can't write an instance of 'Storable' for 'SockAddr' because
1144
1132
-- @sockaddr@ is a sum type of variable size but
@@ -1149,7 +1137,6 @@ unixPathMax = #const sizeof(((struct sockaddr_un *)NULL)->sun_path)
1149
1137
1150
1138
-- | Write the given 'SockAddr' to the given memory location.
1151
1139
pokeSockAddr :: Ptr a -> SockAddr -> IO ()
1152
- #if defined(DOMAIN_SOCKET_SUPPORT)
1153
1140
pokeSockAddr p sa@ (SockAddrUnix path) = do
1154
1141
when (length path > unixPathMax) $ error
1155
1142
$ " pokeSockAddr: path is too long in SockAddrUnix " <> show path
@@ -1162,9 +1149,6 @@ pokeSockAddr p sa@(SockAddrUnix path) = do
1162
1149
let pathC = map castCharToCChar path
1163
1150
-- the buffer is already filled with nulls.
1164
1151
pokeArray ((# ptr struct sockaddr_un, sun_path) p) pathC
1165
- #else
1166
- pokeSockAddr _ SockAddrUnix {} = error " pokeSockAddr: not supported"
1167
- #endif
1168
1152
pokeSockAddr p (SockAddrInet port addr) = do
1169
1153
zeroMemory p (# const sizeof(struct sockaddr_in))
1170
1154
#if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
@@ -1189,11 +1173,9 @@ peekSockAddr :: Ptr SockAddr -> IO SockAddr
1189
1173
peekSockAddr p = do
1190
1174
family <- (# peek struct sockaddr, sa_family) p
1191
1175
case family :: CSaFamily of
1192
- #if defined(DOMAIN_SOCKET_SUPPORT)
1193
1176
(# const AF_UNIX ) -> do
1194
1177
str <- peekCAString ((# ptr struct sockaddr_un, sun_path) p)
1195
1178
return (SockAddrUnix str)
1196
- #endif
1197
1179
(# const AF_INET ) -> do
1198
1180
addr <- (# peek struct sockaddr_in, sin_addr) p
1199
1181
port <- (# peek struct sockaddr_in, sin_port) p
0 commit comments