From 322193f14a6213b60263296ed82a9e25b0575b54 Mon Sep 17 00:00:00 2001 From: Avril Date: Wed, 19 May 2021 00:24:24 +0100 Subject: [PATCH] added back comments --- src/bits.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bits.c b/src/bits.c index e733961..5855f5a 100644 --- a/src/bits.c +++ b/src/bits.c @@ -15,6 +15,9 @@ #define LIF(ex) if(LIKELY(!!(ex))) #define UIF(ex) if(UNLIKELY(!!(ex))) +//TODO: For explicitly threaded version: Make a lazy thread spawner, spawning up to 8 threads which will each work on a byte and atomically write back to a central array of `uint64_t [num_of_bytes / num_of_threads]`. +//TODO: But how to sync the fwrites of this buffer? An atomic counter of which threads have completed their operations, and a condvar that allows the controlling thread to check if the counter is full before `fwrite_all()`ing the array, resetting the counter, and carrying on + static inline int sfread(void* out, size_t *restrict size, FILE* f) { register ssize_t r = fread(out, 1, *size, f); @@ -30,9 +33,10 @@ static int fwrite_all(const void* _buf, size_t sz, size_t num, FILE* out) else return 1; } -static inline void pbits(char out[restrict 8], unsigned char byte, const char bit[static 2]) +static void pbits(char out[restrict 8], unsigned char byte, const char bit[static 2]) { for(register int i=8; i --> 0; byte >>= 1) *out++=bit[byte & 1]; + //TODO: In explicitly threaded version, we can use an atomic (atomic.h) 64-bit integer `store()` to output those 8 bytes in `out`, which will be re-cast as `uint64_t out[restrict 1]` } // Light assertion (likely to succeed)