Home | History | Annotate | Download | only in Time
      1 /** @file
      2     Definitions private to the Implementation of <time.h>.
      3 
      4     Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
      5     This program and the accompanying materials are licensed and made available under
      6     the terms and conditions of the BSD License that accompanies this distribution.
      7     The full text of the license may be found at
      8     http://opensource.org/licenses/bsd-license.php.
      9 
     10     THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11     WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13   Portions derived from the NIH time zone package files,
     14   which contain the following notice:
     15 
     16     This file is in the public domain, so clarified as of
     17     1996-06-05 by Arthur David Olson (arthur_david_olson (at) nih.gov).
     18 **/
     19 #ifndef _TIMEVAL_H
     20 #define _TIMEVAL_H
     21 
     22 extern struct state * lclptr;
     23 extern struct state * gmtptr;
     24 extern char         * tzname[2];
     25 extern const char     gmt[4];
     26 extern const char     wildabbr[9];
     27 extern const int      year_lengths[2];
     28 extern const int      mon_lengths[2][MONSPERYEAR];
     29 extern long int       timezone;
     30 extern int            daylight;
     31 
     32 #define EFI_UNSPECIFIED_TIMEZONE  0x07FF
     33 
     34 /*
     35 ** The DST rules to use if TZ has no rules and we can't load TZDEFRULES.
     36 ** We default to US rules as of 1999-08-17.
     37 ** POSIX 1003.1 section 8.1.1 says that the default DST rules are
     38 ** implementation dependent; for historical reasons, US rules are a
     39 ** common default.
     40 */
     41 #ifndef TZDEFRULESTRING
     42 #define TZDEFRULESTRING ",M4.1.0,M10.5.0"
     43 #endif
     44 
     45 // Facilities for external time-zone definition files do not currently exist
     46 #define NO_ZONEINFO_FILES
     47 
     48 #define EPOCH_DAY     5
     49 #define DAY_TO_uSEC   86400000000
     50 
     51 /* Rule type values for the r_type member of a rule structure */
     52 #define JULIAN_DAY            0   /* Jn - Julian day */
     53 #define DAY_OF_YEAR           1   /* n - day of year */
     54 #define MONTH_NTH_DAY_OF_WEEK 2   /* Mm.n.d - month, week, day of week */
     55 
     56 #ifdef TZNAME_MAX
     57   #define MY_TZNAME_MAX TZNAME_MAX
     58 #endif /* defined TZNAME_MAX */
     59 
     60 #ifndef TZNAME_MAX
     61   #define MY_TZNAME_MAX 255
     62 #endif /* !defined TZNAME_MAX */
     63 
     64 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
     65 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
     66 
     67 #define LEAPS_THRU_END_OF(y)  ((y) / 4 - (y) / 100 + (y) / 400)
     68 
     69 #define BIGGEST(a, b) (((a) > (b)) ? (a) : (b))
     70 
     71 #ifndef INITIALIZE
     72 #define INITIALIZE(x) ((x) = 0)
     73 #endif /* !defined INITIALIZE */
     74 
     75 struct ttinfo {       /* time type information */
     76   LONG32    tt_gmtoff;  /* UTC offset in seconds */
     77   int   tt_isdst; /* used to set tm_isdst */
     78   int   tt_abbrind; /* abbreviation list index */
     79   int   tt_ttisstd; /* TRUE if transition is std time */
     80   int   tt_ttisgmt; /* TRUE if transition is UTC */
     81 };
     82 
     83 struct lsinfo {       /* leap second information */
     84   time_t    ls_trans; /* transition time */
     85   LONG32    ls_corr;  /* correction to apply */
     86 };
     87 
     88 struct state {
     89   int           leapcnt;
     90   int           timecnt;
     91   int           typecnt;
     92   int           charcnt;
     93   time_t        ats[TZ_MAX_TIMES];
     94   unsigned char types[TZ_MAX_TIMES];
     95   struct ttinfo ttis[TZ_MAX_TYPES];
     96   char          chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt), (2 * (MY_TZNAME_MAX + 1)))];
     97   struct lsinfo lsis[TZ_MAX_LEAPS];
     98 };
     99 
    100 struct rule {
    101   int     r_type;   /* type of rule--see below */
    102   int     r_day;    /* day number of rule */
    103   int     r_week;   /* week number of rule */
    104   int     r_mon;    /* month number of rule */
    105   LONG32    r_time;   /* transition time of rule */
    106 };
    107 
    108 #define JULIAN_DAY    0 /* Jn - Julian day */
    109 #define DAY_OF_YEAR   1 /* n - day of year */
    110 #define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */
    111 
    112 __BEGIN_DECLS
    113 extern void gmtload(struct state * const sp);
    114 extern void tzset(void);
    115 __END_DECLS
    116 
    117 #endif  /* _TIMEVAL_H */
    118