updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / gcc4ti / stdlib.h
blob1ccabe7aa178eb087e4eea554d840570de779930
1 #ifndef __STDLIB
2 #define __STDLIB
4 #include <default.h>
6 #ifndef DOORS
7 #define ldiv(n,d) ({ldiv_t __r;long __n=(n),__d=(d);asm("move.l 0xC8,%%a5;move.l %2,%%d1;move.l %3,%%d0;move.l (%%a5,2720),%%a0;jsr (%%a0);move.l %%d1,%0;move.l %2,%%d1;move.l %3,%%d0;move.l (%%a5,2724),%%a0;jsr (%%a0);move.l %%d1,%1" : "=&g"(__r.quot),"=g"(__r.rem) : "g"(__n),"g"(__d) : "a0","a1","a5","d0","d1","d2");__r;})
8 #else
9 #define ldiv(n,d) ({ldiv_t __r;long __n=(n),__d=(d);asm("move.l %2,%%d1;move.l %3,%%d0;jsr _ROM_CALL_2A8;move.l %%d1,%0;move.l %2,%%d1;move.l %3,%%d0;jsr _ROM_CALL_2A9;move.l %%d1,%1" : "=&g"(__r.quot),"=g"(__r.rem) : "g"(__n),"g"(__d) : "a0","a1","d0","d1","d2");__r;})
10 #endif
12 #ifndef NO_EXIT_SUPPORT
13 extern void __exit(void)__ATTR_LIB_ASM_NORETURN__;
14 #endif
16 extern long __randseed;
18 /* Begin Auto-Generated Part */
19 #define NULL ((void*)0)
20 #define RAND_MAX 32767
21 #ifndef __HAVE_size_t
22 #define __HAVE_size_t
23 typedef unsigned long size_t;
24 #endif
25 typedef CALLBACK void(*atexit_t)(void);
26 typedef CALLBACK short(*compare_t)(const void*elem1,const void*elem2);
27 #ifndef __HAVE_div_t
28 #define __HAVE_div_t
29 typedef struct{short quot,rem;}div_t;
30 #endif
31 #ifndef __HAVE_ldiv_t
32 #define __HAVE_ldiv_t
33 typedef struct{long quot,rem;}ldiv_t;
34 #endif
35 #define abort() (_rom_call(void,(const char*),E6)("ABNORMAL PROGRAM TERMINATION"),exit(0))
36 #define abs(x) ({typeof(x) __x = (x); __x >= 0 ? __x : -__x;})
37 #ifndef __HAVE_alloca
38 #define __HAVE_alloca
39 void *alloca(long)__ATTR_GCC__;
40 #endif
41 extern short atexit(atexit_t)__ATTR_LIB_ASM__;
42 extern short atoi(const char*)__ATTR_LIB_C__;
43 extern long atol(const char*)__ATTR_LIB_C__;
44 extern void *bsearch(const void* asm("a0"),const void* asm("a1"),short asm("d0"),short asm("d1"),compare_t asm("a2")) __ATTR_LIB_ASM__;
45 #ifndef __HAVE_calloc
46 #define __HAVE_calloc
47 extern void *calloc(short asm("d0"),short asm("d1"))__ATTR_LIB_ASM__;
48 #endif
49 #define div(n,d) ({short __n=(n),__d=(d);div_t __r;__r.quot=__n/__d;__r.rem=__n%__d;__r;})
50 #define exit(n) ({(n)?_rom_call(void,(short),152)(n):0;__exit();})
51 #define fabs(x) _tios_float_1(106,x,float)
52 #define free _rom_call(void,(void*),A3)
53 #ifndef __HAVE_labs
54 #define __HAVE_labs
55 long labs(long)__ATTR_GCC__;
56 #endif
57 #define malloc _rom_call(void*,(long),A2)
58 #define max(a,b) ({typeof(a) __a = (a); typeof(b) __b = (b); (__a > __b) ? __a : __b;})
59 #define min(a,b) ({typeof(a) __a = (a); typeof(b) __b = (b); (__a < __b) ? __a : __b;})
60 extern void qsort(void* asm("a0"),short asm("d0"),short asm("d1"),compare_t asm("a2"))__ATTR_LIB_ASM__;
61 extern short rand(void)__ATTR_LIB_ASM__;
62 #define random(x) ((short)((long)(unsigned short)rand()*(unsigned short)(x)/32768))
63 #define randomize() srand(*(volatile unsigned char*)0x600017)
64 #ifndef __HAVE_realloc
65 #define __HAVE_realloc
66 extern void *realloc(void* asm("a0"),long asm("d0"))__ATTR_LIB_ASM__;
67 #endif
68 #define srand(x) (__randseed=(x))
69 extern long strtol(const char*,char**,short)__ATTR_LIB_C__;
70 extern unsigned long strtoul(const char*,char**,short)__ATTR_LIB_C__;
71 #if MIN_AMS>=101
72 #ifndef __HAVE_atof
73 #define __HAVE_atof
74 extern float atof(const char*)__ATTR_LIB_ASM__;
75 #endif
76 #endif
77 /* End Auto-Generated Part */
79 #endif