packages feed

gore-and-ash-network 1.1.0.1 → 1.2.0.0

raw patch · 22 files changed

+45/−1989 lines, 22 files

Files

− bin/mkDerivedGmpConstants.c
@@ -1,73 +0,0 @@-/* --------------------------------------------------------------------------- *- * (c) The GHC Team, 1992-2004- *- * mkDerivedConstants.c- *- * Basically this is a C program that extracts information from the C- * declarations in the header files (primarily struct field offsets)- * and generates a header file that can be #included into non-C source- * containing this information.- *- * ------------------------------------------------------------------------*/--#include <stdio.h>-#include <gmp.h>---#define str(a,b) #a "_" #b--#define OFFSET(s_type, field) ((size_t)&(((s_type*)0)->field))--/* struct_size(TYPE)- *- */-#define def_size(str, size) \-    printf("#define SIZEOF_" str " %lu\n", (unsigned long)size);--#define struct_size(s_type) \-    def_size(#s_type, sizeof(s_type));----/* struct_field(TYPE, FIELD)- *- */-#define def_offset(str, offset) \-    printf("#define OFFSET_" str " %d\n", (int)(offset));--#define field_offset_(str, s_type, field) \-    def_offset(str, OFFSET(s_type,field));--#define field_offset(s_type, field) \-    field_offset_(str(s_type,field),s_type,field);--#define field_type_(str, s_type, field) \-    printf("#define REP_" str " b"); \-    printf("%lu\n", (unsigned long)sizeof (__typeof__(((((s_type*)0)->field)))) * 8);--#define field_type(s_type, field) \-    field_type_(str(s_type,field),s_type,field);--/* An access macro for use in C-- sources. */-#define struct_field_macro(str) \-    printf("#define " str "(__ptr__)  REP_" str "[__ptr__+OFFSET_" str "]\n");--/* Outputs the byte offset and MachRep for a field */-#define struct_field(s_type, field)		\-    field_offset(s_type, field);		\-    field_type(s_type, field);			\-    struct_field_macro(str(s_type,field))---int main(void)-{-    printf("/* This file is created automatically.  Do not edit by hand.*/\n\n");--    struct_size(MP_INT);-    struct_field(MP_INT,_mp_alloc);-    struct_field(MP_INT,_mp_size);-    struct_field(MP_INT,_mp_d);--    return 0;-}
− bitset/Data/BitSet.hs
@@ -1,16 +0,0 @@--------------------------------------------------------------------------------- |--- Module      :  Data.BitSet.Dynamic--- Copyright   :  (c) Sergei Lebedev, Aleksey Kladov, Fedor Gogolev 2013---                Based on Data.BitSet (c) Denis Bueno 2008-2009--- License     :  MIT--- Maintainer  :  superbobry@gmail.com--- Stability   :  experimental--- Portability :  GHC------ A space-efficient implementation of set data structure for enumerated--- data types.--module Data.BitSet ( module Data.BitSet.Dynamic ) where--import Data.BitSet.Dynamic
− bitset/Data/BitSet/Dynamic.hs
@@ -1,240 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE MagicHash #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}---------------------------------------------------------------------------------- |--- Module      :  Data.BitSet.Dynamic--- Copyright   :  (c) Sergei Lebedev, Aleksey Kladov, Fedor Gogolev 2013---                Based on Data.BitSet (c) Denis Bueno 2008-2009--- License     :  MIT--- Maintainer  :  superbobry@gmail.com--- Stability   :  experimental--- Portability :  GHC------ A space-efficient implementation of set data structure for enumerated--- data types.------ /Note/: Read below the synopsis for important notes on the use of--- this module.------ This module is intended to be imported @qualified@, to avoid name--- clashes with "Prelude" functions, e.g.------ > import Data.BitSet.Dynamic (BitSet)--- > import qualified Data.BitSet.Dynamic as BS------ The implementation uses 'Integer' as underlying container, thus it--- grows automatically when more elements are inserted into the bit set.--module Data.BitSet.Dynamic-    (-    -- * Bit set type-      FasterInteger(FasterInteger)-    , BitSet--    -- * Operators-    , (\\)--    -- * Construction-    , empty-    , singleton-    , insert-    , delete--    -- * Query-    , null-    , size-    , member-    , notMember-    , isSubsetOf-    , isProperSubsetOf--    -- * Combine-    , union-    , difference-    , intersection--    -- * Transformations-    , map--    -- * Folds-    , foldl'-    , foldr--    -- * Filter-    , filter--    -- * Lists-    , toList-    , fromList-    ) where--import Prelude hiding (null, map, filter, foldr)--import Data.Bits (Bits(..))-import GHC.Base (Int(..))-import Data.Maybe (fromJust)--import Control.DeepSeq (NFData(..))--import GHC.Integer.GMP.TypeExt (popCountInteger, testBitInteger,-                                setBitInteger, clearBitInteger)-import qualified Data.BitSet.Generic as GS---- | A wrapper around 'Integer' which provides faster bit-level operations.-newtype FasterInteger = FasterInteger { unFI :: Integer }-    deriving (Read, Show, Eq, Ord, Enum, Integral, Num, Real, NFData)--instance Bits FasterInteger where-    FasterInteger x .&. FasterInteger y = FasterInteger $ x .&. y-    {-# INLINE (.&.) #-}--    FasterInteger x .|. FasterInteger y = FasterInteger $ x .|. y-    {-# INLINE (.|.) #-}--    FasterInteger x `xor` FasterInteger y = FasterInteger $ x `xor` y-    {-# INLINE xor #-}--    complement = FasterInteger . complement . unFI-    {-# INLINE complement #-}--    shift (FasterInteger x) = FasterInteger . shift x-    {-# INLINE shift #-}--    rotate (FasterInteger x) = FasterInteger . rotate x-    {-# INLINE rotate #-}--    bit = FasterInteger . bit-    {-# INLINE bit #-}--    testBit (FasterInteger x) (I# i) = testBitInteger x i-    {-# SPECIALIZE INLINE testBit :: FasterInteger -> Int -> Bool #-}--    setBit (FasterInteger x) (I# i) = FasterInteger $ setBitInteger x i-    {-# SPECIALIZE INLINE setBit :: FasterInteger -> Int -> FasterInteger #-}--    clearBit (FasterInteger x) (I# i) = FasterInteger $ clearBitInteger x i-    {-# SPECIALIZE INLINE clearBit :: FasterInteger -> Int -> FasterInteger #-}--    popCount (FasterInteger x) = I# (popCountInteger x)-    {-# SPECIALIZE INLINE popCount :: FasterInteger -> Int #-}--    isSigned = isSigned . unFI-    {-# INLINE isSigned #-}--    bitSize = fromJust . bitSizeMaybe . unFI-    {-# INLINE bitSize #-}--#if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ >= 707)-    bitSizeMaybe = bitSizeMaybe . unFI-    {-# INLINE bitSizeMaybe #-}-#endif--type BitSet = GS.BitSet FasterInteger---- | /O(1)/. Is the bit set empty?-null :: BitSet a -> Bool-null = GS.null-{-# INLINE null #-}---- | /O(1)/. The number of elements in the bit set.-size :: BitSet a -> Int-size = GS.size-{-# INLINE size #-}---- | /O(1)/. Ask whether the item is in the bit set.-member :: Enum a => a -> BitSet a -> Bool-member = GS.member-{-# INLINE member #-}---- | /O(1)/. Ask whether the item is in the bit set.-notMember :: Enum a => a -> BitSet a -> Bool-notMember = GS.notMember-{-# INLINE notMember #-}---- | /O(max(n, m))/. Is this a subset? (@s1 isSubsetOf s2@) tells whether--- @s1@ is a subset of @s2@.-isSubsetOf :: BitSet a -> BitSet a -> Bool-isSubsetOf = GS.isSubsetOf-{-# INLINE isSubsetOf #-}---- | /O(max(n, m)/. Is this a proper subset? (ie. a subset but not equal).-isProperSubsetOf :: BitSet a -> BitSet a -> Bool-isProperSubsetOf = GS.isProperSubsetOf-{-# INLINE isProperSubsetOf #-}---- | The empty bit set.-empty :: Enum a => BitSet a-empty = GS.empty-{-# INLINE empty #-}---- | O(1). Create a singleton set.-singleton :: Enum a => a -> BitSet a-singleton = GS.singleton-{-# INLINE singleton #-}---- | /O(1)/. Insert an item into the bit set.-insert :: Enum a => a -> BitSet a -> BitSet a-insert = GS.insert-{-# INLINE insert #-}---- | /O(1)/. Delete an item from the bit set.-delete :: Enum a => a -> BitSet a -> BitSet a-delete = GS.delete-{-# INLINE delete #-}---- | /O(max(m, n))/. The union of two bit sets.-union :: BitSet a -> BitSet a -> BitSet a-union = GS.union-{-# INLINE union #-}---- | /O(1)/. Difference of two bit sets.-difference :: BitSet a -> BitSet a -> BitSet a-difference = GS.difference-{-# INLINE difference #-}---- | /O(1)/. See `difference'.-(\\) :: BitSet a -> BitSet a -> BitSet a-(\\) = difference---- | /O(1)/. The intersection of two bit sets.-intersection :: BitSet a -> BitSet a -> BitSet a-intersection = GS.intersection-{-# INLINE intersection #-}---- | /O(n)/ Transform this bit set by applying a function to every value.--- Resulting bit set may be smaller then the original.-map :: (Enum a, Enum b) => (a -> b) -> BitSet a -> BitSet b-map = GS.map-{-# INLINE map #-}---- | /O(n)/ Reduce this bit set by applying a binary function to all--- elements, using the given starting value.  Each application of the--- operator is evaluated before before using the result in the next--- application.  This function is strict in the starting value.-foldl' :: Enum a => (b -> a -> b) -> b -> BitSet a -> b-foldl' = GS.foldl'-{-# INLINE foldl' #-}---- | /O(n)/ Reduce this bit set by applying a binary function to all--- elements, using the given starting value.-foldr :: Enum a => (a -> b -> b) -> b -> BitSet a -> b-foldr = GS.foldr-{-# INLINE foldr #-}---- | /O(n)/ Filter this bit set by retaining only elements satisfying a--- predicate.-filter :: Enum a => (a -> Bool) -> BitSet a -> BitSet a-filter = GS.filter-{-# INLINE filter #-}---- | /O(n)/. Convert the bit set set to a list of elements.-toList :: Enum a => BitSet a -> [a]-toList = GS.toList-{-# INLINE toList #-}---- | /O(n)/. Make a bit set from a list of elements.-fromList :: Enum a => [a] -> BitSet a-fromList = GS.fromList-{-# INLINE fromList #-}
− bitset/Data/BitSet/Generic.hs
@@ -1,230 +0,0 @@--------------------------------------------------------------------------------- |--- Module      :  Data.BitSet.Generic--- Copyright   :  (c) Sergei Lebedev, Aleksey Kladov, Fedor Gogolev 2013---                Based on Data.BitSet (c) Denis Bueno 2008-2009--- License     :  MIT--- Maintainer  :  superbobry@gmail.com--- Stability   :  experimental--- Portability :  GHC------ A space-efficient implementation of set data structure for enumerated--- data types.------ /Note/: Read below the synopsis for important notes on the use of--- this module.------ This module is intended to be imported @qualified@, to avoid name--- clashes with "Prelude" functions, e.g.------ > import Data.BitSet.Generic (BitSet)--- > import qualified Data.BitSet.Generic as BS------ The implementation is abstract with respect to container type, so any--- numeric type with 'Bits' instance can be used as a container. However,--- independent of container choice, the maximum number of elements in a--- bit set is bounded by @maxBound :: Int@.--{-# LANGUAGE CPP #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE BangPatterns #-}-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}--module Data.BitSet.Generic-    (-    -- * Bit set type-      BitSet(..)--    -- * Operators-    , (\\)--    -- * Construction-    , empty-    , singleton-    , insert-    , delete--    -- * Query-    , null-    , size-    , member-    , notMember-    , isSubsetOf-    , isProperSubsetOf--    -- * Combine-    , union-    , difference-    , intersection--    -- * Transformations-    , map--    -- * Folds-    , foldl'-    , foldr--    -- * Filter-    , filter--    -- * Lists-    , toList-    , fromList-    ) where--import Prelude hiding (null, map, filter, foldr)--import Control.DeepSeq (NFData(..))-import Data.Bits (Bits, (.|.), (.&.), complement, bit,-                  testBit, setBit, clearBit, popCount)-import Data.Data (Typeable)-import Foreign (Storable)-import GHC.Exts (build)-#if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ >= 707)-import GHC.Exts (IsList)-import qualified GHC.Exts as Exts-#endif-import Text.Read (Read(..), Lexeme(..), lexP, prec, parens)-import qualified Data.List as List---- | A bit set with unspecified container type.-newtype BitSet c a = BitSet { getBits :: c }-   deriving (Eq, NFData, Storable, Ord, Typeable)--instance (Enum a, Read a, Bits c, Num c) => Read (BitSet c a) where-    readPrec = parens . prec 10 $ do-        Ident "fromList" <- lexP-        fromList <$> readPrec--instance (Enum a, Show a, Bits c,  Num c) => Show (BitSet c a) where-    showsPrec p bs = showParen (p > 10) $-                     showString "fromList " . shows (toList bs)--instance (Enum a, Bits c, Num c) => Monoid (BitSet c a) where-    mempty  = empty-    mappend = union--#if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ >= 707)-instance (Enum a, Bits c, Num c) => IsList (BitSet c a) where-    type Item (BitSet c a) = a-    fromList = fromList-    toList = toList-#endif---- | /O(1)/. Is the bit set empty?-null :: (Eq c, Num c) => BitSet c a -> Bool-null = (== 0) . getBits-{-# INLINE null #-}---- | /O(1)/. The number of elements in the bit set.-size :: Bits c => BitSet c a -> Int-size = popCount . getBits-{-# INLINE size #-}---- | /O(d)/. Ask whether the item is in the bit set.-member :: (Enum a , Bits c) => a -> BitSet c a -> Bool-member x = (`testBit` fromEnum x) . getBits-{-# INLINE member #-}---- | /O(d)/. Ask whether the item is not in the bit set.-notMember :: (Enum a, Bits c) => a -> BitSet c a -> Bool-notMember x = not . member x-{-# INLINE notMember #-}---- | /O(max(n, m))/. Is this a subset? (@s1 `isSubsetOf` s2@) tells whether--- @s1@ is a subset of @s2@.-isSubsetOf :: (Bits c, Eq c) => BitSet c a -> BitSet c a -> Bool-isSubsetOf (BitSet bits1) (BitSet bits2) = bits2 .|. bits1 == bits2-{-# INLINE isSubsetOf #-}---- | /O(max(n, m)/. Is this a proper subset? (ie. a subset but not equal).-isProperSubsetOf :: (Bits c, Eq c) => BitSet c a -> BitSet c a -> Bool-isProperSubsetOf bs1 bs2 = bs1 `isSubsetOf` bs2 && bs1 /= bs2-{-# INLINE isProperSubsetOf #-}---- | The empty bit set.-empty :: (Enum a, Bits c, Num c) => BitSet c a-empty = BitSet 0-{-# INLINE empty #-}---- | O(1). Create a singleton set.-singleton :: (Enum a, Bits c, Num c) => a -> BitSet c a-singleton = BitSet . bit . fromEnum-{-# INLINE singleton #-}---- | /O(d)/. Insert an item into the bit set.-insert :: (Enum a, Bits c) => a -> BitSet c a -> BitSet c a-insert x (BitSet bits) = BitSet $ bits `setBit` fromEnum x-{-# INLINE insert #-}---- | /O(d)/. Delete an item from the bit set.-delete :: (Enum a, Bits c) => a -> BitSet c a -> BitSet c a-delete x (BitSet bits ) = BitSet $ bits `clearBit` fromEnum x-{-# INLINE delete #-}---- | /O(max(m, n))/. The union of two bit sets.-union :: Bits c => BitSet c a -> BitSet c a -> BitSet c a-union (BitSet bits1) (BitSet bits2) = BitSet $ bits1 .|. bits2-{-# INLINE union #-}---- | /O(max(m, n))/. Difference of two bit sets.-difference :: Bits c => BitSet c a -> BitSet c a -> BitSet c a-difference (BitSet bits1) (BitSet bits2) = BitSet $ bits1 .&. complement bits2-{-# INLINE difference #-}---- | /O(max(m, n))/. See 'difference'.-(\\) :: Bits c => BitSet c a -> BitSet c a -> BitSet c a-(\\) = difference---- | /O(max(m, n))/. The intersection of two bit sets.-intersection :: Bits c => BitSet c a -> BitSet c a -> BitSet c a-intersection (BitSet bits1) (BitSet bits2) = BitSet $ bits1 .&. bits2-{-# INLINE intersection #-}---- | /O(d * n)/ Transform this bit set by applying a function to every--- value.  Resulting bit set may be smaller then the original.-map :: (Enum a, Enum b, Bits c, Num c) => (a -> b) -> BitSet c a -> BitSet c b-map f = foldl' (\bs -> (`insert` bs) . f) empty-{-# INLINE map #-}---- | /O(d * n)/ Reduce this bit set by applying a binary function to all--- elements, using the given starting value.  Each application of the--- operator is evaluated before before using the result in the next--- application.  This function is strict in the starting value.-foldl' :: (Enum a, Bits c) => (b -> a -> b) -> b -> BitSet c a -> b-foldl' f acc0  (BitSet bits) = go acc0 (popCount bits) 0 where-  go !acc 0 _b = acc-  go !acc !n b = if bits `testBit` b-                 then go (f acc $ toEnum b) (pred n) (succ b)-                 else go acc n (succ b)-{-# INLINE foldl' #-}---- | /O(d * n)/ Reduce this bit set by applying a binary function to--- all elements, using the given starting value.-foldr :: (Enum a, Bits c) => (a -> b -> b) -> b -> BitSet c a -> b-foldr f acc0 (BitSet bits) = go (popCount bits) 0 where-  go 0 _b = acc0-  go !n b = if bits `testBit` b-            then toEnum b `f` go (pred n) (succ b)-            else go n (succ b)-{-# INLINE foldr #-}---- | /O(d * n)/ Filter this bit set by retaining only elements satisfying--- predicate.-filter :: (Enum a, Bits c, Num c) => (a -> Bool) -> BitSet c a -> BitSet c a-filter f = foldl' (\bs x -> if f x then x `insert` bs else bs) empty-{-# INLINE filter #-}---- | /O(d * n)/. Convert this bit set set to a list of elements.-toList :: (Enum a, Bits c, Num c) => BitSet c a -> [a]-toList bs = build (\k z -> foldr k z bs)-{-# INLINE [0] toList #-}---- | /O(d * n)/. Make a bit set from a list of elements.-fromList :: (Enum a, Bits c, Num c) => [a] -> BitSet c a-fromList = BitSet . List.foldl' (\i x -> i `setBit` fromEnum x) 0-{-# INLINE [0] fromList #-}-{-# RULES-"fromList/toList"    forall bs. fromList (toList bs) = bs-  #-}
− bitset/Data/BitSet/Word.hs
@@ -1,181 +0,0 @@--------------------------------------------------------------------------------- |--- Module      :  Data.BitSet.Word--- Copyright   :  (c) Sergei Lebedev, Aleksey Kladov, Fedor Gogolev 2013---                Based on Data.BitSet (c) Denis Bueno 2008-2009--- License     :  MIT--- Maintainer  :  superbobry@gmail.com--- Stability   :  experimental--- Portability :  GHC------ A space-efficient implementation of set data structure for enumerated--- data types.------ /Note/: Read below the synopsis for important notes on the use of--- this module.------ This module is intended to be imported @qualified@, to avoid name--- clashes with "Prelude" functions, e.g.------ > import Data.BitSet.Word (BitSet)--- > import qualified Data.BitSet.Word as BS------ The implementation uses 'Word' as underlying container, thus the--- maximum number of elements you can store in this bit set is bounded--- by the number of bits in 'Word' data type. However, due to native bitwise--- operations "Data.BitSet.Word" is significantly faster then "Data.Set"--- on all operations.--module Data.BitSet.Word-    (-    -- * Bit set type-      BitSet--    -- * Operators-    , (\\)--    -- * Construction-    , empty-    , singleton-    , insert-    , delete--    -- * Query-    , null-    , size-    , member-    , notMember-    , isSubsetOf-    , isProperSubsetOf--    -- * Combine-    , union-    , difference-    , intersection--    -- * Transformations-    , map--    -- * Folds-    , foldl'-    , foldr--    -- * Filter-    , filter--    -- * Lists-    , toList-    , fromList-    ) where--import Prelude hiding (null, map, filter, foldr)--import qualified Data.BitSet.Generic as GS--type BitSet = GS.BitSet Word---- | /O(1)/. Is the bit set empty?-null :: BitSet a -> Bool-null = GS.null-{-# INLINE null #-}---- | /O(1)/. The number of elements in the bit set.-size :: BitSet a -> Int-size = GS.size-{-# INLINE size #-}---- | /O(1)/. Ask whether the item is in the bit set.-member :: Enum a => a -> BitSet a -> Bool-member = GS.member-{-# INLINE member #-}---- | /O(1)/. Ask whether the item is in the bit set.-notMember :: Enum a => a -> BitSet a -> Bool-notMember = GS.notMember-{-# INLINE notMember #-}---- | /O(1)/. Is this a subset? (@s1 isSubsetOf s2@) tells whether--- @s1@ is a subset of @s2@.-isSubsetOf :: BitSet a -> BitSet a -> Bool-isSubsetOf = GS.isSubsetOf-{-# INLINE isSubsetOf #-}---- | /O(1)/. Is this a proper subset? (ie. a subset but not equal).-isProperSubsetOf :: BitSet a -> BitSet a -> Bool-isProperSubsetOf = GS.isProperSubsetOf-{-# INLINE isProperSubsetOf #-}---- | The empty bit set.-empty :: Enum a => BitSet a-empty = GS.empty-{-# INLINE empty #-}---- | O(1). Create a singleton set.-singleton :: Enum a => a -> BitSet a-singleton = GS.singleton-{-# INLINE singleton #-}---- | /O(1)/. Insert an item into the bit set.-insert :: Enum a => a -> BitSet a -> BitSet a-insert = GS.insert-{-# INLINE insert #-}---- | /O(1)/. Delete an item from the bit set.-delete :: Enum a => a -> BitSet a -> BitSet a-delete = GS.delete-{-# INLINE delete #-}---- | /O(1)/. The union of two bit sets.-union :: BitSet a -> BitSet a -> BitSet a-union = GS.union-{-# INLINE union #-}---- | /O(1)/. Difference of two bit sets.-difference :: BitSet a -> BitSet a -> BitSet a-difference = GS.difference-{-# INLINE difference #-}---- | /O(1)/. See `difference'.-(\\) :: BitSet a -> BitSet a -> BitSet a-(\\) = difference---- | /O(1)/. The intersection of two bit sets.-intersection :: BitSet a -> BitSet a -> BitSet a-intersection = GS.intersection-{-# INLINE intersection #-}---- | /O(n)/ Transform this bit set by applying a function to every value.--- Resulting bit set may be smaller then the original.-map :: (Enum a, Enum b) => (a -> b) -> BitSet a -> BitSet b-map = GS.map-{-# INLINE map #-}---- | /O(n)/ Reduce this bit set by applying a binary function to all--- elements, using the given starting value.  Each application of the--- operator is evaluated before before using the result in the next--- application.  This function is strict in the starting value.-foldl' :: Enum a => (b -> a -> b) -> b -> BitSet a -> b-foldl' = GS.foldl'-{-# INLINE foldl' #-}---- | /O(n)/ Reduce this bit set by applying a binary function to all--- elements, using the given starting value.-foldr :: Enum a => (a -> b -> b) -> b -> BitSet a -> b-foldr = GS.foldr-{-# INLINE foldr #-}---- | /O(n)/ Filter this bit set by retaining only elements satisfying a--- predicate.-filter :: Enum a => (a -> Bool) -> BitSet a -> BitSet a-filter = GS.filter-{-# INLINE filter #-}---- | /O(n)/. Convert the bit set set to a list of elements.-toList :: Enum a => BitSet a -> [a]-toList = GS.toList-{-# INLINE toList #-}---- | /O(n)/. Make a bit set from a list of elements.-fromList :: Enum a => [a] -> BitSet a-fromList = GS.fromList-{-# INLINE fromList #-}
− bitset/GHC/Integer/GMP/PrimExt.hs
@@ -1,26 +0,0 @@-{-# LANGUAGE ForeignFunctionInterface #-}-{-# LANGUAGE GHCForeignImportPrim #-}-{-# LANGUAGE MagicHash #-}-{-# LANGUAGE UnliftedFFITypes #-}-{-# LANGUAGE UnboxedTuples #-}--module GHC.Integer.GMP.PrimExt-    ( popCountInteger#-    , testBitInteger#-    , setBitInteger#-    , clearBitInteger#-    ) where--import GHC.Prim (Int#, ByteArray#)--foreign import prim "integer_cmm_popCountIntegerzh" popCountInteger#-  :: Int# -> ByteArray# -> Int#--foreign import prim "integer_cmm_testBitIntegerzh" testBitInteger#-  :: Int# -> ByteArray# -> Int# -> Int#--foreign import prim "integer_cmm_setBitIntegerzh" setBitInteger#-  :: Int# -> ByteArray# -> Int# -> (# Int#, ByteArray# #)--foreign import prim "integer_cmm_clearBitIntegerzh" clearBitInteger#-  :: Int# -> ByteArray# -> Int# -> (# Int#, ByteArray# #)
− bitset/GHC/Integer/GMP/TypeExt.hs
@@ -1,24 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE MagicHash #-}-{-# LANGUAGE UnboxedTuples #-}-{-# LANGUAGE BangPatterns #-}--module GHC.Integer.GMP.TypeExt-    ( popCountInteger-    , testBitInteger-    , setBitInteger-    , clearBitInteger-    ) where--#include "MachDeps.h"--import GHC.Integer.GMP.Internals (popCountInteger, bitInteger)-import GHC.Prim (Int#)--import GHC.Integer (testBitInteger, orInteger, complementInteger, andInteger)--setBitInteger :: Integer -> Int# -> Integer-setBitInteger j i = bitInteger i `orInteger` j--clearBitInteger :: Integer -> Int# -> Integer-clearBitInteger j i = complementInteger (bitInteger i) `andInteger` j
− cbits/gmp-extras.cmm
@@ -1,149 +0,0 @@-#include "Cmm.h"-#include "GmpDerivedConstants.h"--// TODO(superbobry): in the future release the syntax for calling-// foreign funcations will CHANGE.--import "integer-gmp" __gmpz_init_set;-import "integer-gmp" __gmpz_popcount;-import "integer-gmp" __gmpz_setbit;-import "integer-gmp" __gmpz_clrbit;--#if __GLASGOW_HASKELL__ >= 707--#define GMP_TAKE1_UL1_RET1(name,mp_fun)                         \-name (W_ ws1, P_ d1, W_ wul)                                    \-{                                                               \-  CInt s1;                                                      \-  CLong ul;                                                     \-  W_ mp_tmp;                                                    \-  W_ mp_result;                                                 \-                                                                \-  /* call doYouWantToGC() */                                    \-again:                                                          \-  STK_CHK_GEN_N (2 * SIZEOF_MP_INT);                            \-  MAYBE_GC(again);                                              \-                                                                \-  s1 = W_TO_INT(ws1);                                           \-  ul = W_TO_LONG(wul);                                          \-                                                                \-  mp_tmp     = Sp - 1 * SIZEOF_MP_INT;                          \-  mp_result  = Sp - 2 * SIZEOF_MP_INT;                          \-  MP_INT__mp_alloc(mp_tmp) = W_TO_INT(BYTE_ARR_WDS(d1));        \-  MP_INT__mp_size(mp_tmp)  = (s1);                              \-  MP_INT__mp_d(mp_tmp)     = BYTE_ARR_CTS(d1);                  \-                                                                \-  ccall __gmpz_init_set(mp_result "ptr", mp_tmp "ptr");         \-                                                                \-  /* Perform the operation */                                   \-  ccall mp_fun(mp_result "ptr", ul);                            \-                                                                \-  return(TO_W_(MP_INT__mp_size(mp_result)),                     \-         MP_INT__mp_d(mp_result) - SIZEOF_StgArrWords);         \-}--GMP_TAKE1_UL1_RET1(integer_cmm_setBitIntegerzh,   __gmpz_setbit)-GMP_TAKE1_UL1_RET1(integer_cmm_clearBitIntegerzh, __gmpz_clrbit)--integer_cmm_popCountIntegerzh (W_ ws, W_ d)-{-  CInt s, res;-  W_ mp_tmp;--again:-  STK_CHK_P_LL(SIZEOF_MP_INT, integer_cmm_popCountIntegerzh, R2);-  MAYBE_GC(again);--  s = W_TO_INT(ws);--  mp_tmp = Sp - 1 * SIZEOF_MP_INT;-  MP_INT__mp_alloc(mp_tmp) = W_TO_INT(BYTE_ARR_WDS(d));-  MP_INT__mp_size(mp_tmp)  = (s);-  MP_INT__mp_d(mp_tmp)     = BYTE_ARR_CTS(d);--  (res) = foreign "C" __gmpz_popcount(mp_tmp "ptr");--  return (TO_W_(res));-}-#else--#define GMP_TAKE1_UL1_RET1(name,mp_fun)                         \-name                                                            \-{                                                               \-  CInt s;                                                       \-  W_ d;                                                         \-  CLong ul;                                                     \-  W_ mp_tmp;                                                    \-  W_ mp_result;                                                 \-                                                                \-  STK_CHK_GEN(2 * SIZEOF_MP_INT, R2, name);                     \-  MAYBE_GC(R2_PTR, name);                                       \-                                                                \-  s = W_TO_INT(R1);                                             \-  d = R2;                                                       \-  ul = R3;                                                      \-                                                                \-  mp_tmp    = Sp - 1 * SIZEOF_MP_INT;                           \-  mp_result = Sp - 2 * SIZEOF_MP_INT;                           \-  MP_INT__mp_alloc(mp_tmp) = W_TO_INT(BYTE_ARR_WDS(d));         \-  MP_INT__mp_size(mp_tmp)  = (s);                               \-  MP_INT__mp_d(mp_tmp)     = BYTE_ARR_CTS(d);                   \-                                                                \-  foreign "C" __gmpz_init_set(mp_result "ptr", mp_tmp "ptr") [];\-                                                                \-  /* Perform the operation */                                   \-  foreign "C" mp_fun(mp_result "ptr", ul) [];                   \-                                                                \-  RET_NP(TO_W_(MP_INT__mp_size(mp_result)),                     \-         MP_INT__mp_d(mp_result) - SIZEOF_StgArrWords);         \-}--GMP_TAKE1_UL1_RET1(integer_cmm_setBitIntegerzh,   __gmpz_setbit)-GMP_TAKE1_UL1_RET1(integer_cmm_clearBitIntegerzh, __gmpz_clrbit)--integer_cmm_testBitIntegerzh-{-  CInt s, res;-  CLong ul;-  W_ d;-  W_ mp_tmp;--  STK_CHK_GEN(SIZEOF_MP_INT, R2_PTR, integer_cmm_testBitIntegerzh);-  MAYBE_GC(R2_PTR, integer_cmm_testBitIntegerzh);--  s  = W_TO_INT(R1);-  d  = R2;-  ul = R3;--  mp_tmp = Sp - 1 * SIZEOF_MP_INT;-  MP_INT__mp_alloc(mp_tmp) = W_TO_INT(BYTE_ARR_WDS(d));-  MP_INT__mp_size(mp_tmp)  = (s);-  MP_INT__mp_d(mp_tmp)     = BYTE_ARR_CTS(d);--  (res) = foreign "C" __gmpz_tstbit(mp_tmp "ptr", ul) [];--  RET_N(TO_W_(res));-}--integer_cmm_popCountIntegerzh-{-  CInt s, res;-  W_ d;-  W_ mp_tmp;--  STK_CHK_GEN(SIZEOF_MP_INT, R2_PTR, integer_cmm_popCountIntegerzh);-  MAYBE_GC(R2_PTR, integer_cmm_popCountIntegerzh);--  s = W_TO_INT(R1);-  d = R2;--  mp_tmp = Sp - 1 * SIZEOF_MP_INT;-  MP_INT__mp_alloc(mp_tmp) = W_TO_INT(BYTE_ARR_WDS(d));-  MP_INT__mp_size(mp_tmp)  = (s);-  MP_INT__mp_d(mp_tmp)     = BYTE_ARR_CTS(d);--  (res) = foreign "C" __gmpz_popcount(mp_tmp "ptr") [];--  RET_N(TO_W_(res));-}-#endif
− enet/include/enet/callbacks.h
@@ -1,27 +0,0 @@-/** - @file  callbacks.h- @brief ENet callbacks-*/-#ifndef __ENET_CALLBACKS_H__-#define __ENET_CALLBACKS_H__--#include <stdlib.h>--typedef struct _ENetCallbacks-{-    void * (ENET_CALLBACK * malloc) (size_t size);-    void (ENET_CALLBACK * free) (void * memory);-    void (ENET_CALLBACK * no_memory) (void);-} ENetCallbacks;--/** @defgroup callbacks ENet internal callbacks-    @{-    @ingroup private-*/-extern void * enet_malloc (size_t);-extern void   enet_free (void *);--/** @} */--#endif /* __ENET_CALLBACKS_H__ */-
− enet/include/enet/enet.h
@@ -1,589 +0,0 @@-/** - @file  enet.h- @brief ENet public header file-*/-#ifndef __ENET_ENET_H__-#define __ENET_ENET_H__--#ifdef __cplusplus-extern "C"-{-#endif--#include <stdlib.h>--#ifdef _WIN32-#include "enet/win32.h"-#else-#include "enet/unix.h"-#endif--#include "enet/types.h"-#include "enet/protocol.h"-#include "enet/list.h"-#include "enet/callbacks.h"--#define ENET_VERSION_MAJOR 1-#define ENET_VERSION_MINOR 3-#define ENET_VERSION_PATCH 9-#define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))-#define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)-#define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)-#define ENET_VERSION_GET_PATCH(version) ((version)&0xFF)-#define ENET_VERSION ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH)--typedef enet_uint32 ENetVersion;--struct _ENetHost;-struct _ENetEvent;-struct _ENetPacket;--typedef enum _ENetSocketType-{-   ENET_SOCKET_TYPE_STREAM   = 1,-   ENET_SOCKET_TYPE_DATAGRAM = 2-} ENetSocketType;--typedef enum _ENetSocketWait-{-   ENET_SOCKET_WAIT_NONE      = 0,-   ENET_SOCKET_WAIT_SEND      = (1 << 0),-   ENET_SOCKET_WAIT_RECEIVE   = (1 << 1),-   ENET_SOCKET_WAIT_INTERRUPT = (1 << 2)-} ENetSocketWait;--typedef enum _ENetSocketOption-{-   ENET_SOCKOPT_NONBLOCK  = 1,-   ENET_SOCKOPT_BROADCAST = 2,-   ENET_SOCKOPT_RCVBUF    = 3,-   ENET_SOCKOPT_SNDBUF    = 4,-   ENET_SOCKOPT_REUSEADDR = 5,-   ENET_SOCKOPT_RCVTIMEO  = 6,-   ENET_SOCKOPT_SNDTIMEO  = 7,-   ENET_SOCKOPT_ERROR     = 8-} ENetSocketOption;--typedef enum _ENetSocketShutdown-{-    ENET_SOCKET_SHUTDOWN_READ       = 0,-    ENET_SOCKET_SHUTDOWN_WRITE      = 1,-    ENET_SOCKET_SHUTDOWN_READ_WRITE = 2-} ENetSocketShutdown;--enum-{-   ENET_HOST_ANY       = 0,            /**< specifies the default server host */-   ENET_HOST_BROADCAST = 0xFFFFFFFF,   /**< specifies a subnet-wide broadcast */--   ENET_PORT_ANY       = 0             /**< specifies that a port should be automatically chosen */-};--/**- * Portable internet address structure. - *- * The host must be specified in network byte-order, and the port must be in host - * byte-order. The constant ENET_HOST_ANY may be used to specify the default - * server host. The constant ENET_HOST_BROADCAST may be used to specify the- * broadcast address (255.255.255.255).  This makes sense for enet_host_connect,- * but not for enet_host_create.  Once a server responds to a broadcast, the- * address is updated from ENET_HOST_BROADCAST to the server's actual IP address.- */-typedef struct _ENetAddress-{-   enet_uint32 host;-   enet_uint16 port;-} ENetAddress;--/**- * Packet flag bit constants.- *- * The host must be specified in network byte-order, and the port must be in- * host byte-order. The constant ENET_HOST_ANY may be used to specify the- * default server host.- -   @sa ENetPacket-*/-typedef enum _ENetPacketFlag-{-   /** packet must be received by the target peer and resend attempts should be-     * made until the packet is delivered */-   ENET_PACKET_FLAG_RELIABLE    = (1 << 0),-   /** packet will not be sequenced with other packets-     * not supported for reliable packets-     */-   ENET_PACKET_FLAG_UNSEQUENCED = (1 << 1),-   /** packet will not allocate data, and user must supply it instead */-   ENET_PACKET_FLAG_NO_ALLOCATE = (1 << 2),-   /** packet will be fragmented using unreliable (instead of reliable) sends-     * if it exceeds the MTU */-   ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT = (1 << 3),--   /** whether the packet has been sent from all queues it has been entered into */-   ENET_PACKET_FLAG_SENT = (1<<8)-} ENetPacketFlag;--typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *);--/**- * ENet packet structure.- *- * An ENet data packet that may be sent to or received from a peer. The shown - * fields should only be read and never modified. The data field contains the - * allocated data for the packet. The dataLength fields specifies the length - * of the allocated data.  The flags field is either 0 (specifying no flags), - * or a bitwise-or of any combination of the following flags:- *- *    ENET_PACKET_FLAG_RELIABLE - packet must be received by the target peer- *    and resend attempts should be made until the packet is delivered- *- *    ENET_PACKET_FLAG_UNSEQUENCED - packet will not be sequenced with other packets - *    (not supported for reliable packets)- *- *    ENET_PACKET_FLAG_NO_ALLOCATE - packet will not allocate data, and user must supply it instead- -   @sa ENetPacketFlag- */-typedef struct _ENetPacket-{-   size_t                   referenceCount;  /**< internal use only */-   enet_uint32              flags;           /**< bitwise-or of ENetPacketFlag constants */-   enet_uint8 *             data;            /**< allocated data for packet */-   size_t                   dataLength;      /**< length of data */-   ENetPacketFreeCallback   freeCallback;    /**< function to be called when the packet is no longer in use */-   void *                   userData;        /**< application private data, may be freely modified */-} ENetPacket;--typedef struct _ENetAcknowledgement-{-   ENetListNode acknowledgementList;-   enet_uint32  sentTime;-   ENetProtocol command;-} ENetAcknowledgement;--typedef struct _ENetOutgoingCommand-{-   ENetListNode outgoingCommandList;-   enet_uint16  reliableSequenceNumber;-   enet_uint16  unreliableSequenceNumber;-   enet_uint32  sentTime;-   enet_uint32  roundTripTimeout;-   enet_uint32  roundTripTimeoutLimit;-   enet_uint32  fragmentOffset;-   enet_uint16  fragmentLength;-   enet_uint16  sendAttempts;-   ENetProtocol command;-   ENetPacket * packet;-} ENetOutgoingCommand;--typedef struct _ENetIncomingCommand-{  -   ENetListNode     incomingCommandList;-   enet_uint16      reliableSequenceNumber;-   enet_uint16      unreliableSequenceNumber;-   ENetProtocol     command;-   enet_uint32      fragmentCount;-   enet_uint32      fragmentsRemaining;-   enet_uint32 *    fragments;-   ENetPacket *     packet;-} ENetIncomingCommand;--typedef enum _ENetPeerState-{-   ENET_PEER_STATE_DISCONNECTED                = 0,-   ENET_PEER_STATE_CONNECTING                  = 1,-   ENET_PEER_STATE_ACKNOWLEDGING_CONNECT       = 2,-   ENET_PEER_STATE_CONNECTION_PENDING          = 3,-   ENET_PEER_STATE_CONNECTION_SUCCEEDED        = 4,-   ENET_PEER_STATE_CONNECTED                   = 5,-   ENET_PEER_STATE_DISCONNECT_LATER            = 6,-   ENET_PEER_STATE_DISCONNECTING               = 7,-   ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT    = 8,-   ENET_PEER_STATE_ZOMBIE                      = 9 -} ENetPeerState;--#ifndef ENET_BUFFER_MAXIMUM-#define ENET_BUFFER_MAXIMUM (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS)-#endif--enum-{-   ENET_HOST_RECEIVE_BUFFER_SIZE          = 256 * 1024,-   ENET_HOST_SEND_BUFFER_SIZE             = 256 * 1024,-   ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL  = 1000,-   ENET_HOST_DEFAULT_MTU                  = 1400,--   ENET_PEER_DEFAULT_ROUND_TRIP_TIME      = 500,-   ENET_PEER_DEFAULT_PACKET_THROTTLE      = 32,-   ENET_PEER_PACKET_THROTTLE_SCALE        = 32,-   ENET_PEER_PACKET_THROTTLE_COUNTER      = 7, -   ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2,-   ENET_PEER_PACKET_THROTTLE_DECELERATION = 2,-   ENET_PEER_PACKET_THROTTLE_INTERVAL     = 5000,-   ENET_PEER_PACKET_LOSS_SCALE            = (1 << 16),-   ENET_PEER_PACKET_LOSS_INTERVAL         = 10000,-   ENET_PEER_WINDOW_SIZE_SCALE            = 64 * 1024,-   ENET_PEER_TIMEOUT_LIMIT                = 32,-   ENET_PEER_TIMEOUT_MINIMUM              = 5000,-   ENET_PEER_TIMEOUT_MAXIMUM              = 30000,-   ENET_PEER_PING_INTERVAL                = 500,-   ENET_PEER_UNSEQUENCED_WINDOWS          = 64,-   ENET_PEER_UNSEQUENCED_WINDOW_SIZE      = 1024,-   ENET_PEER_FREE_UNSEQUENCED_WINDOWS     = 32,-   ENET_PEER_RELIABLE_WINDOWS             = 16,-   ENET_PEER_RELIABLE_WINDOW_SIZE         = 0x1000,-   ENET_PEER_FREE_RELIABLE_WINDOWS        = 8-};--typedef struct _ENetChannel-{-   enet_uint16  outgoingReliableSequenceNumber;-   enet_uint16  outgoingUnreliableSequenceNumber;-   enet_uint16  usedReliableWindows;-   enet_uint16  reliableWindows [ENET_PEER_RELIABLE_WINDOWS];-   enet_uint16  incomingReliableSequenceNumber;-   enet_uint16  incomingUnreliableSequenceNumber;-   ENetList     incomingReliableCommands;-   ENetList     incomingUnreliableCommands;-} ENetChannel;--/**- * An ENet peer which data packets may be sent or received from. - *- * No fields should be modified unless otherwise specified. - */-typedef struct _ENetPeer-{ -   ENetListNode  dispatchList;-   struct _ENetHost * host;-   enet_uint16   outgoingPeerID;-   enet_uint16   incomingPeerID;-   enet_uint32   connectID;-   enet_uint8    outgoingSessionID;-   enet_uint8    incomingSessionID;-   ENetAddress   address;            /**< Internet address of the peer */-   void *        data;               /**< Application private data, may be freely modified */-   ENetPeerState state;-   ENetChannel * channels;-   size_t        channelCount;       /**< Number of channels allocated for communication with peer */-   enet_uint32   incomingBandwidth;  /**< Downstream bandwidth of the client in bytes/second */-   enet_uint32   outgoingBandwidth;  /**< Upstream bandwidth of the client in bytes/second */-   enet_uint32   incomingBandwidthThrottleEpoch;-   enet_uint32   outgoingBandwidthThrottleEpoch;-   enet_uint32   incomingDataTotal;-   enet_uint32   outgoingDataTotal;-   enet_uint32   lastSendTime;-   enet_uint32   lastReceiveTime;-   enet_uint32   nextTimeout;-   enet_uint32   earliestTimeout;-   enet_uint32   packetLossEpoch;-   enet_uint32   packetsSent;-   enet_uint32   packetsLost;-   enet_uint32   packetLoss;          /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */-   enet_uint32   packetLossVariance;-   enet_uint32   packetThrottle;-   enet_uint32   packetThrottleLimit;-   enet_uint32   packetThrottleCounter;-   enet_uint32   packetThrottleEpoch;-   enet_uint32   packetThrottleAcceleration;-   enet_uint32   packetThrottleDeceleration;-   enet_uint32   packetThrottleInterval;-   enet_uint32   pingInterval;-   enet_uint32   timeoutLimit;-   enet_uint32   timeoutMinimum;-   enet_uint32   timeoutMaximum;-   enet_uint32   lastRoundTripTime;-   enet_uint32   lowestRoundTripTime;-   enet_uint32   lastRoundTripTimeVariance;-   enet_uint32   highestRoundTripTimeVariance;-   enet_uint32   roundTripTime;            /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgement */-   enet_uint32   roundTripTimeVariance;-   enet_uint32   mtu;-   enet_uint32   windowSize;-   enet_uint32   reliableDataInTransit;-   enet_uint16   outgoingReliableSequenceNumber;-   ENetList      acknowledgements;-   ENetList      sentReliableCommands;-   ENetList      sentUnreliableCommands;-   ENetList      outgoingReliableCommands;-   ENetList      outgoingUnreliableCommands;-   ENetList      dispatchedCommands;-   int           needsDispatch;-   enet_uint16   incomingUnsequencedGroup;-   enet_uint16   outgoingUnsequencedGroup;-   enet_uint32   unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32]; -   enet_uint32   eventData;-} ENetPeer;--/** An ENet packet compressor for compressing UDP packets before socket sends or receives.- */-typedef struct _ENetCompressor-{-   /** Context data for the compressor. Must be non-NULL. */-   void * context;-   /** Compresses from inBuffers[0:inBufferCount-1], containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */-   size_t (ENET_CALLBACK * compress) (void * context, const ENetBuffer * inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 * outData, size_t outLimit);-   /** Decompresses from inData, containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */-   size_t (ENET_CALLBACK * decompress) (void * context, const enet_uint8 * inData, size_t inLimit, enet_uint8 * outData, size_t outLimit);-   /** Destroys the context when compression is disabled or the host is destroyed. May be NULL. */-   void (ENET_CALLBACK * destroy) (void * context);-} ENetCompressor;--/** Callback that computes the checksum of the data held in buffers[0:bufferCount-1] */-typedef enet_uint32 (ENET_CALLBACK * ENetChecksumCallback) (const ENetBuffer * buffers, size_t bufferCount);--/** Callback for intercepting received raw UDP packets. Should return 1 to intercept, 0 to ignore, or -1 to propagate an error. */-typedef int (ENET_CALLBACK * ENetInterceptCallback) (struct _ENetHost * host, struct _ENetEvent * event);- -/** An ENet host for communicating with peers.-  *-  * No fields should be modified unless otherwise stated.--    @sa enet_host_create()-    @sa enet_host_destroy()-    @sa enet_host_connect()-    @sa enet_host_service()-    @sa enet_host_flush()-    @sa enet_host_broadcast()-    @sa enet_host_compress()-    @sa enet_host_compress_with_range_coder()-    @sa enet_host_channel_limit()-    @sa enet_host_bandwidth_limit()-    @sa enet_host_bandwidth_throttle()-  */-typedef struct _ENetHost-{-   ENetSocket           socket;-   ENetAddress          address;                     /**< Internet address of the host */-   enet_uint32          incomingBandwidth;           /**< downstream bandwidth of the host */-   enet_uint32          outgoingBandwidth;           /**< upstream bandwidth of the host */-   enet_uint32          bandwidthThrottleEpoch;-   enet_uint32          mtu;-   enet_uint32          randomSeed;-   int                  recalculateBandwidthLimits;-   ENetPeer *           peers;                       /**< array of peers allocated for this host */-   size_t               peerCount;                   /**< number of peers allocated for this host */-   size_t               channelLimit;                /**< maximum number of channels allowed for connected peers */-   enet_uint32          serviceTime;-   ENetList             dispatchQueue;-   int                  continueSending;-   size_t               packetSize;-   enet_uint16          headerFlags;-   ENetProtocol         commands [ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS];-   size_t               commandCount;-   ENetBuffer           buffers [ENET_BUFFER_MAXIMUM];-   size_t               bufferCount;-   ENetChecksumCallback checksum;                    /**< callback the user can set to enable packet checksums for this host */-   ENetCompressor       compressor;-   enet_uint8           packetData [2][ENET_PROTOCOL_MAXIMUM_MTU];-   ENetAddress          receivedAddress;-   enet_uint8 *         receivedData;-   size_t               receivedDataLength;-   enet_uint32          totalSentData;               /**< total data sent, user should reset to 0 as needed to prevent overflow */-   enet_uint32          totalSentPackets;            /**< total UDP packets sent, user should reset to 0 as needed to prevent overflow */-   enet_uint32          totalReceivedData;           /**< total data received, user should reset to 0 as needed to prevent overflow */-   enet_uint32          totalReceivedPackets;        /**< total UDP packets received, user should reset to 0 as needed to prevent overflow */-   ENetInterceptCallback intercept;                  /**< callback the user can set to intercept received raw UDP packets */-   size_t               connectedPeers;-   size_t               bandwidthLimitedPeers;-} ENetHost;--/**- * An ENet event type, as specified in @ref ENetEvent.- */-typedef enum _ENetEventType-{-   /** no event occurred within the specified time limit */-   ENET_EVENT_TYPE_NONE       = 0,  --   /** a connection request initiated by enet_host_connect has completed.  -     * The peer field contains the peer which successfully connected. -     */-   ENET_EVENT_TYPE_CONNECT    = 1,  --   /** a peer has disconnected.  This event is generated on a successful -     * completion of a disconnect initiated by enet_pper_disconnect, if -     * a peer has timed out, or if a connection request intialized by -     * enet_host_connect has timed out.  The peer field contains the peer -     * which disconnected. The data field contains user supplied data -     * describing the disconnection, or 0, if none is available.-     */-   ENET_EVENT_TYPE_DISCONNECT = 2,  --   /** a packet has been received from a peer.  The peer field specifies the-     * peer which sent the packet.  The channelID field specifies the channel-     * number upon which the packet was received.  The packet field contains-     * the packet that was received; this packet must be destroyed with-     * enet_packet_destroy after use.-     */-   ENET_EVENT_TYPE_RECEIVE    = 3-} ENetEventType;--/**- * An ENet event as returned by enet_host_service().-   -   @sa enet_host_service- */-typedef struct _ENetEvent -{-   ENetEventType        type;      /**< type of the event */-   ENetPeer *           peer;      /**< peer that generated a connect, disconnect or receive event */-   enet_uint8           channelID; /**< channel on the peer that generated the event, if appropriate */-   enet_uint32          data;      /**< data associated with the event, if appropriate */-   ENetPacket *         packet;    /**< packet associated with the event, if appropriate */-} ENetEvent;--/** @defgroup global ENet global functions-    @{ -*/--/** -  Initializes ENet globally.  Must be called prior to using any functions in-  ENet.-  @returns 0 on success, < 0 on failure-*/-ENET_API int enet_initialize (void);--/** -  Initializes ENet globally and supplies user-overridden callbacks. Must be called prior to using any functions in ENet. Do not use enet_initialize() if you use this variant. Make sure the ENetCallbacks structure is zeroed out so that any additional callbacks added in future versions will be properly ignored.--  @param version the constant ENET_VERSION should be supplied so ENet knows which version of ENetCallbacks struct to use-  @param inits user-overriden callbacks where any NULL callbacks will use ENet's defaults-  @returns 0 on success, < 0 on failure-*/-ENET_API int enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits);--/** -  Shuts down ENet globally.  Should be called when a program that has-  initialized ENet exits.-*/-ENET_API void enet_deinitialize (void);--/**-  Gives the linked version of the ENet library.-  @returns the version number -*/-ENET_API ENetVersion enet_linked_version (void);--/** @} */--/** @defgroup private ENet private implementation functions */--/**-  Returns the wall-time in milliseconds.  Its initial value is unspecified-  unless otherwise set.-  */-ENET_API enet_uint32 enet_time_get (void);-/**-  Sets the current wall-time in milliseconds.-  */-ENET_API void enet_time_set (enet_uint32);--/** @defgroup socket ENet socket functions-    @{-*/-ENET_API ENetSocket enet_socket_create (ENetSocketType);-ENET_API int        enet_socket_bind (ENetSocket, const ENetAddress *);-ENET_API int        enet_socket_get_address (ENetSocket, ENetAddress *);-ENET_API int        enet_socket_listen (ENetSocket, int);-ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress *);-ENET_API int        enet_socket_connect (ENetSocket, const ENetAddress *);-ENET_API int        enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t);-ENET_API int        enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t);-ENET_API int        enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32);-ENET_API int        enet_socket_set_option (ENetSocket, ENetSocketOption, int);-ENET_API int        enet_socket_get_option (ENetSocket, ENetSocketOption, int *);-ENET_API int        enet_socket_shutdown (ENetSocket, ENetSocketShutdown);-ENET_API void       enet_socket_destroy (ENetSocket);-ENET_API int        enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSocketSet *, enet_uint32);--/** @} */--/** @defgroup Address ENet address functions-    @{-*/-/** Attempts to resolve the host named by the parameter hostName and sets-    the host field in the address parameter if successful.-    @param address destination to store resolved address-    @param hostName host name to lookup-    @retval 0 on success-    @retval < 0 on failure-    @returns the address of the given hostName in address on success-*/-ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName);--/** Gives the printable form of the ip address specified in the address parameter.-    @param address    address printed-    @param hostName   destination for name, must not be NULL-    @param nameLength maximum length of hostName.-    @returns the null-terminated name of the host in hostName on success-    @retval 0 on success-    @retval < 0 on failure-*/-ENET_API int enet_address_get_host_ip (const ENetAddress * address, char * hostName, size_t nameLength);--/** Attempts to do a reverse lookup of the host field in the address parameter.-    @param address    address used for reverse lookup-    @param hostName   destination for name, must not be NULL-    @param nameLength maximum length of hostName.-    @returns the null-terminated name of the host in hostName on success-    @retval 0 on success-    @retval < 0 on failure-*/-ENET_API int enet_address_get_host (const ENetAddress * address, char * hostName, size_t nameLength);--/** @} */--ENET_API ENetPacket * enet_packet_create (const void *, size_t, enet_uint32);-ENET_API void         enet_packet_destroy (ENetPacket *);-ENET_API int          enet_packet_resize  (ENetPacket *, size_t);-ENET_API enet_uint32  enet_crc32 (const ENetBuffer *, size_t);-                -ENET_API ENetHost * enet_host_create (const ENetAddress *, size_t, size_t, enet_uint32, enet_uint32);-ENET_API void       enet_host_destroy (ENetHost *);-ENET_API ENetPeer * enet_host_connect (ENetHost *, const ENetAddress *, size_t, enet_uint32);-ENET_API int        enet_host_check_events (ENetHost *, ENetEvent *);-ENET_API int        enet_host_service (ENetHost *, ENetEvent *, enet_uint32);-ENET_API void       enet_host_flush (ENetHost *);-ENET_API void       enet_host_broadcast (ENetHost *, enet_uint8, ENetPacket *);-ENET_API void       enet_host_compress (ENetHost *, const ENetCompressor *);-ENET_API int        enet_host_compress_with_range_coder (ENetHost * host);-ENET_API void       enet_host_channel_limit (ENetHost *, size_t);-ENET_API void       enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32);-extern   void       enet_host_bandwidth_throttle (ENetHost *);-extern  enet_uint32 enet_host_random_seed (void);--ENET_API int                 enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *);-ENET_API ENetPacket *        enet_peer_receive (ENetPeer *, enet_uint8 * channelID);-ENET_API void                enet_peer_ping (ENetPeer *);-ENET_API void                enet_peer_ping_interval (ENetPeer *, enet_uint32);-ENET_API void                enet_peer_timeout (ENetPeer *, enet_uint32, enet_uint32, enet_uint32);-ENET_API void                enet_peer_reset (ENetPeer *);-ENET_API void                enet_peer_disconnect (ENetPeer *, enet_uint32);-ENET_API void                enet_peer_disconnect_now (ENetPeer *, enet_uint32);-ENET_API void                enet_peer_disconnect_later (ENetPeer *, enet_uint32);-ENET_API void                enet_peer_throttle_configure (ENetPeer *, enet_uint32, enet_uint32, enet_uint32);-extern int                   enet_peer_throttle (ENetPeer *, enet_uint32);-extern void                  enet_peer_reset_queues (ENetPeer *);-extern void                  enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *);-extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16);-extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32);-extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16);-extern void                  enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *);-extern void                  enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *);-extern void                  enet_peer_on_connect (ENetPeer *);-extern void                  enet_peer_on_disconnect (ENetPeer *);--ENET_API void * enet_range_coder_create (void);-ENET_API void   enet_range_coder_destroy (void *);-ENET_API size_t enet_range_coder_compress (void *, const ENetBuffer *, size_t, size_t, enet_uint8 *, size_t);-ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t, enet_uint8 *, size_t);-   -extern size_t enet_protocol_command_size (enet_uint8);--#ifdef __cplusplus-}-#endif--#endif /* __ENET_ENET_H__ */-
− enet/include/enet/list.h
@@ -1,43 +0,0 @@-/** - @file  list.h- @brief ENet list management -*/-#ifndef __ENET_LIST_H__-#define __ENET_LIST_H__--#include <stdlib.h>--typedef struct _ENetListNode-{-   struct _ENetListNode * next;-   struct _ENetListNode * previous;-} ENetListNode;--typedef ENetListNode * ENetListIterator;--typedef struct _ENetList-{-   ENetListNode sentinel;-} ENetList;--extern void enet_list_clear (ENetList *);--extern ENetListIterator enet_list_insert (ENetListIterator, void *);-extern void * enet_list_remove (ENetListIterator);-extern ENetListIterator enet_list_move (ENetListIterator, void *, void *);--extern size_t enet_list_size (ENetList *);--#define enet_list_begin(list) ((list) -> sentinel.next)-#define enet_list_end(list) (& (list) -> sentinel)--#define enet_list_empty(list) (enet_list_begin (list) == enet_list_end (list))--#define enet_list_next(iterator) ((iterator) -> next)-#define enet_list_previous(iterator) ((iterator) -> previous)--#define enet_list_front(list) ((void *) (list) -> sentinel.next)-#define enet_list_back(list) ((void *) (list) -> sentinel.previous)--#endif /* __ENET_LIST_H__ */-
− enet/include/enet/protocol.h
@@ -1,199 +0,0 @@-/** - @file  protocol.h- @brief ENet protocol-*/-#ifndef __ENET_PROTOCOL_H__-#define __ENET_PROTOCOL_H__--#include "enet/types.h"--enum-{-   ENET_PROTOCOL_MINIMUM_MTU             = 576,-   ENET_PROTOCOL_MAXIMUM_MTU             = 4096,-   ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32,-   ENET_PROTOCOL_MINIMUM_WINDOW_SIZE     = 4096,-   ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE     = 32768,-   ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT   = 1,-   ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT   = 255,-   ENET_PROTOCOL_MAXIMUM_PEER_ID         = 0xFFF,-   ENET_PROTOCOL_MAXIMUM_PACKET_SIZE     = 1024 * 1024 * 1024,-   ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT  = 1024 * 1024-};--typedef enum _ENetProtocolCommand-{-   ENET_PROTOCOL_COMMAND_NONE               = 0,-   ENET_PROTOCOL_COMMAND_ACKNOWLEDGE        = 1,-   ENET_PROTOCOL_COMMAND_CONNECT            = 2,-   ENET_PROTOCOL_COMMAND_VERIFY_CONNECT     = 3,-   ENET_PROTOCOL_COMMAND_DISCONNECT         = 4,-   ENET_PROTOCOL_COMMAND_PING               = 5,-   ENET_PROTOCOL_COMMAND_SEND_RELIABLE      = 6,-   ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE    = 7,-   ENET_PROTOCOL_COMMAND_SEND_FRAGMENT      = 8,-   ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED   = 9,-   ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT    = 10,-   ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,-   ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12,-   ENET_PROTOCOL_COMMAND_COUNT              = 13,--   ENET_PROTOCOL_COMMAND_MASK               = 0x0F-} ENetProtocolCommand;--typedef enum _ENetProtocolFlag-{-   ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7),-   ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6),--   ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14),-   ENET_PROTOCOL_HEADER_FLAG_SENT_TIME  = (1 << 15),-   ENET_PROTOCOL_HEADER_FLAG_MASK       = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME,--   ENET_PROTOCOL_HEADER_SESSION_MASK    = (3 << 12),-   ENET_PROTOCOL_HEADER_SESSION_SHIFT   = 12-} ENetProtocolFlag;--#ifdef _MSC_VER_-#pragma pack(push, 1)-#define ENET_PACKED-#elif defined(__GNUC__) || defined(__clang__)-#define ENET_PACKED __attribute__ ((packed))-#else-#define ENET_PACKED-#endif--typedef struct _ENetProtocolHeader-{-   enet_uint16 peerID;-   enet_uint16 sentTime;-} ENET_PACKED ENetProtocolHeader;--typedef struct _ENetProtocolCommandHeader-{-   enet_uint8 command;-   enet_uint8 channelID;-   enet_uint16 reliableSequenceNumber;-} ENET_PACKED ENetProtocolCommandHeader;--typedef struct _ENetProtocolAcknowledge-{-   ENetProtocolCommandHeader header;-   enet_uint16 receivedReliableSequenceNumber;-   enet_uint16 receivedSentTime;-} ENET_PACKED ENetProtocolAcknowledge;--typedef struct _ENetProtocolConnect-{-   ENetProtocolCommandHeader header;-   enet_uint16 outgoingPeerID;-   enet_uint8  incomingSessionID;-   enet_uint8  outgoingSessionID;-   enet_uint32 mtu;-   enet_uint32 windowSize;-   enet_uint32 channelCount;-   enet_uint32 incomingBandwidth;-   enet_uint32 outgoingBandwidth;-   enet_uint32 packetThrottleInterval;-   enet_uint32 packetThrottleAcceleration;-   enet_uint32 packetThrottleDeceleration;-   enet_uint32 connectID;-   enet_uint32 data;-} ENET_PACKED ENetProtocolConnect;--typedef struct _ENetProtocolVerifyConnect-{-   ENetProtocolCommandHeader header;-   enet_uint16 outgoingPeerID;-   enet_uint8  incomingSessionID;-   enet_uint8  outgoingSessionID;-   enet_uint32 mtu;-   enet_uint32 windowSize;-   enet_uint32 channelCount;-   enet_uint32 incomingBandwidth;-   enet_uint32 outgoingBandwidth;-   enet_uint32 packetThrottleInterval;-   enet_uint32 packetThrottleAcceleration;-   enet_uint32 packetThrottleDeceleration;-   enet_uint32 connectID;-} ENET_PACKED ENetProtocolVerifyConnect;--typedef struct _ENetProtocolBandwidthLimit-{-   ENetProtocolCommandHeader header;-   enet_uint32 incomingBandwidth;-   enet_uint32 outgoingBandwidth;-} ENET_PACKED ENetProtocolBandwidthLimit;--typedef struct _ENetProtocolThrottleConfigure-{-   ENetProtocolCommandHeader header;-   enet_uint32 packetThrottleInterval;-   enet_uint32 packetThrottleAcceleration;-   enet_uint32 packetThrottleDeceleration;-} ENET_PACKED ENetProtocolThrottleConfigure;--typedef struct _ENetProtocolDisconnect-{-   ENetProtocolCommandHeader header;-   enet_uint32 data;-} ENET_PACKED ENetProtocolDisconnect;--typedef struct _ENetProtocolPing-{-   ENetProtocolCommandHeader header;-} ENET_PACKED ENetProtocolPing;--typedef struct _ENetProtocolSendReliable-{-   ENetProtocolCommandHeader header;-   enet_uint16 dataLength;-} ENET_PACKED ENetProtocolSendReliable;--typedef struct _ENetProtocolSendUnreliable-{-   ENetProtocolCommandHeader header;-   enet_uint16 unreliableSequenceNumber;-   enet_uint16 dataLength;-} ENET_PACKED ENetProtocolSendUnreliable;--typedef struct _ENetProtocolSendUnsequenced-{-   ENetProtocolCommandHeader header;-   enet_uint16 unsequencedGroup;-   enet_uint16 dataLength;-} ENET_PACKED ENetProtocolSendUnsequenced;--typedef struct _ENetProtocolSendFragment-{-   ENetProtocolCommandHeader header;-   enet_uint16 startSequenceNumber;-   enet_uint16 dataLength;-   enet_uint32 fragmentCount;-   enet_uint32 fragmentNumber;-   enet_uint32 totalLength;-   enet_uint32 fragmentOffset;-} ENET_PACKED ENetProtocolSendFragment;--typedef union _ENetProtocol-{-   ENetProtocolCommandHeader header;-   ENetProtocolAcknowledge acknowledge;-   ENetProtocolConnect connect;-   ENetProtocolVerifyConnect verifyConnect;-   ENetProtocolDisconnect disconnect;-   ENetProtocolPing ping;-   ENetProtocolSendReliable sendReliable;-   ENetProtocolSendUnreliable sendUnreliable;-   ENetProtocolSendUnsequenced sendUnsequenced;-   ENetProtocolSendFragment sendFragment;-   ENetProtocolBandwidthLimit bandwidthLimit;-   ENetProtocolThrottleConfigure throttleConfigure;-} ENET_PACKED ENetProtocol;--#ifdef _MSC_VER_-#pragma pack(pop)-#endif--#endif /* __ENET_PROTOCOL_H__ */-
− enet/include/enet/time.h
@@ -1,18 +0,0 @@-/** - @file  time.h- @brief ENet time constants and macros-*/-#ifndef __ENET_TIME_H__-#define __ENET_TIME_H__--#define ENET_TIME_OVERFLOW 86400000--#define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW)-#define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW)-#define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b))-#define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b))--#define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b))--#endif /* __ENET_TIME_H__ */-
− enet/include/enet/types.h
@@ -1,13 +0,0 @@-/** - @file  types.h- @brief type definitions for ENet-*/-#ifndef __ENET_TYPES_H__-#define __ENET_TYPES_H__--typedef unsigned char enet_uint8;       /**< unsigned 8-bit type  */-typedef unsigned short enet_uint16;     /**< unsigned 16-bit type */-typedef unsigned int enet_uint32;      /**< unsigned 32-bit type */--#endif /* __ENET_TYPES_H__ */-
− enet/include/enet/unix.h
@@ -1,50 +0,0 @@-/** - @file  unix.h- @brief ENet Unix header-*/-#ifndef __ENET_UNIX_H__-#define __ENET_UNIX_H__--#include <stdlib.h>-#include <sys/time.h>-#include <sys/types.h>-#include <sys/socket.h>-#include <netinet/in.h>-#include <unistd.h>--#ifdef MSG_MAXIOVLEN-#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN-#endif--typedef int ENetSocket;--enum-{-    ENET_SOCKET_NULL = -1-};--#define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */-#define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */--#define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */-#define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */--typedef struct-{-    void * data;-    size_t dataLength;-} ENetBuffer;--#define ENET_CALLBACK--#define ENET_API extern--typedef fd_set ENetSocketSet;--#define ENET_SOCKETSET_EMPTY(sockset)          FD_ZERO (& (sockset))-#define ENET_SOCKETSET_ADD(sockset, socket)    FD_SET (socket, & (sockset))-#define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLEAR (socket, & (sockset))-#define ENET_SOCKETSET_CHECK(sockset, socket)  FD_ISSET (socket, & (sockset))-    -#endif /* __ENET_UNIX_H__ */-
− enet/include/enet/utility.h
@@ -1,12 +0,0 @@-/** - @file  utility.h- @brief ENet utility header-*/-#ifndef __ENET_UTILITY_H__-#define __ENET_UTILITY_H__--#define ENET_MAX(x, y) ((x) > (y) ? (x) : (y))-#define ENET_MIN(x, y) ((x) < (y) ? (x) : (y))--#endif /* __ENET_UTILITY_H__ */-
− enet/include/enet/win32.h
@@ -1,60 +0,0 @@-/** - @file  win32.h- @brief ENet Win32 header-*/-#ifndef __ENET_WIN32_H__-#define __ENET_WIN32_H__--#ifdef _MSC_VER-#ifdef ENET_BUILDING_LIB-#pragma warning (disable: 4996) // 'strncpy' was declared deprecated-#pragma warning (disable: 4267) // size_t to int conversion-#pragma warning (disable: 4244) // 64bit to 32bit int-#pragma warning (disable: 4018) // signed/unsigned mismatch-#endif-#endif--#include <stdlib.h>-#include <winsock2.h>--typedef SOCKET ENetSocket;--enum-{-    ENET_SOCKET_NULL = INVALID_SOCKET-};--#define ENET_HOST_TO_NET_16(value) (htons (value))-#define ENET_HOST_TO_NET_32(value) (htonl (value))--#define ENET_NET_TO_HOST_16(value) (ntohs (value))-#define ENET_NET_TO_HOST_32(value) (ntohl (value))--typedef struct-{-    size_t dataLength;-    void * data;-} ENetBuffer;--#define ENET_CALLBACK __cdecl--#ifdef ENET_DLL-#ifdef ENET_BUILDING_LIB-#define ENET_API __declspec( dllexport )-#else-#define ENET_API __declspec( dllimport )-#endif /* ENET_BUILDING_LIB */-#else /* !ENET_DLL */-#define ENET_API extern-#endif /* ENET_DLL */--typedef fd_set ENetSocketSet;--#define ENET_SOCKETSET_EMPTY(sockset)          FD_ZERO (& (sockset))-#define ENET_SOCKETSET_ADD(sockset, socket)    FD_SET (socket, & (sockset))-#define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLEAR (socket, & (sockset))-#define ENET_SOCKETSET_CHECK(sockset, socket)  FD_ISSET (socket, & (sockset))--#endif /* __ENET_WIN32_H__ */--
gore-and-ash-network.cabal view
@@ -1,5 +1,5 @@ name:                gore-and-ash-network-version:             1.1.0.1+version:             1.2.0.0 synopsis:            Core module for Gore&Ash engine with low level network API description:         Please see README.md homepage:            https://github.com/Teaspot-Studio/gore-and-ash-network@@ -11,17 +11,12 @@ maintainer:          ncrashed@gmail.com copyright:           2015-2016 Anton Gushcha,                      2013-2015 John Ericson,-                     2002-2013 Lee Salzman,-                     2013 Sergei Lebedev <superbobry@gmail.com>, -                     2013 Aleksey Kladov <aleksey.kladov@gmail.com>,-                     2013 Fedor Gogolev <knsd@knsd.net>+                     2002-2013 Lee Salzman  category:            Game-build-type:          Custom+build-type:          Simple cabal-version:       >=1.10 -extra-source-files:   enet/include/enet/*.h-                      bin/mkDerivedGmpConstants.c  Bug-reports:          https://github.com/Teaspot-Studio/gore-and-ash-network/issues Source-repository head@@ -29,19 +24,13 @@   location:           git@github.com:Teaspot-Studio/gore-and-ash-network.git  library-  hs-source-dirs:     src, henet, bitset+  hs-source-dirs:     src, henet   exposed-modules:    Game.GoreAndAsh.Network                       Game.GoreAndAsh.Network.API                       Game.GoreAndAsh.Network.Message                       Game.GoreAndAsh.Network.Module                       Game.GoreAndAsh.Network.State   other-modules:-                      Data.BitSet-                      Data.BitSet.Dynamic-                      Data.BitSet.Generic-                      Data.BitSet.Word-                      GHC.Integer.GMP.PrimExt-                      GHC.Integer.GMP.TypeExt                       Network.ENet                       Network.ENet.Bindings                       Network.ENet.Bindings.Callbacks@@ -60,11 +49,8 @@                       enet/peer.c                       enet/protocol.c -                      cbits/gmp-extras.cmm-   include-dirs:       enet                       enet/include-                      cbits    build-tools:        hsc2hs @@ -101,11 +87,6 @@                        TypeFamilies                        TypeSynonymInstances                        UndecidableInstances--  if os(windows)-    extra-libraries:  gmp-10-  else-    extra-libraries:  gmp    cc-options:         -g   ld-options:         -g
henet/Network/ENet.hs view
@@ -5,11 +5,12 @@  import Data.ByteString (ByteString) import Data.Word (Word32)-import Data.BitSet.Generic (BitSet)+import Data.Bits ((.|.), (.&.))  import Foreign.C.Error  import qualified Network.ENet.Bindings as B+import qualified Data.Foldable as F   {-| Like 'withSocketsDo' from the network package. On windows it checks the version of Winsock, initializes it, and then after execution of the given@@ -44,7 +45,20 @@   B.deinitialize   return retVal -type PacketFlagSet = BitSet Word32 B.PacketFlag+-- | Build from combining B.PacketFlag+newtype PacketFlagSet = PacketFlagSet { unPacketFlagSet :: Word32 }++makePacketFlagSet :: (F.Foldable t, Functor t) => (t B.PacketFlag) -> PacketFlagSet+makePacketFlagSet = PacketFlagSet . F.foldl' (.|.) 0 . fmap (fromIntegral . fromEnum)++unpackPacketFlagSet :: PacketFlagSet -> [B.PacketFlag]+unpackPacketFlagSet (PacketFlagSet w) = filter ((/= 0) . (w .&.) . fromIntegral . fromEnum) [B.Reliable .. B.IsSent]++emptyPacketFlagSet :: PacketFlagSet+emptyPacketFlagSet = PacketFlagSet 0 ++instance Show PacketFlagSet where +  show = show . unpackPacketFlagSet  -- | A more high level notion of a packet than used by the basic Bindings data Packet = Packet PacketFlagSet ByteString
henet/Network/ENet/Bindings.hsc view
@@ -100,13 +100,26 @@                 | Unsequenced                 | NoAllocate                 | UnreliableFragment-                | PF_Unused_1-                | PF_Unused_2-                | PF_Unused_3-                | PF_Unused_4                 | IsSent-                deriving (Show, Eq, Enum) -- safe because used in bitset+                | PacketFlagUnknown+                deriving (Show, Eq) +-- | Used in creation of flag set+instance Enum PacketFlag where +  fromEnum f = case f of +    Reliable -> 1+    Unsequenced -> 2+    NoAllocate -> 4+    UnreliableFragment -> 8+    IsSent -> 256+    PacketFlagUnknown -> 0+  toEnum i = case i of +    1 -> Reliable+    2 -> Unsequenced+    4 -> NoAllocate+    8 -> UnreliableFragment+    256 -> IsSent+    _ -> PacketFlagUnknown ------  -- Opaque/Abstract types, cause I am lazy
henet/Network/ENet/Packet.hsc view
@@ -5,7 +5,6 @@ import Foreign.C.Error import Foreign.C.Types -import Data.BitSet.Generic(BitSet(getBits)) import Data.ByteString.Unsafe  import Network.ENet@@ -23,7 +22,7 @@ -- this ^ is why unsafe is OK poke :: Packet -> IO (Ptr B.Packet) poke (Packet f bs) = unsafeUseAsCStringLen bs $ \(ptr, len) ->-  B.packetCreate (castPtr ptr) (fromIntegral len) $ getBits f+  B.packetCreate (castPtr ptr) (fromIntegral len) $ unPacketFlagSet f  destroy :: Ptr B.Packet -> IO () destroy = B.packetDestroy@@ -40,7 +39,7 @@               p <- (#peek ENetPacket, data      ) ptr               l <- (#peek ENetPacket, dataLength) ptr               b <- unsafePackCStringFinalizer p l $ destroy ptr-              return $ Packet f b+              return $ Packet (PacketFlagSet f) b  resize :: Ptr B.Packet -> CSize -> IO () resize ptr size = do _ <- throwErrnoIf -- explicity throw away return after
src/Game/GoreAndAsh/Network/Message.hs view
@@ -16,7 +16,6 @@ import Control.DeepSeq import GHC.Generics import Network.ENet-import qualified Data.BitSet.Generic as B import qualified Data.ByteString as BS  import qualified Network.ENet.Bindings as B @@ -34,11 +33,11 @@ -- | Converts high-level message type to bits option for ENet messageTypeToBits :: MessageType -> PacketFlagSet messageTypeToBits t = case t of -  ReliableMessage -> B.singleton B.Reliable-  UnsequencedMessage -> B.singleton B.Unsequenced-  UnsequencedFragmentedMessage -> B.UnreliableFragment `B.insert` B.singleton B.Unsequenced-  UnreliableMessage -> B.empty-  UnreliableFragmentedMessage -> B.singleton B.UnreliableFragment+  ReliableMessage -> makePacketFlagSet [B.Reliable]+  UnsequencedMessage -> makePacketFlagSet [B.Unsequenced]+  UnsequencedFragmentedMessage -> makePacketFlagSet [B.UnreliableFragment, B.Unsequenced]+  UnreliableMessage -> emptyPacketFlagSet+  UnreliableFragmentedMessage -> makePacketFlagSet [B.UnreliableFragment]  -- | Message that has individual options about reliability  data Message = Message {