packages feed

Z-IO 0.1.5.0 → 0.1.5.1

raw patch · 31 files changed

+309/−187 lines, 31 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Z.Compression.Zlib: data CompressLevel
- Z.Compression.Zlib: data MemLevel
- Z.Compression.Zlib: data Strategy
- Z.Compression.Zlib: data WindowBits
- Z.Compression.Zlib: instance GHC.Classes.Eq Z.Compression.Zlib.CompressLevel
- Z.Compression.Zlib: instance GHC.Classes.Eq Z.Compression.Zlib.MemLevel
- Z.Compression.Zlib: instance GHC.Classes.Eq Z.Compression.Zlib.Strategy
- Z.Compression.Zlib: instance GHC.Classes.Eq Z.Compression.Zlib.WindowBits
- Z.Compression.Zlib: instance GHC.Classes.Eq Z.Compression.Zlib.ZReturn
- Z.Compression.Zlib: instance GHC.Classes.Ord Z.Compression.Zlib.CompressLevel
- Z.Compression.Zlib: instance GHC.Classes.Ord Z.Compression.Zlib.MemLevel
- Z.Compression.Zlib: instance GHC.Classes.Ord Z.Compression.Zlib.Strategy
- Z.Compression.Zlib: instance GHC.Classes.Ord Z.Compression.Zlib.WindowBits
- Z.Compression.Zlib: instance GHC.Classes.Ord Z.Compression.Zlib.ZReturn
- Z.Compression.Zlib: instance GHC.Generics.Generic Z.Compression.Zlib.CompressLevel
- Z.Compression.Zlib: instance GHC.Generics.Generic Z.Compression.Zlib.MemLevel
- Z.Compression.Zlib: instance GHC.Generics.Generic Z.Compression.Zlib.Strategy
- Z.Compression.Zlib: instance GHC.Generics.Generic Z.Compression.Zlib.WindowBits
- Z.Compression.Zlib: instance GHC.Num.Num Z.Compression.Zlib.MemLevel
- Z.Compression.Zlib: instance GHC.Num.Num Z.Compression.Zlib.WindowBits
- Z.Compression.Zlib: instance GHC.Read.Read Z.Compression.Zlib.MemLevel
- Z.Compression.Zlib: instance GHC.Read.Read Z.Compression.Zlib.WindowBits
- Z.Compression.Zlib: instance GHC.Show.Show Z.Compression.Zlib.CompressLevel
- Z.Compression.Zlib: instance GHC.Show.Show Z.Compression.Zlib.MemLevel
- Z.Compression.Zlib: instance GHC.Show.Show Z.Compression.Zlib.Strategy
- Z.Compression.Zlib: instance GHC.Show.Show Z.Compression.Zlib.WindowBits
- Z.Compression.Zlib: instance GHC.Show.Show Z.Compression.Zlib.ZReturn
- Z.Compression.Zlib: instance Z.Data.Text.ShowT.ShowT Z.Compression.Zlib.CompressLevel
- Z.Compression.Zlib: instance Z.Data.Text.ShowT.ShowT Z.Compression.Zlib.MemLevel
- Z.Compression.Zlib: instance Z.Data.Text.ShowT.ShowT Z.Compression.Zlib.Strategy
- Z.Compression.Zlib: instance Z.Data.Text.ShowT.ShowT Z.Compression.Zlib.WindowBits
- Z.IO.Network.SocketAddr: data ProtocolNumber
- Z.IO.Network.SocketAddr: data SocketFamily
- Z.IO.Network.SocketAddr: data SocketType
- Z.IO.Network.SocketAddr: instance Foreign.Storable.Storable Z.IO.Network.SocketAddr.ProtocolNumber
- Z.IO.Network.SocketAddr: instance Foreign.Storable.Storable Z.IO.Network.SocketAddr.SocketFamily
- Z.IO.Network.SocketAddr: instance Foreign.Storable.Storable Z.IO.Network.SocketAddr.SocketType
- Z.IO.Network.SocketAddr: instance GHC.Classes.Eq Z.IO.Network.SocketAddr.ProtocolNumber
- Z.IO.Network.SocketAddr: instance GHC.Classes.Eq Z.IO.Network.SocketAddr.SocketFamily
- Z.IO.Network.SocketAddr: instance GHC.Classes.Eq Z.IO.Network.SocketAddr.SocketType
- Z.IO.Network.SocketAddr: instance GHC.Classes.Ord Z.IO.Network.SocketAddr.ProtocolNumber
- Z.IO.Network.SocketAddr: instance GHC.Classes.Ord Z.IO.Network.SocketAddr.SocketFamily
- Z.IO.Network.SocketAddr: instance GHC.Classes.Ord Z.IO.Network.SocketAddr.SocketType
- Z.IO.Network.SocketAddr: instance GHC.Read.Read Z.IO.Network.SocketAddr.ProtocolNumber
- Z.IO.Network.SocketAddr: instance GHC.Read.Read Z.IO.Network.SocketAddr.SocketFamily
- Z.IO.Network.SocketAddr: instance GHC.Read.Read Z.IO.Network.SocketAddr.SocketType
- Z.IO.Network.SocketAddr: instance GHC.Show.Show Z.IO.Network.SocketAddr.ProtocolNumber
- Z.IO.Network.SocketAddr: instance GHC.Show.Show Z.IO.Network.SocketAddr.SocketFamily
- Z.IO.Network.SocketAddr: instance GHC.Show.Show Z.IO.Network.SocketAddr.SocketType
+ Z.Compression.Zlib: instance GHC.Classes.Eq Z.Compression.Zlib.CompressConfig
+ Z.Compression.Zlib: instance GHC.Classes.Eq Z.Compression.Zlib.DecompressConfig
+ Z.Compression.Zlib: instance GHC.Classes.Ord Z.Compression.Zlib.CompressConfig
+ Z.Compression.Zlib: instance GHC.Classes.Ord Z.Compression.Zlib.DecompressConfig
+ Z.Compression.Zlib: instance GHC.Generics.Generic Z.Compression.Zlib.CompressConfig
+ Z.Compression.Zlib: instance GHC.Generics.Generic Z.Compression.Zlib.DecompressConfig
+ Z.Compression.Zlib: instance GHC.Show.Show Z.Compression.Zlib.CompressConfig
+ Z.Compression.Zlib: instance GHC.Show.Show Z.Compression.Zlib.DecompressConfig
+ Z.Compression.Zlib: instance Z.Data.Text.ShowT.ShowT Z.Compression.Zlib.CompressConfig
+ Z.Compression.Zlib: instance Z.Data.Text.ShowT.ShowT Z.Compression.Zlib.DecompressConfig
+ Z.Compression.Zlib: type CompressLevel = CInt
+ Z.Compression.Zlib: type MemLevel = CInt
+ Z.Compression.Zlib: type Strategy = CInt
+ Z.Compression.Zlib: type WindowBits = CInt
+ Z.IO.Buffered: chunkOverhead :: Int
+ Z.IO.FileSystem: quickReadFile :: HasCallStack => CBytes -> IO Bytes
+ Z.IO.FileSystem: quickReadTextFile :: HasCallStack => CBytes -> IO Text
+ Z.IO.FileSystem: quickWriteFile :: HasCallStack => CBytes -> Bytes -> IO ()
+ Z.IO.FileSystem: quickWriteTextFile :: HasCallStack => CBytes -> Text -> IO ()
+ Z.IO.FileSystem.Threaded: quickReadFile :: HasCallStack => CBytes -> IO Bytes
+ Z.IO.FileSystem.Threaded: quickReadTextFile :: HasCallStack => CBytes -> IO Text
+ Z.IO.FileSystem.Threaded: quickWriteFile :: HasCallStack => CBytes -> Bytes -> IO ()
+ Z.IO.FileSystem.Threaded: quickWriteTextFile :: HasCallStack => CBytes -> Text -> IO ()
+ Z.IO.Network.SocketAddr: type ProtocolNumber = CInt
+ Z.IO.Network.SocketAddr: type SocketFamily = CInt
+ Z.IO.Network.SocketAddr: type SocketType = CInt
+ Z.IO.Process: pattern PROCESS_DETACHED :: ProcessFlag
+ Z.IO.Process: pattern PROCESS_SETGID :: ProcessFlag
+ Z.IO.Process: pattern PROCESS_SETUID :: ProcessFlag
+ Z.IO.Process: pattern PROCESS_WINDOWS_HIDE_CONSOLE :: ProcessFlag
+ Z.IO.Process: pattern PROCESS_WINDOWS_HIDE_GUI :: ProcessFlag
+ Z.IO.Process: pattern PROCESS_WINDOWS_VERBATIM_ARGUMENTS :: ProcessFlag
+ Z.IO.Process: type ProcessFlag = CUInt
+ Z.IO.UV.FFI: hs_uv_accept_check_start :: Ptr UVHandle -> IO CInt
+ Z.IO.UV.FFI: uv_unref :: Ptr UVHandle -> IO ()
- Z.IO.Exception: IOEInfo :: CBytes -> CBytes -> CallStack -> IOEInfo
+ Z.IO.Exception: IOEInfo :: Text -> Text -> CallStack -> IOEInfo
- Z.IO.Exception: [ioeDescription] :: IOEInfo -> CBytes
+ Z.IO.Exception: [ioeDescription] :: IOEInfo -> Text
- Z.IO.Exception: [ioeName] :: IOEInfo -> CBytes
+ Z.IO.Exception: [ioeName] :: IOEInfo -> Text
- Z.IO.UV.Errno: uvErrName :: CInt -> IO CBytes
+ Z.IO.UV.Errno: uvErrName :: CInt -> IO Text
- Z.IO.UV.Errno: uvStdError :: CInt -> IO CBytes
+ Z.IO.UV.Errno: uvStdError :: CInt -> IO Text
- Z.IO.UV.FFI: hs_uv_accept_check_alloc :: Ptr UVHandle -> IO (Ptr UVHandle)
+ Z.IO.UV.FFI: hs_uv_accept_check_alloc :: IO (Ptr UVHandle)
- Z.IO.UV.FFI: hs_uv_accept_check_init :: Ptr UVHandle -> IO CInt
+ Z.IO.UV.FFI: hs_uv_accept_check_init :: Ptr UVHandle -> Ptr UVHandle -> IO CInt

