Merge branch 'release/2.10/master' into fedora/2.10/master
[glibc.git] / fedora / tzdata-update.c
blobf94f9a2609ee8707d87c9d5ca776ed14e8f16dd5
1 #ifdef __sparc__
2 register void *__thread_self __asm ("g7");
3 #endif
4 #define _GNU_SOURCE 1
5 #include <errno.h>
6 #include <fcntl.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <syscall.h>
10 #include <unistd.h>
12 #if defined __i386__
13 # define INTERNAL_SYSCALL_DECL(err) do { } while (0)
14 # define INTERNAL_SYSCALL(name, err, nr, args...) \
15 ({ \
16 register unsigned int resultvar; \
17 asm volatile ( \
18 "movl %1, %%eax\n\t" \
19 "int $0x80\n\t" \
20 : "=a" (resultvar) \
21 : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc"); \
22 (int) resultvar; })
23 # define INTERNAL_SYSCALL_ERROR_P(val, err) \
24 ((unsigned int) (val) >= 0xfffff001u)
25 # define ASMFMT_0()
26 # define ASMFMT_1(arg1) \
27 , "b" (arg1)
28 # define ASMFMT_2(arg1, arg2) \
29 , "b" (arg1), "c" (arg2)
30 # define ASMFMT_3(arg1, arg2, arg3) \
31 , "b" (arg1), "c" (arg2), "d" (arg3)
32 #elif defined __x86_64__
33 # define INTERNAL_SYSCALL_DECL(err) do { } while (0)
34 # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
35 ({ \
36 unsigned long resultvar; \
37 LOAD_ARGS_##nr (args) \
38 LOAD_REGS_##nr \
39 asm volatile ( \
40 "syscall\n\t" \
41 : "=a" (resultvar) \
42 : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
43 (long) resultvar; })
44 # define INTERNAL_SYSCALL(name, err, nr, args...) \
45 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
46 # define INTERNAL_SYSCALL_ERROR_P(val, err) \
47 ((unsigned long) (val) >= -4095L)
48 # define LOAD_ARGS_0()
49 # define LOAD_REGS_0
50 # define ASM_ARGS_0
51 # define LOAD_ARGS_1(a1) \
52 long int __arg1 = (long) (a1); \
53 LOAD_ARGS_0 ()
54 # define LOAD_REGS_1 \
55 register long int _a1 asm ("rdi") = __arg1; \
56 LOAD_REGS_0
57 # define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
58 # define LOAD_ARGS_2(a1, a2) \
59 long int __arg2 = (long) (a2); \
60 LOAD_ARGS_1 (a1)
61 # define LOAD_REGS_2 \
62 register long int _a2 asm ("rsi") = __arg2; \
63 LOAD_REGS_1
64 # define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
65 # define LOAD_ARGS_3(a1, a2, a3) \
66 long int __arg3 = (long) (a3); \
67 LOAD_ARGS_2 (a1, a2)
68 # define LOAD_REGS_3 \
69 register long int _a3 asm ("rdx") = __arg3; \
70 LOAD_REGS_2
71 # define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
72 #elif defined __powerpc__
73 # define INTERNAL_SYSCALL_DECL(err) long int err
74 # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
75 ({ \
76 register long int r0 __asm__ ("r0"); \
77 register long int r3 __asm__ ("r3"); \
78 register long int r4 __asm__ ("r4"); \
79 register long int r5 __asm__ ("r5"); \
80 register long int r6 __asm__ ("r6"); \
81 register long int r7 __asm__ ("r7"); \
82 register long int r8 __asm__ ("r8"); \
83 LOADARGS_##nr(name, args); \
84 __asm__ __volatile__ \
85 ("sc\n\t" \
86 "mfcr %0\n\t" \
87 : "=&r" (r0), \
88 "=&r" (r3), "=&r" (r4), "=&r" (r5), \
89 "=&r" (r6), "=&r" (r7), "=&r" (r8) \
90 : ASM_INPUT_##nr \
91 : "r9", "r10", "r11", "r12", \
92 "cr0", "ctr", "memory"); \
93 err = r0; \
94 (int) r3; \
96 # define INTERNAL_SYSCALL(name, err, nr, args...) \
97 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
98 # define INTERNAL_SYSCALL_ERROR_P(val, err) \
99 ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
100 # define LOADARGS_0(name, dummy) \
101 r0 = name
102 # define LOADARGS_1(name, __arg1) \
103 long int arg1 = (long int) (__arg1); \
104 LOADARGS_0(name, 0); \
105 r3 = arg1
106 # define LOADARGS_2(name, __arg1, __arg2) \
107 long int arg2 = (long int) (__arg2); \
108 LOADARGS_1(name, __arg1); \
109 r4 = arg2
110 # define LOADARGS_3(name, __arg1, __arg2, __arg3) \
111 long int arg3 = (long int) (__arg3); \
112 LOADARGS_2(name, __arg1, __arg2); \
113 r5 = arg3
114 # define ASM_INPUT_0 "0" (r0)
115 # define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
116 # define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
117 # define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
118 #elif defined __ia64__
119 # define DO_INLINE_SYSCALL_NCS(name, nr, args...) \
120 LOAD_ARGS_##nr (args) \
121 register long _r8 asm ("r8"); \
122 register long _r10 asm ("r10"); \
123 register long _r15 asm ("r15") = name; \
124 long _retval; \
125 LOAD_REGS_##nr \
126 __asm __volatile ("break 0x100000;;" \
127 : "=r" (_r8), "=r" (_r10), "=r" (_r15) \
128 ASM_OUTARGS_##nr \
129 : "2" (_r15) ASM_ARGS_##nr \
130 : "memory" ASM_CLOBBERS_##nr); \
131 _retval = _r8;
132 # define INTERNAL_SYSCALL_DECL(err) long int err
133 # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
134 ({ \
135 DO_INLINE_SYSCALL_NCS (name, nr, args) \
136 err = _r10; \
137 _retval; })
138 # define INTERNAL_SYSCALL(name, err, nr, args...) \
139 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
140 # define INTERNAL_SYSCALL_ERROR_P(val, err) (err == -1)
141 # define LOAD_ARGS_0()
142 # define LOAD_REGS_0
143 # define LOAD_ARGS_1(a1) \
144 long _arg1 = (long) (a1); \
145 LOAD_ARGS_0 ()
146 # define LOAD_REGS_1 \
147 register long _out0 asm ("out0") = _arg1; \
148 LOAD_REGS_0
149 # define LOAD_ARGS_2(a1, a2) \
150 long _arg2 = (long) (a2); \
151 LOAD_ARGS_1 (a1)
152 # define LOAD_REGS_2 \
153 register long _out1 asm ("out1") = _arg2; \
154 LOAD_REGS_1
155 # define LOAD_ARGS_3(a1, a2, a3) \
156 long _arg3 = (long) (a3); \
157 LOAD_ARGS_2 (a1, a2)
158 # define LOAD_REGS_3 \
159 register long _out2 asm ("out2") = _arg3; \
160 LOAD_REGS_2
161 # define ASM_OUTARGS_0
162 # define ASM_OUTARGS_1 ASM_OUTARGS_0, "=r" (_out0)
163 # define ASM_OUTARGS_2 ASM_OUTARGS_1, "=r" (_out1)
164 # define ASM_OUTARGS_3 ASM_OUTARGS_2, "=r" (_out2)
165 # define ASM_ARGS_0
166 # define ASM_ARGS_1 ASM_ARGS_0, "3" (_out0)
167 # define ASM_ARGS_2 ASM_ARGS_1, "4" (_out1)
168 # define ASM_ARGS_3 ASM_ARGS_2, "5" (_out2)
169 # define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0"
170 # define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1"
171 # define ASM_CLOBBERS_2 ASM_CLOBBERS_3, "out2"
172 # define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3"
173 # define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4"
174 # define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5"
175 # define ASM_CLOBBERS_6_COMMON , "out6", "out7", \
176 /* Non-stacked integer registers, minus r8, r10, r15. */ \
177 "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
178 "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
179 "r28", "r29", "r30", "r31", \
180 /* Predicate registers. */ \
181 "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
182 /* Non-rotating fp registers. */ \
183 "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
184 /* Branch registers. */ \
185 "b6"
186 # define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON , "b7"
187 #elif defined __s390__
188 # define INTERNAL_SYSCALL_DECL(err) do { } while (0)
189 # define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...) \
190 ({ \
191 DECLARGS_##nr(args) \
192 register long _ret asm("2"); \
193 asm volatile ( \
194 "svc %b1\n\t" \
195 : "=d" (_ret) \
196 : "i" (__NR_##name) ASMFMT_##nr \
197 : "memory" ); \
198 _ret; })
199 # define INTERNAL_SYSCALL_SVC0(name, err, nr, args...) \
200 ({ \
201 DECLARGS_##nr(args) \
202 register unsigned long _nr asm("1") = (unsigned long)(__NR_##name); \
203 register long _ret asm("2"); \
204 asm volatile ( \
205 "svc 0\n\t" \
206 : "=d" (_ret) \
207 : "d" (_nr) ASMFMT_##nr \
208 : "memory" ); \
209 _ret; })
210 # define INTERNAL_SYSCALL(name, err, nr, args...) \
211 (((__NR_##name) < 256) ? \
212 INTERNAL_SYSCALL_DIRECT(name, err, nr, args) : \
213 INTERNAL_SYSCALL_SVC0(name, err,nr, args))
214 # define INTERNAL_SYSCALL_ERROR_P(val, err) \
215 ((unsigned long) (val) >= -4095UL)
216 # define DECLARGS_0()
217 # define DECLARGS_1(arg1) \
218 register unsigned long gpr2 asm ("2") = (unsigned long)(arg1);
219 # define DECLARGS_2(arg1, arg2) \
220 DECLARGS_1(arg1) \
221 register unsigned long gpr3 asm ("3") = (unsigned long)(arg2);
222 # define DECLARGS_3(arg1, arg2, arg3) \
223 DECLARGS_2(arg1, arg2) \
224 register unsigned long gpr4 asm ("4") = (unsigned long)(arg3);
225 # define ASMFMT_0
226 # define ASMFMT_1 , "0" (gpr2)
227 # define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
228 # define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
229 #elif defined __sparc__
230 # ifndef __arch64__
231 # define __INTERNAL_SYSCALL_STRING \
232 "ta 0x10;" \
233 "bcs,a 1f;" \
234 " sub %%g0, %%o0, %%o0;" \
235 "1:"
236 # define __SYSCALL_CLOBBERS "g2", "g3", "g4", "g5", "g6", \
237 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
238 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
239 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
240 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
241 "cc", "memory"
242 # else
243 # define __INTERNAL_SYSCALL_STRING \
244 "ta 0x6d;" \
245 "bcs,a,pt %%xcc, 1f;" \
246 " sub %%g0, %%o0, %%o0;" \
247 "1:"
248 # define __SYSCALL_CLOBBERS "g2", "g3", "g4", "g5", "g6", \
249 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
250 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
251 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
252 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
253 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \
254 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \
255 "cc", "memory"
256 # endif
257 #define INTERNAL_SYSCALL_DECL(err) do { } while (0)
258 #define INTERNAL_SYSCALL(name, err, nr, args...) \
259 inline_syscall##nr(__INTERNAL_SYSCALL_STRING, __NR_##name, args)
260 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
261 ((unsigned long) (val) >= -515L)
262 # define inline_syscall0(string,name,dummy...) \
263 ({ \
264 register long __o0 __asm__ ("o0"); \
265 register long __g1 __asm__ ("g1") = name; \
266 __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \
267 "0" (__g1) : \
268 __SYSCALL_CLOBBERS); \
269 __o0; \
271 # define inline_syscall1(string,name,arg1) \
272 ({ \
273 register long __o0 __asm__ ("o0") = (long)(arg1); \
274 register long __g1 __asm__ ("g1") = name; \
275 __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \
276 "0" (__g1), "1" (__o0) : \
277 __SYSCALL_CLOBBERS); \
278 __o0; \
280 # define inline_syscall2(string,name,arg1,arg2) \
281 ({ \
282 register long __o0 __asm__ ("o0") = (long)(arg1); \
283 register long __o1 __asm__ ("o1") = (long)(arg2); \
284 register long __g1 __asm__ ("g1") = name; \
285 __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \
286 "0" (__g1), "1" (__o0), "r" (__o1) : \
287 __SYSCALL_CLOBBERS); \
288 __o0; \
290 # define inline_syscall3(string,name,arg1,arg2,arg3) \
291 ({ \
292 register long __o0 __asm__ ("o0") = (long)(arg1); \
293 register long __o1 __asm__ ("o1") = (long)(arg2); \
294 register long __o2 __asm__ ("o2") = (long)(arg3); \
295 register long __g1 __asm__ ("g1") = name; \
296 __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \
297 "0" (__g1), "1" (__o0), "r" (__o1), \
298 "r" (__o2) : \
299 __SYSCALL_CLOBBERS); \
300 __o0; \
302 #elif defined __alpha__
303 # define INTERNAL_SYSCALL(name, err_out, nr, args...) \
304 INTERNAL_SYSCALL1(name, err_out, nr, args)
305 # define INTERNAL_SYSCALL1(name, err_out, nr, args...) \
306 INTERNAL_SYSCALL_NCS(__NR_##name, err_out, nr, args)
307 # define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
308 ({ \
309 long _sc_ret, _sc_err; \
310 inline_syscall##nr(name, args); \
311 err_out = _sc_err; \
312 _sc_ret; \
314 # define INTERNAL_SYSCALL_DECL(err) long int err
315 # define INTERNAL_SYSCALL_ERROR_P(val, err) err
316 # define inline_syscall_clobbers \
317 "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
318 "$22", "$23", "$24", "$25", "$27", "$28", "memory"
319 # define inline_syscall_r0_asm
320 # define inline_syscall_r0_out_constraint "=v"
321 # define inline_syscall0(name, args...) \
323 register long _sc_0 inline_syscall_r0_asm; \
324 register long _sc_19 __asm__("$19"); \
326 _sc_0 = name; \
327 __asm__ __volatile__ \
328 ("callsys # %0 %1 <= %2" \
329 : inline_syscall_r0_out_constraint (_sc_0), \
330 "=r"(_sc_19) \
331 : "0"(_sc_0) \
332 : inline_syscall_clobbers, \
333 "$16", "$17", "$18", "$20", "$21"); \
334 _sc_ret = _sc_0, _sc_err = _sc_19; \
336 # define inline_syscall1(name,arg1) \
338 register long _sc_0 inline_syscall_r0_asm; \
339 register long _sc_16 __asm__("$16"); \
340 register long _sc_19 __asm__("$19"); \
342 _sc_0 = name; \
343 _sc_16 = (long) (arg1); \
344 __asm__ __volatile__ \
345 ("callsys # %0 %1 <= %2 %3" \
346 : inline_syscall_r0_out_constraint (_sc_0), \
347 "=r"(_sc_19), "=r"(_sc_16) \
348 : "0"(_sc_0), "2"(_sc_16) \
349 : inline_syscall_clobbers, \
350 "$17", "$18", "$20", "$21"); \
351 _sc_ret = _sc_0, _sc_err = _sc_19; \
353 # define inline_syscall2(name,arg1,arg2) \
355 register long _sc_0 inline_syscall_r0_asm; \
356 register long _sc_16 __asm__("$16"); \
357 register long _sc_17 __asm__("$17"); \
358 register long _sc_19 __asm__("$19"); \
360 _sc_0 = name; \
361 _sc_16 = (long) (arg1); \
362 _sc_17 = (long) (arg2); \
363 __asm__ __volatile__ \
364 ("callsys # %0 %1 <= %2 %3 %4" \
365 : inline_syscall_r0_out_constraint (_sc_0), \
366 "=r"(_sc_19), "=r"(_sc_16), "=r"(_sc_17) \
367 : "0"(_sc_0), "2"(_sc_16), "3"(_sc_17) \
368 : inline_syscall_clobbers, \
369 "$18", "$20", "$21"); \
370 _sc_ret = _sc_0, _sc_err = _sc_19; \
372 # define inline_syscall3(name,arg1,arg2,arg3) \
374 register long _sc_0 inline_syscall_r0_asm; \
375 register long _sc_16 __asm__("$16"); \
376 register long _sc_17 __asm__("$17"); \
377 register long _sc_18 __asm__("$18"); \
378 register long _sc_19 __asm__("$19"); \
380 _sc_0 = name; \
381 _sc_16 = (long) (arg1); \
382 _sc_17 = (long) (arg2); \
383 _sc_18 = (long) (arg3); \
384 __asm__ __volatile__ \
385 ("callsys # %0 %1 <= %2 %3 %4 %5" \
386 : inline_syscall_r0_out_constraint (_sc_0), \
387 "=r"(_sc_19), "=r"(_sc_16), "=r"(_sc_17), \
388 "=r"(_sc_18) \
389 : "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), \
390 "4"(_sc_18) \
391 : inline_syscall_clobbers, "$20", "$21"); \
392 _sc_ret = _sc_0, _sc_err = _sc_19; \
394 #endif
396 char buffer[32768], data[32768];
397 size_t datasize;
398 char zonename[1024];
400 ssize_t
401 readall (int fd, void *buf, size_t len)
403 INTERNAL_SYSCALL_DECL (err);
404 size_t n = len;
405 ssize_t ret;
408 ret = INTERNAL_SYSCALL (read, err, 3, fd, buf, n);
409 if (INTERNAL_SYSCALL_ERROR_P (ret, err))
411 ret = -1;
412 break;
414 else if (ret == 0)
415 break;
416 buf = (char *) buf + ret;
417 n -= ret;
419 while (n > 0);
420 return ret < 0 ? ret : (ssize_t) (len - n);
423 ssize_t
424 writeall (int fd, const void *buf, size_t len)
426 INTERNAL_SYSCALL_DECL (err);
427 size_t n = len;
428 ssize_t ret;
431 ret = INTERNAL_SYSCALL (write, err, 3, fd, buf, n);
432 if (INTERNAL_SYSCALL_ERROR_P (ret, err))
434 ret = -1;
435 break;
437 else if (ret == 0)
438 break;
439 buf = (const char *) buf + ret;
440 n -= ret;
442 while (n > 0);
443 return ret < 0 ? ret : (ssize_t) (len - n);
446 void
447 update (const char *filename)
449 INTERNAL_SYSCALL_DECL (err);
450 long int fd = INTERNAL_SYSCALL (open, err, 2, filename, O_RDONLY);
451 if (INTERNAL_SYSCALL_ERROR_P (fd, err))
452 return;
453 ssize_t ret = readall (fd, buffer, sizeof (buffer));
454 INTERNAL_SYSCALL (close, err, 1, fd);
455 if (ret <= 0 || (size_t) ret == sizeof (buffer))
456 return;
457 /* Don't update the file unnecessarily. */
458 if ((size_t) ret == datasize && memcmp (buffer, data, datasize) == 0)
459 return;
460 size_t len = strlen (filename);
461 char tempfilename[len + sizeof (".tzupdate")];
462 memcpy (tempfilename, filename, len);
463 memcpy (tempfilename + len, ".tzupdate", sizeof (".tzupdate"));
465 fd = INTERNAL_SYSCALL (open, err, 3, tempfilename, O_WRONLY | O_CREAT | O_EXCL, 0600);
466 if (INTERNAL_SYSCALL_ERROR_P (fd, err))
467 return;
468 if (writeall (fd, data, datasize) != datasize)
470 clean_up:
471 INTERNAL_SYSCALL (unlink, err, 1, tempfilename);
472 INTERNAL_SYSCALL (close, err, 1, fd);
473 return;
475 long int sret;
476 sret = INTERNAL_SYSCALL (fchmod, err, 2, fd, 0644);
477 if (INTERNAL_SYSCALL_ERROR_P (sret, err))
478 goto clean_up;
479 INTERNAL_SYSCALL (close, err, 1, fd);
481 sret = INTERNAL_SYSCALL (rename, err, 2, tempfilename, filename);
482 if (INTERNAL_SYSCALL_ERROR_P (sret, err))
483 INTERNAL_SYSCALL (unlink, err, 1, tempfilename);
487 main (int argc, char **argv)
489 INTERNAL_SYSCALL_DECL (err);
490 long int fd = INTERNAL_SYSCALL (open, err, 2, "/etc/sysconfig/clock", O_RDONLY);
491 if (INTERNAL_SYSCALL_ERROR_P (fd, err))
492 return 0;
493 ssize_t ret = readall (fd, buffer, sizeof (buffer) - 1);
494 INTERNAL_SYSCALL (close, err, 1, fd);
495 if (ret <= 0 || (size_t) ret == sizeof (buffer) - 1)
496 return 0;
497 char *p = buffer;
498 while (p != NULL)
500 while (*p == ' ' || *p == '\t') p++;
501 if (memcmp (p, "ZONE", 4) == 0)
503 p += 4;
504 while (*p == ' ' || *p == '\t') p++;
505 if (*p == '=')
507 p++;
508 while (*p == ' ' || *p == '\t') p++;
509 if (*p == '"') p++;
510 char *q = p;
511 while (strchr (" \t\n\"", *p) == NULL) p++;
512 const char path[] = "/usr/share/zoneinfo/";
513 if (p - q >= sizeof (zonename) - sizeof (path))
514 return 0;
515 memcpy (zonename, path, sizeof (path) - 1);
516 memcpy (zonename + sizeof (path) - 1, q, p - q);
517 break;
520 p = strchr (p, '\n');
521 if (p) p++;
523 if (*zonename == '\0')
524 return 0;
525 fd = INTERNAL_SYSCALL (open, err, 2, zonename, O_RDONLY);
526 if (INTERNAL_SYSCALL_ERROR_P (fd, err))
527 return 0;
528 ret = readall (fd, data, sizeof (data));
529 INTERNAL_SYSCALL (close, err, 1, fd);
530 if (ret <= 0 || (size_t) ret == sizeof (data))
531 return 0;
532 datasize = (size_t) ret;
533 update ("/etc/localtime");
534 update ("/var/spool/postfix/etc/localtime");
535 return 0;
538 int __libc_multiple_threads __attribute__((nocommon));
539 int __libc_enable_asynccancel (void) { return 0; }
540 void __libc_disable_asynccancel (int x) { }
541 void __libc_csu_init (void) { }
542 void __libc_csu_fini (void) { }
543 pid_t __fork (void) { return -1; }
544 char thr_buf[65536];
546 #ifndef __powerpc__
547 int __libc_start_main (int (*main) (int argc, char **argv),
548 int argc, char **argv,
549 void (*init) (void), void (*fini) (void),
550 void (*rtld_fini) (void), void * stack_end)
551 #else
552 struct startup_info
554 void *sda_base;
555 int (*main) (int, char **, char **, void *);
556 int (*init) (int, char **, char **, void *);
557 void (*fini) (void);
560 int __libc_start_main (int argc, char **argv, char **ev,
561 void *auxvec, void (*rtld_fini) (void),
562 struct startup_info *stinfo,
563 char **stack_on_entry)
564 #endif
566 #if defined __ia64__ || defined __powerpc64__
567 register void *r13 __asm ("r13") = thr_buf + 32768;
568 __asm ("" : : "r" (r13));
569 #elif defined __sparc__
570 register void *g6 __asm ("g6") = thr_buf + 32768;
571 __thread_self = thr_buf + 32768;
572 __asm ("" : : "r" (g6), "r" (__thread_self));
573 #elif defined __s390__ && !defined __s390x__
574 __asm ("sar %%a0,%0" : : "d" (thr_buf + 32768));
575 #elif defined __s390x__
576 __asm ("sar %%a1,%0; srlg 0,%0,32; sar %%a0,0" : : "d" (thr_buf + 32768) : "0");
577 #elif defined __powerpc__ && !defined __powerpc64__
578 register void *r2 __asm ("r2") = thr_buf + 32768;
579 __asm ("" : : "r" (r2));
580 #endif
581 #ifdef __powerpc__
582 argc = (long)*stack_on_entry;
583 argv = stack_on_entry + 1;
584 #endif
585 long ret = main (argc, argv);
586 INTERNAL_SYSCALL_DECL (err);
587 INTERNAL_SYSCALL (exit, err, 1, ret);
588 return 110;