These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / ipxe / src / include / stdlib.h
1 #ifndef STDLIB_H
2 #define STDLIB_H
3
4 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
5
6 #include <stdint.h>
7 #include <assert.h>
8
9 /*****************************************************************************
10  *
11  * Numeric parsing
12  *
13  ****************************************************************************
14  */
15
16 extern unsigned long strtoul ( const char *string, char **endp, int base );
17 extern unsigned long long strtoull ( const char *string, char **endp,
18                                      int base );
19
20 /*****************************************************************************
21  *
22  * Memory allocation
23  *
24  ****************************************************************************
25  */
26
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 );
31
32 /**
33  * Allocate cleared memory
34  *
35  * @v nmemb             Number of members
36  * @v size              Size of each member
37  * @ret ptr             Allocated memory
38  *
39  * Allocate memory as per malloc(), and zero it.
40  *
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.
44  */
45 static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
46         return zalloc ( nmemb * size );
47 }
48
49 /*****************************************************************************
50  *
51  * Random number generation
52  *
53  ****************************************************************************
54  */
55
56 extern long int random ( void );
57 extern void srandom ( unsigned int seed );
58
59 static inline int rand ( void ) {
60         return random();
61 }
62
63 static inline void srand ( unsigned int seed ) {
64         srandom ( seed );
65 }
66
67 /*****************************************************************************
68  *
69  * Miscellaneous
70  *
71  ****************************************************************************
72  */
73
74 static inline __attribute__ (( always_inline )) int abs ( int value ) {
75         return __builtin_abs ( value );
76 }
77
78 extern int system ( const char *command );
79 extern __asmcall int main ( void );
80
81 #endif /* STDLIB_H */