Berry update from upstream (#23159)

This commit is contained in:
s-hadinger 2025-03-17 08:27:03 +01:00 committed by GitHub
parent e1f7ee26fa
commit ce92723c41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 5 deletions

View File

@ -354,9 +354,6 @@ const bntvmodule_t be_native_module(_module) = { \
#else
// #define be_define_const_bytes(_name, ...) \
// const uint8_t be_const_bin_##_name[] = { __VA_ARGS__ }
#define be_define_const_str_weak(_name, _s, _len) \
const bcstring be_const_str_##_name = { \
NULL, \

View File

@ -234,7 +234,9 @@ int be_nfunc_open(bvm *vm)
{ "flush", i_flush },
{ "close", i_close },
{ "deinit", i_close },
#if BE_USE_BYTECODE_SAVER
{ "savecode", i_savecode },
#endif
{ NULL, NULL }
};
fname = argc >= 1 && be_isstring(vm, 1) ? be_tostring(vm, 1) : NULL;

View File

@ -40,10 +40,15 @@
#elif defined(_MSC_VER)
#define popcount(v) __popcnt(v)
// Find a free slot in the space bitmask
// Find the least significant 1-bit in x and return its 1-based index.
static int ffs(unsigned x)
{
unsigned long i;
return _BitScanForward(&i, x) ? i : 0;
// NOTE: _BitScanForward is 0-based, see:
// https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64?view=msvc-170
// _BitScanForward(&index, 12) populates index with 2
return _BitScanForward(&i, x) ? i + 1 : 0;
}
#else
/* https://github.com/hcs0/Hackers-Delight/blob/master/pop.c.txt - count number of 1-bits */

View File

@ -324,8 +324,8 @@ static void end_func(bparser *parser)
proto->codesize = finfo->pc;
proto->ktab = be_vector_release(vm, &finfo->kvec);
proto->nconst = be_vector_count(&finfo->kvec);
proto->nproto = be_vector_count(&finfo->pvec);
proto->ptab = be_vector_release(vm, &finfo->pvec);
proto->nproto = be_vector_count(&finfo->pvec);
#if BE_USE_MEM_ALIGNED
proto->code = be_move_to_aligned(vm, proto->code, proto->codesize * sizeof(binstruction)); /* move `code` to 4-bytes aligned memory region */
proto->ktab = be_move_to_aligned(vm, proto->ktab, proto->nconst * sizeof(bvalue)); /* move `ktab` to 4-bytes aligned memory region */