From 412b5aaa5810cbac75ef41d29a36898ff1480129 Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Wed, 24 Aug 2016 11:46:34 +0200 Subject: Replace misspelled symbolic time units Besides using two words for 'milliseconds' et. al. they are also changed from plural to singular. --- erts/doc/src/erlang.xml | 53 ++++++++++++++++++++++++++++---------- erts/emulator/beam/atom.names | 4 +++ erts/emulator/beam/erl_time_sup.c | 6 ++++- erts/example/time_compat.erl | 4 +++ erts/preloaded/ebin/erlang.beam | Bin 104816 -> 105100 bytes erts/preloaded/src/erlang.erl | 31 +++++++++++++++++++--- 6 files changed, 79 insertions(+), 19 deletions(-) (limited to 'erts') diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index 6289f033b2..e06ad461d8 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -70,26 +70,26 @@ -

- Supported time unit representations:

+ +

Supported time unit representations:

PartsPerSecond :: integer() >= 1

Time unit expressed in parts per second. That is, the time unit equals 1/PartsPerSecond second.

- seconds + second

Symbolic representation of the time unit represented by the integer 1.

- milli_seconds + millisecond

Symbolic representation of the time unit represented by the integer 1000.

- micro_seconds + microsecond

Symbolic representation of the time unit represented by the integer 1000000.

- nano_seconds + nanosecond

Symbolic representation of the time unit represented by the integer 1000000000.

@@ -108,7 +108,7 @@

One can get an approximation of the native time unit by calling erlang:convert_time_unit(1, - seconds, native). The result equals the number + second, native). The result equals the number of whole native time units per second. In case the number of native time units per second does not add up to a whole number, the result is rounded downwards.

@@ -138,8 +138,12 @@ as the native time unit. That is it might differ inbetween run-time restarts. You get values of this type by calling os:perf_counter() -

- +

+ + deprecated_time_unit() +

+ Deprecated symbolic representations kept for backwards-compatibility. +

@@ -149,6 +153,27 @@
+ + + +

The time_unit() + type also consist of the following deprecated symbolic + time units:

+ + seconds +

Same as second.

+ + milli_seconds +

Same as millisecond.

+ + micro_seconds +

Same as microsecond.

+ + nano_seconds +

Same as nanosecond.

+
+
+
@@ -8284,7 +8309,7 @@ ok Erlang monotonic time. The time-stamp (Ts) has the same format and value as produced by - erlang:monotonic_time(nano_seconds).

+ erlang:monotonic_time(nanosecond).

