stdlib.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #pragma once
  27. #include <stddef.h>
  28. #include <sys/cdefs.h>
  29. #include <sys/types.h>
  30. __attribute__((warn_unused_result)) int __generate_unique_filename(char* pattern);
  31. __BEGIN_DECLS
  32. #define EXIT_SUCCESS 0
  33. #define EXIT_FAILURE 1
  34. #define MB_CUR_MAX 1
  35. __attribute__((malloc)) __attribute__((alloc_size(1))) void* malloc(size_t);
  36. __attribute__((malloc)) __attribute__((alloc_size(1, 2))) void* calloc(size_t nmemb, size_t);
  37. size_t malloc_size(void*);
  38. void serenity_dump_malloc_stats(void);
  39. void free(void*);
  40. __attribute__((alloc_size(2))) void* realloc(void* ptr, size_t);
  41. char* getenv(const char* name);
  42. int putenv(char*);
  43. int unsetenv(const char*);
  44. int setenv(const char* name, const char* value, int overwrite);
  45. int atoi(const char*);
  46. long atol(const char*);
  47. long long atoll(const char*);
  48. double strtod(const char*, char** endptr);
  49. long double strtold(const char*, char** endptr);
  50. float strtof(const char*, char** endptr);
  51. long strtol(const char*, char** endptr, int base);
  52. long long strtoll(const char*, char** endptr, int base);
  53. unsigned long long strtoull(const char*, char** endptr, int base);
  54. unsigned long strtoul(const char*, char** endptr, int base);
  55. void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
  56. void qsort_r(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void* arg);
  57. int atexit(void (*function)());
  58. __attribute__((noreturn)) void exit(int status);
  59. __attribute__((noreturn)) void abort();
  60. char* ptsname(int fd);
  61. int ptsname_r(int fd, char* buffer, size_t);
  62. int abs(int);
  63. long labs(long);
  64. double atof(const char*);
  65. int system(const char* command);
  66. char* mktemp(char*);
  67. int mkstemp(char*);
  68. char* mkdtemp(char*);
  69. void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
  70. size_t mbstowcs(wchar_t*, const char*, size_t);
  71. int mbtowc(wchar_t*, const char*, size_t);
  72. int wctomb(char*, wchar_t);
  73. size_t wcstombs(char*, const wchar_t*, size_t);
  74. char* realpath(const char* pathname, char* buffer);
  75. #define RAND_MAX 32767
  76. int rand();
  77. void srand(unsigned seed);
  78. long int random();
  79. void srandom(unsigned seed);
  80. uint32_t arc4random(void);
  81. void arc4random_buf(void*, size_t);
  82. uint32_t arc4random_uniform(uint32_t);
  83. typedef struct {
  84. int quot;
  85. int rem;
  86. } div_t;
  87. div_t div(int, int);
  88. typedef struct {
  89. long quot;
  90. long rem;
  91. } ldiv_t;
  92. ldiv_t ldiv(long, long);
  93. int posix_openpt(int flags);
  94. int grantpt(int fd);
  95. int unlockpt(int fd);
  96. __END_DECLS