build: add some build options to customise library functionality
This commit is contained in:
@@ -217,6 +217,7 @@ static uint64_t genrand64_int64(struct fx_random_ctx *context)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FX_ENABLE_FLOATING_POINT == 1
|
||||
/* generates a random number on [0,1]-real-interval */
|
||||
double genrand64_real1(struct fx_random_ctx *context)
|
||||
{
|
||||
@@ -235,6 +236,7 @@ double genrand64_real3(struct fx_random_ctx *context)
|
||||
return ((genrand64_int64(context) >> 12) + 0.5)
|
||||
* (1.0 / 4503599627370496.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct fx_random_algorithm z__fx_gen_mt19937 = {
|
||||
.gen_name = "mt19937",
|
||||
|
||||
@@ -45,6 +45,11 @@
|
||||
|
||||
#include "printf.h"
|
||||
|
||||
#if FX_ENABLE_FLOATING_POINT == 0
|
||||
#define PRINTF_SUPPORT_DECIMAL_SPECIFIERS 0
|
||||
#define PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
|
||||
+4
-1
@@ -60,6 +60,7 @@ unsigned long long fx_random_next_int64(struct fx_random_ctx *ctx)
|
||||
return ctx->__a->gen_getrand(ctx);
|
||||
}
|
||||
|
||||
#if FX_ENABLE_FLOATING_POINT
|
||||
double fx_random_next_double(struct fx_random_ctx *ctx)
|
||||
{
|
||||
unsigned long long v = fx_random_next_int64(ctx);
|
||||
@@ -69,8 +70,10 @@ double fx_random_next_double(struct fx_random_ctx *ctx)
|
||||
|
||||
return (double)(v >> 11) * (1.0 / 9007199254740991.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void fx_random_next_bytes(struct fx_random_ctx *ctx, unsigned char *out, size_t nbytes)
|
||||
void fx_random_next_bytes(
|
||||
struct fx_random_ctx *ctx, unsigned char *out, size_t nbytes)
|
||||
{
|
||||
size_t n_qwords = 0;
|
||||
n_qwords = nbytes >> 3;
|
||||
|
||||
Reference in New Issue
Block a user