diff options
-rw-r--r-- | meson.build | 6 | ||||
-rw-r--r-- | meson_options.txt | 6 | ||||
-rw-r--r-- | src/defs.h | 31 | ||||
-rw-r--r-- | src/mergesort.c | 2 | ||||
-rw-r--r-- | src/util.h | 38 |
5 files changed, 7 insertions, 76 deletions
diff --git a/meson.build b/meson.build index f378dcc..0b23a41 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('algos ld1', 'c', license : 'LGPL2.1', - default_options : ['c_std=gnu11', 'buildtype=release', 'warning_level=2']) + default_options : ['c_std=gnu11', 'optimization=3', 'b_lto=true', 'debug=false', 'warning_level=3']) deps = [dependency('rin', version : '>= 0.0.4')] @@ -8,9 +8,9 @@ progname = 'alg' add_project_arguments('-D', '_GNU_SOURCE', language : 'c') add_project_arguments('-fplan9-extensions', language : 'c') -add_project_arguments('-D', 'entry_field_size=' + get_option('data-bitness'), language : 'c') +add_project_arguments('-D', 'entry_field_size=' + get_option('data-bits'), language : 'c') -if get_option('data-signed').enabled() +if get_option('data-sign').enabled() add_project_arguments('-D', 'entry_field_signed', language : 'c') endif diff --git a/meson_options.txt b/meson_options.txt index 3833423..80bd07d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,9 +1,9 @@ -option('data-signed', +option('data-sign', type : 'feature', value : 'disabled', description : 'Switch whether to use signed data type') -option('data-bitness', +option('data-bits', type : 'combo', - choices : ['256', '128', '64', '32', '16', '8'], + choices : ['64', '32', '16', '8'], value : '64', description : 'Size of a data entry to use, in bits') @@ -49,37 +49,6 @@ # else typedef uint64_t field; # endif - -/* 128 bit and up do not fit in basic types; building composites */ - -#elif entry_field_size == 128 -# ifdef entry_field_signed - typedef struct field { - uint64_t low; - int64_t high; - } field; -# else - typedef struct field { - uint64_t low; - uint64_t high; - } field; -# endif -#elif entry_field_size == 256 -# ifdef entry_field_signed - typedef struct field { - uint64_t low; - uint64_t midlow; - uint64_t midhigh; - int64_t high; - } field; -# else - typedef struct field { - uint64_t low; - uint64_t midlow; - uint64_t midhigh; - uint64_t high; - } field; -# endif #endif union nextoff { diff --git a/src/mergesort.c b/src/mergesort.c index aa05f8e..fb08d29 100644 --- a/src/mergesort.c +++ b/src/mergesort.c @@ -56,7 +56,7 @@ static int merge(struct stream * const dest, struct stream * const A, struct str b = B->get(B, &b_store); while (a || b) { - if (a && (!b || is_less_equal(a_store.val, b_store.val))) { + if (a && (!b || a_store.val <= b_store.val)) { dest->put(dest, a); a = A->get(A, &a_store); } else { @@ -10,42 +10,4 @@ int stream_rewind(struct stream * const restrict in); int split(struct stream * const src, struct stream * const A, struct stream * const B); -/* inline crap below */ - -static inline int is_less_equal(const field a, const field b) __attribute__((always_inline)); - -static inline int is_less_equal(const field a, const field b) -{ - int ret; - -/* all sizes fitting in a primitive type */ -#if entry_field_size <= 64 - - ret = a <= b; - -/* composite of two 64bit */ -#elif entry_field_size == 128 - - if (unlikely(a.high == b.high)) { - ret = a.low <= b.low; - } else { - ret = a.high < b.high; - } - -/* composite of four 64bit */ -#elif entry_field_size == 256 - if (likely(a.high != b.high)) { - ret = a.high < b.high; - } else if (likely(a.midhigh != b.midhigh)){ - ret = a.midhigh < b.midhigh; - } else if (likely(a.midlow != b.midlow)){ - ret = a.midlow < b.midlow; - } else { - ret = a.low <= b.low; - } -#endif - - return ret; -} - #endif /* ALGOS_UTIL_H_INCLUDED */ |