10 #include <sys/types.h>
\r
12 #define EXIT_FAILURE 1
\r
13 #define EXIT_SUCCESS 0
\r
15 /* --- Spinlock Macros --- */
\r
16 /* TODO: Support non-x86 architectures */
\r
17 #define DEFLOCK(_name) static int _spinlock_##_name=0;
\r
18 #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
19 #define UNLOCK(_name) __asm__ __volatile__("lock andl $0, (%0)"::"D"(&_spinlock_##_name))
\r
21 /* --- StdLib --- */
\r
22 extern void _exit(int code) __attribute__((noreturn)); /* NOTE: Also defined in acess/sys.h */
\r
23 extern int atoi(const char *ptr);
\r
24 extern void exit(int status) __attribute__((noreturn));
\r
25 extern void atexit(void (*__func)(void));
\r
26 extern void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
\r
28 /* --- Environment --- */
\r
29 extern char *getenv(const char *name);
\r
32 extern void free(void *mem);
\r
33 extern void *malloc(size_t bytes);
\r
34 extern void *calloc(size_t __nmemb, size_t __size);
\r
35 extern void *realloc(void *__ptr, size_t __size);
\r
36 extern int IsHeap(void *ptr);
\r
38 /* --- Random --- */
\r
39 extern void srand(unsigned int seed);
\r
40 extern int rand(void);
\r
41 extern int rand_p(unsigned int *seedp);
\r
46 # define SEEK_END (-1)
\r