source: bootcd/isolinux/syslinux-6.03/gpxe/src/include/stdlib.h @ dd1be7c

Last change on this file since dd1be7c was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#ifndef STDLIB_H
2#define STDLIB_H
3
4FILE_LICENCE ( GPL2_OR_LATER );
5
6#include <stdint.h>
7#include <assert.h>
8
9/*****************************************************************************
10 *
11 * Numeric parsing
12 *
13 ****************************************************************************
14 */
15
16extern unsigned long strtoul ( const char *p, char **endp, int base );
17
18/*****************************************************************************
19 *
20 * Memory allocation
21 *
22 ****************************************************************************
23 */
24
25extern void * __malloc malloc ( size_t size );
26extern void * realloc ( void *old_ptr, size_t new_size );
27extern void free ( void *ptr );
28extern void * __malloc zalloc ( size_t len );
29
30/**
31 * Allocate cleared memory
32 *
33 * @v nmemb             Number of members
34 * @v size              Size of each member
35 * @ret ptr             Allocated memory
36 *
37 * Allocate memory as per malloc(), and zero it.
38 *
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.
42 */
43static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
44        return zalloc ( nmemb * size );
45}
46
47/*****************************************************************************
48 *
49 * Random number generation
50 *
51 ****************************************************************************
52 */
53
54extern long int random ( void );
55extern void srandom ( unsigned int seed );
56
57static inline int rand ( void ) {
58        return random();
59}
60
61static inline void srand ( unsigned int seed ) {
62        srandom ( seed );
63}
64
65/*****************************************************************************
66 *
67 * Miscellaneous
68 *
69 ****************************************************************************
70 */
71
72extern int system ( const char *command );
73extern __asmcall int main ( void );
74
75#endif /* STDLIB_H */
Note: See TracBrowser for help on using the repository browser.