Skip to content

Commit

Permalink
Move sources around
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed May 18, 2024
1 parent b88e9b3 commit d1085cc
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 44 deletions.
26 changes: 11 additions & 15 deletions hashable-bench/hashable-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ tested-with:

extra-source-files:
include/HsHashable.h
xxhash/include/HsXXHash.h
xxhash/xxHash-0.8.2/xxhash.h
include/HsXXHash.h
xxHash-0.8.2/xxhash.h

flag integer-gmp
description:
Expand All @@ -52,14 +52,20 @@ library

other-modules:
Data.Hashable.Class
Data.Hashable.FFI
Data.Hashable.Generic.Instances
Data.Hashable.Imports
Data.Hashable.LowLevel
Data.Hashable.Mix

Data.Hashable.XXH3

c-sources: cbits/fnv.c
include-dirs: include
include-dirs: include xxHash-0.8.2/
includes:
HsHashable.h
HsXXHash.h
xxhash.h

hs-source-dirs: src
build-depends:
base >=4.10.1.0 && <4.21
Expand Down Expand Up @@ -119,15 +125,7 @@ library
UnliftedFFITypes

ghc-options: -Wall -fwarn-tabs
ghc-options: -optc=-march=native -optc-mtune=native

include-dirs: xxhash/xxHash-0.8.2/ xxhash/include/
includes:
HsXXHash.h
xxhash.h

other-modules: XXH3 FFI
hs-source-dirs: xxhash/src
ghc-options: -optc=-march=native -optc-mtune=native

benchmark hashable-benchmark
-- We cannot depend on the hashable library directly as that creates
Expand Down Expand Up @@ -158,8 +156,6 @@ benchmark hashable-benchmark
ghc-options: -Wall -O2
default-language: Haskell2010



source-repository head
type: git
location:
Expand Down
1 change: 1 addition & 0 deletions hashable-bench/xxHash-0.8.2
1 change: 0 additions & 1 deletion hashable-bench/xxhash

This file was deleted.

66 changes: 49 additions & 17 deletions hashable.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ tested-with:
extra-source-files:
CHANGES.md
include/HsHashable.h
include/HsXXHash.h
README.md
xxhash/include/HsXXHash.h
xxhash/xxHash-0.8.2/xxhash.h
xxHash-0.8.2/xxhash.h

flag integer-gmp
description:
Expand All @@ -58,6 +58,14 @@ flag integer-gmp
manual: False
default: True

flag march-native
description:
Use @-march=native@ when compiling C sources.
You may need to disable this flag if you are building distributable binaries

manual: True
default: True

flag random-initial-seed
description:
Randomly initialize the initial seed on each final executable invocation
Expand All @@ -76,12 +84,19 @@ library

other-modules:
Data.Hashable.Class
Data.Hashable.FFI
Data.Hashable.Generic.Instances
Data.Hashable.Imports
Data.Hashable.LowLevel
Data.Hashable.Mix
Data.Hashable.XXH3

include-dirs: include xxHash-0.8.2
includes:
HsHashable.h
HsXXHash.h
xxhash.h

include-dirs: include
hs-source-dirs: src
build-depends:
, base >=4.12.0.0 && <4.21
Expand Down Expand Up @@ -150,25 +165,18 @@ library
TypeOperators
UnliftedFFITypes

ghc-options: -Wall -fwarn-tabs
ghc-options: -Wall

if flag(march-native)
-- Cabal doesn't pass cc-options to "ordinary" Haskell source compilation
-- https://github.com/haskell/cabal/issues/9801
ghc-options: -optc=-march=native -optc-mtune=native

if impl(ghc >=9.0)
-- these flags may abort compilation with GHC-8.10
-- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3295
ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode

include-dirs: xxhash/xxHash-0.8.2/ xxhash/include/
includes:
HsXXHash.h
xxhash.h

-- Cabal doesn't pass cc-options to "ordinary" Haskell source compilation
-- https://github.com/haskell/cabal/issues/9801
ghc-options: -optc=-march=native -optc-mtune=native

