FreeBSD kernel kern code
subr_fattime.c File Reference
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/clock.h>
Include dependency graph for subr_fattime.c:

Go to the source code of this file.

Macros

#define DAY   (24 * 60 * 60) /* Length of day in seconds */
 
#define YEAR   365 /* Length of normal year */
 
#define LYC   (4 * YEAR + 1) /* Length of 4 year leap-year cycle */
 
#define T1980   (10 * 365 + 2) /* Days from 1970 to 1980 */
 
#define JAN   31
 
#define FEB   (JAN + 28)
 
#define MAR   (FEB + 31)
 
#define APR   (MAR + 30)
 
#define MAY   (APR + 31)
 
#define JUN   (MAY + 30)
 
#define JUL   (JUN + 31)
 
#define AUG   (JUL + 31)
 
#define SEP   (AUG + 30)
 
#define OCT   (SEP + 31)
 
#define NOV   (OCT + 30)
 
#define DEC   (NOV + 31)
 
#define ENC(y, m)   (((y) << 9) | ((m) << 5))
 
#define DCOD(m, y, l)   ((m) + YEAR * (y) + (l))
 

Functions

void timespec2fattime (const struct timespec *tsp, int utc, uint16_t *ddp, uint16_t *dtp, uint8_t *dhp)
 
void fattime2timespec (unsigned dd, unsigned dt, unsigned dh, int utc, struct timespec *tsp)
 

Variables

struct {
   uint16_t   days
 
   uint16_t   coded
 
mtab [48]
 
static const uint16_t daytab [64]
 

Macro Definition Documentation

◆ APR

#define APR   (MAR + 30)

Definition at line 89 of file subr_fattime.c.

◆ AUG

#define AUG   (JUL + 31)

Definition at line 93 of file subr_fattime.c.

◆ DAY

#define DAY   (24 * 60 * 60) /* Length of day in seconds */

Definition at line 80 of file subr_fattime.c.

◆ DCOD

#define DCOD (   m,
  y,
 
)    ((m) + YEAR * (y) + (l))

Definition at line 199 of file subr_fattime.c.

◆ DEC

#define DEC   (NOV + 31)

Definition at line 97 of file subr_fattime.c.

◆ ENC

#define ENC (   y,
 
)    (((y) << 9) | ((m) << 5))

Definition at line 101 of file subr_fattime.c.

◆ FEB

#define FEB   (JAN + 28)

Definition at line 87 of file subr_fattime.c.

◆ JAN

#define JAN   31

Definition at line 86 of file subr_fattime.c.

◆ JUL

#define JUL   (JUN + 31)

Definition at line 92 of file subr_fattime.c.

◆ JUN

#define JUN   (MAY + 30)

Definition at line 91 of file subr_fattime.c.

◆ LYC

#define LYC   (4 * YEAR + 1) /* Length of 4 year leap-year cycle */

Definition at line 82 of file subr_fattime.c.

◆ MAR

#define MAR   (FEB + 31)

Definition at line 88 of file subr_fattime.c.

◆ MAY

#define MAY   (APR + 31)

Definition at line 90 of file subr_fattime.c.

◆ NOV

#define NOV   (OCT + 30)

Definition at line 96 of file subr_fattime.c.

◆ OCT

#define OCT   (SEP + 31)

Definition at line 95 of file subr_fattime.c.

◆ SEP

#define SEP   (AUG + 30)

Definition at line 94 of file subr_fattime.c.

◆ T1980

#define T1980   (10 * 365 + 2) /* Days from 1970 to 1980 */

Definition at line 83 of file subr_fattime.c.

◆ YEAR

#define YEAR   365 /* Length of normal year */

Definition at line 81 of file subr_fattime.c.

Function Documentation

◆ fattime2timespec()

void fattime2timespec ( unsigned  dd,
unsigned  dt,
unsigned  dh,
int  utc,
struct timespec *  tsp 
)

Definition at line 220 of file subr_fattime.c.

References DAY, daytab, FEB, LYC, T1980, and utc_offset().

Here is the call graph for this function:

◆ timespec2fattime()

void timespec2fattime ( const struct timespec *  tsp,
int  utc,
uint16_t *  ddp,
uint16_t *  dtp,
uint8_t *  dhp 
)

Definition at line 139 of file subr_fattime.c.

References DAY, days, FEB, LYC, mtab, T1980, and utc_offset().

Here is the call graph for this function:

Variable Documentation

◆ coded

uint16_t coded

Definition at line 105 of file subr_fattime.c.

◆ days

uint16_t days

Definition at line 104 of file subr_fattime.c.

Referenced by clock_ct_to_ts(), clock_ts_to_ct(), and timespec2fattime().

◆ daytab

const uint16_t daytab[64]
static
Initial value:
= {
0, DCOD( 0, 0, 0), DCOD(JAN, 0, 0), DCOD(FEB, 0, 1),
DCOD(MAR, 0, 1), DCOD(APR, 0, 1), DCOD(MAY, 0, 1), DCOD(JUN, 0, 1),
DCOD(JUL, 0, 1), DCOD(AUG, 0, 1), DCOD(SEP, 0, 1), DCOD(OCT, 0, 1),
DCOD(NOV, 0, 1), DCOD(DEC, 0, 1), 0, 0,
0, DCOD( 0, 1, 1), DCOD(JAN, 1, 1), DCOD(FEB, 1, 1),
DCOD(MAR, 1, 1), DCOD(APR, 1, 1), DCOD(MAY, 1, 1), DCOD(JUN, 1, 1),
DCOD(JUL, 1, 1), DCOD(AUG, 1, 1), DCOD(SEP, 1, 1), DCOD(OCT, 1, 1),
DCOD(NOV, 1, 1), DCOD(DEC, 1, 1), 0, 0,
0, DCOD( 0, 2, 1), DCOD(JAN, 2, 1), DCOD(FEB, 2, 1),
DCOD(MAR, 2, 1), DCOD(APR, 2, 1), DCOD(MAY, 2, 1), DCOD(JUN, 2, 1),
DCOD(JUL, 2, 1), DCOD(AUG, 2, 1), DCOD(SEP, 2, 1), DCOD(OCT, 2, 1),
DCOD(NOV, 2, 1), DCOD(DEC, 2, 1), 0, 0,
0, DCOD( 0, 3, 1), DCOD(JAN, 3, 1), DCOD(FEB, 3, 1),
DCOD(MAR, 3, 1), DCOD(APR, 3, 1), DCOD(MAY, 3, 1), DCOD(JUN, 3, 1),
DCOD(JUL, 3, 1), DCOD(AUG, 3, 1), DCOD(SEP, 3, 1), DCOD(OCT, 3, 1),
DCOD(NOV, 3, 1), DCOD(DEC, 3, 1), 0, 0
}
#define APR
Definition: subr_fattime.c:89
#define NOV
Definition: subr_fattime.c:96
#define AUG
Definition: subr_fattime.c:93
#define MAY
Definition: subr_fattime.c:90
#define JUN
Definition: subr_fattime.c:91
#define MAR
Definition: subr_fattime.c:88
#define OCT
Definition: subr_fattime.c:95
#define JUL
Definition: subr_fattime.c:92
#define SEP
Definition: subr_fattime.c:94
#define FEB
Definition: subr_fattime.c:87
#define JAN
Definition: subr_fattime.c:86
#define DCOD(m, y, l)
Definition: subr_fattime.c:199
#define DEC
Definition: subr_fattime.c:97

Definition at line 200 of file subr_fattime.c.

Referenced by fattime2timespec().

◆ 

const struct { ... } mtab[48]

Referenced by timespec2fattime().