diff options
Diffstat (limited to 'include/base.h')
-rw-r--r-- | include/base.h | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/include/base.h b/include/base.h index 99cd40b..7c8afbb 100644 --- a/include/base.h +++ b/include/base.h @@ -6,30 +6,14 @@ #include <rt.h> #include <sys.h> -// TODO: remove dependency system headers -#include <assert.h> -/* remaining libc functions we depend upon */ +// TODO: remove dependency on malloc + +/* all libc functions we depend upon */ void *malloc(uintptr size); void *calloc(uintptr n, uintptr size); void *realloc(void *ptr, uintptr size); void free(void *ptr); -void abort(void); -#if 0 -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <ctype.h> -#include <stdio.h> -#include <wchar.h> -#include <errno.h> -#include <pwd.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/types.h> - -typedef wchar_t wchar; -#endif -#include <sys/stat.h> +noreturn void abort(void); /* must be included first */ #include <base/memory.h> @@ -52,6 +36,13 @@ typedef wchar_t wchar; // ----------------------------------------------------------------------------- // variable arguments +noreturn void ·failassert(const char *, const char *, int, const char *); +#ifdef NDEBUG +# define assert(x) (void)0; +#else +# define assert(x) ((void)((x) || (·failassert(#x, __FILE__, __LINE__, __func__),0))) +#endif + /* from plan9 libc */ #define ERRMAX 128 /* max length of error string */ |