aboutsummaryrefslogtreecommitdiffstats
path: root/com32/include/stdlib.h
blob: fad0082d18aad9d1e9b4f9af30afbb790ce07887 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * stdlib.h
 */

#ifndef _STDLIB_H
#define _STDLIB_H

#include <klibc/extern.h>
#include <klibc/compiler.h>
#include <stddef.h>

#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0

__extern __noreturn abort(void);
static __inline__ int abs(int __n)
{
    return (__n < 0) ? -__n : __n;
}

__extern int atexit(void (*)(void));
__extern int on_exit(void (*)(int, void *), void *);
__extern int atoi(const char *);
__extern long atol(const char *);
__extern long long atoll(const char *);
__extern __noreturn exit(int);
__extern __noreturn _Exit(int);
static __inline__ long labs(long __n)
{
    return (__n < 0L) ? -__n : __n;
}

static __inline__ long long llabs(long long __n)
{
    return (__n < 0LL) ? -__n : __n;
}

__extern __mallocfunc void *malloc(size_t);
__extern __mallocfunc void *zalloc(size_t);
__extern __mallocfunc void *calloc(size_t, size_t);
__extern __mallocfunc void *realloc(void *, size_t);
__extern int posix_memalign(void **memptr, size_t alignment,
		size_t size);

__extern void free(void *);

__extern void *__malloc_global_tag;

static __inline__ void *__mem_get_tag_global(void)
{
    return __malloc_global_tag;
}

static __inline__ void __mem_set_tag_global(void *__tag)
{
    __malloc_global_tag = __tag;
}

__extern void *__mem_get_tag(void *);
__extern void __mem_set_tag(void *, void *);

__extern void __free_tagged(void *);

static __inline__ void *__malloc_tagged(size_t __size, void *__tag)
{
    void *__result = malloc(__size);
    __mem_set_tag(__result, __tag);

    return __result;
}

__extern long strtol(const char *, char **, int);
__extern long long strtoll(const char *, char **, int);
__extern unsigned long strtoul(const char *, char **, int);
__extern unsigned long long strtoull(const char *, char **, int);

__extern char *getenv(const char *);
__extern int putenv(const char *);
__extern int setenv(const char *, const char *, int);
__extern int unsetenv(const char *);

__extern void qsort(void *, size_t, size_t,
		    int (*)(const void *, const void *));

__extern long jrand48(unsigned short *);
__extern long mrand48(void);
__extern long nrand48(unsigned short *);
__extern long lrand48(void);
__extern unsigned short *seed48(const unsigned short *);
__extern void srand48(long);

#define RAND_MAX 0x7fffffff
static __inline__ int rand(void)
{
    return (int)lrand48();
}

static __inline__ void srand(unsigned int __s)
{
    srand48(__s);
}

static __inline__ long random(void)
{
    return lrand48();
}

static __inline__ void srandom(unsigned int __s)
{
    srand48(__s);
}

/* Basic PTY functions.  These only work if devpts is mounted! */

__extern int unlockpt(int);
__extern char *ptsname(int);
__extern int getpt(void);

static __inline__ int grantpt(int __fd)
{
    (void)__fd;
    return 0;			/* devpts does this all for us! */
}

#endif /* _STDLIB_H */