stdlib.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* stdlib.h */
  2. /*
  3. * Copyright (c) 2011-2014 Wind River Systems, Inc.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDLIB_H_
  8. #define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDLIB_H_
  9. #include <stddef.h>
  10. #include <limits.h>
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. unsigned long strtoul(const char *nptr, char **endptr, int base);
  15. long strtol(const char *nptr, char **endptr, int base);
  16. int atoi(const char *s);
  17. void *malloc(size_t size);
  18. void free(void *ptr);
  19. void *calloc(size_t nmemb, size_t size);
  20. void *realloc(void *ptr, size_t size);
  21. void *reallocarray(void *ptr, size_t nmemb, size_t size);
  22. void *bsearch(const void *key, const void *array,
  23. size_t count, size_t size,
  24. int (*cmp)(const void *key, const void *element));
  25. long long strtoll(const char *str, char **endptr, int base);
  26. #define EXIT_SUCCESS 0
  27. #define EXIT_FAILURE 1
  28. void _exit(int status);
  29. static inline void exit(int status)
  30. {
  31. _exit(status);
  32. }
  33. void abort(void);
  34. #ifdef CONFIG_MINIMAL_LIBC_RAND
  35. #define RAND_MAX INT_MAX
  36. int rand(void);
  37. void srand(unsigned int seed);
  38. #endif /* CONFIG_MINIMAL_LIBC_RAND */
  39. static inline int abs(int __n)
  40. {
  41. return (__n < 0) ? -__n : __n;
  42. }
  43. static inline long labs(long __n)
  44. {
  45. return (__n < 0L) ? -__n : __n;
  46. }
  47. static inline long long llabs(long long __n)
  48. {
  49. return (__n < 0LL) ? -__n : __n;
  50. }
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDLIB_H_ */