2013-03-08 00:27:29 +08:00
|
|
|
/**
|
|
|
|
* @file clockadj.h
|
|
|
|
* @brief Wraps clock_adjtime functionality.
|
|
|
|
* @note Copyright (C) 2013 Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
#ifndef HAVE_CLOCKADJ_H
|
|
|
|
#define HAVE_CLOCKADJ_H
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2013-12-20 01:39:11 +08:00
|
|
|
/**
|
|
|
|
* Initialize state needed when adjusting or reading the clock.
|
|
|
|
* @param clkid A clock ID obtained using phc_open() or CLOCK_REALTIME.
|
|
|
|
*/
|
|
|
|
void clockadj_init(clockid_t clkid);
|
|
|
|
|
2013-04-05 15:44:34 +08:00
|
|
|
/**
|
2013-03-08 00:27:29 +08:00
|
|
|
* Set clock's frequency offset.
|
|
|
|
* @param clkid A clock ID obtained using phc_open() or CLOCK_REALTIME.
|
|
|
|
* @param freq The frequency offset in parts per billion (ppb).
|
|
|
|
*/
|
|
|
|
void clockadj_set_freq(clockid_t clkid, double freq);
|
|
|
|
|
2013-04-05 15:44:34 +08:00
|
|
|
/**
|
2013-03-08 00:27:29 +08:00
|
|
|
* Read clock's frequency offset.
|
|
|
|
* @param clkid A clock ID obtained using phc_open() or CLOCK_REALTIME.
|
|
|
|
* @return The frequency offset in parts per billion (ppb).
|
|
|
|
*/
|
|
|
|
double clockadj_get_freq(clockid_t clkid);
|
|
|
|
|
2020-05-05 02:07:57 +08:00
|
|
|
/**
|
|
|
|
* Set clock's phase offset.
|
|
|
|
* @param clkid A clock ID obtained using phc_open() or CLOCK_REALTIME.
|
|
|
|
* @param offset The phase offset in nanoseconds.
|
|
|
|
*/
|
|
|
|
void clockadj_set_phase(clockid_t clkid, long offset);
|
|
|
|
|
2013-04-05 15:44:34 +08:00
|
|
|
/**
|
2013-03-08 00:27:29 +08:00
|
|
|
* Step clock's time.
|
|
|
|
* @param clkid A clock ID obtained using phc_open() or CLOCK_REALTIME.
|
|
|
|
* @param step The time step in nanoseconds.
|
|
|
|
*/
|
|
|
|
void clockadj_step(clockid_t clkid, int64_t step);
|
|
|
|
|
2018-11-08 22:05:12 +08:00
|
|
|
/**
|
|
|
|
* Read maximum frequency adjustment of the target clock.
|
|
|
|
* @return The maximum frequency adjustment in parts per billion (ppb).
|
|
|
|
*/
|
|
|
|
int clockadj_max_freq(clockid_t clkid);
|
|
|
|
|
2013-04-05 15:44:34 +08:00
|
|
|
/**
|
2013-04-08 21:44:09 +08:00
|
|
|
* Set the system clock to insert/delete leap second at midnight.
|
2013-03-08 00:27:30 +08:00
|
|
|
* @param leap +1 to insert leap second, -1 to delete leap second,
|
|
|
|
* 0 to reset the leap state.
|
|
|
|
*/
|
2013-04-08 21:44:09 +08:00
|
|
|
void sysclk_set_leap(int leap);
|
2013-04-04 23:28:23 +08:00
|
|
|
|
2014-06-18 21:44:49 +08:00
|
|
|
/**
|
|
|
|
* Set the TAI offset of the system clock to have correct CLOCK_TAI.
|
|
|
|
* @param offset The TAI-UTC offset in seconds.
|
|
|
|
*/
|
|
|
|
void sysclk_set_tai_offset(int offset);
|
|
|
|
|
2013-04-05 15:44:34 +08:00
|
|
|
/**
|
2013-04-05 15:47:21 +08:00
|
|
|
* Read maximum frequency adjustment of the system clock (CLOCK_REALTIME).
|
|
|
|
* @return The maximum frequency adjustment in parts per billion (ppb).
|
2013-04-04 23:28:23 +08:00
|
|
|
*/
|
2013-04-05 15:47:21 +08:00
|
|
|
int sysclk_max_freq(void);
|
|
|
|
|
2013-04-08 21:44:10 +08:00
|
|
|
/**
|
|
|
|
* Mark the system clock as synchronized to let the kernel synchronize
|
|
|
|
* the real-time clock (RTC) to it.
|
|
|
|
*/
|
|
|
|
void sysclk_set_sync(void);
|
2013-03-08 00:27:29 +08:00
|
|
|
#endif
|