1 /* Copyright (c) 2002 Jeff Johnston <jjohnstn@redhat.com> */
2 /* local header used by libc/time routines */
3 #ifndef _DEFAULT_SOURCE
4 #define _DEFAULT_SOURCE
5 #endif
6 #include <_ansi.h>
7 #include <time.h>
8 #include <sys/_tz_structs.h>
9 #include <sys/lock.h>
10 
11 #define SECSPERMIN	60L
12 #define MINSPERHOUR	60L
13 #define HOURSPERDAY	24L
14 #define SECSPERHOUR	(SECSPERMIN * MINSPERHOUR)
15 #define SECSPERDAY	(SECSPERHOUR * HOURSPERDAY)
16 #define DAYSPERWEEK	7
17 #define MONSPERYEAR	12
18 
19 #define YEAR_BASE	1900
20 #define EPOCH_YEAR      1970
21 #define EPOCH_WDAY      4
22 #define EPOCH_YEARS_SINCE_LEAP 2
23 #define EPOCH_YEARS_SINCE_CENTURY 70
24 #define EPOCH_YEARS_SINCE_LEAP_CENTURY 370
25 
isleap(int y)26 static inline int isleap (int y)
27 {
28   // This routine must return exactly 0 or 1, because the result is used to index on __month_lengths[].
29   // The order of checks below is the fastest for a random year.
30   return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
31 }
32 
33 int         __tzcalc_limits (int __year);
34 
35 extern const uint8_t __month_lengths[2][MONSPERYEAR];
36 
37 void _tzset_unlocked (void);
38 
39 /* locks for multi-threading */
40 #define TZ_LOCK		__LIBC_LOCK()
41 #define TZ_UNLOCK	__LIBC_UNLOCK()
42 
43