4 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL
);
9 /*****************************************************************************
13 ****************************************************************************
16 extern unsigned long strtoul ( const char *string
, char **endp
, int base
);
17 extern unsigned long long strtoull ( const char *string
, char **endp
,
20 /*****************************************************************************
24 ****************************************************************************
27 extern void * __malloc
malloc ( size_t size
);
28 extern void * realloc ( void *old_ptr
, size_t new_size
);
29 extern void free ( void *ptr
);
30 extern void * __malloc
zalloc ( size_t len
);
33 * Allocate cleared memory
35 * @v nmemb Number of members
36 * @v size Size of each member
37 * @ret ptr Allocated memory
39 * Allocate memory as per malloc(), and zero it.
41 * This is implemented as a static inline, with the body of the
42 * function in zalloc(), since in most cases @c nmemb will be 1 and
43 * doing the multiply is just wasteful.
45 static inline void * __malloc
calloc ( size_t nmemb
, size_t size
) {
46 return zalloc ( nmemb
* size
);
49 /*****************************************************************************
51 * Random number generation
53 ****************************************************************************
56 extern long int random ( void );
57 extern void srandom ( unsigned int seed
);
59 static inline int rand ( void ) {
63 static inline void srand ( unsigned int seed
) {
67 /*****************************************************************************
71 ****************************************************************************
74 static inline __attribute__ (( always_inline
)) int abs ( int value
) {
75 return __builtin_abs ( value
);
78 extern int system ( const char *command
);
79 extern __asmcall
int main ( void );