From: Kevin Day Date: Tue, 2 Jan 2024 00:25:12 +0000 (-0600) Subject: Update: Add custom defines for the random seed macros via random/common.h. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=6a6be39e3b7f530b1bd0246bf407ae2b96b97ae5;p=fll Update: Add custom defines for the random seed macros via random/common.h. I try to avoid the direct use of core/standard macros like GRND_NONBLOCK. Add f_random specific macros for these GRND_* macros. --- diff --git a/build/level_0/settings b/build/level_0/settings index 140879c..c870f37 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -105,7 +105,7 @@ build_sources_headers parse.h parse/utf.h build_sources_headers path.h path/common.h build_sources_headers pipe.h build_sources_headers print.h print/to.h print/common.h -build_sources_headers random.h +build_sources_headers random.h random/common.h build_sources_headers rip.h rip/utf.h build_sources_headers serialize.h serialize/common.h build_sources_headers signal.h signal/common.h diff --git a/build/monolithic/settings b/build/monolithic/settings index ded3fc9..fb943cf 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -126,7 +126,7 @@ build_sources_headers level_0/parse.h level_0/parse/utf.h build_sources_headers level_0/path.h level_0/path/common.h build_sources_headers level_0/pipe.h build_sources_headers level_0/print.h level_0/print/to.h level_0/print/common.h -build_sources_headers level_0/random.h +build_sources_headers level_0/random.h level_0/random/common.h build_sources_headers level_0/rip.h level_0/rip/utf.h build_sources_headers level_0/serialize.h level_0/serialize/common.h build_sources_headers level_0/signal.h level_0/signal/common.h diff --git a/level_0/f_random/c/random.h b/level_0/f_random/c/random.h index f58f739..cdb7c99 100644 --- a/level_0/f_random/c/random.h +++ b/level_0/f_random/c/random.h @@ -21,6 +21,9 @@ #include #include +// FLL-0 random includes. +#include + #ifdef __cplusplus extern "C" { #endif @@ -62,8 +65,8 @@ extern "C" { * The flags to be passed to getrandom(). * * Flag bits: - * - GRND_RANDOM: Random data is taken from the random source, such as /dev/random and not the urandom source. - * - GRND_NONBLOCK: Does not block when getting the bits. + * - F_random_seed_flag_block_not_d: Does not block when getting the bits. + * - F_random_seed_flag_source_d: Random data is taken from the random source, such as /dev/random and not the urandom source. * @param length * The size within the destination string to copy. * The standard max size is 255. @@ -108,8 +111,8 @@ extern "C" { * The flags to be passed to getrandom(). * * Flag bits: - * - GRND_RANDOM: Random data is taken from the random source, such as /dev/random and not the urandom source. - * - GRND_NONBLOCK: Does not block when getting the bits. + * - F_random_seed_flag_block_not_d: Does not block when getting the bits. + * - F_random_seed_flag_source_d: Random data is taken from the random source, such as /dev/random and not the urandom source. * * @return * F_okay on success. diff --git a/level_0/f_random/c/random/common.h b/level_0/f_random/c/random/common.h new file mode 100644 index 0000000..9431477 --- /dev/null +++ b/level_0/f_random/c/random/common.h @@ -0,0 +1,42 @@ +/** + * FLL - Level 0 + * + * Project: Random + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines common data to be used for/by project random. + * + * This is auto-included by random.h and should not need to be explicitly included. + */ +#ifndef _F_random_common_h +#define _F_random_common_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Defines associated with random seed flags. + * + * F_random_seed_flag_*: + * - block_not: Does not block when getting the bits. + * - insecure: Use insecure, aka non-cryptographic, random bytes. + * - source: Random data is taken from the random source, such as /dev/random and not the urandom source. + */ +#ifndef _di_f_random_seed_flag_d_ + #define F_random_seed_flag_block_not_d GRND_NONBLOCK + #define F_random_seed_flag_source_d GRND_RANDOM + + #ifdef GRND_INSECURE + #define F_random_seed_flag_insecure_d GRND_INSECURE + #else + #define F_random_seed_flag_insecure_d 0x0004 + #endif // GRND_INSECURE +#endif // _di_f_random_seed_flag_d_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_random_common_h diff --git a/level_0/f_random/data/build/settings b/level_0/f_random/data/build/settings index b9bb7f8..d4f56f4 100644 --- a/level_0/f_random/data/build/settings +++ b/level_0/f_random/data/build/settings @@ -34,7 +34,7 @@ build_libraries-individual -lf_memory -lf_string build_sources_library random.c -build_sources_headers random.h +build_sources_headers random.h random/common.h build_script yes build_shared yes diff --git a/level_0/f_random/data/build/settings-mocks b/level_0/f_random/data/build/settings-mocks index 9548555..4ee4533 100644 --- a/level_0/f_random/data/build/settings-mocks +++ b/level_0/f_random/data/build/settings-mocks @@ -23,7 +23,7 @@ build_libraries-individual -lf_memory build_sources_library random.c build_sources_library ../../tests/unit/c/mock-random.c -build_sources_headers random.h +build_sources_headers random.h random/common.h build_script yes build_shared yes