Blame clockcheck.h

Packit 9c3e7e
/**
Packit 9c3e7e
 * @file clockcheck.h
Packit 9c3e7e
 * @brief Implements clock sanity checking.
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_CLOCKCHECK_H
Packit 9c3e7e
#define HAVE_CLOCKCHECK_H
Packit 9c3e7e
Packit 9c3e7e
#include <stdint.h>
Packit 9c3e7e
Packit 9c3e7e
/** Opaque type */
Packit 9c3e7e
struct clockcheck;
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * Create a new instance of a clock sanity check.
Packit 9c3e7e
 * @param freq_limit The maximum allowed frequency offset between uncorrected
Packit 9c3e7e
 *                   clock and the system monotonic clock in ppb.
Packit 9c3e7e
 * @return A pointer to a new clock check on success, NULL otherwise.
Packit 9c3e7e
 */
Packit 9c3e7e
struct clockcheck *clockcheck_create(int freq_limit);
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * Perform the sanity check on a time stamp.
Packit 9c3e7e
 * @param cc Pointer to a clock check obtained via @ref clockcheck_create().
Packit 9c3e7e
 * @param ts Time stamp made by the clock in nanoseconds.
Packit 9c3e7e
 * @return Zero if ts passed the check, non-zero otherwise.
Packit 9c3e7e
 */
Packit 9c3e7e
int clockcheck_sample(struct clockcheck *cc, uint64_t ts);
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * Inform clock check about changes in current frequency of the clock.
Packit 9c3e7e
 * @param cc   Pointer to a clock check obtained via @ref clockcheck_create().
Packit 9c3e7e
 * @param freq Frequency correction applied to the clock in ppb.
Packit 9c3e7e
 */
Packit 9c3e7e
void clockcheck_set_freq(struct clockcheck *cc, int freq);
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * Inform clock check that the clock was stepped.
Packit 9c3e7e
 * @param cc   Pointer to a clock check obtained via @ref clockcheck_create().
Packit 9c3e7e
 * @param step Step correction applied to the clock in nanoseconds.
Packit 9c3e7e
 */
Packit 9c3e7e
void clockcheck_step(struct clockcheck *cc, int64_t step);
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * Destroy a clock check.
Packit 9c3e7e
 * @param cc Pointer to a clock check obtained via @ref clockcheck_create().
Packit 9c3e7e
 */
Packit 9c3e7e
void clockcheck_destroy(struct clockcheck *cc);
Packit 9c3e7e
Packit 9c3e7e
#endif