Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
stdlib.h
Go to the documentation of this file.
1/* stdlib.h */
2
3/*
4 * Copyright (c) 2011-2014 Wind River Systems, Inc.
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9#ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDLIB_H_
10#define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDLIB_H_
11
12#include <stddef.h>
13#include <limits.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19unsigned long strtoul(const char *nptr, char **endptr, int base);
20long strtol(const char *nptr, char **endptr, int base);
21unsigned long long strtoull(const char *nptr, char **endptr, int base);
22long long strtoll(const char *nptr, char **endptr, int base);
23int atoi(const char *s);
24
25void *malloc(size_t size);
26void *aligned_alloc(size_t alignment, size_t size); /* From C11 */
27
28void free(void *ptr);
29void *calloc(size_t nmemb, size_t size);
30void *realloc(void *ptr, size_t size);
31void *reallocarray(void *ptr, size_t nmemb, size_t size);
32
33void *bsearch(const void *key, const void *array,
34 size_t count, size_t size,
35 int (*cmp)(const void *key, const void *element));
36
37void qsort_r(void *base, size_t nmemb, size_t size,
38 int (*compar)(const void *, const void *, void *), void *arg);
39void qsort(void *base, size_t nmemb, size_t size,
40 int (*compar)(const void *, const void *));
41
42#define EXIT_SUCCESS 0
43#define EXIT_FAILURE 1
44void _exit(int status);
45static inline void exit(int status)
46{
47 _exit(status);
48}
49void abort(void);
50
51#ifdef CONFIG_MINIMAL_LIBC_RAND
52#define RAND_MAX INT_MAX
53int rand_r(unsigned int *seed);
54int rand(void);
55void srand(unsigned int seed);
56#endif /* CONFIG_MINIMAL_LIBC_RAND */
57
58static inline int abs(int __n)
59{
60 return (__n < 0) ? -__n : __n;
61}
62
63static inline long labs(long __n)
64{
65 return (__n < 0L) ? -__n : __n;
66}
67
68static inline long long llabs(long long __n)
69{
70 return (__n < 0LL) ? -__n : __n;
71}
72
73char *getenv(const char *name);
74#if _POSIX_C_SOURCE >= 200112L
75int setenv(const char *name, const char *val, int overwrite);
76int unsetenv(const char *name);
77#endif
78
79#ifdef _BSD_SOURCE
80int getenv_r(const char *name, char *buf, size_t len);
81#endif
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDLIB_H_ */
irp nz macro MOVR cc s mov cc s endm endr irp aw macro LDR aa s
Definition: asm-macro-32-bit-gnu.h:17
void qsort_r(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *, void *), void *arg)
void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
void * calloc(size_t nmemb, size_t size)
int atoi(const char *s)
long strtol(const char *nptr, char **endptr, int base)
static long long llabs(long long __n)
Definition: stdlib.h:68
void * bsearch(const void *key, const void *array, size_t count, size_t size, int(*cmp)(const void *key, const void *element))
unsigned long strtoul(const char *nptr, char **endptr, int base)
void * aligned_alloc(size_t alignment, size_t size)
void abort(void)
static long labs(long __n)
Definition: stdlib.h:63
void * malloc(size_t size)
void * reallocarray(void *ptr, size_t nmemb, size_t size)
char * getenv(const char *name)
void * realloc(void *ptr, size_t size)
static int abs(int __n)
Definition: stdlib.h:58
unsigned long long strtoull(const char *nptr, char **endptr, int base)
static void exit(int status)
Definition: stdlib.h:45
long long strtoll(const char *nptr, char **endptr, int base)
void free(void *ptr)