[3c90x] Remove src/drivers/3c90x.txt
[gpxe.git] / src / include / stdlib.h
blob838a22acff22162969602a703287f425fcc01cf4
1 #ifndef STDLIB_H
2 #define STDLIB_H
4 #include <stdint.h>
5 #include <assert.h>
7 /*****************************************************************************
9 * Numeric parsing
11 ****************************************************************************
14 extern unsigned long strtoul ( const char *p, char **endp, int base );
16 /*****************************************************************************
18 * Memory allocation
20 ****************************************************************************
23 extern void * __malloc malloc ( size_t size );
24 extern void * realloc ( void *old_ptr, size_t new_size );
25 extern void free ( void *ptr );
26 extern void * __malloc zalloc ( size_t len );
28 /**
29 * Allocate cleared memory
31 * @v nmemb Number of members
32 * @v size Size of each member
33 * @ret ptr Allocated memory
35 * Allocate memory as per malloc(), and zero it.
37 * This is implemented as a static inline, with the body of the
38 * function in zalloc(), since in most cases @c nmemb will be 1 and
39 * doing the multiply is just wasteful.
41 static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
42 return zalloc ( nmemb * size );
45 /*****************************************************************************
47 * Random number generation
49 ****************************************************************************
52 extern long int random ( void );
53 extern void srandom ( unsigned int seed );
55 static inline int rand ( void ) {
56 return random();
59 static inline void srand ( unsigned int seed ) {
60 srandom ( seed );
63 /*****************************************************************************
65 * Miscellaneous
67 ****************************************************************************
70 extern int system ( const char *command );
71 extern __asmcall int main ( void );
73 #endif /* STDLIB_H */