aboutsummaryrefslogtreecommitdiff
path: root/user/include/stdlib.h
blob: 31de474945b669f2742f413c76acf2fdaf3f1c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once

#include "limits.h"
#include "sys/types.h"

#ifndef NULL
#define NULL 0
#endif

#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif

#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif

/* Exit */
__attribute__((noreturn)) void exit(int status);

int atexit(void (*func)(void));
void _Exit(int status); /* NYI */

/* string to num conversion */
int atoi(const char *val);

/* --- NYI --- */
long atol(const char *val);

float atof(const char *val);

#define atoi(val) ((int)strtol(val, NULL, 10))
#define atol(val) strtol(val, NULL, 10)
#define atolf(val) strtof(val, NULL)

long strtol(const char *nptr, char **endptr, int base);

long long strtoll(const char *nptr, char **endptr, int base);

double strtod(const char *nptr, char **endptr);

float strtof(const char *nptr, char **endptr);

long double strtold(const char *nptr, char **endptr);
/* --- END NYI --- */

/* Malloc library */
void *malloc(size_t size);

void free(void *ptr);

void *realloc(void *ptr, size_t size);

void *calloc(size_t nelem, size_t elsize);

#define RAND_MAX INT_MAX

int rand(void);

void srand(unsigned int seed);