Skip to content

Commit f6d5d16

Browse files
committed
Forward port changes from v0.6 release branch
Merge fixes and minor changes from release-0.6 branch, such as: - CI: update macos version (gh deprecation) (#1837) - opcodesswitch: fix OP_BS_CREATE_BIN that can have an allocator list (1832) - Enable forgotten test bs_append_extra_words (#1831)
2 parents 68312ab + e639a37 commit f6d5d16

File tree

6 files changed

+31
-9
lines changed

6 files changed

+31
-9
lines changed

.github/workflows/build-and-test-macos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
strategy:
3939
fail-fast: false
4040
matrix:
41-
os: ["macos-13", "macos-14", "macos-15"]
41+
os: ["macos-14", "macos-15", "macos-15-intel", "macos-26"]
4242
otp: ["24", "25", "26", "27", "28"]
4343
cmake_opts_other: [""]
4444

src/libAtomVM/opcodesswitch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6731,7 +6731,7 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
67316731
uint32_t fail;
67326732
DECODE_LABEL(fail, pc);
67336733
uint32_t alloc;
6734-
DECODE_LITERAL(alloc, pc);
6734+
DECODE_ALLOCATOR_LIST(alloc, pc);
67356735
uint32_t live;
67366736
DECODE_LITERAL(live, pc);
67376737
uint32_t unit;

src/platforms/generic_unix/lib/sys.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,14 @@ Context *sys_create_port(GlobalContext *glb, const char *driver_name, term opts)
485485
#ifdef DYNLOAD_PORT_DRIVERS
486486
void *handle;
487487
{
488-
char port_driver_name[64 + strlen("avm_"
489-
"_port_driver.so")
490-
+ 1];
488+
char port_driver_name[64 + sizeof("avm_") - 1 + sizeof("_port_driver.so") - 1 + 1];
491489
snprintf(port_driver_name, sizeof(port_driver_name), "./avm_%s_port_driver.so", driver_name);
492490
handle = dlopen(port_driver_name, RTLD_NOW);
493491
if (!handle) {
494492
return NULL;
495493
}
496494
}
497-
char port_driver_func_name[64 + strlen("_create_port") + 1];
495+
char port_driver_func_name[64 + sizeof("_create_port") - 1 + 1];
498496
snprintf(port_driver_func_name, sizeof(port_driver_func_name), "%s_create_port", driver_name);
499497
create_port_t create_port
500498
= (create_port_t) CAST_VOID_TO_FUNC_PTR(dlsym(handle, port_driver_func_name));

tests/erlang_tests/test_op_bs_create_bin.erl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ start() ->
3838
ok = test_bs_create_bin_utf16(),
3939
ok = test_bs_create_bin_utf32(),
4040
ok = test_bs_create_bin_integer(),
41-
ok = test_bs_create_bin_binary();
41+
ok = test_bs_create_bin_binary(),
42+
ok = test_bs_create_bin_alloc_list();
4243
true ->
4344
ok
4445
end,
@@ -266,3 +267,15 @@ test_bs_create_bin_binary() ->
266267
error:badarg -> unexpected
267268
end,
268269
ok.
270+
271+
test_bs_create_bin_alloc_list() ->
272+
%% Test that bs_create_bin with allocator list works correctly
273+
%% Expected result: <<0,0,0,42>> (42 as 32-bit big-endian integer)
274+
Expected = <<0, 0, 0, 42>>,
275+
Result = test_op_bs_create_bin_asm:bs_create_bin_alloc_list(42),
276+
case Result of
277+
Expected ->
278+
ok;
279+
_ ->
280+
error({unexpected_result, Result, expected, Expected})
281+
end.

tests/erlang_tests/test_op_bs_create_bin_asm.S

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
{bs_create_bin_integer_no_fail, 3},
3232
{bs_create_bin_integer_fail, 3},
3333
{bs_create_bin_binary_no_fail, 3},
34-
{bs_create_bin_binary_fail, 3}
34+
{bs_create_bin_binary_fail, 3},
35+
{bs_create_bin_alloc_list, 1}
3536
]}.
3637

3738
{attributes, []}.
3839

39-
{labels, 26}.
40+
{labels, 28}.
4041

4142
{function, bs_create_bin_utf8_no_fail, 3, 2}.
4243
{label, 1}.
@@ -122,3 +123,12 @@ return.
122123
{label, 26}.
123124
{move, {atom, fail}, {x, 0}}.
124125
return.
126+
127+
{function, bs_create_bin_alloc_list, 1, 28}.
128+
{label, 27}.
129+
{func_info, {atom, test_op_bs_create_bin_asm}, {atom, bs_create_bin_alloc_list}, 1}.
130+
{label, 28}.
131+
%% Test bs_create_bin with allocator list instead of simple literal
132+
{bs_create_bin, {f, 0}, {alloc, [{words, 2}, {floats, 1}, {funs, 1}]}, 1, 1, {x, 0},
133+
{list, [{atom, integer}, 1, 1, nil, {x, 0}, {integer, 32}]}}.
134+
return.

tests/test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ struct Test tests[] = {
410410
TEST_CASE(test_bs_int_unaligned),
411411
TEST_CASE(test_bs_start_match_live),
412412
TEST_CASE(test_bs_utf),
413+
TEST_CASE_EXPECTED(bs_append_extra_words, 1),
413414
TEST_CASE(test_catch),
414415
TEST_CASE(test_gc),
415416
TEST_CASE_EXPECTED(test_raise, 7),

0 commit comments

Comments
 (0)