source: mainline/uspace/lib/posix/stdlib.h@ e7ed26be

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since e7ed26be was 2a53f71, checked in by Petr Koupy <petr.koupy@…>, 14 years ago

Added missing comments to the newly implemented functions.

  • Property mode set to 100644
File size: 5.1 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 */
[087c8798]33/** @file Standard library definitions.
[2fc5072]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
[087c8798]58/* Integer Division */
[cc3652db]59
60typedef struct {
61 int quot, rem;
62} posix_div_t;
63
64typedef struct {
65 long quot, rem;
66} posix_ldiv_t;
67
68typedef struct {
69 long long quot, rem;
70} posix_lldiv_t;
71
72extern posix_div_t posix_div(int numer, int denom);
73extern posix_ldiv_t posix_ldiv(long numer, long denom);
74extern posix_lldiv_t posix_lldiv(long long numer, long long denom);
75
76/* Array Functions */
[4f4b4e7]77extern void posix_qsort(void *array, size_t count, size_t size,
78 int (*compare)(const void *, const void *));
[cc3652db]79extern void *posix_bsearch(const void *key, const void *base,
80 size_t nmemb, size_t size, int (*compar)(const void *, const void *));
81
[2fc5072]82/* Environment Access */
83extern char *posix_getenv(const char *name);
[823a929]84extern int posix_putenv(char *string);
[cc3652db]85extern int posix_system(const char *string);
86
[2fc5072]87/* Symbolic Links */
88extern char *posix_realpath(const char *restrict name, char *restrict resolved);
89
[4f4b4e7]90/* Floating Point Conversion */
[2b83add]91extern double posix_atof(const char *nptr);
[ceebf0a]92extern float posix_strtof(const char *restrict nptr, char **restrict endptr);
93extern double posix_strtod(const char *restrict nptr, char **restrict endptr);
94extern long double posix_strtold(const char *restrict nptr, char **restrict endptr);
95
[4f4b4e7]96/* Integer Conversion */
[2b83add]97extern int posix_atoi(const char *nptr);
98extern long int posix_atol(const char *nptr);
99extern long long int posix_atoll(const char *nptr);
100extern long int posix_strtol(const char *restrict nptr,
101 char **restrict endptr, int base);
102extern long long int posix_strtoll(const char *restrict nptr,
103 char **restrict endptr, int base);
104extern unsigned long int posix_strtoul(const char *restrict nptr,
105 char **restrict endptr, int base);
106extern unsigned long long int posix_strtoull(
107 const char *restrict nptr, char **restrict endptr, int base);
108
[823a929]109/* Memory Allocation */
110extern void *posix_malloc(size_t size);
111extern void *posix_calloc(size_t nelem, size_t elsize);
112extern void *posix_realloc(void *ptr, size_t size);
113extern void posix_free(void *ptr);
114
[2a53f71]115/* Temporary Files */
[11544f4]116extern int posix_mkstemp(char *tmpl);
117
[823a929]118/* Legacy Declarations */
119extern char *posix_mktemp(char *tmpl);
[3acff69]120extern int bsd_getloadavg(double loadavg[], int nelem);
[823a929]121
[4d10fc8]122#ifndef LIBPOSIX_INTERNAL
[823a929]123 #define atexit posix_atexit
124
125 #define abs posix_abs
[2b83add]126 #define labs posix_labs
127 #define llabs posix_llabs
[823a929]128
[cc3652db]129 #define div_t posix_div_t
130 #define ldiv_t posix_ldiv_t
131 #define lldiv_t posix_lldiv_t
132 #define div posix_div
133 #define ldiv posix_ldiv
134 #define lldiv posix_lldiv
135
[4d10fc8]136 #define qsort posix_qsort
[cc3652db]137 #define bsearch posix_bsearch
[823a929]138
[4d10fc8]139 #define getenv posix_getenv
[2b83add]140 #define putenv posix_putenv
[cc3652db]141 #define system posix_system
[823a929]142
[4d10fc8]143 #define realpath posix_realpath
[ceebf0a]144
[2b83add]145 #define atof posix_atof
[ceebf0a]146 #define strtof posix_strtof
147 #define strtod posix_strtod
148 #define strtold posix_strtold
[09b0b1fb]149
150 #define atoi posix_atoi
[2b83add]151 #define atol posix_atol
152 #define atoll posix_atoll
153 #define strtol posix_strtol
154 #define strtoll posix_strtoll
155 #define strtoul posix_strtoul
156 #define strtoull posix_strtoull
[823a929]157
158 #define malloc posix_malloc
159 #define calloc posix_calloc
160 #define realloc posix_realloc
161 #define free posix_free
162
[11544f4]163 #define mkstemp posix_mkstemp
164
[823a929]165 #define mktemp posix_mktemp
[3acff69]166 #define getloadavg bsd_getloadavg
[4d10fc8]167#endif
168
[2fc5072]169#endif // POSIX_STDLIB_H_
170
171/** @}
172 */
Note: See TracBrowser for help on using the repository browser.