From 61c3a9aa7a636ada2cedd5b6025d5c7ccc598c85 Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Tue, 10 Mar 2020 10:15:53 +0200 Subject: bolt on data generation, kind of. Signed-off-by: Gediminas Jakutis --- src/defs.h | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/defs.h') 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 */ -- cgit v1.2.3