fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / sys / z8ksim / crt0.c
blobf9aad6d95a32364fb9888cdd24feaced7f6d0d9b
1 extern char _start_bss;
2 extern char _end_bss;
3 extern int main(int argc, char **argv, char **environ);
4 void __main();
6 static void
7 enter()
9 #if defined(__Z8002__)
10 __main();
11 #endif
12 exit(main(0,0,0));
14 start()
16 char *p;
17 #if defined(__Z8002__)
18 asm("ld r15,#__stack_top");
19 asm("ld r10,r15");
20 #endif
21 #if defined(__Z8001__)
22 asm("ldl rr14,#__stack_top");
23 asm("ldl rr10,rr14");
24 #endif
27 /* zero bss */
28 p = &_start_bss;
29 while (p < & _end_bss)
31 *p++ = 0;
33 enter();
36 #if defined(__Z8002__)
37 void __do_global_ctors ()
39 typedef void (*pfunc)();
40 extern pfunc __ctors[];
41 extern pfunc __ctors_end[];
42 pfunc *p;
43 for (p = __ctors_end; p > __ctors; )
45 (*--p)();
49 void __main()
51 static int initialized;
52 if (! initialized)
54 initialized = 1;
55 __do_global_ctors ();
58 #endif