[Previous] [Contents] [Next]

ClockTime(), ClockTime_r()

Get or set a clock

Synopsis:

#include <sys/neutrino.h>

int ClockTime( clockid_t id,
               const uint64_t * new,
               uint64_t * old );

int ClockTime_r( clockid_t id,
                 const uint64_t * new,
                 uint64_t * old );

Library:

libc

Description:

The ClockTime() and ClockTime_r() functions are identical except in the way they indicate errors. See the Returns section for details.

These kernel calls allow you to get or set the system clock specified by id. The clock ID, CLOCK_REALTIME, maintains the system time.

If new isn't NULL, then it contains the absolute time to set the system clock to. This affects the software clock maintained by the system. It won't change any underlying hardware clock which maintains the time when the system is powered off.

Once set, the system time increments by some number of nanoseconds, based upon the resolution of the system clock. This resolution can be queried or changed using the ClockPeriod() kernel call.

Superuser privileges are required to set the clock.

If old isn't NULL, then the current time (before being changed by a non-NULL new) is returned init.

Blocking states

These calls don't block.

Returns:

The only difference between these functions is the way they indicate errors:

ClockTime()
If an error occurs, -1 is returned and errno is set. Any other value returned indicates success.
ClockTime_r()
EOK is returned on success. This function does NOT set errno. If an error occurs, any value in the Errors section may be returned.

Errors:

EFAULT
A fault occurred when the kernel tried to access the buffers provided.
EINVAL
The clock ID isn't CLOCK_REALTIME.
EPERM
The process tried to change the time without having superuser capabilities.
ESRCH
The process associated with this request doesn't exist.

Classification:

QNX 6

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread No

See also:

ClockAdjust(), ClockPeriod()


[Previous] [Contents] [Next]