stdlib.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <bits/wchar.h>
  8. #include <stddef.h>
  9. #include <sys/cdefs.h>
  10. #include <sys/types.h>
  11. __BEGIN_DECLS
  12. #define EXIT_SUCCESS 0
  13. #define EXIT_FAILURE 1
  14. __attribute__((noreturn)) void _abort(void);
  15. __attribute__((malloc)) __attribute__((alloc_size(1))) void* malloc(size_t);
  16. __attribute__((malloc)) __attribute__((alloc_size(1, 2))) void* calloc(size_t nmemb, size_t);
  17. size_t malloc_size(void const*);
  18. size_t malloc_good_size(size_t);
  19. void serenity_dump_malloc_stats(void);
  20. void free(void*);
  21. __attribute__((alloc_size(2))) void* realloc(void* ptr, size_t);
  22. char* getenv(char const* name);
  23. char* secure_getenv(char const* name);
  24. int putenv(char*);
  25. int serenity_putenv(char const* new_var, size_t length);
  26. int unsetenv(char const*);
  27. int clearenv(void);
  28. int setenv(char const* name, char const* value, int overwrite);
  29. char const* getprogname(void);
  30. void setprogname(char const*);
  31. int atoi(char const*);
  32. long atol(char const*);
  33. long long atoll(char const*);
  34. double strtod(char const*, char** endptr);
  35. long double strtold(char const*, char** endptr);
  36. float strtof(char const*, char** endptr);
  37. long strtol(char const*, char** endptr, int base);
  38. long long strtoll(char const*, char** endptr, int base);
  39. unsigned long long strtoull(char const*, char** endptr, int base);
  40. unsigned long strtoul(char const*, char** endptr, int base);
  41. void qsort(void* base, size_t nmemb, size_t size, int (*compar)(void const*, void const*));
  42. void qsort_r(void* base, size_t nmemb, size_t size, int (*compar)(void const*, void const*, void*), void* arg);
  43. int atexit(void (*function)(void));
  44. __attribute__((noreturn)) void exit(int status);
  45. __attribute__((noreturn)) void abort(void);
  46. char* ptsname(int fd);
  47. int ptsname_r(int fd, char* buffer, size_t);
  48. int abs(int);
  49. long labs(long);
  50. long long int llabs(long long int);
  51. double atof(char const*);
  52. int system(char const* command);
  53. char* mktemp(char*);
  54. int mkstemp(char*);
  55. int mkstemps(char*, int);
  56. char* mkdtemp(char*);
  57. void* bsearch(void const* key, void const* base, size_t nmemb, size_t size, int (*compar)(void const*, void const*));
  58. int mblen(char const*, size_t);
  59. size_t mbstowcs(wchar_t*, char const*, size_t);
  60. int mbtowc(wchar_t*, char const*, size_t);
  61. int wctomb(char*, wchar_t);
  62. size_t wcstombs(char*, wchar_t const*, size_t);
  63. char* realpath(char const* pathname, char* buffer);
  64. __attribute__((noreturn)) void _Exit(int status);
  65. #define RAND_MAX 32767
  66. int rand(void);
  67. void srand(unsigned seed);
  68. long int random(void);
  69. void srandom(unsigned seed);
  70. uint32_t arc4random(void);
  71. void arc4random_buf(void*, size_t);
  72. uint32_t arc4random_uniform(uint32_t);
  73. typedef struct {
  74. int quot;
  75. int rem;
  76. } div_t;
  77. div_t div(int, int);
  78. typedef struct {
  79. long quot;
  80. long rem;
  81. } ldiv_t;
  82. ldiv_t ldiv(long, long);
  83. typedef struct {
  84. long long quot;
  85. long long rem;
  86. } lldiv_t;
  87. lldiv_t lldiv(long long, long long);
  88. int posix_openpt(int flags);
  89. int grantpt(int fd);
  90. int unlockpt(int fd);
  91. int posix_memalign(void**, size_t alignment, size_t size);
  92. __attribute__((malloc, alloc_size(2), alloc_align(1))) void* aligned_alloc(size_t alignment, size_t size);
  93. __END_DECLS