Use const pointers for input data not modified by clock utility functions.
This commit is contained in:
parent
8f926da325
commit
7f4e81c493
@ -132,7 +132,7 @@ leapyear(int year)
|
||||
}
|
||||
|
||||
static void
|
||||
print_ct(struct clocktime *ct)
|
||||
print_ct(const struct clocktime *ct)
|
||||
{
|
||||
printf("[%04d-%02d-%02d %02d:%02d:%02d]",
|
||||
ct->year, ct->mon, ct->day,
|
||||
@ -140,7 +140,7 @@ print_ct(struct clocktime *ct)
|
||||
}
|
||||
|
||||
int
|
||||
clock_ct_to_ts(struct clocktime *ct, struct timespec *ts)
|
||||
clock_ct_to_ts(const struct clocktime *ct, struct timespec *ts)
|
||||
{
|
||||
int i, year, days;
|
||||
|
||||
@ -200,7 +200,7 @@ clock_ct_to_ts(struct clocktime *ct, struct timespec *ts)
|
||||
}
|
||||
|
||||
int
|
||||
clock_bcd_to_ts(struct bcd_clocktime *bct, struct timespec *ts, bool ampm)
|
||||
clock_bcd_to_ts(const struct bcd_clocktime *bct, struct timespec *ts, bool ampm)
|
||||
{
|
||||
struct clocktime ct;
|
||||
int bcent, byear;
|
||||
@ -249,7 +249,7 @@ clock_bcd_to_ts(struct bcd_clocktime *bct, struct timespec *ts, bool ampm)
|
||||
}
|
||||
|
||||
void
|
||||
clock_ts_to_ct(struct timespec *ts, struct clocktime *ct)
|
||||
clock_ts_to_ct(const struct timespec *ts, struct clocktime *ct)
|
||||
{
|
||||
time_t i, year, days;
|
||||
time_t rsec; /* remainder seconds */
|
||||
@ -310,7 +310,7 @@ clock_ts_to_ct(struct timespec *ts, struct clocktime *ct)
|
||||
}
|
||||
|
||||
void
|
||||
clock_ts_to_bcd(struct timespec *ts, struct bcd_clocktime *bct, bool ampm)
|
||||
clock_ts_to_bcd(const struct timespec *ts, struct bcd_clocktime *bct, bool ampm)
|
||||
{
|
||||
struct clocktime ct;
|
||||
|
||||
|
@ -137,7 +137,8 @@ static const struct {
|
||||
|
||||
|
||||
void
|
||||
timespec2fattime(struct timespec *tsp, int utc, uint16_t *ddp, uint16_t *dtp, uint8_t *dhp)
|
||||
timespec2fattime(const struct timespec *tsp, int utc, uint16_t *ddp,
|
||||
uint16_t *dtp, uint8_t *dhp)
|
||||
{
|
||||
time_t t1;
|
||||
unsigned t2, l, m;
|
||||
@ -217,7 +218,8 @@ static const uint16_t daytab[64] = {
|
||||
};
|
||||
|
||||
void
|
||||
fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc, struct timespec *tsp)
|
||||
fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc,
|
||||
struct timespec *tsp)
|
||||
{
|
||||
unsigned day;
|
||||
|
||||
|
@ -88,8 +88,8 @@ struct clocktime {
|
||||
long nsec; /* nano seconds */
|
||||
};
|
||||
|
||||
int clock_ct_to_ts(struct clocktime *, struct timespec *);
|
||||
void clock_ts_to_ct(struct timespec *, struct clocktime *);
|
||||
int clock_ct_to_ts(const struct clocktime *, struct timespec *);
|
||||
void clock_ts_to_ct(const struct timespec *, struct clocktime *);
|
||||
|
||||
/*
|
||||
* Structure to hold the values typically reported by time-of-day clocks,
|
||||
@ -125,8 +125,8 @@ struct bcd_clocktime {
|
||||
bool ispm; /* true if hour represents pm time */
|
||||
};
|
||||
|
||||
int clock_bcd_to_ts(struct bcd_clocktime *, struct timespec *, bool ampm);
|
||||
void clock_ts_to_bcd(struct timespec *, struct bcd_clocktime *, bool ampm);
|
||||
int clock_bcd_to_ts(const struct bcd_clocktime *, struct timespec *, bool ampm);
|
||||
void clock_ts_to_bcd(const struct timespec *, struct bcd_clocktime *, bool ampm);
|
||||
|
||||
/*
|
||||
* Time-of-day clock functions and flags. These functions might sleep.
|
||||
@ -177,8 +177,10 @@ void clock_unregister(device_t _clockdev);
|
||||
/* Traditional POSIX base year */
|
||||
#define POSIX_BASE_YEAR 1970
|
||||
|
||||
void timespec2fattime(struct timespec *tsp, int utc, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp);
|
||||
void fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc, struct timespec *tsp);
|
||||
void timespec2fattime(const struct timespec *tsp, int utc, u_int16_t *ddp,
|
||||
u_int16_t *dtp, u_int8_t *dhp);
|
||||
void fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc,
|
||||
struct timespec *tsp);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user