pass ARCH down to uClibc
[buildroot.git] / toolchain / uClibc / uClibc-0.9.28-new_dst_rules.patch
blob8b1a5a9ac97ed7c617335f875f34a50e29709406
1 --- uClibc/libc/misc/time/time.c (revision 16488)
2 +++ uClibc/libc/misc/time/time.c (working copy)
3 @@ -157,6 +157,22 @@
4 #define TZNAME_MAX _POSIX_TZNAME_MAX
5 #endif
7 +#if defined (L_tzset) || defined (L_localtime_r) || defined(L_strftime) || \
8 + defined(L__time_mktime) || defined(L__time_mktime_tzi) || \
9 + ((defined(L_strftime) || defined(L_strftime_l)) && \
10 + defined(__UCLIBC_HAS_XLOCALE__))
12 +void _time_tzset (int);
14 +#ifndef L__time_mktime
16 + /* Jan 1, 2007 Z - tm = 0,0,0,1,0,107,1,0,0 */
18 +const static time_t new_rule_starts = 1167609600;
20 +#endif
21 +#endif
23 /**********************************************************************/
24 /* The era code is currently unfinished. */
25 /* #define ENABLE_ERA_CODE */
26 @@ -532,7 +548,7 @@
28 __UCLIBC_MUTEX_LOCK(_time_tzlock);
30 - tzset();
31 + _time_tzset(*timer < new_rule_starts);
33 __time_localtime_tzi(timer, result, _time_tzinfo);
35 @@ -956,7 +972,8 @@
36 unsigned char mod;
37 unsigned char code;
39 - tzset(); /* We'll, let's get this out of the way. */
40 + /* We'll, let's get this out of the way. */
41 + _time_tzset(_time_mktime((struct tm *) timeptr, 0) < new_rule_starts);
43 lvl = 0;
44 p = format;
45 @@ -1644,7 +1661,9 @@
46 6, 0, 0, /* Note: overloaded for non-M non-J case... */
47 0, 1, 0, /* J */
48 ',', 'M', '4', '.', '1', '.', '0',
49 - ',', 'M', '1', '0', '.', '5', '.', '0', 0
50 + ',', 'M', '1', '0', '.', '5', '.', '0', 0,
51 + ',', 'M', '3', '.', '2', '.', '0',
52 + ',', 'M', '1', '1', '.', '1', '.', '0', 0
55 #define TZ vals
56 @@ -1652,6 +1671,7 @@
57 #define RANGE (vals + 7)
58 #define RULE (vals + 11 - 1)
59 #define DEFAULT_RULES (vals + 22)
60 +#define DEFAULT_2007_RULES (vals + 38)
62 /* Initialize to UTC. */
63 int daylight = 0;
64 @@ -1774,6 +1794,11 @@
66 void tzset(void)
68 + _time_tzset((time(NULL)) < new_rule_starts);
71 +void _time_tzset(int use_old_rules)
73 register const char *e;
74 register char *s;
75 long off;
76 @@ -1896,7 +1921,15 @@
77 } else { /* OK, we have dst, so get some rules. */
78 count = 0;
79 if (!*e) { /* No rules so default to US rules. */
80 - e = DEFAULT_RULES;
81 + e = use_old_rules ? DEFAULT_RULES : DEFAULT_2007_RULES;
82 +#ifdef DEBUG_TZSET
83 + if (e == DEFAULT_RULES)
84 + printf("tzset: Using old rules.\n");
85 + else if (e == DEFAULT_2007_RULES)
86 + printf("tzset: Using new rules\n");
87 + else
88 + printf("tzset: Using undefined rules\n");
89 +#endif /* DEBUG_TZSET */
92 do {
93 @@ -2230,6 +2263,8 @@
94 --d;
97 + _time_tzset (x.tm_year < 2007); /* tm_year was expanded above */
99 #ifdef __BCC__
100 d = p[5] - 1;
101 days = -719163L + ((long)d)*365 + ((d/4) - (d/100) + (d/400) + p[3] + p[7]);