@@ -127,6 +127,7 @@ static term nif_erlang_float_to_list(Context *ctx, int argc, term argv[]);
127127static term nif_erlang_list_to_binary_1 (Context * ctx , int argc , term argv []);
128128static term nif_erlang_list_to_integer (Context * ctx , int argc , term argv []);
129129static term nif_erlang_list_to_float_1 (Context * ctx , int argc , term argv []);
130+ static term nif_erlang_monotonic_time_0 (Context * ctx , int argc , term argv []);
130131static term nif_erlang_monotonic_time_1 (Context * ctx , int argc , term argv []);
131132static term nif_erlang_iolist_size_1 (Context * ctx , int argc , term argv []);
132133static term nif_erlang_iolist_to_binary_1 (Context * ctx , int argc , term argv []);
@@ -499,7 +500,13 @@ static const struct Nif concat_nif =
499500 .nif_ptr = nif_erlang_concat_2
500501};
501502
502- static const struct Nif monotonic_time_nif =
503+ static const struct Nif monotonic_time_0_nif =
504+ {
505+ .base .type = NIFFunctionType ,
506+ .nif_ptr = nif_erlang_monotonic_time_0
507+ };
508+
509+ static const struct Nif monotonic_time_1_nif =
503510{
504511 .base .type = NIFFunctionType ,
505512 .nif_ptr = nif_erlang_monotonic_time_1
@@ -1626,6 +1633,18 @@ term nif_erlang_make_ref_0(Context *ctx, int argc, term argv[])
16261633 return term_from_ref_ticks (ref_ticks , & ctx -> heap );
16271634}
16281635
1636+ term nif_erlang_monotonic_time_0 (Context * ctx , int argc , term argv [])
1637+ {
1638+ UNUSED (argc );
1639+ UNUSED (argv );
1640+
1641+ struct timespec ts ;
1642+ sys_monotonic_time (& ts );
1643+
1644+ // Return nanoseconds as the native unit
1645+ return make_maybe_boxed_int64 (ctx , ((int64_t ) ts .tv_sec ) * 1000000000UL + ts .tv_nsec );
1646+ }
1647+
16291648term nif_erlang_monotonic_time_1 (Context * ctx , int argc , term argv [])
16301649{
16311650 UNUSED (ctx );
0 commit comments