other-modules: XXH3 FFI
hs-source-dirs: xxhash/src

test-suite hashable-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests
Expand Down Expand Up @@ -197,12 +205,36 @@ test-suite hashable-tests
if !os(windows)
build-depends: unix
cpp-options: -DHAVE_MMAP
other-modules: Regress.Mmap
other-extensions: CApiFFI

ghc-options: -Wall -fno-warn-orphans
default-language: Haskell2010

test-suite xxhash-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests src
main-is: xxhash-tests.hs
other-modules:
Data.Hashable.FFI
Data.Hashable.XXH3

default-language: Haskell2010
build-depends:
, base
, bytestring
, primitive ^>=0.9.0.0
, tasty ^>=1.5
, tasty-hunit ^>=0.10.1
, tasty-quickcheck ^>=0.10.3

include-dirs: include xxHash-0.8.2
includes:
HsXXHash.h
xxhash.h

if !impl(ghc >=9.4)
build-depends: data-array-byte >=0.1.0.1 && <0.2

test-suite hashable-examples
type: exitcode-stdio-1.0
build-depends:
Expand Down
2 changes: 2 additions & 0 deletions include/HsHashable.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef HS_HASHABLE_H
#define HS_HASHABLE_H

#include <stdint.h>

uint64_t hs_hashable_init();

#endif
6 changes: 3 additions & 3 deletions xxhash/include/HsXXHash.h → include/HsXXHash.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HS_XXHASH
#define HS_XXHASH
#ifndef HS_XXHASH_H
#define HS_XXHASH_H

#include <stdint.h>

Expand Down Expand Up @@ -32,4 +32,4 @@ static inline void hs_XXH3_64bits_update_u32(XXH3_state_t *statePtr, uint32_t va
XXH3_64bits_update(statePtr, &val, sizeof(val));
}

#endif /* HS_XXHASH */
#endif /* HS_XXHASH_H */
3 changes: 1 addition & 2 deletions src/Data/Hashable/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ import GHC.Num.Orphans ()

import Data.Hashable.Imports
import Data.Hashable.LowLevel

import XXH3
import Data.Hashable.XXH3

#include "MachDeps.h"

Expand Down
2 changes: 1 addition & 1 deletion xxhash/src/FFI.hs → src/Data/Hashable/FFI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE UnliftedFFITypes #-}
module FFI (
module Data.Hashable.FFI (
-- * One shot
unsafe_xxh3_64bit_withSeed_ptr,
unsafe_xxh3_64bit_withSeed_ba,
Expand Down
3 changes: 1 addition & 2 deletions src/Data/Hashable/LowLevel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import System.IO.Unsafe (unsafePerformIO)

import Data.Hashable.Imports
import Data.Hashable.Mix

import XXH3
import Data.Hashable.XXH3

-------------------------------------------------------------------------------
-- Initial seed
Expand Down
4 changes: 2 additions & 2 deletions xxhash/src/XXH3.hs → src/Data/Hashable/XXH3.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE ViewPatterns #-}
module XXH3 (
module Data.Hashable.XXH3 (
-- * One shot
xxh3_64bit_withSeed_ptr,
xxh3_64bit_withSeed_bs,
Expand All @@ -32,7 +32,7 @@ import Foreign (Ptr)
import GHC.Exts (Int (..), MutableByteArray#, newAlignedPinnedByteArray#)
import GHC.ST (ST (..))

import FFI
import Data.Hashable.FFI

#if MIN_VERSION_base(4,15,0)
import GHC.ForeignPtr (unsafeWithForeignPtr)
Expand Down
2 changes: 1 addition & 1 deletion xxhash/tests/xxhash-tests.hs → tests/xxhash-tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Test.Tasty (defaultMain, testGroup)
import Test.Tasty.HUnit (testCase, (@=?))
import Test.Tasty.QuickCheck (testProperty, (===))

import XXH3
import Data.Hashable.XXH3

main :: IO ()
main = defaultMain $ testGroup "xxhash"
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit d1085cc

Please sign in to comment.