SPRUIG8I January 2018 – December 2023
The compiler RTS library supports two low-level time-related standard C functions in
time.h
:
clock_t clock(void);
time_t time(time_t *timer);
The time() function returns the wall-clock time. The clock() function returns the number of clock cycles since the program began executing; it has nothing to do with wall-clock time.
The default implementations of these functions require that the program be run under CCS or a similar tool that supports the CIO System Call Protocol. If CIO is not available and you need to use one of these functions, you must provide your own definition of the function.
The clock() function returns the number of clock cycles since the program began executing. This information might be available in a register on the device itself, but the location varies from platform to platform. The compiler's RTS library provides an implementation that uses the CIO System Call Protocol to communicate with CCS, which figures out how to compute the right value for this device.
If CCS is not available, you must provide an implementation of the clock() function that gathers clock cycle information from the appropriate location on the device.
The time() function returns the real-world time, in terms of seconds since an epoch.
On many embedded systems, there is no internal real-world clock, so a program needs to discover the time from an external source. The compiler's RTS library provides an implementation that uses the CIO System Call Protocol to communicate with CCS, which provides the real-world time.
If CCS is not available, you must provide an implementation of the time() function that finds the time from some other source. If the program is running under an operating system, that operating system should provide an implementation of time().
The time() function returns the number of seconds since an epoch. On C7000 systems, the epoch is defined as the number of seconds since midnight UTC January 1, 1970.