Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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);
21int atoi(const char *s);
22
23void *malloc(size_t size);
24void free(void *ptr);
25void *calloc(size_t nmemb, size_t size);
26void *realloc(void *ptr, size_t size);
27void *reallocarray(void *ptr, size_t nmemb, size_t size);
28
29void *bsearch(const void *key, const void *array,
30 size_t count, size_t size,
31 int (*cmp)(const void *key, const void *element));
32
33void qsort_r(void *base, size_t nmemb, size_t size,
34 int (*compar)(const void *, const void *, void *), void *arg);
35
36#define EXIT_SUCCESS 0
37#define EXIT_FAILURE 1
38void _exit(int status);
39static inline void exit(int status)
40{
41 _exit(status);
42}
43void abort(void);
44
45#ifdef CONFIG_MINIMAL_LIBC_RAND
46#define RAND_MAX INT_MAX
47int rand(void);
48void srand(unsigned int seed);
49#endif /* CONFIG_MINIMAL_LIBC_RAND */
50
51static inline int abs(int __n)
52{
53 return (__n < 0) ? -__n : __n;
54}
55
56static inline long labs(long __n)
57{
58 return (__n < 0L) ? -__n : __n;
59}
60
61static inline long long llabs(long long __n)
62{
63 return (__n < 0LL) ? -__n : __n;
64}
65
66static inline void qsort(void *base, size_t nmemb, size_t size,
67 int (*compar)(const void *, const void *))
68{
69 typedef int (*compar3)(const void *, const void *, void *);
70
71 qsort_r(base, nmemb, size, (compar3)compar, NULL);
72}
73
74#ifdef __cplusplus
75}
76#endif
77
78#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:79
static k_spinlock_key_t key
Definition: spinlock_error_case.c:14
void qsort_r(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *, void *), void *arg)
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:61
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)
static void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
Definition: stdlib.h:66
void abort(void)
static long labs(long __n)
Definition: stdlib.h:56
void * malloc(size_t size)
void * reallocarray(void *ptr, size_t nmemb, size_t size)
void * realloc(void *ptr, size_t size)
static int abs(int __n)
Definition: stdlib.h:51
static void exit(int status)
Definition: stdlib.h:39
void free(void *ptr)