aca9d5bc40
* modframebuf: _mp_framebuf_p_t is not "really" a protocol, but the QSTR assignment caused problems when building as a dynamic module * modure: str_index_to_ptr is not in the natmod API, disable URE match spans when dynamic. mp_obj_len() is a bugfix, we should throw here if the object is not string-like * moduzlib: Correct paths to uzlib headers & sources. this relative path (from moduzlib.c to the referenced file) works in all cases, the other only worked from ports/PORTNAME. * dynruntime: Handle 2-arg m_malloc, assert_native_inited, add a micropythonish mp_arg_check_num_mp, fix mp_raise_msg to use dumb strings, add mp_raise_arg1 * nativeglue: ad assert_native_inited * translate: MP_ERROR_TEXT evaluates to its argument for DYNRUNTIME * mpy-tool: A straggling magic number change * mpy_ld: Have to renumber manually after dynruntime change * import_mpy_native_gc.py: Update copy of features0 baked into this test
34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
#define MICROPY_PY_URANDOM (1)
|
|
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
|
|
|
|
#include "py/dynruntime.h"
|
|
|
|
// Dynamic native modules don't support a data section so these must go in the BSS
|
|
uint32_t yasmarang_pad, yasmarang_n, yasmarang_d;
|
|
uint8_t yasmarang_dat;
|
|
|
|
#include "extmod/modurandom.c"
|
|
|
|
mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) {
|
|
MP_DYNRUNTIME_INIT_ENTRY
|
|
|
|
yasmarang_pad = 0xeda4baba;
|
|
yasmarang_n = 69;
|
|
yasmarang_d = 233;
|
|
|
|
mp_store_global(MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR_urandom));
|
|
mp_store_global(MP_QSTR_getrandbits, MP_OBJ_FROM_PTR(&mod_urandom_getrandbits_obj));
|
|
mp_store_global(MP_QSTR_seed, MP_OBJ_FROM_PTR(&mod_urandom_seed_obj));
|
|
#if MICROPY_PY_URANDOM_EXTRA_FUNCS
|
|
mp_store_global(MP_QSTR_randrange, MP_OBJ_FROM_PTR(&mod_urandom_randrange_obj));
|
|
mp_store_global(MP_QSTR_randint, MP_OBJ_FROM_PTR(&mod_urandom_randint_obj));
|
|
mp_store_global(MP_QSTR_choice, MP_OBJ_FROM_PTR(&mod_urandom_choice_obj));
|
|
#if MICROPY_PY_BUILTINS_FLOAT
|
|
mp_store_global(MP_QSTR_random, MP_OBJ_FROM_PTR(&mod_urandom_random_obj));
|
|
mp_store_global(MP_QSTR_uniform, MP_OBJ_FROM_PTR(&mod_urandom_uniform_obj));
|
|
#endif
|
|
#endif
|
|
|
|
MP_DYNRUNTIME_INIT_EXIT
|
|
}
|