summaryrefslogtreecommitdiffstats
path: root/src/defs.h
diff options
context:
space:
mode:
authorGravatar Gediminas Jakutis <gediminas@varciai.lt> 2020-03-10 10:15:53 +0200
committerGravatar Gediminas Jakutis <gediminas@varciai.lt> 2020-03-10 10:15:53 +0200
commit61c3a9aa7a636ada2cedd5b6025d5c7ccc598c85 (patch)
tree6732e0e6847cc860c98bb9bfa7e5a5619d3504e2 /src/defs.h
parent9eb76eda865dc4f82fd53223e5c557f707b569b9 (diff)
downloadalgos-ld1-61c3a9aa7a636ada2cedd5b6025d5c7ccc598c85.tar.gz
algos-ld1-61c3a9aa7a636ada2cedd5b6025d5c7ccc598c85.tar.bz2
algos-ld1-61c3a9aa7a636ada2cedd5b6025d5c7ccc598c85.zip
bolt on data generation, kind of.
Signed-off-by: Gediminas Jakutis <gediminas@varciai.lt>
Diffstat (limited to 'src/defs.h')
-rw-r--r--src/defs.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/defs.h b/src/defs.h
index 1ad2d72..3b8f1c1 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -1,3 +1,7 @@
+/* SPDX-License-Identifier: LGPL-2.1-only */
+
+/* Copyright (C) 2020 Gediminas Jakutis */
+
#ifndef ALGOS_DEFS_H_INCLUDED
#define ALGOS_DEFS_H_INCLUDED
@@ -16,6 +20,9 @@
goto l;\
}} while (0);
+#define get(in, idx, data) (in->cached ? in->get_element_cache(in, idx, data) | in->get_element(in, idx, data))
+#define put(in, idx, data) (in->cached ? in->put_element_cache(in, idx, data) | in->put_element(in, idx, data))
+
/* for array implementation */
struct entry {
uint64_t val;
@@ -24,8 +31,8 @@ struct entry {
/* for linked list implementation */
struct entry_l {
struct entry;
- uint32_t next; /* """pointer""" to the next element. */
- uint32_t prev; /* """pointer""" to the previous element. */
+ int32_t next; /* """pointer""" to the next element. */
+ int32_t prev; /* """pointer""" to the previous element. */
};
enum opmode {
@@ -34,14 +41,28 @@ enum opmode {
mode_generate
};
+enum accessmode {
+ cached,
+ direct
+};
+
+enum dataformat {
+ array,
+ list
+};
+
struct stream {
size_t n;
ssize_t prev_idx;
int fd;
int out;
+ int cached;
char *name;
- int (*get)(struct stream *, size_t, struct entry_l *, int);
- int (*put)(struct stream *, size_t, struct entry_l *, int);
+ struct entry_l *cache;
+ int (*get_element)(struct stream * const restrict, size_t, struct entry_l *);
+ int (*put_element)(struct stream * const restrict, size_t, struct entry_l *);
+ int (*get_element_cache)(struct stream * const restrict, size_t, struct entry_l *);
+ int (*put_element_cache)(struct stream * const restrict, size_t, struct entry_l *);
};
struct settings {
@@ -50,8 +71,9 @@ struct settings {
size_t stride;
char *filein;
char *fileout;
- unsigned int flags;
enum opmode opmode;
+ enum dataformat format;
+ enum accessmode access;
};
#endif /* ALGOS_DEFS_H_INCLUDED */