From 41efe7b8f9f67d5956ab677f3631478c48114ac1 Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Tue, 9 Feb 2021 05:43:36 +0200 Subject: A major overhaul of the whole thing. It has come to my attention that previously, the project was built on top of some *very* incorrect assumptions. This patch mostly addresses that. And while it does NOT leave the project in otherwise working state, it does weed out most, if not all, of effects of previously incorrect assumptions, so it can be built the right way from here on forth. Signed-off-by: Gediminas Jakutis --- src/defs.h | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/defs.h') 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 { -- cgit v1.2.3