source: mainline/uspace/lib/posix/stdlib.h@ 3acff69

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

Add getloadavg() stub to stdlib

  • Property mode set to 100644
File size: 5.0 KB
Line 
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
51extern int posix_atexit(void (*func)(void));
52
53/* Absolute Value */
54extern int posix_abs(int i);
55extern long posix_labs(long i);
56extern long long posix_llabs(long long i);
57
58/* Integer division */
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 */
77extern void posix_qsort(void *array, size_t count, size_t size,
78 int (*compare)(const void *, const void *));
79extern void *posix_bsearch(const void *key, const void *base,
80 size_t nmemb, size_t size, int (*compar)(const void *, const void *));
81
82
83/* Environment Access */
84extern char *posix_getenv(const char *name);
85extern int posix_putenv(char *string);
86
87extern int posix_system(const char *string);
88
89
90/* Symbolic Links */
91extern char *posix_realpath(const char *restrict name, char *restrict resolved);
92
93/* Floating Point Conversion */
94extern double posix_atof(const char *nptr);
95extern float posix_strtof(const char *restrict nptr, char **restrict endptr);
96extern double posix_strtod(const char *restrict nptr, char **restrict endptr);
97extern long double posix_strtold(const char *restrict nptr, char **restrict endptr);
98
99/* Integer Conversion */
100extern int posix_atoi(const char *nptr);
101extern long int posix_atol(const char *nptr);
102extern long long int posix_atoll(const char *nptr);
103
104extern long int posix_strtol(const char *restrict nptr,
105 char **restrict endptr, int base);
106extern long long int posix_strtoll(const char *restrict nptr,
107 char **restrict endptr, int base);
108extern unsigned long int posix_strtoul(const char *restrict nptr,
109 char **restrict endptr, int base);
110extern unsigned long long int posix_strtoull(
111 const char *restrict nptr, char **restrict endptr, int base);
112
113
114/* Memory Allocation */
115extern void *posix_malloc(size_t size);
116extern void *posix_calloc(size_t nelem, size_t elsize);
117extern void *posix_realloc(void *ptr, size_t size);
118extern void posix_free(void *ptr);
119
120/* Legacy Declarations */
121extern char *posix_mktemp(char *tmpl);
122extern int bsd_getloadavg(double loadavg[], int nelem);
123
124#ifndef LIBPOSIX_INTERNAL
125 #define atexit posix_atexit
126
127 #define abs posix_abs
128 #define labs posix_labs
129 #define llabs posix_llabs
130
131 #define div_t posix_div_t
132 #define ldiv_t posix_ldiv_t
133 #define lldiv_t posix_lldiv_t
134 #define div posix_div
135 #define ldiv posix_ldiv
136 #define lldiv posix_lldiv
137
138 #define qsort posix_qsort
139 #define bsearch posix_bsearch
140
141 #define getenv posix_getenv
142 #define putenv posix_putenv
143 #define system posix_system
144
145 #define realpath posix_realpath
146
147 #define atof posix_atof
148 #define strtof posix_strtof
149 #define strtod posix_strtod
150 #define strtold posix_strtold
151
152 #define atoi posix_atoi
153 #define atol posix_atol
154 #define atoll posix_atoll
155 #define strtol posix_strtol
156 #define strtoll posix_strtoll
157 #define strtoul posix_strtoul
158 #define strtoull posix_strtoull
159
160 #define malloc posix_malloc
161 #define calloc posix_calloc
162 #define realloc posix_realloc
163 #define free posix_free
164
165 #define mktemp posix_mktemp
166 #define getloadavg bsd_getloadavg
167#endif
168
169#endif // POSIX_STDLIB_H_
170
171/** @}
172 */
Note: See TracBrowser for help on using the repository browser.