Use bitfields for ty + tyflag in struct for `rng_next()` options. Fortune for rngxx's current commit: Middle blessing − 中吉capi
parent
af095e2a41
commit
fc70397536
@ -1,11 +1,22 @@
|
|||||||
// Contains the library exported C API functions.
|
// Contains the library exported C API functions.
|
||||||
// Actual work may be done in `capi-bridge.cpp`, `capi-bridge.h` bridges this shim TU with that working one
|
// Actual work may be done in `capi-bridge.cpp`, `capi-bridge.h` bridges this shim TU with that working one
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
#include <rngxx.h>
|
#include <rngxx.h>
|
||||||
|
|
||||||
#include "capi-bridge.h"
|
#include "capi-bridge.h"
|
||||||
|
|
||||||
|
#define assert_not_null(expr, ...) ({ __auto_type _nn__expr = (expr); \
|
||||||
|
if(UNLIKELY(_nn__expr == NULL)) { fprintf(stderr, "fatal (unexpected null pointer): " __VA_ARGS__); abort(); } \
|
||||||
|
_nn__expr; })
|
||||||
|
|
||||||
rng_t* rng_new(enum rng_kind kind, u64 seed[static restrict 1])
|
rng_t* rng_new(enum rng_kind kind, u64 seed[static restrict 1])
|
||||||
{
|
{
|
||||||
return RNG_IMPL(mkdriver) (kind, &seed[0]);
|
return assert_not_null(RNG_IMPL(mkdriver) (kind, &seed[0]), "invalid kind %d", (int)kind);
|
||||||
}
|
}
|
||||||
|
// void rng_free() - direct bridge
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in new issue