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