Blame clockadj.h

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