runnable_procs @@ -8312,7 +8337,7 @@ ok Erlang monotonic time and a monotonically increasing integer. The time-stamp (Ts) has the same format and value - as produced by {erlang:monotonic_time(nano_seconds), + as produced by {erlang:monotonic_time(nanosecond), erlang:unique_integer([monotonic])}.

timestamp @@ -8525,7 +8550,7 @@ ok

The erlang:timestamp() BIF is equivalent to:

timestamp() -> - ErlangSystemTime = erlang:system_time(micro_seconds), + ErlangSystemTime = erlang:system_time(microsecond), MegaSecs = ErlangSystemTime div 1000000000000, Secs = ErlangSystemTime div 1000000 - MegaSecs*1000000, MicroSecs = ErlangSystemTime rem 1000000, @@ -8762,7 +8787,7 @@ timestamp() -> Erlang monotonic time time-stamp in all trace messages. The time-stamp (Ts) has the same format and value as produced by - erlang:monotonic_time(nano_seconds). + erlang:monotonic_time(nanosecond). This flag overrides the cpu_timestamp flag.

strict_monotonic_timestamp @@ -8772,7 +8797,7 @@ timestamp() -> monotonic time and a monotonically increasing integer in all trace messages. The time-stamp (Ts) has the same format and value as produced by - {erlang:monotonic_time(nano_seconds), + {erlang:monotonic_time(nanosecond), erlang:unique_integer([monotonic])}. This flag overrides the cpu_timestamp flag.

diff --git a/erts/emulator/beam/atom.names b/erts/emulator/beam/atom.names index badd69856e..263c7d4ac2 100644 --- a/erts/emulator/beam/atom.names +++ b/erts/emulator/beam/atom.names @@ -384,8 +384,10 @@ atom merge_trap atom meta atom meta_match_spec atom micro_seconds +atom microsecond atom microstate_accounting atom milli_seconds +atom millisecond atom min_heap_size atom min_bin_vheap_size atom minor_version @@ -402,6 +404,7 @@ atom more atom multi_scheduling atom multiline atom nano_seconds +atom nanosecond atom name atom named_table atom namelist @@ -554,6 +557,7 @@ atom schedulers_online atom scheme atom scientific atom scope +atom second atom seconds atom send_to_non_existing_process atom sensitive diff --git a/erts/emulator/beam/erl_time_sup.c b/erts/emulator/beam/erl_time_sup.c index 9e37106b88..6aa2a7500f 100644 --- a/erts/emulator/beam/erl_time_sup.c +++ b/erts/emulator/beam/erl_time_sup.c @@ -2133,22 +2133,26 @@ time_unit_conversion(Process *c_p, Eterm term, ErtsMonotonicTime val, ErtsMonoto /* Convert to common user specified time units */ switch (term) { + case am_second: case am_seconds: case make_small(1): result = ERTS_MONOTONIC_TO_SEC(val) + muloff*ERTS_MONOTONIC_OFFSET_SEC; ERTS_BIF_PREP_RET(ret, make_time_val(c_p, result)); break; + case am_millisecond: case am_milli_seconds: case make_small(1000): result = ERTS_MONOTONIC_TO_MSEC(val) + muloff*ERTS_MONOTONIC_OFFSET_MSEC; ERTS_BIF_PREP_RET(ret, make_time_val(c_p, result)); break; + case am_microsecond: case am_micro_seconds: case make_small(1000*1000): result = ERTS_MONOTONIC_TO_USEC(val) + muloff*ERTS_MONOTONIC_OFFSET_USEC; ERTS_BIF_PREP_RET(ret, make_time_val(c_p, result)); break; #ifdef ARCH_64 + case am_nanosecond: case am_nano_seconds: case make_small(1000*1000*1000): result = ERTS_MONOTONIC_TO_NSEC(val) + muloff*ERTS_MONOTONIC_OFFSET_NSEC; @@ -2159,7 +2163,7 @@ time_unit_conversion(Process *c_p, Eterm term, ErtsMonotonicTime val, ErtsMonoto Eterm value, native_res; #ifndef ARCH_64 Sint user_res; - if (term == am_nano_seconds) + if (term == am_nanosecond || term == am_nano_seconds) goto to_nano_seconds; if (term_to_Sint(term, &user_res)) { if (user_res == 1000*1000*1000) { diff --git a/erts/example/time_compat.erl b/erts/example/time_compat.erl index b87c6cc550..589781c8e8 100644 --- a/erts/example/time_compat.erl +++ b/erts/example/time_compat.erl @@ -272,6 +272,10 @@ system_flag(Flag, Value) -> %% integer_time_unit(native) -> 1000*1000; +integer_time_unit(nanosecond) -> 1000*1000*1000; +integer_time_unit(microsecond) -> 1000*1000; +integer_time_unit(millisecond) -> 1000; +integer_time_unit(second) -> 1; integer_time_unit(nano_seconds) -> 1000*1000*1000; integer_time_unit(micro_seconds) -> 1000*1000; integer_time_unit(milli_seconds) -> 1000; diff --git a/erts/preloaded/ebin/erlang.beam b/erts/preloaded/ebin/erlang.beam index b62da04bfd..c68debeabc 100644 Binary files a/erts/preloaded/ebin/erlang.beam and b/erts/preloaded/ebin/erlang.beam differ diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index edf79b8f75..652a954807 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -59,6 +59,7 @@ -export_type([timestamp/0]). -export_type([time_unit/0]). +-export_type([deprecated_time_unit/0]). -type ext_binary() :: binary(). -type timestamp() :: {MegaSecs :: non_neg_integer(), @@ -67,12 +68,20 @@ -type time_unit() :: pos_integer() - | 'seconds' + | 'second' + | 'millisecond' + | 'microsecond' + | 'nanosecond' + | 'native' + | 'perf_counter' + | deprecated_time_unit(). + +%% Deprecated symbolic units... +-type deprecated_time_unit() :: + 'seconds' | 'milli_seconds' | 'micro_seconds' - | 'nano_seconds' - | 'native' - | 'perf_counter'. + | 'nano_seconds'. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Native code BIF stubs and their types @@ -1365,19 +1374,33 @@ convert_time_unit(Time, FromUnit, ToUnit) -> FU = case FromUnit of native -> erts_internal:time_unit(); perf_counter -> erts_internal:perf_counter_unit(); + nanosecond -> 1000*1000*1000; + microsecond -> 1000*1000; + millisecond -> 1000; + second -> 1; + + %% Deprecated symbolic units... nano_seconds -> 1000*1000*1000; micro_seconds -> 1000*1000; milli_seconds -> 1000; seconds -> 1; + _ when FromUnit > 0 -> FromUnit end, TU = case ToUnit of native -> erts_internal:time_unit(); perf_counter -> erts_internal:perf_counter_unit(); + nanosecond -> 1000*1000*1000; + microsecond -> 1000*1000; + millisecond -> 1000; + second -> 1; + + %% Deprecated symbolic units... nano_seconds -> 1000*1000*1000; micro_seconds -> 1000*1000; milli_seconds -> 1000; seconds -> 1; + _ when ToUnit > 0 -> ToUnit end, case Time < 0 of -- cgit v1.2.3