Zephyr Project API 3.7.0
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#include <zephyr/toolchain.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21unsigned long strtoul(const char *nptr, char **endptr, int base);
22long strtol(const char *nptr, char **endptr, int base);
23unsigned long long strtoull(const char *nptr, char **endptr, int base);
24long long strtoll(const char *nptr, char **endptr, int base);
25int atoi(const char *s);
26
27void *malloc(size_t size);
28void *aligned_alloc(size_t alignment, size_t size); /* From C11 */
29
30void free(void *ptr);
31void *calloc(size_t nmemb, size_t size);
32void *realloc(void *ptr, size_t size);
33void *reallocarray(void *ptr, size_t nmemb, size_t size);
34
35void *bsearch(const void *key, const void *array,
36 size_t count, size_t size,
37 int (*cmp)(const void *key, const void *element));
38
39void qsort_r(void *base, size_t nmemb, size_t size,
40 int (*compar)(const void *, const void *, void *), void *arg);
41void qsort(void *base, size_t nmemb, size_t size,
42 int (*compar)(const void *, const void *));
43
44#define EXIT_SUCCESS 0
45#define EXIT_FAILURE 1
46FUNC_NORETURN void _exit(int status);
47FUNC_NORETURN static inline void exit(int status)
48{
49 _exit(status);
50}
51FUNC_NORETURN void abort(void);
52
53#ifdef CONFIG_MINIMAL_LIBC_RAND
54#define RAND_MAX INT_MAX
55int rand_r(unsigned int *seed);
56int rand(void);
57void srand(unsigned int seed);
58#endif /* CONFIG_MINIMAL_LIBC_RAND */
59
60static inline int abs(int __n)
61{
62 return (__n < 0) ? -__n : __n;
63}
64
65static inline long labs(long __n)
66{
67 return (__n < 0L) ? -__n : __n;
68}
69
70static inline long long llabs(long long __n)
71{
72 return (__n < 0LL) ? -__n : __n;
73}
74
75char *getenv(const char *name);
76#if _POSIX_C_SOURCE >= 200112L
77int setenv(const char *name, const char *val, int overwrite);
78int unsetenv(const char *name);
79#endif
80
81#ifdef _BSD_SOURCE
82int getenv_r(const char *name, char *buf, size_t len);
83#endif
84
85#ifdef __cplusplus
86}
87#endif
88
89#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
ZTEST_BMEM int count
Definition main.c:33
void * ptr
Definition printk.c:177
static k_spinlock_key_t key
Definition spinlock_error_case.c:15
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)
FUNC_NORETURN void abort(void)
static long long llabs(long long __n)
Definition stdlib.h:70
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)
static long labs(long __n)
Definition stdlib.h:65
void * malloc(size_t size)
void * reallocarray(void *ptr, size_t nmemb, size_t size)
char * getenv(const char *name)
static FUNC_NORETURN void exit(int status)
Definition stdlib.h:47
void * realloc(void *ptr, size_t size)
static int abs(int __n)
Definition stdlib.h:60
unsigned long long strtoull(const char *nptr, char **endptr, int base)
long long strtoll(const char *nptr, char **endptr, int base)
void free(void *ptr)
Macros to abstract toolchain specific capabilities.