source: mainline/uspace/lib/posix/stdlib.h@ 2b83add

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 2b83add was 2b83add, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Add string to int conversion functions and implement some in stdlib.h

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[2fc5072]1/*
2 * Copyright (c) 2011 Petr Koupy
[ceebf0a]3 * Copyright (c) 2011 Jiri Zarevucky
[2fc5072]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
[acc3f82c]39#include "libc/stdlib.h"
[2fc5072]40
41#ifndef NULL
42 #define NULL ((void *) 0)
43#endif
44
[4f4b4e7]45/* Process Termination */
[2fc5072]46#undef EXIT_FAILURE
47#define EXIT_FAILURE 1
48#undef EXIT_SUCCESS
49#define EXIT_SUCCESS 0
[1eee1283]50#define _Exit exit
[823a929]51extern int posix_atexit(void (*func)(void));
52
53/* Absolute Value */
54extern int posix_abs(int i);
[2b83add]55extern long posix_labs(long i);
56extern long long posix_llabs(long long i);
[1eee1283]57
[2fc5072]58/* Array Sort Function */
[4f4b4e7]59extern void posix_qsort(void *array, size_t count, size_t size,
60 int (*compare)(const void *, const void *));
[2fc5072]61
62/* Environment Access */
63extern char *posix_getenv(const char *name);
[823a929]64extern int posix_putenv(char *string);
[2fc5072]65
66/* Symbolic Links */
67extern char *posix_realpath(const char *restrict name, char *restrict resolved);
68
[4f4b4e7]69/* Floating Point Conversion */
[2b83add]70extern double posix_atof(const char *nptr);
[ceebf0a]71extern float posix_strtof(const char *restrict nptr, char **restrict endptr);
72extern double posix_strtod(const char *restrict nptr, char **restrict endptr);
73extern long double posix_strtold(const char *restrict nptr, char **restrict endptr);
74
[4f4b4e7]75/* Integer Conversion */
[2b83add]76extern int posix_atoi(const char *nptr);
77extern long int posix_atol(const char *nptr);
78extern long long int posix_atoll(const char *nptr);
79
80extern long int posix_strtol(const char *restrict nptr,
81 char **restrict endptr, int base);
82extern long long int posix_strtoll(const char *restrict nptr,
83 char **restrict endptr, int base);
84extern unsigned long int posix_strtoul(const char *restrict nptr,
85 char **restrict endptr, int base);
86extern unsigned long long int posix_strtoull(
87 const char *restrict nptr, char **restrict endptr, int base);
88
[09b0b1fb]89
[823a929]90/* Memory Allocation */
91extern void *posix_malloc(size_t size);
92extern void *posix_calloc(size_t nelem, size_t elsize);
93extern void *posix_realloc(void *ptr, size_t size);
94extern void posix_free(void *ptr);
95
96/* Legacy Declarations */
97extern char *posix_mktemp(char *tmpl);
98
[4d10fc8]99#ifndef LIBPOSIX_INTERNAL
[823a929]100 #define atexit posix_atexit
101
102 #define abs posix_abs
[2b83add]103 #define labs posix_labs
104 #define llabs posix_llabs
[823a929]105
[4d10fc8]106 #define qsort posix_qsort
[823a929]107
[4d10fc8]108 #define getenv posix_getenv
[2b83add]109 #define putenv posix_putenv
[823a929]110
[4d10fc8]111 #define realpath posix_realpath
[ceebf0a]112
[2b83add]113 #define atof posix_atof
[ceebf0a]114 #define strtof posix_strtof
115 #define strtod posix_strtod
116 #define strtold posix_strtold
[09b0b1fb]117
118 #define atoi posix_atoi
[2b83add]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
[823a929]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
[4d10fc8]132#endif
133
[2fc5072]134#endif // POSIX_STDLIB_H_
135
136/** @}
137 */
Note: See TracBrowser for help on using the repository browser.