10 #include <sys/types.h>
\r
16 #define EXIT_FAILURE 1
\r
17 #define EXIT_SUCCESS 0
\r
19 #ifdef ARCHDIR_is_native
\r
20 # define _exit acess__exit
\r
22 //# define strtoll acess_strtoll
\r
23 //# define strtol acess_strtol
\r
24 //# define strtoul acess_strtoul
\r
25 //# define strtoull acess_strtoull
\r
27 # define strtod acess_strtod
\r
28 # define strtof acess_strtof
\r
29 # define atof acess_atof
\r
31 # define exit acess_exit
\r
32 # define atexit acess_atexit
\r
33 # define abort acess_abort
\r
34 # define abs acess_abs
\r
35 # define labs acess_labs
\r
36 # define llabs acess_llabs
\r
38 # define mktemp acess_mktemp
\r
40 # define getenv acess_getenv
\r
41 # define putenv acess_putenv
\r
43 # define bsearch acess_bsearch
\r
44 # define qsort acess_qsort
\r
46 # define free acess_free
\r
47 # define malloc acess_malloc
\r
48 # define calloc acess_calloc
\r
49 # define realloc acess_realloc
\r
50 # define IsHeap acess_IsHeap
\r
52 # define srand acess_srand
\r
53 # define rand acess_rand
\r
54 # define rand_p acess_rand_p
\r
57 /* --- Spinlock Macros --- */
\r
58 /* TODO: Support non-x86 architectures */
\r
59 #define DEFLOCK(_name) static int _spinlock_##_name=0;
\r
60 #define LOCK(_name) do{int v=1;while(v){__asm__ __volatile__("lock cmpxchgl %0, (%1)":"=a"(v):"D"((&_spinlock_##_name)),"a"(1));yield();}}while(0)
\r
61 #define UNLOCK(_name) __asm__ __volatile__("lock andl $0, (%0)"::"D"(&_spinlock_##_name))
\r
63 /* --- StdLib --- */
\r
64 extern void _exit(int code) __attribute__((noreturn)); /* NOTE: Also defined in acess/sys.h */
\r
66 extern long long strtoll(const char *ptr, char **end, int base);
\r
67 extern long strtol(const char *ptr, char **end, int base);
\r
68 extern unsigned long long strtoull(const char *ptr, char **end, int base);
\r
69 extern unsigned long strtoul(const char *ptr, char **end, int base);
\r
70 extern int atoi(const char *ptr);
\r
71 extern long atol(const char *ptr);
\r
72 extern long long atoll(const char *ptr);
\r
74 extern double strtod(const char *ptr, char **end);
\r
75 extern float strtof(const char *ptr, char **end);
\r
76 extern float atof(const char *ptr);
\r
78 extern void exit(int status) __attribute__((noreturn));
\r
79 extern void abort(void);
\r
80 extern void atexit(void (*__func)(void));
\r
81 extern int abs(int j);
\r
82 extern long int labs(long int j);
\r
83 extern long long int llabs(long long int j);
\r
85 extern char *mktemp(char *__template);
\r
87 /* --- Environment --- */
\r
88 extern char *getenv(const char *name);
\r
89 extern int putenv(char *string);
\r
91 /* --- Search/Sort --- */
\r
92 typedef int (*_stdlib_compar_t)(const void *, const void *);
\r
93 extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, _stdlib_compar_t compar);
\r
94 extern void qsort(void *base, size_t nmemb, size_t size, _stdlib_compar_t compar);
\r
97 extern void free(void *mem);
\r
98 extern void *malloc(size_t bytes);
\r
99 extern void *calloc(size_t __nmemb, size_t __size);
\r
100 extern void *realloc(void *__ptr, size_t __size);
\r
101 extern int IsHeap(void *ptr);
\r
102 extern int Heap_Validate(int bDump);
\r
104 /* --- Random --- */
\r
105 extern void srand(unsigned int seed);
\r
106 extern int rand(void);
\r
107 extern int rand_p(unsigned int *seedp);
\r
110 # define SEEK_CUR 0
\r
111 # define SEEK_SET 1
\r
112 # define SEEK_END (-1)
\r
119 #include <libposix_stdlib.h>
\r