tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Unification of common date/time macros



Hello,

I did some further investigation:
- FreeBSD provides NetBSD's src/syc/dev/clock_subr.h as /usr/include/sys/clock.h
- OpenBSD merged src/sys/dev/clock_subr.h with src/sys/sys/time.h [2]
- Linux kernel nothing (?)
- Tru64 as mentioned before, clock.h inside several paths:
include/alpha/clock.h
include/machine/clock.h
include/sys/machine/clock.h
sys/include/arch/alpha/clock.h
sys/include/machine/clock.h
sys/include/sys/machine/clock.h

My proposition is to go for a new file src/sys/sys/clock.h. Normalize naming 
with /usr/include/tzfile.h, then uniformly export the file for reuse across the 
kernel.

#define SECSPERMIN      60L
#define MINSPERHOUR     60L
#define HOURSPERDAY     24L
#define DAYSPERWEEK     7L
#define DAYSPERNYEAR    365L
#define DAYSPERLYEAR    366L
#define SECSPERHOUR     (SECSPERMIN * MINSPERHOUR)
#define SECSPERDAY      (SECSPERHOUR * HOURSPERDAY)
#define MONSPERYEAR     12L
#define EPOCH_YEAR      1970L

+ macros/defines of leap-year macro, weak-of-day etc.

Maybe avoid name-clashes with tzfile.h and go for SECSMIN etc.?

What do you think? Is it worth adding?

Thanks in advance,

[1] http://fxr.watson.org/fxr/source/sys/clock.h
[2] 
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/time.h.diff?r1=1.22&r2=1.23&f=h


Home | Main Index | Thread Index | Old Index