-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Efficient atomic and non-atomic bit operations not found in Data.Bits -- -- Mostly wraps low-level bit operations provided by GCC builtins, which -- translate to specialized instructions where available. -- -- Atomic operations include CAS (compare-and-swap), lock, fetch & -- add and similar primitives suitable for low-level shared-memory -- synchronization. -- -- Primitives from the Extras subpackage would be useful to have -- in the proper Data.Bits package, although this would probably -- require broader support across different compiler backends. -- -- The C code dynamically links to libgcc_s, which can cause -- problems in GHCi. GHCi does not currently support sonames and tries to -- open libgcc_s.so while ignoring e.g. libgcc_s.so.1. -- A possible workaround for GHCi on a linux system: ln -s -- /lib/libgcc_s.so.1 /lib/libgcc_s.so. Let me know about any other -- solutions to this issue for GHCi. Regular GHC compilation uses the -- system linker with soname support and does not run into this issue. -- -- Relevant Hackage tickets: -- --
@package bits-extras @version 0.1.1 -- | Atomic bit operations, using GCC's built-in atomic operations in small -- C wrapper functions called through the FFI. See -- http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Atomic-Builtins.html -- or the version corresponding to your compiler for more detail. module Data.Bits.Atomic -- | Atomic bit operations on a memory location. -- -- Instances: Word, Word8, Word16, Word32, -- Word64, Int, Int8, Int16, Int32, -- Int64. class (Bits x) => AtomicBits x fetchAndAdd :: (AtomicBits x) => Ptr x -> x -> IO x fetchAndSub :: (AtomicBits x) => Ptr x -> x -> IO x fetchAndOr :: (AtomicBits x) => Ptr x -> x -> IO x fetchAndAnd :: (AtomicBits x) => Ptr x -> x -> IO x fetchAndXor :: (AtomicBits x) => Ptr x -> x -> IO x fetchAndNand :: (AtomicBits x) => Ptr x -> x -> IO x addAndFetch :: (AtomicBits x) => Ptr x -> x -> IO x subAndFetch :: (AtomicBits x) => Ptr x -> x -> IO x orAndFetch :: (AtomicBits x) => Ptr x -> x -> IO x andAndFetch :: (AtomicBits x) => Ptr x -> x -> IO x xorAndFetch :: (AtomicBits x) => Ptr x -> x -> IO x nandAndFetch :: (AtomicBits x) => Ptr x -> x -> IO x compareAndSwapBool :: (AtomicBits x) => Ptr x -> x -> x -> IO Bool compareAndSwap :: (AtomicBits x) => Ptr x -> x -> x -> IO x lockTestAndSet :: (AtomicBits x) => Ptr x -> IO x lockRelease :: (AtomicBits x) => Ptr x -> IO () -- | A full memory barrier. memoryBarrier :: IO () instance AtomicBits Int64 instance AtomicBits Int32 instance AtomicBits Int16 instance AtomicBits Int8 instance AtomicBits Int instance AtomicBits Word instance AtomicBits Word64 instance AtomicBits Word32 instance AtomicBits Word16 instance AtomicBits Word8 -- | Extended bit operations, implemented using GCC builtins (see -- http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Other-Builtins.html). module Data.Bits.Extras -- | Instances provided: Word, Word8, Word16, -- Word32, Word64, Int, Int8, Int16, -- Int32, Int64 class (Bits x) => ExtraBits x lowestBitPlus1 :: (ExtraBits x) => x -> Word32 leadingZeros :: (ExtraBits x) => x -> Word32 trailingZeros :: (ExtraBits x) => x -> Word32 populationCount :: (ExtraBits x) => x -> Word32 parity :: (ExtraBits x) => x -> Word32 byteSwap :: (ExtraBits x) => x -> x instance ExtraBits Int64 instance ExtraBits Int32 instance ExtraBits Int16 instance ExtraBits Int8 instance ExtraBits Int instance ExtraBits Word64 instance ExtraBits Word32 instance ExtraBits Word16 instance ExtraBits Word8 instance ExtraBits Word