summaryrefslogtreecommitdiffstats
path: root/src/defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/defs.h')
-rw-r--r--src/defs.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/defs.h b/src/defs.h
index f3eb48f..cb03c81 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -23,8 +23,12 @@
}} 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))
+#define get(in) (in->cached ? in->get_next_element_cache(in) : in->get_next_element_direct(in))
+#define put(in, data) (in->cached ? in->place_next_element_cache(in, data) : in->place_next_element_direct(in, data))
+
+#define stream_blank .fd = -1, .settings = &settings, .get_next_element_direct = stub_getnext, \
+ .get_next_element_cache = stub_getnext, .place_next_element_direct = stub_put, \
+ .place_next_element_cache = stub_put, .split = stub_split, .flush = stub_flush
/* for array implementation */
struct entry {
@@ -34,8 +38,7 @@ struct entry {
/* for linked list implementation */
struct entry_l {
struct entry;
- int32_t next; /* """pointer""" to the next element. */
- int32_t prev; /* """pointer""" to the previous element. */
+ int64_t next; /* """pointer""" to the next element. */
};
enum opmode {
@@ -55,18 +58,25 @@ enum dataformat {
};
struct stream {
+ struct stream *parent;
size_t n;
- ssize_t prev_idx;
- off_t prev_off;
int fd;
int out;
int cached;
char *name;
- struct entry_l *cache;
- int (*get_element)(struct stream * const, ssize_t, struct entry_l * const);
- int (*put_element)(struct stream * const restrict, ssize_t, struct entry_l const * const);
- int (*get_element_cache)(struct stream * const, ssize_t, struct entry_l * const);
- int (*put_element_cache)(struct stream * const restrict, ssize_t, struct entry_l const * const);
+ size_t stride;
+ size_t index;
+ struct entry_l *cnode;
+ char *cache;
+ struct settings *settings;
+ struct entry *cache_a;
+ struct entry_l *cache_l;
+ struct entry_l *(*get_next_element_direct)(struct stream * const);
+ struct entry_l *(*get_next_element_cache)(struct stream * const);
+ int (*place_next_element_direct)(struct stream * const, struct entry_l const * const);
+ int (*place_next_element_cache)(struct stream * const, struct entry_l const * const);
+ int (*split)(struct stream * const, struct stream * const, struct stream * const);
+ int (*flush)(struct stream * const);
};
struct settings {