[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / include / stdlib.h
blob254e39b3aed44f64bde3a8a29277271b1d70209c
1 #ifndef STDLIB_H
2 #define STDLIB_H
4 FILE_LICENCE ( GPL2_OR_LATER );
6 #include <stdint.h>
7 #include <assert.h>
9 /*****************************************************************************
11 * Numeric parsing
13 ****************************************************************************
16 extern unsigned long strtoul ( const char *p, char **endp, int base );
18 /*****************************************************************************
20 * Memory allocation
22 ****************************************************************************
25 extern void * __malloc malloc ( size_t size );
26 extern void * realloc ( void *old_ptr, size_t new_size );
27 extern void free ( void *ptr );
28 extern void * __malloc zalloc ( size_t len );
30 /**
31 * Allocate cleared memory
33 * @v nmemb Number of members
34 * @v size Size of each member
35 * @ret ptr Allocated memory
37 * Allocate memory as per malloc(), and zero it.
39 * This is implemented as a static inline, with the body of the
40 * function in zalloc(), since in most cases @c nmemb will be 1 and
41 * doing the multiply is just wasteful.
43 static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
44 return zalloc ( nmemb * size );
47 /*****************************************************************************
49 * Random number generation
51 ****************************************************************************
54 extern long int random ( void );
55 extern void srandom ( unsigned int seed );
57 static inline int rand ( void ) {
58 return random();
61 static inline void srand ( unsigned int seed ) {
62 srandom ( seed );
65 /*****************************************************************************
67 * Miscellaneous
69 ****************************************************************************
72 extern int system ( const char *command );
73 extern __asmcall int main ( void );
75 #endif /* STDLIB_H */