Support integer parts-per-second time unit#2227
Conversation
dad612d to
1f640b2
Compare
0303a59 to
4dff77a
Compare
4dff77a to
b5006b8
Compare
b5006b8 to
fe55a5f
Compare
bettio
left a comment
There was a problem hiding this comment.
tests are not working on the BEAM, let's fix this first.
log from run-tests:
datetime:OK
Raised {badmatch,fail}, stacktrace:
[{test_system_time,test_bad_integer_unit_universal_time,0,
[{file,"/__w/AtomVM/AtomVM/tests/erlang_tests/test_system_time.erl"},
{line,259}]},
{test_system_time,start,0,
[{file,"/__w/AtomVM/AtomVM/tests/erlang_tests/test_system_time.erl"},
{line,45}]},
{erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,915}]},
{erl_eval,try_clauses,10,[{file,"erl_eval.erl"},{line,1233}]},
{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,663}]},
{erl_eval,exprs,6,[{file,"erl_eval.erl"},{line,271}]},
{init,start_it,1,[]},
{init,start_em,1,[]}]
test_system_time:
test_system_time:FAILED
|
thank you, shall blame the CI blunder on it being backed up;-) let me know if a squash is needed. |
f713183 to
c817ad6
Compare
|
AMP, all fixed: PR Review — Integer parts-per-second time units & calendar hardeningReviewed commits (oldest → newest):
Scope: adds positive integer ("parts per second") time units to VerdictSolid work. The overflow math and floor-division semantics are correct under the documented Findings1. (Bug, low-frequency / UB) Negative year can reach
|
bettio
left a comment
There was a problem hiding this comment.
Just a couple of minor fixes. Feel free to cleanup PR history and push it for merge.
4c19344 to
df30d10
Compare
b52198f to
69a2fdd
Compare
…bounds - Add support for integer parts-per-second time units (e.g. 1_000_000 for microseconds) - Refactor time-unit conversion into shared helper functions - Harden calendar and integer time unit conversion bounds - Fix input validation and negative rounding in calendar:system_time_to_universal_time/2 - Ensure BEAM compatibility for monotonic_time and system_time tests - Use AVM_INT range for calendar year and add year boundary tests Signed-off-by: Peter M <petermm@gmail.com>
69a2fdd to
b751fb0
Compare
Add support for positive integer time units ("parts per second") in erlang:monotonic_time/1, erlang:system_time/1, and calendar:system_time_to_universal_time/2.
Used in elixir DynamicSupervisor - completes the timeunit support.
Restrict integer-unit handling to int64 inputs in the affected NIF paths. Use checked int64 decomposition for monotonic/system time conversion to avoid signed overflow in intermediate arithmetic. For calendar integer units, floor negative fractional values to whole seconds before converting to UTC.
Add focused Erlang tests for integer-unit parity, badarg on non-positive integer units, and negative fractional calendar conversion for integer units.
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