Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Network/Socket/Fcntl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import GHC.IO.SubSystem ((<!>))
# endif
#endif
import Network.Socket.Imports

Check warning on line 15 in Network/Socket/Fcntl.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.4)

The import of ‘Network.Socket.Imports’ is redundant

Check warning on line 15 in Network/Socket/Fcntl.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.4)

The import of ‘Network.Socket.Imports’ is redundant

Check warning on line 15 in Network/Socket/Fcntl.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.4)

The import of ‘Network.Socket.Imports’ is redundant

Check warning on line 15 in Network/Socket/Fcntl.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.14)

The import of ‘Network.Socket.Imports’ is redundant

Check warning on line 15 in Network/Socket/Fcntl.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.14)

The import of ‘Network.Socket.Imports’ is redundant

Check warning on line 15 in Network/Socket/Fcntl.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.14)

The import of ‘Network.Socket.Imports’ is redundant

-- | Set the nonblocking flag on Unix.
-- On Windows, nothing is done.
Expand All @@ -34,8 +34,8 @@
#endif

#if !defined(mingw32_HOST_OS)
foreign import ccall unsafe "fcntl"
c_fcntl_read :: CSocket -> CInt -> CInt -> IO CInt
foreign import ccall unsafe "hsnet_fcntl_get"
c_fcntl_get :: CSocket -> CInt -> IO CInt
#endif

-- | Get the close_on_exec flag.
Expand All @@ -47,7 +47,7 @@
getCloseOnExec _ = return False
#else
getCloseOnExec fd = do
flags <- c_fcntl_read fd fGetFd 0
flags <- c_fcntl_get fd fGetFd
let ret = flags .&. fdCloexec
return (ret /= 0)
#endif
Expand All @@ -69,7 +69,7 @@
# endif
#else
getNonBlock fd = do
flags <- c_fcntl_read fd fGetFl 0
flags <- c_fcntl_get fd fGetFl
let ret = flags .&. oNonBlock
return (ret /= 0)
#endif
7 changes: 7 additions & 0 deletions include/HsNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ hsnet_ready_now(int fd, int write)
p.revents = 0;
return poll(&p, 1, 0) > 0;
}

/* fcntl is variadic, which ccall cannot call portably; this takes no arg. */
INLINE int
hsnet_fcntl_get(int fd, int cmd)
{
return fcntl(fd, cmd);
}
#endif

#ifndef IOV_MAX
Expand Down
Loading