1 | /*
|
---|
2 | * Copyright (c) 2011 Petr Koupy
|
---|
3 | * Copyright (c) 2011 Jiri Zarevucky
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** @addtogroup libposix
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 | /** @file
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef POSIX_STDLIB_H_
|
---|
37 | #define POSIX_STDLIB_H_
|
---|
38 |
|
---|
39 | #include "libc/stdlib.h"
|
---|
40 |
|
---|
41 | #ifndef NULL
|
---|
42 | #define NULL ((void *) 0)
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | /* Process Termination */
|
---|
46 | #undef EXIT_FAILURE
|
---|
47 | #define EXIT_FAILURE 1
|
---|
48 | #undef EXIT_SUCCESS
|
---|
49 | #define EXIT_SUCCESS 0
|
---|
50 | #define _Exit exit
|
---|
51 | extern int posix_atexit(void (*func)(void));
|
---|
52 |
|
---|
53 | /* Absolute Value */
|
---|
54 | extern int posix_abs(int i);
|
---|
55 | extern long posix_labs(long i);
|
---|
56 | extern long long posix_llabs(long long i);
|
---|
57 |
|
---|
58 | /* Array Sort Function */
|
---|
59 | extern void posix_qsort(void *array, size_t count, size_t size,
|
---|
60 | int (*compare)(const void *, const void *));
|
---|
61 |
|
---|
62 | /* Environment Access */
|
---|
63 | extern char *posix_getenv(const char *name);
|
---|
64 | extern int posix_putenv(char *string);
|
---|
65 |
|
---|
66 | /* Symbolic Links */
|
---|
67 | extern char *posix_realpath(const char *restrict name, char *restrict resolved);
|
---|
68 |
|
---|
69 | /* Floating Point Conversion */
|
---|
70 | extern double posix_atof(const char *nptr);
|
---|
71 | extern float posix_strtof(const char *restrict nptr, char **restrict endptr);
|
---|
72 | extern double posix_strtod(const char *restrict nptr, char **restrict endptr);
|
---|
73 | extern long double posix_strtold(const char *restrict nptr, char **restrict endptr);
|
---|
74 |
|
---|
75 | /* Integer Conversion */
|
---|
76 | extern int posix_atoi(const char *nptr);
|
---|
77 | extern long int posix_atol(const char *nptr);
|
---|
78 | extern long long int posix_atoll(const char *nptr);
|
---|
79 |
|
---|
80 | extern long int posix_strtol(const char *restrict nptr,
|
---|
81 | char **restrict endptr, int base);
|
---|
82 | extern long long int posix_strtoll(const char *restrict nptr,
|
---|
83 | char **restrict endptr, int base);
|
---|
84 | extern unsigned long int posix_strtoul(const char *restrict nptr,
|
---|
85 | char **restrict endptr, int base);
|
---|
86 | extern unsigned long long int posix_strtoull(
|
---|
87 | const char *restrict nptr, char **restrict endptr, int base);
|
---|
88 |
|
---|
89 |
|
---|
90 | /* Memory Allocation */
|
---|
91 | extern void *posix_malloc(size_t size);
|
---|
92 | extern void *posix_calloc(size_t nelem, size_t elsize);
|
---|
93 | extern void *posix_realloc(void *ptr, size_t size);
|
---|
94 | extern void posix_free(void *ptr);
|
---|
95 |
|
---|
96 | /* Legacy Declarations */
|
---|
97 | extern char *posix_mktemp(char *tmpl);
|
---|
98 |
|
---|
99 | #ifndef LIBPOSIX_INTERNAL
|
---|
100 | #define atexit posix_atexit
|
---|
101 |
|
---|
102 | #define abs posix_abs
|
---|
103 | #define labs posix_labs
|
---|
104 | #define llabs posix_llabs
|
---|
105 |
|
---|
106 | #define qsort posix_qsort
|
---|
107 |
|
---|
108 | #define getenv posix_getenv
|
---|
109 | #define putenv posix_putenv
|
---|
110 |
|
---|
111 | #define realpath posix_realpath
|
---|
112 |
|
---|
113 | #define atof posix_atof
|
---|
114 | #define strtof posix_strtof
|
---|
115 | #define strtod posix_strtod
|
---|
116 | #define strtold posix_strtold
|
---|
117 |
|
---|
118 | #define atoi posix_atoi
|
---|
119 | #define atol posix_atol
|
---|
120 | #define atoll posix_atoll
|
---|
121 | #define strtol posix_strtol
|
---|
122 | #define strtoll posix_strtoll
|
---|
123 | #define strtoul posix_strtoul
|
---|
124 | #define strtoull posix_strtoull
|
---|
125 |
|
---|
126 | #define malloc posix_malloc
|
---|
127 | #define calloc posix_calloc
|
---|
128 | #define realloc posix_realloc
|
---|
129 | #define free posix_free
|
---|
130 |
|
---|
131 | #define mktemp posix_mktemp
|
---|
132 | #endif
|
---|
133 |
|
---|
134 | #endif // POSIX_STDLIB_H_
|
---|
135 |
|
---|
136 | /** @}
|
---|
137 | */
|
---|