meta: rename to fx

This commit is contained in:
2026-03-16 10:35:43 +00:00
parent 84df46489a
commit e9d0e323f0
233 changed files with 12875 additions and 12869 deletions

View File

@@ -1,24 +1,24 @@
#include "random.h"
#include <blue/core/random.h>
#include <fx/core/random.h>
#define GET_ALGORITHM_ID(flags) ((flags) & 0xFF)
BLUE_API struct b_random_algorithm z__b_gen_mt19937;
FX_API struct fx_random_algorithm z__fx_gen_mt19937;
static struct b_random_algorithm *generators[] = {
[B_RANDOM_MT19937] = &z__b_gen_mt19937,
static struct fx_random_algorithm *generators[] = {
[FX_RANDOM_MT19937] = &z__fx_gen_mt19937,
};
static size_t nr_generators = sizeof generators / sizeof generators[0];
static struct b_random_ctx g_global_ctx = {0};
static struct fx_random_ctx g_global_ctx = {0};
static void init_global_ctx(void)
{
b_random_init(&g_global_ctx, B_RANDOM_MT19937);
fx_random_init(&g_global_ctx, FX_RANDOM_MT19937);
}
struct b_random_ctx *b_random_global_ctx(void)
struct fx_random_ctx *fx_random_global_ctx(void)
{
if (!g_global_ctx.__f) {
init_global_ctx();
@@ -27,31 +27,31 @@ struct b_random_ctx *b_random_global_ctx(void)
return &g_global_ctx;
}
b_status b_random_init(struct b_random_ctx *ctx, b_random_flags flags)
fx_status fx_random_init(struct fx_random_ctx *ctx, fx_random_flags flags)
{
unsigned int algorithm_id = GET_ALGORITHM_ID(flags);
if (algorithm_id >= nr_generators || !generators[algorithm_id]) {
return B_ERR_INVALID_ARGUMENT;
return FX_ERR_INVALID_ARGUMENT;
}
struct b_random_algorithm *algorithm = generators[algorithm_id];
struct fx_random_algorithm *algorithm = generators[algorithm_id];
ctx->__f = flags;
ctx->__a = algorithm;
unsigned long long seed;
if (flags & B_RANDOM_SECURE) {
seed = z__b_platform_random_seed_secure();
if (flags & FX_RANDOM_SECURE) {
seed = z__fx_platform_random_seed_secure();
} else {
seed = z__b_platform_random_seed();
seed = z__fx_platform_random_seed();
}
algorithm->gen_init(ctx, seed);
return B_SUCCESS;
return FX_SUCCESS;
}
unsigned long long b_random_next_int64(struct b_random_ctx *ctx)
unsigned long long fx_random_next_int64(struct fx_random_ctx *ctx)
{
if (!ctx->__a || !ctx->__a->gen_getrand) {
return 0;
@@ -60,9 +60,9 @@ unsigned long long b_random_next_int64(struct b_random_ctx *ctx)
return ctx->__a->gen_getrand(ctx);
}
double b_random_next_double(struct b_random_ctx *ctx)
double fx_random_next_double(struct fx_random_ctx *ctx)
{
unsigned long long v = b_random_next_int64(ctx);
unsigned long long v = fx_random_next_int64(ctx);
if (!v) {
return 0.0;
}
@@ -70,7 +70,7 @@ double b_random_next_double(struct b_random_ctx *ctx)
return (double)(v >> 11) * (1.0 / 9007199254740991.0);
}
void b_random_next_bytes(struct b_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;
@@ -82,7 +82,7 @@ void b_random_next_bytes(struct b_random_ctx *ctx, unsigned char *out, size_t nb
size_t bytes_written = 0;
for (size_t i = 0; i < n_qwords; i++) {
uint64_t *dest = (uint64_t *)&out[bytes_written];
*dest = b_random_next_int64(ctx);
*dest = fx_random_next_int64(ctx);
bytes_written += 8;
}
@@ -90,7 +90,7 @@ void b_random_next_bytes(struct b_random_ctx *ctx, unsigned char *out, size_t nb
return;
}
uint64_t padding = b_random_next_int64(ctx);
uint64_t padding = fx_random_next_int64(ctx);
unsigned char *padding_bytes = (unsigned char *)&padding;
for (size_t i = 0; i < 8; i++) {