aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src/std/datetime
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-01-25 13:50:55 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2021-01-26 09:54:57 +0100
commit5a36cae275ad84cc7e623f2f5829bdad767e3f6a (patch)
treece6b996b6cfcb1b1aa73bcc7786c07ef8df504b1 /libphobos/src/std/datetime
parenteb77a934eec8fe52e4c5612f5264127290bc517d (diff)
downloadgcc-5a36cae275ad84cc7e623f2f5829bdad767e3f6a.zip
gcc-5a36cae275ad84cc7e623f2f5829bdad767e3f6a.tar.gz
gcc-5a36cae275ad84cc7e623f2f5829bdad767e3f6a.tar.bz2
d: Merge upstream dmd 609c3ce2d, phobos 3dd5df686
D front-end changes: - Contracts for pre- and postconditions are now implicitly "this" const, so that state can no longer be altered in these functions. - Inside a constructor scope, assigning to aggregate declaration members is done by considering the first assignment as initialization and subsequent assignments as modifications of the constructed object. For const/immutable fields the initialization is accepted in the constructor but subsequent modifications are not. However this rule did not apply when inside a constructor scope there is a call to a different constructor. This been changed so it is now an error when there's a double initialization of immutable fields inside a constructor. Phobos changes: - Don't run unit-tests for unsupported clocks in std.datetime. The phobos and phobos_shared tests now add -fversion=Linux_Pre_2639 if required. - Deprecate public extern(C) bindings for getline and getdelim in std.stdio. The correct module for bindings is core.sys.posix.stdio. Reviewed-on: https://github.com/dlang/dmd/pull/12153 https://github.com/dlang/phobos/pull/7768 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 609c3ce2d. * d-compiler.cc (Compiler::loadModule): Rename to ... (Compiler::onParseModule): ... this. (Compiler::onImport): New function. * d-lang.cc (d_parse_file): Remove call to Compiler::loadModule. libphobos/ChangeLog: * src/MERGE: Merge upstream phobos 3dd5df686. * testsuite/libphobos.phobos/phobos.exp: Add compiler flag -fversion=Linux_Pre_2639 if target is linux_pre_2639. * testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.
Diffstat (limited to 'libphobos/src/std/datetime')
-rw-r--r--libphobos/src/std/datetime/systime.d32
1 files changed, 24 insertions, 8 deletions
diff --git a/libphobos/src/std/datetime/systime.d b/libphobos/src/std/datetime/systime.d
index 326b544..0b11ed9 100644
--- a/libphobos/src/std/datetime/systime.d
+++ b/libphobos/src/std/datetime/systime.d
@@ -39,6 +39,16 @@ version (unittest)
initializeTests();
}
+version (unittest) private bool clockSupported(ClockType c)
+{
+ // Skip unsupported clocks on older linux kernels, assume that only
+ // CLOCK_MONOTONIC and CLOCK_REALTIME exist, as that is the lowest
+ // common denominator supported by all versions of Linux pre-2.6.12.
+ version (Linux_Pre_2639)
+ return c == ClockType.normal || c == ClockType.precise;
+ else
+ return true;
+}
/++
Effectively a namespace to make it clear that the methods it contains are
@@ -95,10 +105,13 @@ public:
foreach (ct; AliasSeq!(ClockType.coarse, ClockType.precise, ClockType.second))
{
scope(failure) writefln("ClockType.%s", ct);
- auto value1 = Clock.currTime!ct;
- auto value2 = Clock.currTime!ct(UTC());
- assert(value1 <= value2, format("%s %s", value1, value2));
- assert(abs(value1 - value2) <= seconds(2));
+ static if (clockSupported(ct))
+ {
+ auto value1 = Clock.currTime!ct;
+ auto value2 = Clock.currTime!ct(UTC());
+ assert(value1 <= value2, format("%s %s (ClockType: %s)", value1, value2, ct));
+ assert(abs(value1 - value2) <= seconds(2), format("ClockType.%s", ct));
+ }
}
}
@@ -270,10 +283,13 @@ public:
foreach (ct; AliasSeq!(ClockType.coarse, ClockType.precise, ClockType.second))
{
scope(failure) writefln("ClockType.%s", ct);
- auto value1 = Clock.currStdTime!ct;
- auto value2 = Clock.currStdTime!ct;
- assert(value1 <= value2, format("%s %s", value1, value2));
- assert(abs(value1 - value2) <= limit);
+ static if (clockSupported(ct))
+ {
+ auto value1 = Clock.currStdTime!ct;
+ auto value2 = Clock.currStdTime!ct;
+ assert(value1 <= value2, format("%s %s (ClockType: %s)", value1, value2, ct));
+ assert(abs(value1 - value2) <= limit);
+ }
}
}