/ userspace / include / stdlib.h
stdlib.h
 1  #ifndef STDLIB_H
 2  #define STDLIB_H
 3  
 4  #include "stddef.h"
 5  
 6  // Memory allocation
 7  void* malloc(size_t size);
 8  void* calloc(size_t nmemb, size_t size);
 9  void* realloc(void* ptr, size_t size);
10  void free(void* ptr);
11  
12  // Process control
13  void exit(int status);
14  void abort(void);
15  int atexit(void (*function)(void));
16  int system(const char* command);
17  char* getenv(const char* name);
18  
19  // String conversion
20  int atoi(const char* nptr);
21  long atol(const char* nptr);
22  long strtol(const char* nptr, char** endptr, int base);
23  unsigned long strtoul(const char* nptr, char** endptr, int base);
24  
25  // Random numbers
26  int rand(void);
27  void srand(unsigned int seed);
28  #define RAND_MAX 0x7fffffff
29  
30  // Sorting and searching
31  void qsort(void* base, size_t nmemb, size_t size,
32            int (*compar)(const void*, const void*));
33  void* bsearch(const void* key, const void* base,
34               size_t nmemb, size_t size,
35               int (*compar)(const void*, const void*));
36  
37  // Integer arithmetic
38  int abs(int j);
39  long labs(long j);
40  
41  typedef struct {
42      int quot;
43      int rem;
44  } div_t;
45  
46  typedef struct {
47      long quot;
48      long rem;
49  } ldiv_t;
50  
51  div_t div(int numer, int denom);
52  ldiv_t ldiv(long numer, long denom);
53  
54  #endif // STDLIB_H