stdlib.h

Go to the documentation of this file.
00001 #ifndef STDLIB_H
00002 #define STDLIB_H
00003 
00004 FILE_LICENCE ( GPL2_OR_LATER );
00005 
00006 #include <stdint.h>
00007 #include <assert.h>
00008 
00009 /*****************************************************************************
00010  *
00011  * Numeric parsing
00012  *
00013  ****************************************************************************
00014  */
00015 
00016 extern unsigned long strtoul ( const char *p, char **endp, int base );
00017 
00018 /*****************************************************************************
00019  *
00020  * Memory allocation
00021  *
00022  ****************************************************************************
00023  */
00024 
00025 extern void * __malloc malloc ( size_t size );
00026 extern void * realloc ( void *old_ptr, size_t new_size );
00027 extern void free ( void *ptr );
00028 extern void * __malloc zalloc ( size_t len );
00029 
00030 /**
00031  * Allocate cleared memory
00032  *
00033  * @v nmemb             Number of members
00034  * @v size              Size of each member
00035  * @ret ptr             Allocated memory
00036  *
00037  * Allocate memory as per malloc(), and zero it.
00038  *
00039  * This is implemented as a static inline, with the body of the
00040  * function in zalloc(), since in most cases @c nmemb will be 1 and
00041  * doing the multiply is just wasteful.
00042  */
00043 static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
00044         return zalloc ( nmemb * size );
00045 }
00046 
00047 /*****************************************************************************
00048  *
00049  * Random number generation
00050  *
00051  ****************************************************************************
00052  */
00053 
00054 extern long int random ( void );
00055 extern void srandom ( unsigned int seed );
00056 
00057 static inline int rand ( void ) {
00058         return random();
00059 }
00060 
00061 static inline void srand ( unsigned int seed ) {
00062         srandom ( seed );
00063 }
00064 
00065 /*****************************************************************************
00066  *
00067  * Miscellaneous
00068  *
00069  ****************************************************************************
00070  */
00071 
00072 extern int system ( const char *command );
00073 extern __asmcall int main ( void );
00074 
00075 #endif /* STDLIB_H */

Generated on Tue Apr 6 20:01:09 2010 for gPXE by  doxygen 1.5.7.1