1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Brucifixion ? Yes, out that door, row on the left, one patch each.

This commit is contained in:
Poul-Henning Kamp 2002-04-30 19:48:45 +00:00
parent d5efb9fab4
commit 9c30ce571e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95817
3 changed files with 51 additions and 54 deletions

View File

@ -79,11 +79,9 @@ struct timezone {
#define DST_EET 5 /* Eastern European dst */
#define DST_CAN 6 /* Canada */
/* start of struct bintime stuff */
struct bintime {
time_t sec;
uint64_t frac;
time_t sec;
uint64_t frac;
};
static __inline void
@ -133,7 +131,6 @@ bintime_sub(struct bintime *bt, struct bintime *bt2)
* Even at 15:59:59.999999999 it's not four'o'clock.
*
* time_second ticks after N.999999999 not after N.4999999999
*
*/
static __inline void
@ -141,8 +138,7 @@ bintime2timespec(struct bintime *bt, struct timespec *ts)
{
ts->tv_sec = bt->sec;
ts->tv_nsec =
((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32;
ts->tv_nsec = ((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32;
}
static __inline void
@ -159,8 +155,7 @@ bintime2timeval(struct bintime *bt, struct timeval *tv)
{
tv->tv_sec = bt->sec;
tv->tv_usec =
((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32;
tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32;
}
static __inline void
@ -172,8 +167,6 @@ timeval2bintime(struct timeval *tv, struct bintime *bt)
bt->frac = tv->tv_usec * (uint64_t)18446744073709LL;
}
/* end of struct bintime stuff */
#ifdef _KERNEL
/* Operations on timespecs */
@ -282,7 +275,7 @@ struct clockinfo {
#ifdef _KERNEL
extern time_t time_second;
/*-
/*
* Functions for looking at our clock: [get]{bin,nano,micro}[up]time()
*
* Functions without the "get" prefix returns the best timestamp
@ -305,27 +298,27 @@ extern time_t time_second;
*/
void binuptime(struct bintime *bt);
void nanouptime(struct timespec *ts);
void microuptime(struct timeval *tv);
void nanouptime(struct timespec *tsp);
void microuptime(struct timeval *tvp);
void bintime(struct bintime *bt);
void nanotime(struct timespec *ts);
void microtime(struct timeval *tv);
void nanotime(struct timespec *tsp);
void microtime(struct timeval *tvp);
void getbinuptime(struct bintime *bt);
void getnanouptime(struct timespec *tsp);
void getmicrouptime(struct timeval *tv);
void getmicrouptime(struct timeval *tvp);
void getbintime(struct bintime *bt);
void getnanotime(struct timespec *tsp);
void getmicrotime(struct timeval *tv);
void getmicrotime(struct timeval *tvp);
/* other prototypes */
/* Other functions */
int itimerdecr(struct itimerval *itp, int usec);
int itimerfix(struct timeval *tv);
void timevaladd(struct timeval *, struct timeval *);
void timevalsub(struct timeval *, struct timeval *);
int tvtohz(struct timeval *);
void timevaladd(struct timeval *t1, struct timeval *t2);
void timevalsub(struct timeval *t1, struct timeval *t2);
int tvtohz(struct timeval *tv);
#else /* !_KERNEL */
#include <time.h>

View File

@ -16,6 +16,7 @@
#define _SYS_TIMEPPS_H_
#include <sys/ioccom.h>
#include <sys/time.h>
#define PPS_API_VERS_1 1
@ -103,26 +104,26 @@ struct pps_kcbind_args {
#define PPS_IOC_KCBIND _IOW('1', 7, struct pps_kcbind_args)
#ifdef _KERNEL
struct timehands;
struct timecounter;
struct pps_state {
/* capture information */
struct timehands *capth;
u_int capgen;
u_int capcount;
/* state information */
pps_params_t ppsparam;
pps_info_t ppsinfo;
int kcmode;
int ppscap;
struct timecounter *ppstc;
unsigned ppscount[3];
/* Capture information. */
struct timehands *capth;
unsigned capgen;
unsigned capcount;
/* State information. */
pps_params_t ppsparam;
pps_info_t ppsinfo;
int kcmode;
int ppscap;
struct timecounter *ppstc;
unsigned ppscount[3];
};
void pps_capture(struct pps_state *pps);
void pps_event(struct pps_state *pps, int event);
void pps_init(struct pps_state *pps);
int pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps);
int pps_ioctl(unsigned long cmd, caddr_t data, struct pps_state *pps);
void hardpps(struct timespec *tsp, long nsec);
#else /* !_KERNEL */
@ -194,5 +195,6 @@ time_pps_kcbind(pps_handle_t handle, const int kernel_consumer,
return (ioctl(handle, PPS_IOC_KCBIND, &arg));
}
#endif /* !_KERNEL */
#endif /* _SYS_TIMEPPS_H_ */
#endif /* KERNEL */
#endif /* !_SYS_TIMEPPS_H_ */

View File

@ -1,4 +1,4 @@
/*
/*-
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
@ -10,18 +10,21 @@
*/
#ifndef _SYS_TIMETC_H_
#define _SYS_TIMETC_H_
#define _SYS_TIMETC_H_
/*
* Struct timecounter is the interface between the hardware which implements
#ifndef _KERNEL
#error "no user-serviceable parts inside"
#endif
/*-
* `struct timecounter' is the interface between the hardware which implements
* a timecounter and the MI code which uses this to keep track of time.
*
* A timecounter is a binary counter which has two properties:
* * it runs at a fixed, known frequency.
* * it has sufficient bits to not roll over in faster than approx
* 2 msec or 2/hz, whichever is faster. (The value of 2 here is
* really 1 + delta, for some indeterminate value of delta).
*
* * it has sufficient bits to not roll over in less than approximately
* max(2 msec, 2/HZ seconds). (The value 2 here is really 1 + delta,
* for some indeterminate value of delta.)
*/
struct timecounter;
@ -37,28 +40,27 @@ struct timecounter {
*/
timecounter_pps_t *tc_poll_pps;
/*
* This function is optional, it will be called whenever the
* This function is optional. It will be called whenever the
* timecounter is rewound, and is intended to check for PPS
* events. Most hardware do not need it.
* events. Normal hardware does not need it but timecounters
* which latch PPS in hardware (like sys/pci/xrpu.c) do.
*/
u_int tc_counter_mask;
/* This mask should mask off any unimplemnted bits. */
/* This mask should mask off any unimplemented bits. */
u_int32_t tc_frequency;
/* Frequency of the counter in Hz. */
char *tc_name;
/* Name of the counter. */
/* Name of the timecounter. */
void *tc_priv;
/* Pointer to the counters private parts. */
/* Pointer to the timecounter's private parts. */
struct timecounter *tc_next;
/* Initialize this to NUL */
/* Pointer to the next timecounter. */
};
#ifdef _KERNEL
extern struct timecounter *timecounter;
u_int32_t tc_getfrequency(void);
void tc_init(struct timecounter *tc);
void tc_setclock(struct timespec *ts);
#endif /* !_KERNEL */
#endif /* !_SYS_TIMETC_H_ */