On this page
Machine interfaces, addresses and time
These packages describe the target's representations and the operations that reach outside the program: machine integers, C types, addresses, bit conversion, clocks and tasking.
Interfaces
Interfaces provides Integer_8/16/32/64 and Unsigned_8/16/32/64. The signed types have the listed two's-complement ranges; the unsigned types are modular. Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left and Rotate_Right are overloaded for the four unsigned widths. Shift amounts are Natural and defined even at/above the bit width: logical shifts give zero, arithmetic right shift fills from the sign bit, and rotations use the amount modulo width. The compiler implements them directly; no timing property, such as constant time, is stated.
Interfaces.C
Interfaces.C defines the actual supplied LP64 types: int32, short16, long64, signed_char8; corresponding unsigned forms; size_t64; C_float binary32; double binary64; and char derived from Character. These are the C types of the 64-bit hosts Verada runs on. The nul constant is char position zero. Scalar To_C/To_Ada convert character types.
char_array is indexed by size_t. String To_C returns characters from zero and appends nul by default. Its Pre condition bounds length and excludes a zero-length, no-nul result; choose Append_Nul=False only when that condition holds. To_Ada can trim at the first nul (default), requiring one present, or convert the full array when Trim_Nul=False; its range/length bound must also hold. Source and destination lower bounds need not agree. Arrays passed to C receive component pointers with no implicit length, so declare explicit lengths and lifetime contracts.
System and Storage_Elements
System publishes Verada's limits as RM 13.7's named numbers: Min_Int and Max_Int are Long_Long_Long_Integer's bounds (the integer types go to 128 bits), Max_Binary_Modulus is 2128 and Max_Nonbinary_Modulus 264 - 1 (a modulus that is not a power of two is at most that, so that a product of two values fits in 128 bits before it is reduced: B2002 otherwise), Max_Digits and Max_Base_Digits are 15 (binary64), Max_Mantissa is 63 and Fine_Delta 2.0**(-63) (an ordinary fixed-point value is 64 bits), and Tick is a nanosecond, Ada.Real_Time's. With them come System_Name, Bit_Order (Default_Bit_Order is Low_Order_First), Storage_Unit=8, Word_Size=64, Memory_Size=2**64, modular Address, Null_Address=0, Any_Priority 0 .. 98, Priority 0 .. 97, Interrupt_Priority 98 .. 98 and Default_Priority 48. They are constants of the implementation, not values read from the machine.
System.Storage_Elements defines signed64 Storage_Offset, nonnegative Storage_Count, byte-sized modular Storage_Element and modular Integer_Address. To_Address and To_Integer convert between Address and Integer_Address. A conversion only changes the number's type: it does not map memory or check alignment. An object placed at an address follows the language's rules for external objects; a device example proves on any host but runs only where the device exists.
Memory and sizes
Verada.Storage states the machine's memory as the library's contracts use it: no string, text or container holds Length_Bound (2⁶⁰) or more elements, so a sum of two lengths is a Natural. An operation that would make a longer one calls Reserve, whose only failure is Storage_Error, as an allocation the heap cannot make; no library operation has a precondition on the sizes it is given.
Unchecked conversion and deallocation
Ada.Unchecked_Conversion converts between scalar types stored in the same number of bits: the result is the value with the source's bits. When the target type has bit patterns that are not values of it (a range narrower than its storage, an enumeration with fewer literals, a float's NaNs and infinities), the conversion has a check that the bits are a value, which the prover proves like a range check.
Ada.Unchecked_Deallocation frees the object an access value owns and makes the access value null. Ownership makes this safe: the access value is the object's only owner, and the prover checks that the freed object owns nothing itself (B6005). A general access type (access all T) has no deallocation instance (B2028).
Time and tasking
Ada.Real_Time has all of Ada's D.8: Time and Time_Span, counts of nanoseconds in 64 bits (about 292 years either way), with Time_First, Time_Last, Time_Span_First, Time_Span_Last, Time_Span_Zero, Time_Span_Unit and Tick (a nanosecond). Nanoseconds_Of and Span_Nanoseconds give the counts, and the contracts are written in them. Clock reads the monotonic clock, which counts from about when the machine started; its contract says it is below 4 * 10 ** 18 nanoseconds (about 127 years), and a proof knows no more of a reading.
Adding a span to a time, or subtracting one, never fails: a result beyond Time_Last is Time_Last, and one before Time_First is Time_First. Ada raises Constraint_Error there instead. Verada saturates so that the periodic-task idiom proves:
Next : Time := Clock;
...
loop
delay until Next;
Next := Next + Period;
end loop;The loop runs forever, so no precondition on + could be proved for it. Saturation never happens in practice: from any clock reading, Time_Last is more than 160 years away. The other operations keep their results in range by their preconditions: span plus and minus span, negation and abs, span times Integer, span divided by span (an Integer, truncated) or by Integer, and time minus time. Comparisons compare the counts. Nanoseconds, Microseconds, Milliseconds, Seconds and Minutes make spans. To_Duration and To_Time_Span convert to and from Duration, which holds about 136 years either way. Split gives a time's whole seconds (a Seconds_Count) and the nanoseconds after them, and Time_Of puts them back together.
Verada.Tasking holds the run-time operations that tasks, protected objects and delay statements are made of. Programs call only Stop: it ends every task, including the calling one when it is a task, so the program ends once its main subprogram returns. A program has as many tasks and protected and suspension objects as it declares: the run time's tables grow as they are elaborated, and only memory (or the system's limit on threads) limits them, a failure raising Storage_Error at elaboration. Priorities and ceilings are checked when the program is compiled (B3021); at run time, tasks are threads at the operating system's ordinary priority.
Task_Body, Start, Lock_Id, New_Lock, Lock, Unlock, Wait, Notify and Attach are what the compiler generates for tasks, protected objects and interrupt handlers; a program that calls them directly bypasses the checks the language makes. Delay_Until and Delay_For implement delay until and delay; Delay_For's precondition limits a delay to one day.
Interrupts
Ada.Interrupts declares Interrupt_ID (0 .. 63), and Ada.Interrupts.Names names the interrupts a program may handle. On the hosts Verada runs on, an interrupt is a POSIX signal: SIGHUP, SIGINT, SIGQUIT, SIGALRM, SIGTERM, SIGUSR1 and SIGUSR2. A protected procedure with Attach_Handler handles one, from the moment its package is elaborated.
Suspension objects
Ada.Synchronous_Task_Control declares Suspension_Object: a task waits in Suspend_Until_True until another task calls Set_True, and Suspend_Until_True then sets the object false again. Tasks share a suspension object without a data race (B3019 does not apply), at most one task may ever wait on each (B3029), and since Suspend_Until_True may wait, a protected action does not call it.
Imports
Vada imports these units with with, Varc with import. Vibe's tasks, protected objects, sleep and stop are translated to these operations; see the Vibe reference for their forms.