summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gediminas Jakutis <gediminas@varciai.lt> 2021-02-15 12:26:42 +0200
committerGravatar Gediminas Jakutis <gediminas@varciai.lt> 2021-02-15 12:26:42 +0200
commit3f0c21826b4a4e59c937dc8435edb5be7100b078 (patch)
treec2690004384bb7d8faab85593fd7adefa53f8f7f
parentfb383b792d1044405188e42c4b827858c4a3a038 (diff)
downloadalgos-ld1-3f0c21826b4a4e59c937dc8435edb5be7100b078.tar.gz
algos-ld1-3f0c21826b4a4e59c937dc8435edb5be7100b078.tar.bz2
algos-ld1-3f0c21826b4a4e59c937dc8435edb5be7100b078.zip
now with configurable data size!
Signed-off-by: Gediminas Jakutis <gediminas@varciai.lt>
-rw-r--r--meson.build5
-rw-r--r--meson_options.txt9
-rw-r--r--src/defs.h21
3 files changed, 34 insertions, 1 deletions
diff --git a/meson.build b/meson.build
index da58251..f378dcc 100644
--- a/meson.build
+++ b/meson.build
@@ -8,6 +8,11 @@ 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')
+
+if get_option('data-signed').enabled()
+ add_project_arguments('-D', 'entry_field_signed', language : 'c')
+endif
subdir('src')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..ab26488
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,9 @@
+option('data-signed',
+ type : 'feature',
+ value : 'disabled',
+ description : 'Switch whether to use signed data type')
+option('data-bitness',
+ type : 'combo',
+ choices : ['64', '32', '16'],
+ value : '64',
+ description : 'Size of a data entry to use, in bits')
diff --git a/src/defs.h b/src/defs.h
index f6a7f91..a7a678d 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -22,6 +22,25 @@
goto l;\
}} while (0);
+#if entry_field_size == 16
+# ifdef entry_field_signed
+ typedef int16_t field;
+# else
+ typedef uint16_t field;
+# endif
+#elif entry_field_size == 32
+# ifdef entry_field_signed
+ typedef int32_t field;
+# else
+ typedef uint32_t field;
+# endif
+#else
+# ifdef entry_field_signed
+ typedef int64_t field;
+# else
+ typedef uint64_t field;
+# endif
+#endif
#define get(in) (in->settings->access == cached ? in->get_next_element_cache(in) : in->get_next_element_direct(in))
#define put(in, data) (in->settings->access == cached ? in->place_next_element_cache(in, data) : in->place_next_element_direct(in, data))
@@ -44,7 +63,7 @@ union cachewrap {
/* for array implementation */
struct entry {
- uint64_t val;
+ field val;
};
/* for linked list implementation */