module Data.Bits.Atomic (
AtomicBits(..),
memoryBarrier
) where
import Data.Bits
import Data.Word
import Data.Int
import Foreign.Ptr
class Bits x => AtomicBits x where
fetchAndAdd :: Ptr x -> x -> IO x
fetchAndSub :: Ptr x -> x -> IO x
fetchAndOr :: Ptr x -> x -> IO x
fetchAndAnd :: Ptr x -> x -> IO x
fetchAndXor :: Ptr x -> x -> IO x
fetchAndNand :: Ptr x -> x -> IO x
addAndFetch :: Ptr x -> x -> IO x
subAndFetch :: Ptr x -> x -> IO x
orAndFetch :: Ptr x -> x -> IO x
andAndFetch :: Ptr x -> x -> IO x
xorAndFetch :: Ptr x -> x -> IO x
nandAndFetch :: Ptr x -> x -> IO x
compareAndSwapBool :: Ptr x
-> x
-> x
-> IO Bool
compareAndSwap :: Ptr x
-> x
-> x
-> IO x
lockTestAndSet :: Ptr x -> IO x
lockRelease :: Ptr x -> IO ()
foreign import ccall unsafe "atomic-bitops-gcc.h mem_barrier"
memoryBarrier :: IO ()
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_add_8"
fetch_and_add_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_sub_8"
fetch_and_sub_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_or_8"
fetch_and_or_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_and_8"
fetch_and_and_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_xor_8"
fetch_and_xor_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_nand_8"
fetch_and_nand_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h add_and_fetch_8"
add_and_fetch_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h sub_and_fetch_8"
sub_and_fetch_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h or_and_fetch_8"
or_and_fetch_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h and_and_fetch_8"
and_and_fetch_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h xor_and_fetch_8"
xor_and_fetch_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h nand_and_fetch_8"
nand_and_fetch_8 :: Ptr Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h bool_compare_and_swap_8"
bool_compare_and_swap_8 :: Ptr Word8 -> Word8 -> Word8 -> IO Bool
foreign import ccall unsafe "atomic-bitops-gcc.h val_compare_and_swap_8"
val_compare_and_swap_8 :: Ptr Word8 -> Word8 -> Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h lock_test_and_set_8"
lock_test_and_set_8 :: Ptr Word8 -> IO Word8
foreign import ccall unsafe "atomic-bitops-gcc.h lock_release_8"
lock_release_8 :: Ptr Word8 -> IO ()
instance AtomicBits Word8 where
fetchAndAdd = fetch_and_add_8
fetchAndSub = fetch_and_sub_8
fetchAndOr = fetch_and_or_8
fetchAndAnd = fetch_and_and_8
fetchAndXor = fetch_and_xor_8
fetchAndNand = fetch_and_nand_8
addAndFetch = add_and_fetch_8
subAndFetch = sub_and_fetch_8
orAndFetch = or_and_fetch_8
andAndFetch = and_and_fetch_8
xorAndFetch = xor_and_fetch_8
nandAndFetch = nand_and_fetch_8
compareAndSwapBool = bool_compare_and_swap_8
compareAndSwap = val_compare_and_swap_8
lockTestAndSet = lock_test_and_set_8
lockRelease = lock_release_8
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_add_16"
fetch_and_add_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_sub_16"
fetch_and_sub_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_or_16"
fetch_and_or_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_and_16"
fetch_and_and_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_xor_16"
fetch_and_xor_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_nand_16"
fetch_and_nand_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h add_and_fetch_16"
add_and_fetch_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h sub_and_fetch_16"
sub_and_fetch_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h or_and_fetch_16"
or_and_fetch_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h and_and_fetch_16"
and_and_fetch_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h xor_and_fetch_16"
xor_and_fetch_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h nand_and_fetch_16"
nand_and_fetch_16 :: Ptr Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h bool_compare_and_swap_16"
bool_compare_and_swap_16 :: Ptr Word16 -> Word16 -> Word16 -> IO Bool
foreign import ccall unsafe "atomic-bitops-gcc.h val_compare_and_swap_16"
val_compare_and_swap_16 :: Ptr Word16 -> Word16 -> Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h lock_test_and_set_16"
lock_test_and_set_16 :: Ptr Word16 -> IO Word16
foreign import ccall unsafe "atomic-bitops-gcc.h lock_release_16"
lock_release_16 :: Ptr Word16 -> IO ()
instance AtomicBits Word16 where
fetchAndAdd = fetch_and_add_16
fetchAndSub = fetch_and_sub_16
fetchAndOr = fetch_and_or_16
fetchAndAnd = fetch_and_and_16
fetchAndXor = fetch_and_xor_16
fetchAndNand = fetch_and_nand_16
addAndFetch = add_and_fetch_16
subAndFetch = sub_and_fetch_16
orAndFetch = or_and_fetch_16
andAndFetch = and_and_fetch_16
xorAndFetch = xor_and_fetch_16
nandAndFetch = nand_and_fetch_16
compareAndSwapBool = bool_compare_and_swap_16
compareAndSwap = val_compare_and_swap_16
lockTestAndSet = lock_test_and_set_16
lockRelease = lock_release_16
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_add_32"
fetch_and_add_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_sub_32"
fetch_and_sub_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_or_32"
fetch_and_or_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_and_32"
fetch_and_and_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_xor_32"
fetch_and_xor_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_nand_32"
fetch_and_nand_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h add_and_fetch_32"
add_and_fetch_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h sub_and_fetch_32"
sub_and_fetch_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h or_and_fetch_32"
or_and_fetch_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h and_and_fetch_32"
and_and_fetch_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h xor_and_fetch_32"
xor_and_fetch_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h nand_and_fetch_32"
nand_and_fetch_32 :: Ptr Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h bool_compare_and_swap_32"
bool_compare_and_swap_32 :: Ptr Word32 -> Word32 -> Word32 -> IO Bool
foreign import ccall unsafe "atomic-bitops-gcc.h val_compare_and_swap_32"
val_compare_and_swap_32 :: Ptr Word32 -> Word32 -> Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h lock_test_and_set_32"
lock_test_and_set_32 :: Ptr Word32 -> IO Word32
foreign import ccall unsafe "atomic-bitops-gcc.h lock_release_32"
lock_release_32 :: Ptr Word32 -> IO ()
instance AtomicBits Word32 where
fetchAndAdd = fetch_and_add_32
fetchAndSub = fetch_and_sub_32
fetchAndOr = fetch_and_or_32
fetchAndAnd = fetch_and_and_32
fetchAndXor = fetch_and_xor_32
fetchAndNand = fetch_and_nand_32
addAndFetch = add_and_fetch_32
subAndFetch = sub_and_fetch_32
orAndFetch = or_and_fetch_32
andAndFetch = and_and_fetch_32
xorAndFetch = xor_and_fetch_32
nandAndFetch = nand_and_fetch_32
compareAndSwapBool = bool_compare_and_swap_32
compareAndSwap = val_compare_and_swap_32
lockTestAndSet = lock_test_and_set_32
lockRelease = lock_release_32
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_add_64"
fetch_and_add_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_sub_64"
fetch_and_sub_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_or_64"
fetch_and_or_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_and_64"
fetch_and_and_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_xor_64"
fetch_and_xor_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_nand_64"
fetch_and_nand_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h add_and_fetch_64"
add_and_fetch_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h sub_and_fetch_64"
sub_and_fetch_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h or_and_fetch_64"
or_and_fetch_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h and_and_fetch_64"
and_and_fetch_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h xor_and_fetch_64"
xor_and_fetch_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h nand_and_fetch_64"
nand_and_fetch_64 :: Ptr Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h bool_compare_and_swap_64"
bool_compare_and_swap_64 :: Ptr Word64 -> Word64 -> Word64 -> IO Bool
foreign import ccall unsafe "atomic-bitops-gcc.h val_compare_and_swap_64"
val_compare_and_swap_64 :: Ptr Word64 -> Word64 -> Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h lock_test_and_set_64"
lock_test_and_set_64 :: Ptr Word64 -> IO Word64
foreign import ccall unsafe "atomic-bitops-gcc.h lock_release_64"
lock_release_64 :: Ptr Word64 -> IO ()
instance AtomicBits Word64 where
fetchAndAdd = fetch_and_add_64
fetchAndSub = fetch_and_sub_64
fetchAndOr = fetch_and_or_64
fetchAndAnd = fetch_and_and_64
fetchAndXor = fetch_and_xor_64
fetchAndNand = fetch_and_nand_64
addAndFetch = add_and_fetch_64
subAndFetch = sub_and_fetch_64
orAndFetch = or_and_fetch_64
andAndFetch = and_and_fetch_64
xorAndFetch = xor_and_fetch_64
nandAndFetch = nand_and_fetch_64
compareAndSwapBool = bool_compare_and_swap_64
compareAndSwap = val_compare_and_swap_64
lockTestAndSet = lock_test_and_set_64
lockRelease = lock_release_64
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_add_word"
fetch_and_add_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_sub_word"
fetch_and_sub_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_or_word"
fetch_and_or_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_and_word"
fetch_and_and_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_xor_word"
fetch_and_xor_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h fetch_and_nand_word"
fetch_and_nand_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h add_and_fetch_word"
add_and_fetch_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h sub_and_fetch_word"
sub_and_fetch_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h or_and_fetch_word"
or_and_fetch_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h and_and_fetch_word"
and_and_fetch_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h xor_and_fetch_word"
xor_and_fetch_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h nand_and_fetch_word"
nand_and_fetch_word :: Ptr Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h bool_compare_and_swap_word"
bool_compare_and_swap_word :: Ptr Word -> Word -> Word -> IO Bool
foreign import ccall unsafe "atomic-bitops-gcc.h val_compare_and_swap_word"
val_compare_and_swap_word :: Ptr Word -> Word -> Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h lock_test_and_set_word"
lock_test_and_set_word :: Ptr Word -> IO Word
foreign import ccall unsafe "atomic-bitops-gcc.h lock_release_word"
lock_release_word :: Ptr Word -> IO ()
instance AtomicBits Word where
fetchAndAdd = fetch_and_add_word
fetchAndSub = fetch_and_sub_word
fetchAndOr = fetch_and_or_word
fetchAndAnd = fetch_and_and_word
fetchAndXor = fetch_and_xor_word
fetchAndNand = fetch_and_nand_word
addAndFetch = add_and_fetch_word
subAndFetch = sub_and_fetch_word
orAndFetch = or_and_fetch_word
andAndFetch = and_and_fetch_word
xorAndFetch = xor_and_fetch_word
nandAndFetch = nand_and_fetch_word
compareAndSwapBool = bool_compare_and_swap_word
compareAndSwap = val_compare_and_swap_word
lockTestAndSet = lock_test_and_set_word
lockRelease = lock_release_word
instance AtomicBits Int where
fetchAndAdd p v = fmap fromIntegral $ fetch_and_add_word
(castPtr p :: Ptr Word)
(fromIntegral v)
fetchAndSub p v = fmap fromIntegral $ fetch_and_sub_word
(castPtr p :: Ptr Word)
(fromIntegral v)
fetchAndOr p v = fmap fromIntegral $ fetch_and_or_word
(castPtr p :: Ptr Word)
(fromIntegral v)
fetchAndAnd p v = fmap fromIntegral $ fetch_and_and_word
(castPtr p :: Ptr Word)
(fromIntegral v)
fetchAndXor p v = fmap fromIntegral $ fetch_and_xor_word
(castPtr p :: Ptr Word)
(fromIntegral v)
fetchAndNand p v = fmap fromIntegral $ fetch_and_nand_word
(castPtr p :: Ptr Word)
(fromIntegral v)
addAndFetch p v = fmap fromIntegral $ add_and_fetch_word
(castPtr p :: Ptr Word)
(fromIntegral v)
subAndFetch p v = fmap fromIntegral $ sub_and_fetch_word
(castPtr p :: Ptr Word)
(fromIntegral v)
orAndFetch p v = fmap fromIntegral $ or_and_fetch_word
(castPtr p :: Ptr Word)
(fromIntegral v)
andAndFetch p v = fmap fromIntegral $ and_and_fetch_word
(castPtr p :: Ptr Word)
(fromIntegral v)
xorAndFetch p v = fmap fromIntegral $ xor_and_fetch_word
(castPtr p :: Ptr Word)
(fromIntegral v)
nandAndFetch p v = fmap fromIntegral $ nand_and_fetch_word
(castPtr p :: Ptr Word)
(fromIntegral v)
compareAndSwapBool p o n = bool_compare_and_swap_word
(castPtr p :: Ptr Word)
(fromIntegral o)
(fromIntegral n)
compareAndSwap p o n = fmap fromIntegral $ val_compare_and_swap_word
(castPtr p :: Ptr Word)
(fromIntegral o)
(fromIntegral n)
lockTestAndSet p = fmap fromIntegral $ lock_test_and_set_word
(castPtr p :: Ptr Word)
lockRelease p = lock_release_word (castPtr p :: Ptr Word)
instance AtomicBits Int8 where
fetchAndAdd p v = fmap fromIntegral $ fetch_and_add_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
fetchAndSub p v = fmap fromIntegral $ fetch_and_sub_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
fetchAndOr p v = fmap fromIntegral $ fetch_and_or_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
fetchAndAnd p v = fmap fromIntegral $ fetch_and_and_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
fetchAndXor p v = fmap fromIntegral $ fetch_and_xor_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
fetchAndNand p v = fmap fromIntegral $ fetch_and_nand_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
addAndFetch p v = fmap fromIntegral $ add_and_fetch_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
subAndFetch p v = fmap fromIntegral $ sub_and_fetch_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
orAndFetch p v = fmap fromIntegral $ or_and_fetch_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
andAndFetch p v = fmap fromIntegral $ and_and_fetch_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
xorAndFetch p v = fmap fromIntegral $ xor_and_fetch_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
nandAndFetch p v = fmap fromIntegral $ nand_and_fetch_8
(castPtr p :: Ptr Word8)
(fromIntegral v)
compareAndSwapBool p o n = bool_compare_and_swap_8
(castPtr p :: Ptr Word8)
(fromIntegral o)
(fromIntegral n)
compareAndSwap p o n = fmap fromIntegral $ val_compare_and_swap_8
(castPtr p :: Ptr Word8)
(fromIntegral o)
(fromIntegral n)
lockTestAndSet p = fmap fromIntegral $ lock_test_and_set_8
(castPtr p :: Ptr Word8)
lockRelease p = lock_release_8 (castPtr p :: Ptr Word8)
instance AtomicBits Int16 where
fetchAndAdd p v = fmap fromIntegral $ fetch_and_add_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
fetchAndSub p v = fmap fromIntegral $ fetch_and_sub_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
fetchAndOr p v = fmap fromIntegral $ fetch_and_or_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
fetchAndAnd p v = fmap fromIntegral $ fetch_and_and_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
fetchAndXor p v = fmap fromIntegral $ fetch_and_xor_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
fetchAndNand p v = fmap fromIntegral $ fetch_and_nand_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
addAndFetch p v = fmap fromIntegral $ add_and_fetch_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
subAndFetch p v = fmap fromIntegral $ sub_and_fetch_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
orAndFetch p v = fmap fromIntegral $ or_and_fetch_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
andAndFetch p v = fmap fromIntegral $ and_and_fetch_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
xorAndFetch p v = fmap fromIntegral $ xor_and_fetch_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
nandAndFetch p v = fmap fromIntegral $ nand_and_fetch_16
(castPtr p :: Ptr Word16)
(fromIntegral v)
compareAndSwapBool p o n = bool_compare_and_swap_16
(castPtr p :: Ptr Word16)
(fromIntegral o)
(fromIntegral n)
compareAndSwap p o n = fmap fromIntegral $ val_compare_and_swap_16
(castPtr p :: Ptr Word16)
(fromIntegral o)
(fromIntegral n)
lockTestAndSet p = fmap fromIntegral $ lock_test_and_set_16
(castPtr p :: Ptr Word16)
lockRelease p = lock_release_16 (castPtr p :: Ptr Word16)
instance AtomicBits Int32 where
fetchAndAdd p v = fmap fromIntegral $ fetch_and_add_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
fetchAndSub p v = fmap fromIntegral $ fetch_and_sub_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
fetchAndOr p v = fmap fromIntegral $ fetch_and_or_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
fetchAndAnd p v = fmap fromIntegral $ fetch_and_and_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
fetchAndXor p v = fmap fromIntegral $ fetch_and_xor_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
fetchAndNand p v = fmap fromIntegral $ fetch_and_nand_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
addAndFetch p v = fmap fromIntegral $ add_and_fetch_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
subAndFetch p v = fmap fromIntegral $ sub_and_fetch_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
orAndFetch p v = fmap fromIntegral $ or_and_fetch_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
andAndFetch p v = fmap fromIntegral $ and_and_fetch_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
xorAndFetch p v = fmap fromIntegral $ xor_and_fetch_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
nandAndFetch p v = fmap fromIntegral $ nand_and_fetch_32
(castPtr p :: Ptr Word32)
(fromIntegral v)
compareAndSwapBool p o n = bool_compare_and_swap_32
(castPtr p :: Ptr Word32)
(fromIntegral o)
(fromIntegral n)
compareAndSwap p o n = fmap fromIntegral $ val_compare_and_swap_32
(castPtr p :: Ptr Word32)
(fromIntegral o)
(fromIntegral n)
lockTestAndSet p = fmap fromIntegral $ lock_test_and_set_32
(castPtr p :: Ptr Word32)
lockRelease p = lock_release_32 (castPtr p :: Ptr Word32)
instance AtomicBits Int64 where
fetchAndAdd p v = fmap fromIntegral $ fetch_and_add_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
fetchAndSub p v = fmap fromIntegral $ fetch_and_sub_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
fetchAndOr p v = fmap fromIntegral $ fetch_and_or_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
fetchAndAnd p v = fmap fromIntegral $ fetch_and_and_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
fetchAndXor p v = fmap fromIntegral $ fetch_and_xor_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
fetchAndNand p v = fmap fromIntegral $ fetch_and_nand_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
addAndFetch p v = fmap fromIntegral $ add_and_fetch_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
subAndFetch p v = fmap fromIntegral $ sub_and_fetch_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
orAndFetch p v = fmap fromIntegral $ or_and_fetch_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
andAndFetch p v = fmap fromIntegral $ and_and_fetch_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
xorAndFetch p v = fmap fromIntegral $ xor_and_fetch_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
nandAndFetch p v = fmap fromIntegral $ nand_and_fetch_64
(castPtr p :: Ptr Word64)
(fromIntegral v)
compareAndSwapBool p o n = bool_compare_and_swap_64
(castPtr p :: Ptr Word64)
(fromIntegral o)
(fromIntegral n)
compareAndSwap p o n = fmap fromIntegral $ val_compare_and_swap_64
(castPtr p :: Ptr Word64)
(fromIntegral o)
(fromIntegral n)
lockTestAndSet p = fmap fromIntegral $ lock_test_and_set_64
(castPtr p :: Ptr Word64)
lockRelease p = lock_release_64 (castPtr p :: Ptr Word64)