From 5a4b68ab3fad98b8cc685944280296e216055490 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 5 Nov 2021 06:14:41 +0000 Subject: [PATCH] Started implementing next for arrays. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Major version bump: `struct rng_next_opt` ABI break. Fortune for rngxx's current commit: Middle blessing − 中吉 --- Makefile | 4 ++-- include/rngxx.h | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 57cfc70..3c1c84c 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ PROJECT=rngxx AUTHOR=Avril (Flanchan) -VERSION_MAJOR=0 -VERSION_MINOR=3 +VERSION_MAJOR=1 +VERSION_MINOR=0 VERSION=$(VERSION_MAJOR).$(VERSION_MINOR) ifeq ($(PREFIX),) diff --git a/include/rngxx.h b/include/rngxx.h index b5ef735..b152d50 100644 --- a/include/rngxx.h +++ b/include/rngxx.h @@ -29,7 +29,8 @@ enum rng_next_flag { RNG_TYQ_UNSIGNED = 1 << 0, RNG_TYQ_CHAOS = 1 << 1, -}; // 2 bits + RNG_TYQ_ARRAY = 1 << 2, +}; // 3 bits typedef int rng_bool_t; @@ -60,9 +61,15 @@ struct rng_next_opt { struct { enum rng_next_type type : 4; - enum rng_next_flag mod : 2; - uint8_t _unused : 2; - } ty; // 8 bits + enum rng_next_flag mod : 3; + uint8_t _unused0 : 1; + //first byte + + uint32_t _padding : 24; + } ty; // 32 bits :/ + union { + uint32_t array_size; //TODO: Implement next for arrays + } ex; // 32 bits. fills hole }; typedef __typeof( ((struct rng_next_opt*)NULL)->ty ) rng_next_tyq; // Qualified type @@ -74,6 +81,9 @@ typedef struct rng_dyn_ctor* rng_dyn_ctor_ref; // -- // -- #ifndef _RNGXX_IMPL_ONLY_TYPES +_Static_assert(sizeof(rng_next_tyq) == sizeof(uint32_t)); +_Static_assert(sizeof( ((struct rng_next_opt*)NULL)->ex ) == sizeof(uint32_t)); + // -- C API functions -- (C++ NO compat) int rng_raw(rng_t* engine, void* restrict output, struct rng_next_opt opt);