Files

ChangeLog.md view
@@ -1,6 +1,14 @@ # Revision history for Z-IO -## 0.1.5.0  -- 2020-10-02+## 0.1.5.1  -- 2020-10-13++* Export `ProcessFlag` from `Z.IO.Process`.+* Add quick read & write functions to fileSystem modules.+* Fix a bug: when exception raise from server loop an uninitialized uv_check_t is closed.+* Update libuv's version to 1.40.1.+* Change `IOEInfo` type to use `Text` instead of `CBytes`.++## 0.1.5.0  -- 2020-10-10  * Add `Z.IO.Process` module. * Move many flag type to type alias from newtype, adjust patterns haddock.
Z-IO.cabal view
@@ -1,6 +1,6 @@ cabal-version:              2.4 name:                       Z-IO-version:                    0.1.5.0+version:                    0.1.5.1 synopsis:                   Simple and high performance IO toolkit for Haskell description:                Simple and high performance IO toolkit for Haskell, including                             file system, network, ipc and more!@@ -80,7 +80,8 @@     manual: True  library-    exposed-modules:        Z.IO.FileSystem+    exposed-modules:        Z.IO+                            Z.IO.FileSystem                             Z.IO.FileSystem.Threaded                             Z.IO.Network.SocketAddr                             Z.IO.Network.DNS@@ -103,7 +104,6 @@                             Z.IO.UV.Win                              Z.IO.Environment-                            Z.IO                              Z.Compression.Zlib 
Z/Compression/Zlib.hsc view
@@ -15,8 +15,6 @@   , defaultCompressConfig   , compress   , compressSink-  , Strategy (Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED, Z_DEFAULT_STRATEGY)-  , CompressLevel(Z_BEST_SPEED, Z_BEST_COMPRESSION, Z_DEFAULT_COMPRESSION)   , WindowBits   , defaultWindowBits   , MemLevel@@ -26,6 +24,19 @@   , defaultDecompressConfig   , decompress   , decompressSource+  -- * Constants+  -- ** Strategy +  , Strategy +  , pattern Z_FILTERED+  , pattern Z_HUFFMAN_ONLY+  , pattern Z_RLE+  , pattern Z_FIXED+  , pattern Z_DEFAULT_STRATEGY+  -- ** CompressLevel+  , CompressLevel+  , pattern Z_BEST_SPEED+  , pattern Z_BEST_COMPRESSION+  , pattern Z_DEFAULT_COMPRESSION   ) where  import           Control.Monad@@ -46,53 +57,44 @@  #include "zlib.h" -newtype Strategy = Strategy CInt deriving (Eq, Ord, Show, Generic)-                                    deriving anyclass ShowT+type Strategy = CInt   pattern Z_FILTERED           :: Strategy pattern Z_HUFFMAN_ONLY       :: Strategy pattern Z_RLE                :: Strategy pattern Z_FIXED              :: Strategy pattern Z_DEFAULT_STRATEGY   :: Strategy-pattern Z_FILTERED           = Strategy (#const Z_FILTERED        )-pattern Z_HUFFMAN_ONLY       = Strategy (#const Z_HUFFMAN_ONLY    )-pattern Z_RLE                = Strategy (#const Z_RLE             )-pattern Z_FIXED              = Strategy (#const Z_FIXED           )-pattern Z_DEFAULT_STRATEGY   = Strategy (#const Z_DEFAULT_STRATEGY)-+pattern Z_FILTERED           = #const Z_FILTERED        +pattern Z_HUFFMAN_ONLY       = #const Z_HUFFMAN_ONLY    +pattern Z_RLE                = #const Z_RLE             +pattern Z_FIXED              = #const Z_FIXED           +pattern Z_DEFAULT_STRATEGY   = #const Z_DEFAULT_STRATEGY -newtype CompressLevel = CompressLevel CInt deriving (Eq, Ord, Show, Generic)-                                            deriving anyclass ShowT+type CompressLevel = CInt   -- pattern Z_NO_COMPRESSION       =  CompressLevel (#const Z_NO_COMPRESSION     ) pattern Z_BEST_SPEED          :: CompressLevel pattern Z_BEST_COMPRESSION    :: CompressLevel pattern Z_DEFAULT_COMPRESSION :: CompressLevel-pattern Z_BEST_SPEED           =  CompressLevel (#const Z_BEST_SPEED         )-pattern Z_BEST_COMPRESSION     =  CompressLevel (#const Z_BEST_COMPRESSION   )-pattern Z_DEFAULT_COMPRESSION  =  CompressLevel (#const Z_DEFAULT_COMPRESSION)+pattern Z_BEST_SPEED          = #const Z_BEST_SPEED         +pattern Z_BEST_COMPRESSION    = #const Z_BEST_COMPRESSION   +pattern Z_DEFAULT_COMPRESSION = #const Z_DEFAULT_COMPRESSION  {- | The 'WindowBits' is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. The 'defaultWindowBits' value is 15. Decompressing windowBits must be greater than or equal to the compressing windowBits. If a compressed stream with a larger window size is given as input, decompress will throw 'ZDataError' windowBits can also be –8..–15 for raw inflate. In this case, -windowBits determines the window size. inflate() will then process raw deflate data, not looking for a zlib or gzip header, not generating a check value, and not looking for any check values for comparison at the end of the stream. windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format. -}-newtype WindowBits = WindowBits CInt-    deriving (Eq, Ord, Read, Show, Generic)-        deriving newtype Num-        deriving anyclass ShowT+type WindowBits = CInt  defaultWindowBits :: WindowBits-defaultWindowBits = WindowBits 15+defaultWindowBits = 15  -- | The 'MemLevel' specifies how much memory should be allocated for the internal compression state. 1 uses minimum memory but is slow and reduces compression ratio; 9 uses maximum memory for optimal speed. The default value is 8.-newtype MemLevel = MemLevel CInt-    deriving (Eq, Ord, Read, Show, Generic)-        deriving newtype Num-        deriving anyclass ShowT+type MemLevel = CInt  defaultMemLevel :: MemLevel-defaultMemLevel = MemLevel 9+defaultMemLevel = 9  data CompressConfig = CompressConfig     { compressLevel :: CompressLevel@@ -100,7 +102,8 @@     , compressMemoryLevel :: MemLevel     , compressDictionary :: V.Bytes     , compressStrategy :: Strategy-    }+    }   deriving (Show, Eq, Ord, Generic)+        deriving anyclass ShowT  defaultCompressConfig :: CompressConfig defaultCompressConfig =@@ -185,7 +188,8 @@ data DecompressConfig = DecompressConfig     { decompressWindowBits :: WindowBits     , decompressDictionary :: V.Bytes-    }+    }   deriving (Show, Eq, Ord, Generic)+        deriving anyclass ShowT  defaultDecompressConfig :: DecompressConfig defaultDecompressConfig = DecompressConfig defaultWindowBits V.empty@@ -268,8 +272,6 @@      collectSource =<< decompressSource conf =<< sourceFromList [input]  ----------------------------------------------------------------------------------newtype ZReturn = ZReturn CInt deriving (Eq, Ord, Show, Typeable)  toZErrorMsg :: CInt -> CBytes toZErrorMsg (#const Z_OK           ) =  "Z_OK"
Z/IO.hs view
@@ -7,7 +7,7 @@ Stability   : experimental Portability : non-portable -This re-exports several common module to be used together with file, network, and or specific module,+This re-exports several common modules to be used together with file, network, and other specific modules, such as resource management, buffered IO and std streams.  -}
Z/IO/Buffered.hs view
@@ -49,6 +49,7 @@     -- * common buffer size   , V.defaultChunkSize   , V.smallChunkSize+  , V.chunkOverhead   ) where  import           Control.Monad
Z/IO/Exception.hs view
@@ -79,8 +79,7 @@ import Foreign.C.Types import GHC.Stack import Z.IO.UV.Errno-import Z.Data.CBytes (CBytes)-import qualified Z.Data.CBytes as CB+import qualified Z.Data.Text       as T import qualified Z.Data.Text.ShowT as T  @@ -184,26 +183,24 @@  -- | IO exceptions informations. ----- The 'ShowT' instances does not check if name and description are valid UTF8 string, it's your responsibility--- to make sure. data IOEInfo = IOEInfo-    { ioeName        :: CBytes      -- ^ the errno name, e.g. EADDRINUSE, etc. empty if no errno.-    , ioeDescription :: CBytes      -- ^ description for this io error, can be errno description, or some custom description if no errno.+    { ioeName        :: T.Text      -- ^ the errno name, e.g. EADDRINUSE, etc. empty if no errno.+    , ioeDescription :: T.Text      -- ^ description for this io error, can be errno description, or some custom description if no errno.     , ioeCallStack   :: CallStack   -- ^ lightweight partial call-stack     }  instance Show IOEInfo where     show (IOEInfo errno desc cstack) =-         "{name:" ++ CB.unpack errno ++-         ", description:" ++ CB.unpack desc +++         "{name:" ++ T.unpack errno +++         ", description:" ++ T.unpack desc ++          ", callstack:" ++ prettyCallStack cstack ++ "}"  instance T.ShowT IOEInfo where     toTextBuilder _ (IOEInfo errno desc cstack) = do          "{name:"-         T.unsafeFromBuilder(CB.toBuilder errno)  -- we use UTF8 name here+         T.text errno          ", description:"-         T.unsafeFromBuilder (CB.toBuilder desc)+         T.text desc          ", callstack:"          T.stringUTF8 (prettyCallStack cstack)          "}"
Z/IO/FileSystem.hs view
@@ -14,6 +14,7 @@ module Z.IO.FileSystem   ( -- * regular file devices     File, initFile, readFile, writeFile, getFileFD+  , quickReadFile, quickReadTextFile, quickWriteFile, quickWriteTextFile     -- * file offset bundle   , FilePtr, newFilePtr, getFileOffset, setFileOffset   -- * filesystem operations@@ -89,14 +90,17 @@   ) where  import           Control.Monad-import           Data.Word+import           Data.Bits import           Data.Int import           Data.IORef+import           Data.Word import           Foreign.Ptr import           Foreign.Storable               (peekElemOff) import           Foreign.Marshal.Alloc          (allocaBytes)-import           Z.Data.CBytes                 as CBytes+import           Z.Data.CBytes                  as CBytes import           Z.Data.PrimRef.PrimIORef+import qualified Z.Data.Text                    as T+import qualified Z.Data.Vector                  as V import           Z.Foreign import           Z.IO.Buffered import           Z.IO.Exception@@ -232,6 +236,26 @@             unless closed $ do                 throwUVIfMinus_ (hs_uv_fs_close fd)                 writeIORef closedRef True)++-- | Quickly open a file and read its content.+quickReadFile :: HasCallStack => CBytes -> IO V.Bytes+quickReadFile filename = do+    withResource (initFile filename O_RDONLY DEFAULT_MODE) $ \ file -> do+        readAll' =<< newBufferedInput file++-- | Quickly open a file and read its content as UTF8 text.+quickReadTextFile :: HasCallStack => CBytes -> IO T.Text+quickReadTextFile filename = T.validate <$> quickReadFile filename++-- | Quickly open a file and write some content.+quickWriteFile :: HasCallStack => CBytes -> V.Bytes -> IO ()+quickWriteFile filename content = do+    withResource (initFile filename (O_WRONLY .|. O_CREAT) DEFAULT_MODE) $ \ file -> do+        withPrimVectorSafe content (writeOutput file)++-- | Quickly open a file and write some content as UTF8 text.+quickWriteTextFile :: HasCallStack => CBytes -> T.Text -> IO ()+quickWriteTextFile filename content = quickWriteFile filename (T.getUTF8Bytes content)  -------------------------------------------------------------------------------- 
Z/IO/FileSystem/Threaded.hs view
@@ -20,6 +20,7 @@ module Z.IO.FileSystem.Threaded   ( -- * regular file devices     FileT, initFileT, readFileT, writeFileT, getFileTFD+  , quickReadFile, quickReadTextFile, quickWriteFile, quickWriteTextFile     -- * file offset bundle   , FilePtrT, newFilePtrT, getFileOffset, setFileOffset   -- * filesystem operations@@ -95,14 +96,17 @@   ) where  import           Control.Monad-import           Data.Word+import           Data.Bits import           Data.Int import           Data.IORef-import           Z.Data.CBytes                 as CBytes-import           Z.Data.PrimRef.PrimIORef+import           Data.Word import           Foreign.Ptr import           Foreign.Storable               (peekElemOff) import           Foreign.Marshal.Alloc          (allocaBytes)+import           Z.Data.CBytes                 as CBytes+import           Z.Data.PrimRef.PrimIORef+import qualified Z.Data.Text                    as T+import qualified Z.Data.Vector                  as V import           Z.Foreign import           Z.IO.Buffered import           Z.IO.Exception@@ -251,6 +255,26 @@             unless closed $ do                 throwUVIfMinus_ (hs_uv_fs_close fd)                 writeIORef closedRef True)++-- | Quickly open a file and read its content.+quickReadFile :: HasCallStack => CBytes -> IO V.Bytes+quickReadFile filename = do+    withResource (initFileT filename O_RDONLY DEFAULT_MODE) $ \ file -> do+        readAll' =<< newBufferedInput file++-- | Quickly open a file and read its content as UTF8 text.+quickReadTextFile :: HasCallStack => CBytes -> IO T.Text+quickReadTextFile filename = T.validate <$> quickReadFile filename++-- | Quickly open a file and write some content.+quickWriteFile :: HasCallStack => CBytes -> V.Bytes -> IO ()+quickWriteFile filename content = do+    withResource (initFileT filename (O_WRONLY .|. O_CREAT) DEFAULT_MODE) $ \ file -> do+        withPrimVectorSafe content (writeOutput file)++-- | Quickly open a file and write some content as UTF8 text.+quickWriteTextFile :: HasCallStack => CBytes -> T.Text -> IO ()+quickWriteTextFile filename content = quickWriteFile filename (T.getUTF8Bytes content)  -------------------------------------------------------------------------------- 
Z/IO/Network/IPC.hs view
@@ -111,7 +111,9 @@         withCBytesUnsafe ipcListenName $ \ name_p -> do             throwUVIfMinus_ (uv_pipe_bind serverHandle name_p)         bracket-            (throwOOMIfNull $ hs_uv_accept_check_alloc serverHandle)+            (do check <- throwOOMIfNull $ hs_uv_accept_check_alloc+                throwUVIfMinus_ (hs_uv_accept_check_init check serverHandle)+                return check)             hs_uv_accept_check_close $             \ check -> do @@ -139,9 +141,9 @@                     pokeBufferTable serverUVManager serverSlot acceptBufPtr (backLog-1)                     throwUVIfMinus_ (hs_uv_listen serverHandle (fromIntegral backLog)) -- Step 2.--- we initiate a uv_check_t for given uv_stream_t, with predefined checking callback+-- we start a uv_check_t for given uv_stream_t, with predefined checking callback -- see hs_accept_check_cb in hs_uv_stream.c-                    throwUVIfMinus_ $ hs_uv_accept_check_init check+                    throwUVIfMinus_ $ hs_uv_accept_check_start check                  m <- getBlockMVar serverUVManager serverSlot                 forever $ do
Z/IO/Network/SocketAddr.hsc view
@@ -45,9 +45,23 @@   , PortNumber(..)   , portAny   -- * family, type, protocol-  , SocketFamily(AF_UNSPEC, AF_INET, AF_INET6)-  , SocketType(SOCK_DGRAM, SOCK_STREAM, SOCK_SEQPACKET, SOCK_RAW, SOCK_RDM, SOCK_ANY)-  , ProtocolNumber(IPPROTO_DEFAULT, IPPROTO_IP, IPPROTO_TCP, IPPROTO_UDP)+  -- ** SocketFamily+  , SocketFamily+  , pattern AF_UNSPEC+  , pattern AF_INET+  , pattern AF_INET6+  , SocketType+  , pattern SOCK_DGRAM+  , pattern SOCK_STREAM+  , pattern SOCK_SEQPACKET+  , pattern SOCK_RAW+  , pattern SOCK_RDM+  , pattern SOCK_ANY+  , ProtocolNumber+  , pattern IPPROTO_DEFAULT+  , pattern IPPROTO_IP+  , pattern IPPROTO_TCP+  , pattern IPPROTO_UDP   -- * Internal helper   , peekSocketAddr   , pokeSocketAddr@@ -501,63 +515,42 @@      -------------------------------------------------------------------------------- -newtype SocketFamily = SocketFamily CInt-    deriving (Eq, Ord, Read, Show, Typeable)-newtype SocketType = SocketType CInt-    deriving (Eq, Ord, Read, Show, Typeable)-newtype ProtocolNumber = ProtocolNumber CInt-    deriving (Eq, Ord, Read, Show, Typeable)--instance Storable SocketFamily where                      -    sizeOf _ = sizeOf (undefined :: CInt)       -    alignment _ = alignment (undefined :: CInt) -    peek ptr = SocketFamily `fmap` peek (castPtr ptr)             -    poke ptr (SocketFamily v) = poke (castPtr ptr) v--instance Storable SocketType where                      -    sizeOf _ = sizeOf (undefined :: CInt)       -    alignment _ = alignment (undefined :: CInt) -    peek ptr = SocketType `fmap` peek (castPtr ptr)             -    poke ptr (SocketType v) = poke (castPtr ptr) v--instance Storable ProtocolNumber where                      -    sizeOf _ = sizeOf (undefined :: CInt)       -    alignment _ = alignment (undefined :: CInt) -    peek ptr = ProtocolNumber `fmap` peek (castPtr ptr)             -    poke ptr (ProtocolNumber v) = poke (castPtr ptr) v+type SocketFamily = CInt+type SocketType = CInt+type ProtocolNumber = CInt  -- | unspecified pattern AF_UNSPEC :: SocketFamily-pattern AF_UNSPEC = SocketFamily (#const AF_UNSPEC)+pattern AF_UNSPEC = #const AF_UNSPEC -- | internetwork: UDP, TCP, etc pattern AF_INET :: SocketFamily-pattern AF_INET = SocketFamily (#const AF_INET)+pattern AF_INET = #const AF_INET -- | Internet Protocol version 6 pattern AF_INET6 :: SocketFamily-pattern AF_INET6 = SocketFamily (#const AF_INET6)+pattern AF_INET6 = #const AF_INET6  pattern SOCK_STREAM :: SocketType-pattern SOCK_STREAM = SocketType (#const SOCK_STREAM)+pattern SOCK_STREAM = #const SOCK_STREAM pattern SOCK_DGRAM :: SocketType-pattern SOCK_DGRAM = SocketType (#const SOCK_DGRAM)+pattern SOCK_DGRAM = #const SOCK_DGRAM pattern SOCK_RAW :: SocketType-pattern SOCK_RAW = SocketType (#const SOCK_RAW)+pattern SOCK_RAW = #const SOCK_RAW pattern SOCK_RDM :: SocketType-pattern SOCK_RDM = SocketType (#const SOCK_RDM)+pattern SOCK_RDM = #const SOCK_RDM pattern SOCK_SEQPACKET :: SocketType-pattern SOCK_SEQPACKET = SocketType (#const SOCK_SEQPACKET)+pattern SOCK_SEQPACKET = #const SOCK_SEQPACKET -- | Used in getAddrInfo hints, for any type can be returned by getAddrInfo pattern SOCK_ANY :: SocketType-pattern SOCK_ANY = SocketType 0+pattern SOCK_ANY = 0  pattern IPPROTO_DEFAULT :: ProtocolNumber-pattern IPPROTO_DEFAULT = ProtocolNumber 0+pattern IPPROTO_DEFAULT = 0 pattern IPPROTO_IP :: ProtocolNumber-pattern IPPROTO_IP = ProtocolNumber (#const IPPROTO_IP)+pattern IPPROTO_IP = #const IPPROTO_IP pattern IPPROTO_TCP :: ProtocolNumber-pattern IPPROTO_TCP = ProtocolNumber (#const IPPROTO_TCP)+pattern IPPROTO_TCP =  #const IPPROTO_TCP pattern IPPROTO_UDP :: ProtocolNumber-pattern IPPROTO_UDP = ProtocolNumber (#const IPPROTO_UDP)+pattern IPPROTO_UDP = #const IPPROTO_UDP  -------------------------------------------------------------------------------- 
Z/IO/Network/TCP.hs view
@@ -123,7 +123,9 @@         withSocketAddrUnsafe tcpListenAddr $ \ addrPtr -> do             throwUVIfMinus_ (uv_tcp_bind serverHandle addrPtr 0)         bracket-            (throwOOMIfNull $ hs_uv_accept_check_alloc serverHandle)+            (do check <- throwOOMIfNull $ hs_uv_accept_check_alloc+                throwUVIfMinus_ (hs_uv_accept_check_init check serverHandle)+                return check)             hs_uv_accept_check_close $             \ check -> do -- The buffer passing of accept is a litte complicated here, to get maximum performance,@@ -152,10 +154,10 @@                     pokeBufferTable serverUVManager serverSlot acceptBufPtr (backLog-1)                     throwUVIfMinus_ (hs_uv_listen serverHandle (fromIntegral backLog)) -- Step 2.--- we initiate a uv_check_t for given uv_stream_t, with predefined checking callback+-- we start a uv_check_t for given uv_stream_t, with predefined checking callback -- see hs_accept_check_cb in hs_uv_stream.c-                    throwUVIfMinus_ $ hs_uv_accept_check_init check---+                    throwUVIfMinus_ $ hs_uv_accept_check_start check+                 m <- getBlockMVar serverUVManager serverSlot                 forever $ do                     -- wait until accept some FDs
Z/IO/Process.hsc view
@@ -32,6 +32,14 @@   -- * internal    , spawn   -- * Constant+  -- ** ProcessFlag+  , ProcessFlag+  , pattern PROCESS_SETUID+  , pattern PROCESS_SETGID+  , pattern PROCESS_WINDOWS_VERBATIM_ARGUMENTS+  , pattern PROCESS_DETACHED+  , pattern PROCESS_WINDOWS_HIDE_CONSOLE+  , pattern PROCESS_WINDOWS_HIDE_GUI   -- ** Signal   , Signal   , pattern SIGTERM @@ -179,54 +187,54 @@  -- | Spawn a new thread ----- Please manually close child process's std stream(if any) after process exists.+-- Please manually close child process's std stream(if any) after process exits. spawn :: HasCallStack => ProcessOptions -> IO (Maybe UVStream, Maybe UVStream, Maybe UVStream, TVar ProcessState) spawn ProcessOptions{..} = do -    (MutableByteArray popts) <- newByteArray (#size uv_process_options_t)-    (MutableByteArray pstdio) <- newByteArray ((#size uv_stdio_container_t)*3)+    (MutableByteArray popts##) <- newByteArray (#size uv_process_options_t)+    (MutableByteArray pstdio##) <- newByteArray ((#size uv_stdio_container_t)*3) -    pokeMBA popts (#offset uv_process_options_t, flags) processFlags-    pokeMBA popts (#offset uv_process_options_t, uid) processUID-    pokeMBA popts (#offset uv_process_options_t, gid) processGID+    pokeMBA popts## (#offset uv_process_options_t, flags) processFlags+    pokeMBA popts## (#offset uv_process_options_t, uid) processUID+    pokeMBA popts## (#offset uv_process_options_t, gid) processGID      uvm <- getUVManager       let (s0, s1, s2) = processStdStreams -    pokeMBA pstdio (#offset uv_stdio_container_t, flags) (processStdStreamFlag s0)+    pokeMBA pstdio## (#offset uv_stdio_container_t, flags) (processStdStreamFlag s0)     uvs0' <- case s0 of         ProcessInherit fd -> do-            pokeMBA pstdio (#offset uv_stdio_container_t, data) fd+            pokeMBA pstdio## (#offset uv_stdio_container_t, data) fd             return Nothing         ProcessCreate -> do             (uvs0, _) <- acquire (initIPCStream uvm)-            pokeMBA pstdio (#offset uv_stdio_container_t, data) (uvsHandle uvs0)+            pokeMBA pstdio## (#offset uv_stdio_container_t, data) (uvsHandle uvs0)             return (Just uvs0)         _ -> return Nothing         -    pokeMBA pstdio ((#offset uv_stdio_container_t, flags)+(#size uv_stdio_container_t))+    pokeMBA pstdio## ((#offset uv_stdio_container_t, flags)+(#size uv_stdio_container_t))                 (processStdStreamFlag s1)     uvs1' <- case s1 of         ProcessInherit fd -> do-            pokeMBA pstdio ((#offset uv_stdio_container_t, data)+(#size uv_stdio_container_t)) fd+            pokeMBA pstdio## ((#offset uv_stdio_container_t, data)+(#size uv_stdio_container_t)) fd             return Nothing         ProcessCreate -> do             (uvs1, _) <- acquire (initIPCStream uvm)-            pokeMBA pstdio ((#offset uv_stdio_container_t, data)+(#size uv_stdio_container_t))+            pokeMBA pstdio## ((#offset uv_stdio_container_t, data)+(#size uv_stdio_container_t))                 (uvsHandle uvs1)             return (Just uvs1)         _ -> return Nothing -    pokeMBA pstdio ((#offset uv_stdio_container_t, flags)+(#size uv_stdio_container_t)*2)+    pokeMBA pstdio## ((#offset uv_stdio_container_t, flags)+(#size uv_stdio_container_t)*2)                 (processStdStreamFlag s2)     uvs2' <- case s2 of         ProcessInherit fd -> do-            pokeMBA pstdio ((#offset uv_stdio_container_t, data)+(#size uv_stdio_container_t)*2) fd+            pokeMBA pstdio## ((#offset uv_stdio_container_t, data)+(#size uv_stdio_container_t)*2) fd             return Nothing         ProcessCreate -> do             (uvs2, _) <- acquire (initIPCStream uvm)-            pokeMBA pstdio ((#offset uv_stdio_container_t, data.stream)+(#size uv_stdio_container_t)*2)+            pokeMBA pstdio## ((#offset uv_stdio_container_t, data.stream)+(#size uv_stdio_container_t)*2)                 (uvsHandle uvs2)             return (Just uvs2)         _ -> return Nothing@@ -248,8 +256,8 @@             withPrimArrayUnsafe allArgs $ \ pargs _ ->                 withPrimArrayUnsafe allEnv $ \ penv _ ->                     withUVManager uvm $ \ loop -> do-                        slot <- throwUVIfMinus (hs_uv_spawn loop popts pfile-                                        pargs argsLen penv envLen pcwd pstdio)+                        slot <- throwUVIfMinus (hs_uv_spawn loop popts## pfile+                                        pargs argsLen penv envLen pcwd pstdio##)                         pid <- peekBufferTable uvm slot                         return (slot, pid) 
Z/IO/UV/Errno.hsc view
@@ -15,17 +15,18 @@  import Foreign.C.Types import Foreign.C.String-import Z.Data.CBytes+import Z.Data.Text (Text)+import Z.Data.CBytes as CB  #include "hs_uv.h" -uvStdError :: CInt -> IO CBytes-uvStdError errno = fromCString =<< uv_strerror errno+uvStdError :: CInt -> IO Text+uvStdError errno = toText <$> (fromCString =<< uv_strerror errno)  foreign import ccall unsafe uv_strerror :: CInt -> IO CString -uvErrName :: CInt -> IO CBytes-uvErrName errno = fromCString =<< uv_err_name errno+uvErrName :: CInt -> IO Text+uvErrName errno = toText <$> (fromCString =<< uv_err_name errno)  foreign import ccall unsafe uv_err_name :: CInt -> IO CString 
Z/IO/UV/FFI.hsc view
@@ -119,6 +119,7 @@ foreign import ccall unsafe hs_uv_handle_alloc :: Ptr UVLoop -> IO (Ptr UVHandle) foreign import ccall unsafe hs_uv_handle_free  :: Ptr UVHandle -> IO () foreign import ccall unsafe hs_uv_handle_close :: Ptr UVHandle -> IO ()+foreign import ccall unsafe uv_unref :: Ptr UVHandle -> IO ()  -------------------------------------------------------------------------------- -- request@@ -135,8 +136,11 @@ foreign import ccall unsafe uv_read_stop :: Ptr UVHandle -> IO CInt foreign import ccall unsafe hs_uv_write :: Ptr UVHandle -> Ptr Word8 -> Int -> IO UVSlotUnsafe -foreign import ccall unsafe hs_uv_accept_check_alloc :: Ptr UVHandle -> IO (Ptr UVHandle)-foreign import ccall unsafe hs_uv_accept_check_init :: Ptr UVHandle -> IO CInt+foreign import ccall unsafe hs_uv_accept_check_alloc :: IO (Ptr UVHandle)+foreign import ccall unsafe hs_uv_accept_check_init :: Ptr UVHandle -- ^ uv_check_t+                                                    -> Ptr UVHandle -- ^ uv_stream_t+                                                    -> IO CInt+foreign import ccall unsafe hs_uv_accept_check_start :: Ptr UVHandle -> IO CInt foreign import ccall unsafe hs_uv_accept_check_close :: Ptr UVHandle -> IO ()  --------------------------------------------------------------------------------@@ -711,9 +715,7 @@ -- | Spawn the child process in a detached state  -- -- This will make it a process group leader, and will effectively enable the child to keep running after--- the parent exits. Note that the child process will still keep the--- parent's event loop alive unless the parent process calls uv_unref() on--- the child's process handle.+-- the parent exits. pattern PROCESS_DETACHED :: ProcessFlag pattern PROCESS_DETACHED = (#const UV_PROCESS_DETACHED) -- | Hide the subprocess window that would normally be created.
cbits/hs_uv_stream.c view
@@ -351,17 +351,19 @@  // It's hard to arrange accepting notification without check handler, we can't // do it in listen's callback, since it'll be called multiple times during uv_run.-uv_check_t* hs_uv_accept_check_alloc(uv_stream_t* server){+uv_check_t* hs_uv_accept_check_alloc(){     uv_check_t* check = malloc(sizeof(uv_check_t));     if (check == NULL) return NULL;-    check->data = (void*)server;    // we link server to check's data field     return check; } -int hs_uv_accept_check_init(uv_check_t* check){-    uv_stream_t* server = check->data;+int hs_uv_accept_check_init(uv_check_t* check, uv_stream_t* server){     int r = uv_check_init(server->loop, check);-    if (r < 0) return r;+    check->data = (void*)server;    // we link server to check's data field+    return r;+}++int hs_uv_accept_check_start(uv_check_t* check){     return uv_check_start(check, hs_accept_check_cb); } 
include/hs_uv.h view
@@ -258,8 +258,9 @@ void hs_uv_listen_resume(uv_stream_t* server); int hs_uv_read_start(uv_stream_t* handle); HsInt hs_uv_write(uv_stream_t* handle, char* buf, HsInt buf_size);-uv_check_t* hs_uv_accept_check_alloc(uv_stream_t* server);-int hs_uv_accept_check_init(uv_check_t* check);+uv_check_t* hs_uv_accept_check_alloc();+int hs_uv_accept_check_init(uv_check_t* check, uv_stream_t* server);+int hs_uv_accept_check_start(uv_check_t* check); void hs_uv_accept_check_close(uv_check_t* check);  ////////////////////////////////////////////////////////////////////////////////
test/Z/IO/LowResTimerSpec.hs view
@@ -39,7 +39,7 @@             threadDelay 50000         threadDelay 10000000  -- wait 10s here         c' <- readPrimIORef c-        assertBool "throttled add" (6  <= c' && c' <= 7)+        assertBool "throttled add" (6  <= c' && c' <= 8)    -- on osx time drift too much      it "throttleTrailing" $ do         c <- newCounter 0
third_party/libuv/include/uv.h view
@@ -614,6 +614,12 @@    * must not be freed by the recv_cb callback.    */   UV_UDP_MMSG_CHUNK = 8,+  /*+   * Indicates that the buffer provided has been fully utilized by recvmmsg and+   * that it should now be freed by the recv_cb callback. When this flag is set+   * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL.+   */+  UV_UDP_MMSG_FREE = 16,    /*    * Indicates that recvmmsg should be used, if available.@@ -865,6 +871,7 @@ UV_EXTERN int uv_timer_again(uv_timer_t* handle); UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle);+UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle);   /*
third_party/libuv/include/uv/errno.h view
@@ -317,7 +317,7 @@ #if defined(EPROTO) && !defined(_WIN32) # define UV__EPROTO UV__ERR(EPROTO) #else-# define UV__EPROTO UV__ERR(4046)+# define UV__EPROTO (-4046) #endif  #if defined(EPROTONOSUPPORT) && !defined(_WIN32)
third_party/libuv/include/uv/unix.h view
@@ -69,6 +69,8 @@ # include "uv/posix.h" #elif defined(__HAIKU__) # include "uv/posix.h"+#elif defined(__QNX__)+# include "uv/posix.h" #endif  #ifndef NI_MAXHOST
third_party/libuv/include/uv/version.h view
@@ -31,7 +31,7 @@  */  #define UV_VERSION_MAJOR 1-#define UV_VERSION_MINOR 39+#define UV_VERSION_MINOR 40 #define UV_VERSION_PATCH 1 #define UV_VERSION_IS_RELEASE 0 #define UV_VERSION_SUFFIX "dev"
third_party/libuv/src/random.c view
@@ -33,7 +33,7 @@  #if defined(__PASE__)   rc = uv__random_readpath("/dev/urandom", buf, buflen);-#elif defined(_AIX)+#elif defined(_AIX) || defined(__QNX__)   rc = uv__random_readpath("/dev/random", buf, buflen); #elif defined(__APPLE__) || defined(__OpenBSD__) || \      (defined(__ANDROID_API__) && __ANDROID_API__ >= 28)
third_party/libuv/src/timer.c view
@@ -130,6 +130,14 @@ }  +uint64_t uv_timer_get_due_in(const uv_timer_t* handle) {+  if (handle->loop->time >= handle->timeout)+    return 0;++  return handle->timeout - handle->loop->time;+}++ int uv__next_timeout(const uv_loop_t* loop) {   const struct heap_node* heap_node;   const uv_timer_t* handle;
third_party/libuv/src/unix/bsd-ifaddrs.c view
@@ -113,7 +113,9 @@       address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr);     } -    if (ent->ifa_netmask->sa_family == AF_INET6) {+    if (ent->ifa_netmask == NULL) {+      memset(&address->netmask, 0, sizeof(address->netmask));+    } else if (ent->ifa_netmask->sa_family == AF_INET6) {       address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask);     } else {       address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);
third_party/libuv/src/unix/fs.c view
@@ -79,7 +79,11 @@     defined(__NetBSD__) # include <sys/param.h> # include <sys/mount.h>-#elif defined(__sun) || defined(__MVS__) || defined(__NetBSD__) || defined(__HAIKU__)+#elif defined(__sun)      || \+      defined(__MVS__)    || \+      defined(__NetBSD__) || \+      defined(__HAIKU__)  || \+      defined(__QNX__) # include <sys/statvfs.h> #else # include <sys/statfs.h>@@ -629,7 +633,11 @@  static int uv__fs_statfs(uv_fs_t* req) {   uv_statfs_t* stat_fs;-#if defined(__sun) || defined(__MVS__) || defined(__NetBSD__) || defined(__HAIKU__)+#if defined(__sun)      || \+    defined(__MVS__)    || \+    defined(__NetBSD__) || \+    defined(__HAIKU__)  || \+    defined(__QNX__)   struct statvfs buf;    if (0 != statvfs(req->path, &buf))@@ -646,7 +654,12 @@     return -1;   } -#if defined(__sun) || defined(__MVS__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__)+#if defined(__sun)        || \+    defined(__MVS__)      || \+    defined(__OpenBSD__)  || \+    defined(__NetBSD__)   || \+    defined(__HAIKU__)    || \+    defined(__QNX__)   stat_fs->f_type = 0;  /* f_type is not supported. */ #else   stat_fs->f_type = buf.f_type;
third_party/libuv/src/unix/internal.h view
@@ -334,15 +334,8 @@   unsigned int msg_len; }; -int uv__recvmmsg(int fd,-                 struct uv__mmsghdr* mmsg,-                 unsigned int vlen,-                 unsigned int flags,-                 struct timespec* timeout);-int uv__sendmmsg(int fd,-                 struct uv__mmsghdr* mmsg,-                 unsigned int vlen,-                 unsigned int flags);+int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen);+int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen); #else #define HAVE_MMSG 0 #endif
third_party/libuv/src/unix/linux-core.c view
@@ -281,6 +281,7 @@     timeout = 0;   } else {     reset_timeout = 0;+    user_timeout = 0;   }    /* You could argue there is a dependency between these two but
third_party/libuv/src/unix/linux-syscalls.c view
@@ -37,8 +37,6 @@ #ifndef __NR_recvmmsg # if defined(__x86_64__) #  define __NR_recvmmsg 299-# elif defined(__i386__)-#  define __NR_recvmmsg 337 # elif defined(__arm__) #  define __NR_recvmmsg (UV_SYSCALL_BASE + 365) # endif@@ -47,8 +45,6 @@ #ifndef __NR_sendmmsg # if defined(__x86_64__) #  define __NR_sendmmsg 307-# elif defined(__i386__)-#  define __NR_sendmmsg 345 # elif defined(__arm__) #  define __NR_sendmmsg (UV_SYSCALL_BASE + 374) # endif@@ -146,25 +142,51 @@  struct uv__mmsghdr; -int uv__sendmmsg(int fd,-                 struct uv__mmsghdr* mmsg,-                 unsigned int vlen,-                 unsigned int flags) {-#if defined(__NR_sendmmsg)-  return syscall(__NR_sendmmsg, fd, mmsg, vlen, flags);+int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) {+#if defined(__i386__)+  unsigned long args[4];+  int rc;++  args[0] = (unsigned long) fd;+  args[1] = (unsigned long) mmsg;+  args[2] = (unsigned long) vlen;+  args[3] = /* flags */ 0;++  /* socketcall() raises EINVAL when SYS_SENDMMSG is not supported. */+  rc = syscall(/* __NR_socketcall */ 102, 20 /* SYS_SENDMMSG */, args);+  if (rc == -1)+    if (errno == EINVAL)+      errno = ENOSYS;++  return rc;+#elif defined(__NR_sendmmsg)+  return syscall(__NR_sendmmsg, fd, mmsg, vlen, /* flags */ 0); #else   return errno = ENOSYS, -1; #endif }  -int uv__recvmmsg(int fd,-                 struct uv__mmsghdr* mmsg,-                 unsigned int vlen,-                 unsigned int flags,-                 struct timespec* timeout) {-#if defined(__NR_recvmmsg)-  return syscall(__NR_recvmmsg, fd, mmsg, vlen, flags, timeout);+int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) {+#if defined(__i386__)+  unsigned long args[5];+  int rc;++  args[0] = (unsigned long) fd;+  args[1] = (unsigned long) mmsg;+  args[2] = (unsigned long) vlen;+  args[3] = /* flags */ 0;+  args[4] = /* timeout */ 0;++  /* socketcall() raises EINVAL when SYS_RECVMMSG is not supported. */+  rc = syscall(/* __NR_socketcall */ 102, 19 /* SYS_RECVMMSG */, args);+  if (rc == -1)+    if (errno == EINVAL)+      errno = ENOSYS;++  return rc;+#elif defined(__NR_recvmmsg)+  return syscall(__NR_recvmmsg, fd, mmsg, vlen, /* flags */ 0, /* timeout */ 0); #else   return errno = ENOSYS, -1; #endif
third_party/libuv/src/unix/udp.c view
@@ -73,12 +73,12 @@   s = uv__socket(AF_INET, SOCK_DGRAM, 0);   if (s < 0)     return;-  ret = uv__sendmmsg(s, NULL, 0, 0);+  ret = uv__sendmmsg(s, NULL, 0);   if (ret == 0 || errno != ENOSYS) {     uv__sendmmsg_avail = 1;     uv__recvmmsg_avail = 1;   } else {-    ret = uv__recvmmsg(s, NULL, 0, 0, NULL);+    ret = uv__recvmmsg(s, NULL, 0);     if (ret == 0 || errno != ENOSYS)       uv__recvmmsg_avail = 1;   }@@ -213,7 +213,7 @@   }    do-    nread = uv__recvmmsg(handle->io_watcher.fd, msgs, chunks, 0, NULL);+    nread = uv__recvmmsg(handle->io_watcher.fd, msgs, chunks);   while (nread == -1 && errno == EINTR);    if (nread < 1) {@@ -238,7 +238,7 @@      /* one last callback so the original buffer is freed */     if (handle->recv_cb != NULL)-      handle->recv_cb(handle, 0, buf, NULL, 0);+      handle->recv_cb(handle, 0, buf, NULL, UV_UDP_MMSG_FREE);   }   return nread; }@@ -356,7 +356,7 @@   }    do-    npkts = uv__sendmmsg(handle->io_watcher.fd, h, pkts, 0);+    npkts = uv__sendmmsg(handle->io_watcher.fd, h, pkts);   while (npkts == -1 && errno == EINTR);    if (npkts < 1) {@@ -851,7 +851,11 @@ }  -#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__ANDROID__)+#if !defined(__OpenBSD__) &&                                        \+    !defined(__NetBSD__) &&                                         \+    !defined(__ANDROID__) &&                                        \+    !defined(__DragonFly__) &                                       \+    !defined(__QNX__) static int uv__udp_set_source_membership4(uv_udp_t* handle,                                           const struct sockaddr_in* multicast_addr,                                           const char* interface_addr,@@ -1039,7 +1043,11 @@                                  const char* interface_addr,                                  const char* source_addr,                                  uv_membership membership) {-#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__ANDROID__)+#if !defined(__OpenBSD__) &&                                        \+    !defined(__NetBSD__) &&                                         \+    !defined(__ANDROID__) &&                                        \+    !defined(__DragonFly__) &&                                      \+    !defined(__QNX__)   int err;   union uv__sockaddr mcast_addr;   union uv__sockaddr src_addr;@@ -1146,7 +1154,7 @@  * and use the general uv__setsockopt_maybe_char call on other platforms.  */ #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \-    defined(__MVS__)+    defined(__MVS__) || defined(__QNX__)    return uv__setsockopt(handle,                         IP_TTL,@@ -1155,7 +1163,7 @@                         sizeof(ttl));  #else /* !(defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||-           defined(__MVS__)) */+           defined(__MVS__) || defined(__QNX__)) */    return uv__setsockopt_maybe_char(handle,                                    IP_TTL,@@ -1163,7 +1171,7 @@                                    ttl);  #endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||-          defined(__MVS__) */+          defined(__MVS__) || defined(__QNX__) */ }  @@ -1175,7 +1183,7 @@  * and use the general uv__setsockopt_maybe_char call otherwise.  */ #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \-    defined(__MVS__)+    defined(__MVS__) || defined(__QNX__)   if (handle->flags & UV_HANDLE_IPV6)     return uv__setsockopt(handle,                           IP_MULTICAST_TTL,@@ -1183,7 +1191,7 @@                           &ttl,                           sizeof(ttl)); #endif /* defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \-    defined(__MVS__) */+    defined(__MVS__) || defined(__QNX__) */    return uv__setsockopt_maybe_char(handle,                                    IP_MULTICAST_TTL,@@ -1200,7 +1208,7 @@  * and use the general uv__setsockopt_maybe_char call otherwise.  */ #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \-    defined(__MVS__)+    defined(__MVS__) || defined(__QNX__)   if (handle->flags & UV_HANDLE_IPV6)     return uv__setsockopt(handle,                           IP_MULTICAST_LOOP,@@ -1208,7 +1216,7 @@                           &on,                           sizeof(on)); #endif /* defined(__sun) || defined(_AIX) ||defined(__OpenBSD__) ||-    defined(__MVS__) */+    defined(__MVS__) || defined(__QNX__) */    return uv__setsockopt_maybe_char(handle,                                    IP_MULTICAST_LOOP,
third_party/libuv/src/win/tty.c view
@@ -2122,13 +2122,6 @@         abort();       } -      /* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the windows-       * console doesn't really support UTF-16, so just emit the replacement-       * character. */-      if (utf8_codepoint > 0xffff) {-        utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER;-      }-       if (utf8_codepoint == 0x0a || utf8_codepoint == 0x0d) {         /* EOL conversion - emit \r\n when we see \n. */ @@ -2154,6 +2147,12 @@         /* Encode character into utf-16 buffer. */         ENSURE_BUFFER_SPACE(1);         utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint;+        previous_eol = 0;+      } else {+        ENSURE_BUFFER_SPACE(2);+        utf8_codepoint -= 0x10000;+        utf16_buf[utf16_buf_used++] = (WCHAR) (utf8_codepoint / 0x400 + 0xD800);+        utf16_buf[utf16_buf_used++] = (WCHAR) (utf8_codepoint % 0x400 + 0xDC00);         previous_eol = 0;       }     }
third_party/libuv/src/win/udp.c view
@@ -1073,7 +1073,7 @@    err = connect(handle->socket, addr, addrlen);   if (err)-    return uv_translate_sys_error(err);+    return uv_translate_sys_error(WSAGetLastError());    handle->flags |= UV_HANDLE_UDP_CONNECTED; @@ -1089,7 +1089,7 @@      err = connect(handle->socket, &addr, sizeof(addr));     if (err)-      return uv_translate_sys_error(err);+      return uv_translate_sys_error(WSAGetLastError());      handle->flags &= ~UV_HANDLE_UDP_CONNECTED;     return 0;