Parma Polyhedra Library requirements
Internal watchdog time-interval values

Internal watchdog time-interval values

UID:
VERSION:
CLASSIFICATION:
PREFIX:
Type
Level
MID
UID
REFS
Title
Statement
Rationale
Comment
BIBLIOGRAPHY
STATUS
COMPONENT
APPLICABILITY
VERIFICATION_METHODS
VERIFICATION_CRITERIA
SOURCE
LANGUAGE
VISIBILITY
INTERFACE
SW_SPEC
1
PPL-SPEC-000821
Normalized nonnegative microsecond interval values

Time shall represent an exact nonnegative integral number of microseconds, with maximum value 106  LONG_MAX + 999999. A valid completed value shall have whole seconds in [0,  LONG_MAX] and a residual microsecond count in [0, 999999]. This raw value interface shall be available independently of operating-system watchdog-timer support and shall not require PPL initialization or floating-point state.

Constructor inputs shall satisfy their stated nonnegative argument preconditions. Concurrent access shall retain ordinary C++ object synchronization requirements. An interval value shall not itself promise elapsed-time measurement, timer resolution or notification scheduling.

Raw watchdog duration arithmetic needs an exact normalized value domain independent of operating-system timer behavior.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Use independent arbitrary-precision total-microsecond oracles for zero, carry boundaries and the largest representable pair without initializing the PPL.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

class Time;
SW_SPEC
2
PPL-SPEC-000822
PPL-SPEC-000822
Zero and centisecond construction

Default construction shall produce the zero interval. Construction from a nonnegative long centisecond count c shall produce exactly 10000c microseconds in normalized form. Every nonnegative long centisecond value, including LONG_MAX, shall be representable by this conversion. Construction shall retain the allocation-free value protocol of 🔗 9. Allocation-free value operations and fatal range policy.

User timer durations are expressed in centiseconds while internal normalized values use microseconds.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Compare centisecond values around multiples of100, zero, signed-long upper neighbors and LONG_MAX against independent total-microsecond expectations.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

Time();
explicit Time(long centisecs);
SW_SPEC
3
PPL-SPEC-000823
PPL-SPEC-000823
Second/microsecond normalization and excessive results

For nonnegative long arguments s and m, two-argument construction shall represent exactly 106s + m microseconds when that result is within 🔗 1. Normalized nonnegative microsecond interval values. Microseconds at or above one million shall be carried into whole seconds and reduced to a residual less than one million. If this nonnegative mathematical result exceeds the representable maximum, construction shall call std::abort under 🔗 9. Allocation-free value operations and fatal range policy, without signed arithmetic overflow or a constructed C++ exception.

Normalization must distinguish a valid carry from an unrepresentable duration before overflowing signed seconds.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Compare all selected second/microsecond boundary combinations with arbitrary-precision normalization, including LONG_MAX microseconds and the largest admitted carried value; monitor excessive results in an isolated process.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

Time(long seconds, long microseconds);
SW_SPEC
4
PPL-SPEC-000824
PPL-SPEC-000824
Independent value copies and assignment

Copy construction and assignment shall preserve the exact interval value in independent scalar state. Rvalue construction/assignment shall retain the same value semantics, leaving the source value unchanged. Self-assignment shall preserve the interval. Assignment shall return the target object. No copy shall share owned duration state or require allocation, and ordinary destruction shall require no external resource cleanup.

Interval values are copied scalars rather than timer-resource owners.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check normal/rvalue copies and assignments, self-assignment, source mutation and independent surviving values with allocation disabled.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

Time(const Time& y) = default;
Time& operator=(const Time& y) = default;
~Time() = default;
SW_SPEC
5
PPL-SPEC-000825
PPL-SPEC-000825
Whole-second, residual-microsecond and validity queries

For a valid completed interval, seconds() shall return its whole second count and microseconds() its normalized residual, so their mathematical combination equals the exact value. OK() shall test the stored normalization conditions: nonnegative whole seconds and a residual in [0, 999999]. The queries shall preserve the value and require no allocation. They shall not provide a memory-safe validity check for arbitrary corrupted storage or remove constructor preconditions.

Normalized components and the invariant checker must agree on the represented duration.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check both components and the checker for every constructed and computed boundary value; inspect the exact validity predicate without manufacturing invalid objects through prohibited constructor inputs.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

