mirror of
https://github.com/ipxe/ipxe
synced 2025-12-15 00:12:19 +03:00
Split random number generation out into core/random.c, and create the
correct prototypes for srandom(), rand() and srand().
This commit is contained in:
@@ -2,14 +2,27 @@
|
||||
#define STDLIB_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Numeric parsing
|
||||
*
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
extern unsigned long strtoul ( const char *p, char **endp, int base );
|
||||
extern void * realloc ( void *old_ptr, size_t new_size );
|
||||
extern void * malloc ( size_t size );
|
||||
extern void free ( void *ptr );
|
||||
extern int system ( const char *command );
|
||||
extern long int random ( void );
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Memory allocation
|
||||
*
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
extern void * malloc ( size_t size );
|
||||
extern void * realloc ( void *old_ptr, size_t new_size );
|
||||
extern void free ( void *ptr );
|
||||
extern void * _calloc ( size_t len );
|
||||
|
||||
/**
|
||||
@@ -29,4 +42,31 @@ static inline void * calloc ( size_t nmemb, size_t size ) {
|
||||
return _calloc ( nmemb * size );
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Random number generation
|
||||
*
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
extern long int random ( void );
|
||||
extern void srandom ( unsigned int seed );
|
||||
|
||||
static inline int rand ( void ) {
|
||||
return random();
|
||||
}
|
||||
|
||||
static inline void srand ( unsigned int seed ) {
|
||||
srandom ( seed );
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Miscellaneous
|
||||
*
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
extern int system ( const char *command );
|
||||
|
||||
#endif /* STDLIB_H */
|
||||
|
||||
Reference in New Issue
Block a user