Skip to content

Commit 93c6a97

Browse files
committed
Merge pull request #1768 from pguyot/w29/implement-nif_error-1
Implement `erlang:nif_error/1` These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 1459fbb + f3c35db commit 93c6a97

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/libAtomVM/nifs.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ static term nif_base64_decode_to_string(Context *ctx, int argc, term argv[]);
174174
static term nif_code_load_abs(Context *ctx, int argc, term argv[]);
175175
static term nif_code_load_binary(Context *ctx, int argc, term argv[]);
176176
static term nif_code_ensure_loaded(Context *ctx, int argc, term argv[]);
177+
static term nif_erlang_nif_error(Context *ctx, int argc, term argv[]);
177178
static term nif_lists_reverse(Context *ctx, int argc, term argv[]);
178179
static term nif_maps_from_keys(Context *ctx, int argc, term argv[]);
179180
static term nif_maps_next(Context *ctx, int argc, term argv[]);
@@ -715,6 +716,13 @@ static const struct Nif code_ensure_loaded_nif =
715716
.base.type = NIFFunctionType,
716717
.nif_ptr = nif_code_ensure_loaded
717718
};
719+
720+
static const struct Nif nif_error_nif =
721+
{
722+
.base.type = NIFFunctionType,
723+
.nif_ptr = nif_erlang_nif_error
724+
};
725+
718726
static const struct Nif lists_reverse_nif =
719727
{
720728
.base.type = NIFFunctionType,
@@ -4595,6 +4603,14 @@ static term nif_code_ensure_loaded(Context *ctx, int argc, term argv[])
45954603
return result;
45964604
}
45974605

4606+
static term nif_erlang_nif_error(Context *ctx, int argc, term argv[])
4607+
{
4608+
UNUSED(argc);
4609+
UNUSED(argv);
4610+
4611+
RAISE_ERROR(UNDEF_ATOM);
4612+
}
4613+
45984614
static term nif_lists_reverse(Context *ctx, int argc, term argv[])
45994615
{
46004616
// Compared to erlang version, compute the length of the list and allocate

src/libAtomVM/nifs.gperf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ erlang:group_leader/0, &group_leader_nif
126126
erlang:group_leader/2, &group_leader_nif
127127
erlang:get_module_info/1, &get_module_info_nif
128128
erlang:get_module_info/2, &get_module_info_nif
129+
erlang:nif_error/1,&nif_error_nif
129130
erts_debug:flat_size/1, &flat_size_nif
130131
atomvm:add_avm_pack_binary/2, &atomvm_add_avm_pack_binary_nif
131132
atomvm:add_avm_pack_file/2, &atomvm_add_avm_pack_file_nif

0 commit comments

Comments
 (0)