Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
1434-erts-Accept-native-time-unit-where-documen...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1434-erts-Accept-native-time-unit-where-documented-as-sup.patch of Package erlang
From 1867cff4efc3652b31b051ec84ce667b6aece3a1 Mon Sep 17 00:00:00 2001 From: Rickard Green <rickard@erlang.org> Date: Thu, 11 Aug 2022 00:51:47 +0200 Subject: [PATCH] [erts] Accept native time unit where documented as supported Fixes erlang:monotonic_time(native), erlang:system_time(native), erlang:time_offset(native), and os:system_time(native). --- erts/emulator/beam/erl_time_sup.c | 4 +++ erts/emulator/test/time_SUITE.erl | 41 +++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/erts/emulator/beam/erl_time_sup.c b/erts/emulator/beam/erl_time_sup.c index d26ea19494..56a8fa369a 100644 --- a/erts/emulator/beam/erl_time_sup.c +++ b/erts/emulator/beam/erl_time_sup.c @@ -2178,6 +2178,10 @@ time_unit_conversion(Process *c_p, Eterm term, ErtsMonotonicTime val, ErtsMonoto /* Convert to common user specified time units */ switch (term) { + case am_native: + result = val + muloff*ERTS_MONOTONIC_OFFSET_NATIVE; + ERTS_BIF_PREP_RET(ret, make_time_val(c_p, result)); + break; case am_second: case am_seconds: case make_small(1): diff --git a/erts/emulator/test/time_SUITE.erl b/erts/emulator/test/time_SUITE.erl index e01efac86b..6e643fdcbe 100644 --- a/erts/emulator/test/time_SUITE.erl +++ b/erts/emulator/test/time_SUITE.erl @@ -42,7 +42,8 @@ monotonic_time_monotonicity_parallel/1, time_unit_conversion/1, signed_time_unit_conversion/1, - erlang_timestamp/1]). + erlang_timestamp/1, + native_time_unit_gh6165/1]). -export([init_per_testcase/2, end_per_testcase/2]). @@ -85,7 +86,8 @@ all() -> monotonic_time_monotonicity_parallel, time_unit_conversion, signed_time_unit_conversion, - erlang_timestamp]. + erlang_timestamp, + native_time_unit_gh6165]. groups() -> [{now, [], [now_unique, now_update]}]. @@ -857,6 +859,41 @@ process_changed_time_offset(Mon, TO, Changed, Wait) -> end. +native_time_unit_gh6165(Config) when is_list(Config) -> + %% This test could potentially fail even when no bug exists if + %% run during heavy load, or if OS system time or Erlang system time + %% is changed at an unfortunate time, but it is hard to make the test + %% more stable than this without losing actual testing... + + ChkDiff = fun (Val) -> + case erlang:convert_time_unit(Val, native, nanosecond) of + Ns when -1000000 < Ns andalso Ns < 1000000 -> + erlang:display({diff, Ns}), + ok; + Ns -> + erlang:display({large_diff, Ns}), + ct:fail({large_diff, Ns}) + end + end, + + process_flag(priority, max), + + erlang:yield(), + V1 = erlang:monotonic_time(native) - erlang:monotonic_time(), + ChkDiff(V1), + + erlang:yield(), + V2 = erlang:system_time(native) - erlang:system_time(), + ChkDiff(V2), + + erlang:yield(), + V3 = os:system_time(native) - os:system_time(), + ChkDiff(V3), + + erlang:yield(), + 0 = erlang:time_offset() - erlang:time_offset(native), + + ok. %% Returns the test data: a list of {Utc, Local} tuples. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor