Lely core libraries 2.3.4
clock.h File Reference

This header file is part of the I/O library; it contains the abstract clock interface. More...

#include <lely/io2/io2.h>
#include <lely/libc/time.h>
Include dependency graph for clock.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  io_clock_vtbl
 

Typedefs

typedef const struct io_clock_vtbl *const io_clock_t
 An abstract clock.
 

Functions

int io_clock_getres (const io_clock_t *clock, struct timespec *res)
 Obtains the resolution of the specified clock.
 
int io_clock_gettime (const io_clock_t *clock, struct timespec *tp)
 Obtains the current time value of the specified clock.
 
int io_clock_settime (io_clock_t *clock, const struct timespec *tp)
 Sets the time value of the specified clock.
 

Detailed Description

This header file is part of the I/O library; it contains the abstract clock interface.

The clock interface is modeled after the POSIX clock_getres(), clock_gettime() and clock_settime() functions.

Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file clock.h.

Function Documentation

◆ io_clock_getres()

int io_clock_getres ( const io_clock_t clock,
struct timespec res 
)
inline

Obtains the resolution of the specified clock.

Note that the resolution MAY NOT be constant for user-defined clocks (i.e., it MAY be the interval between the last two clock updates).

Parameters
clocka pointer to a clock.
resthe address at which to store the resolution (can be NULL).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 90 of file clock.h.

◆ io_clock_gettime()

int io_clock_gettime ( const io_clock_t clock,
struct timespec tp 
)
inline

Obtains the current time value of the specified clock.

Parameters
clocka pointer to a clock.
tpthe address at which to store the time value.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 96 of file clock.h.

◆ io_clock_settime()

int io_clock_settime ( io_clock_t clock,
const struct timespec tp 
)
inline

Sets the time value of the specified clock.

This operation MAY require elevated privileges in the calling process.

Parameters
clocka pointer to a clock.
tpa pointer to the time value. This value MAY be rounded to the nearest multiple of the clock resolution given by io_clock_getres().
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 102 of file clock.h.