+ exec* functions
[meinos.git] / apps / include / stdlib.h
blob35b5c7a03712a3b6934cd21449db546fbd4620fa
1 /*
2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _STDLIB_H_
20 #define _STDLIB_H_
22 #include <sys/types.h>
23 #include <limits.h>
24 #include <stdint.h>
25 #include <malloc.h>
26 #include <string.h>
28 #ifndef EXIT_SUCCESS
29 #define EXIT_SUCCESS 0
30 #endif
31 #ifndef EXIT_FAILURE
32 #define EXIT_FAILURE 1
33 #endif
35 #ifndef NULL
36 #define NULL ((void*)0)
37 #endif
39 #define on_exit(func) atexit(func)
41 typedef struct {
42 int quot;
43 int rem;
44 } div_t;
46 void exit(int result);
47 void _Exit(int result);
48 void abort();
49 int atexit(void (*function)(void));
50 int system(const char *command);
52 int atoi(const char *str);
54 #define RAND_MAX 32767
55 int rand_seed;
56 void srand(int newseed);
57 int rand();
59 int abs(int num);
60 div_t div(int numer, int denom);
62 char *getenv(const char *name);
63 int setenv(const char *envname, const char *envval, int overwrite);
64 int unsetenv(const char *name);
66 void *sbrk(intptr_t size);
67 void* memalign(size_t, size_t);
69 char *realpath(const char *file_name,char *resolved_name);
71 static inline signed long strtol(const char *nptr,char **endptr,int base) {
72 return (signed long)strntoumax(nptr,endptr,base,~(size_t)0);
75 static inline signed long long strtoll(const char *nptr,char **endptr,int base) {
76 return (signed long long)strntoumax(nptr,endptr,base,~(size_t)0);
79 static inline unsigned long strtoul(const char *nptr,char **endptr,int base) {
80 return (unsigned long)strntoumax(nptr,endptr,base,~(size_t)0);
83 static inline unsigned long long strtoull(const char *nptr,char **endptr,int base) {
84 return (unsigned long long)strntoumax(nptr,endptr,base,~(size_t)0);
88 #endif