|
Packit |
96c956 |
/*
|
|
Packit |
96c956 |
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
**********************************************************************
|
|
Packit |
96c956 |
* Copyright (C) Richard P. Curnow 1997-2002
|
|
Packit |
96c956 |
*
|
|
Packit |
96c956 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
96c956 |
* it under the terms of version 2 of the GNU General Public License as
|
|
Packit |
96c956 |
* published by the Free Software Foundation.
|
|
Packit |
96c956 |
*
|
|
Packit |
96c956 |
* This program is distributed in the hope that it will be useful, but
|
|
Packit |
96c956 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
96c956 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
96c956 |
* General Public License for more details.
|
|
Packit |
96c956 |
*
|
|
Packit |
96c956 |
* You should have received a copy of the GNU General Public License along
|
|
Packit |
96c956 |
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit |
96c956 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
Packit |
96c956 |
*
|
|
Packit |
96c956 |
**********************************************************************
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
=======================================================================
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
Exported header file for sched.c
|
|
Packit |
96c956 |
*/
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
#ifndef GOT_SCHED_H
|
|
Packit |
96c956 |
#define GOT_SCHED_H
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
#include "sysincl.h"
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* Type for timeout IDs, valid IDs are always greater than zero */
|
|
Packit |
96c956 |
typedef unsigned int SCH_TimeoutID;
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
typedef enum {
|
|
Packit |
96c956 |
SCH_ReservedTimeoutValue = 0,
|
|
Packit |
96c956 |
SCH_NtpClientClass,
|
|
Packit |
96c956 |
SCH_NtpPeerClass,
|
|
Packit |
96c956 |
SCH_NtpBroadcastClass,
|
|
Packit |
96c956 |
SCH_NumberOfClasses /* needs to be last */
|
|
Packit |
96c956 |
} SCH_TimeoutClass;
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
typedef void* SCH_ArbitraryArgument;
|
|
Packit |
96c956 |
typedef void (*SCH_FileHandler)(int fd, int event, SCH_ArbitraryArgument);
|
|
Packit |
96c956 |
typedef void (*SCH_TimeoutHandler)(SCH_ArbitraryArgument);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* Exported functions */
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* Initialisation function for the module */
|
|
Packit |
96c956 |
extern void SCH_Initialise(void);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* Finalisation function for the module */
|
|
Packit |
96c956 |
extern void SCH_Finalise(void);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* File events */
|
|
Packit |
96c956 |
#define SCH_FILE_INPUT 1
|
|
Packit |
96c956 |
#define SCH_FILE_OUTPUT 2
|
|
Packit |
96c956 |
#define SCH_FILE_EXCEPTION 4
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* Register a handler for when select goes true on a file descriptor */
|
|
Packit |
96c956 |
extern void SCH_AddFileHandler(int fd, int events, SCH_FileHandler handler, SCH_ArbitraryArgument arg);
|
|
Packit |
96c956 |
extern void SCH_RemoveFileHandler(int fd);
|
|
Packit |
96c956 |
extern void SCH_SetFileHandlerEvent(int fd, int event, int enable);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* Get the time stamp taken after a file descriptor became ready or a timeout expired */
|
|
Packit |
96c956 |
extern void SCH_GetLastEventTime(struct timespec *cooked, double *err, struct timespec *raw);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* This queues a timeout to elapse at a given (raw) local time */
|
|
Packit |
96c956 |
extern SCH_TimeoutID SCH_AddTimeout(struct timespec *ts, SCH_TimeoutHandler handler, SCH_ArbitraryArgument arg);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* This queues a timeout to elapse at a given delta time relative to the current (raw) time */
|
|
Packit |
96c956 |
extern SCH_TimeoutID SCH_AddTimeoutByDelay(double delay, SCH_TimeoutHandler, SCH_ArbitraryArgument);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* This queues a timeout in a particular class, ensuring that the
|
|
Packit |
96c956 |
expiry time is at least a given separation away from any other
|
|
Packit |
96c956 |
timeout in the same class, given randomness is added to the delay
|
|
Packit |
96c956 |
and separation */
|
|
Packit |
96c956 |
extern SCH_TimeoutID SCH_AddTimeoutInClass(double min_delay, double separation, double randomness,
|
|
Packit |
96c956 |
SCH_TimeoutClass class,
|
|
Packit |
96c956 |
SCH_TimeoutHandler handler, SCH_ArbitraryArgument);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
/* The next one probably ought to return a status code */
|
|
Packit |
96c956 |
extern void SCH_RemoveTimeout(SCH_TimeoutID);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
extern void SCH_MainLoop(void);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
extern void SCH_QuitProgram(void);
|
|
Packit |
96c956 |
|
|
Packit |
96c956 |
#endif /* GOT_SCHED_H */
|