stdlib.h (2517B)
1 /* -*-comment-start: "//";comment-end:""-*- 2 * GNU Mes --- Maxwell Equations of Software 3 * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> 4 * Copyright © 2024 Andrius Štikonas <andrius@stikonas.eu> 5 * Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech> 6 * 7 * This file is part of GNU Mes. 8 * 9 * GNU Mes is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 3 of the License, or (at 12 * your option) any later version. 13 * 14 * GNU Mes is distributed in the hope that it will be useful, but 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 #ifndef __MES_STDLIB_H 23 #define __MES_STDLIB_H 1 24 25 #ifndef __MES_COMPARISON_FN_T 26 #define __MES_COMPARISON_FN_T 27 typedef int (*comparison_fn_t) (void const *, void const *); 28 #endif 29 30 #if SYSTEM_LIBC 31 #ifndef _GNU_SOURCE 32 #define _GNU_SOURCE 33 #endif 34 #undef __MES_STDLIB_H 35 #include_next <stdlib.h> 36 #else // ! SYSTEM_LIBC 37 38 #include <sys/types.h> 39 #include <alloca.h> 40 41 #define MB_CUR_MAX 1 42 43 void abort (void); 44 double atof (char const *s); 45 int atoi (char const *s); 46 int atexit (void (*function) (void)); 47 void *calloc (size_t nmemb, size_t size); 48 void _exit (int status); 49 void exit (int status); 50 void free (void *ptr); 51 char *getenv (char const *s); 52 int putenv (char *s); 53 int setenv (char const *s, char const *v, int overwrite_p); 54 void unsetenv (char const *name); 55 void *malloc (size_t); 56 void qsort (void *base, size_t nmemb, size_t size, int (*compar) (void const *, void const *)); 57 int rand (void); 58 void *realloc (void *p, size_t size); 59 double strtod (char const *string, char **tailptr); 60 float strtof (char const *string, char **tailptr); 61 long double strtold (char const *string, char **tailptr); 62 long strtol (char const *string, char **tailptr, int base); 63 long long strtoll (char const *string, char **tailptr, int base); 64 unsigned long strtoul (char const *string, char **tailptr, int base); 65 unsigned long long strtoull (char const *string, char **tailptr, int base); 66 67 #define EXIT_FAILURE 1 68 #define EXIT_SUCCESS 0 69 70 void *bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare); 71 72 #endif // ! SYSTEM_LIBC 73 74 #endif // __MES_STDLIB_H