long seconds() const;
long microseconds() const;
bool OK() const;
SW_SPEC
6
PPL-SPEC-000826
PPL-SPEC-000826
Exact interval ordering and equality

The six comparison operators shall compare exact total-microsecond values. Equality shall hold exactly for the same duration, regardless of which admitted normalization inputs produced it. Strict and nonstrict order shall have their ordinary mathematical meanings and inequality shall negate equality. Comparing valid values shall not change either operand, allocate or depend on the current clock.

Pending event order requires exact duration comparisons across whole-second and microsecond boundaries.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check Boolean inequality expressions in both operand orders through C++20 equality rewriting, retaining the stated equality and mismatch behavior. Compare all ordered pairs of independently valued normalized intervals, alternate equal constructions and maximum boundaries with arbitrary-precision integer order.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

bool operator==(const Time& x, const Time& y);
// Inequality uses C++20 rewriting of operator==.
bool operator<(const Time& x, const Time& y);
bool operator<=(const Time& x, const Time& y);
bool operator>(const Time& x, const Time& y);
bool operator>=(const Time& x, const Time& y);
SW_SPEC
7
PPL-SPEC-000827
PPL-SPEC-000827
Exact addition, aliasing and representability failure

For valid operands with a representable sum, compound addition shall replace the target by their exact total-microsecond sum, normalized into seconds and residual microseconds, and return the target object. Adding an object to itself shall use its value on entry. Free addition shall produce the same exact value without changing either input.

If the exact sum exceeds 🔗 1. Normalized nonnegative microsecond interval values, both forms shall call std::abort under 🔗 9. Allocation-free value operations and fatal range policy before signed arithmetic overflow, without constructing a C++ exception. A valid microsecond carry shall be included in that representability decision.

Normalized duration addition must account for both whole seconds and a possible carry at the representable limit.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Compare independent exact sums for all selected carry/no-carry operand pairs and self-aliasing, preserve free-operation inputs and isolate both excessive whole-second and carry-only failures.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

Time& operator+=(const Time& y);
Time operator+(const Time& x, const Time& y);
SW_SPEC
8
PPL-SPEC-000828
PPL-SPEC-000828
Saturating nonnegative interval subtraction

For valid operands, compound subtraction shall replace the target by max(0, x − y), using their exact values on entry, and return the target object. A needed microsecond borrow shall preserve that exact nonnegative result. Self-subtraction shall yield zero. Free subtraction shall return the same value without modifying either input. Subtraction shall remain within the normalized value domain and shall not allocate or signal an arithmetic-range failure for valid operands.

Timer differences saturate at zero rather than create negative durations.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Compare all selected operand pairs with independent max-zero differences, equal/self operands, whole-second ordering and microsecond-borrow boundaries.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

Time& operator-=(const Time& y);
Time operator-(const Time& x, const Time& y);
SW_SPEC
9
PPL-SPEC-000829

Admitted Time construction, copying, queries, comparisons, addition and subtraction shall use no heap allocation, floating-point arithmetic, PPL initialization or operating-system timer operation. Unrepresentable normalization/addition shall report its fatal condition by calling std::abort; it shall not allocate or construct a C++ exception in an attempt to report that condition. No recovery or owned- resource cleanup after process termination shall be promised by this value interface. The caller shall retain any surrounding signal/thread context restrictions.

The value type is used by watchdog signal paths where exception allocation is not an admissible range-reporting mechanism.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Disable allocation around all valid value operations and use isolated-process controls to distinguish synchronous abort from C++ exceptions or allocation attempts on the three excessive-result histories.

src/Time_defs.hh; src/Time_inlines.hh; src/Time.cc; src/Watchdog.cc; tests/timespec1.cc; tests/timedeathlegacy1.cc; tests/timedeathlegacy1_time.cc.

CPP
Internal

Internal source header: Time_defs.hh. Names belong to Parma_Polyhedra_Library::Implementation::Watchdog. Member excerpts apply to Time; copy/destruction excerpts describe implicitly generated operations.

Time();
explicit Time(long centisecs);
Time(long seconds, long microseconds);
Time& operator+=(const Time& y);
Time& operator-=(const Time& y);