stdlib.h 1.3 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. #define EXIT_SUCCESS 0
  26. #define EXIT_FAILURE 1
  27. void _exit(int status);
  28. static inline void exit(int status)
  29. {
  30. _exit(status);
  31. }
  32. void abort(void);
  33. #ifdef CONFIG_MINIMAL_LIBC_RAND
  34. #define RAND_MAX INT_MAX
  35. int rand(void);
  36. void srand(unsigned int seed);
  37. #endif /* CONFIG_MINIMAL_LIBC_RAND */
  38. static inline int abs(int __n)
  39. {
  40. return (__n < 0) ? -__n : __n;
  41. }
  42. static inline long labs(long __n)
  43. {
  44. return (__n < 0L) ? -__n : __n;
  45. }
  46. static inline long long llabs(long long __n)
  47. {
  48. return (__n < 0LL) ? -__n : __n;
  49. }
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53. #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDLIB_H_ */