From ad84bc75c8621e023ad20fdccaff1256951f9bdd Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 22 Sep 2013 23:55:39 +0200 Subject: [PATCH] Change kernel internal build macro to __is_sortix_kernel. --- libc/Makefile | 2 +- libc/assert/_assert.cpp | 6 +++--- libc/errno/errno.cpp | 4 ++-- libc/include/features.h | 2 +- libc/include/stdint.h | 4 ++-- libc/include/sys/syscall.h | 2 +- libc/include/sys/types.h | 2 +- libc/stdio/fsetdefaultbuf.cpp | 2 +- libc/stdlib/abort.cpp | 2 +- libc/stdlib/heap.cpp | 18 +++++++++--------- sortix/Makefile | 2 +- sortix/include/sortix/__/types.h | 4 ++-- sortix/include/sortix/resource.h | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/libc/Makefile b/libc/Makefile index a2bd6c7e..1e4610ab 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -486,7 +486,7 @@ INSTALLHEADERDIRS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(H INSTALLHEADERS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERS))) SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS)) -SORTIXCPPFLAGS:=$(CPPFLAGS) -DSORTIX_KERNEL +SORTIXCPPFLAGS:=$(CPPFLAGS) -D__is_sortix_kernel=1 SORTIXFLAGS:=$(FLAGS) -ffreestanding SORTIXCFLAGS:=$(CFLAGS) SORTIXCXXFLAGS:=$(CXXFLAGS) diff --git a/libc/assert/_assert.cpp b/libc/assert/_assert.cpp index b0708ff9..659fea68 100644 --- a/libc/assert/_assert.cpp +++ b/libc/assert/_assert.cpp @@ -24,11 +24,11 @@ #include #include -#if !defined(SORTIX_KERNEL) +#if !defined(__is_sortix_kernel) #include #include #endif -#if defined(SORTIX_KERNEL) +#if defined(__is_sortix_kernel) #include #include #endif @@ -36,7 +36,7 @@ void _assert(const char* filename, unsigned int line, const char* functionname, const char* expression) { -#if !defined(SORTIX_KERNEL) +#if !defined(__is_sortix_kernel) fprintf(stderr, "Assertion failure: %s:%u: %s: %s\n", filename, line, functionname, expression); abort(); diff --git a/libc/errno/errno.cpp b/libc/errno/errno.cpp index 87b8b6a8..a67a9418 100644 --- a/libc/errno/errno.cpp +++ b/libc/errno/errno.cpp @@ -25,14 +25,14 @@ #define __SORTIX_STDLIB_REDIRECTS 0 #include #include -#ifndef SORTIX_KERNEL +#ifndef __is_sortix_kernel #include #endif extern "C" { int global_errno = 0; } extern "C" { errno_location_func_t errno_location_func = NULL; } -#ifndef SORTIX_KERNEL +#ifndef __is_sortix_kernel extern "C" void init_error_functions() { global_errno = 0; diff --git a/libc/include/features.h b/libc/include/features.h index f4fd6611..27dd823d 100644 --- a/libc/include/features.h +++ b/libc/include/features.h @@ -52,7 +52,7 @@ #endif /* Sortix system components implicitly use the native API. */ -#if __is_sortix_libc || defined(SORTIX_KERNEL) +#if __is_sortix_libc || __is_sortix_kernel #define _SORTIX_SOURCE 1 #endif diff --git a/libc/include/stdint.h b/libc/include/stdint.h index 23528829..7c690b1d 100644 --- a/libc/include/stdint.h +++ b/libc/include/stdint.h @@ -32,7 +32,7 @@ __BEGIN_DECLS /* Only define these constant macros in C++ if requested. */ #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) || \ - defined(__is_sortix_libc) || defined(SORTIX_KERNEL) /* TODO: HACK! */ + defined(__is_sortix_libc) || defined(__is_sortix_kernel) /* TODO: HACK! */ #define INT8_C(c) __INT8_C(c) #define INT16_C(c) __INT16_C(c) @@ -51,7 +51,7 @@ __BEGIN_DECLS /* Only define these limit macros in C++ if requested. */ #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) || \ - defined(__is_sortix_libc) || defined(SORTIX_KERNEL) /* TODO: HACK! */ + defined(__is_sortix_libc) || defined(__is_sortix_kernel) /* TODO: HACK! */ #define INT8_MIN __INT8_MIN #define INT16_MIN __INT16_MIN diff --git a/libc/include/sys/syscall.h b/libc/include/sys/syscall.h index f1b84a26..f2111120 100644 --- a/libc/include/sys/syscall.h +++ b/libc/include/sys/syscall.h @@ -22,7 +22,7 @@ *******************************************************************************/ -#if defined(SORTIX_KERNEL) +#if defined(__is_sortix_kernel) #error "This file is part of user-space and should not be built in kernel mode" #endif diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h index 07860830..b470f1d2 100644 --- a/libc/include/sys/types.h +++ b/libc/include/sys/types.h @@ -56,7 +56,7 @@ __BEGIN_DECLS @include(uid_t.h) @include(useconds_t.h) -#if !defined(SORTIX_KERNEL) +#if !defined(__is_sortix_kernel) /* TODO: pthread*_t */ #endif diff --git a/libc/stdio/fsetdefaultbuf.cpp b/libc/stdio/fsetdefaultbuf.cpp index f438a60f..f1ce9440 100644 --- a/libc/stdio/fsetdefaultbuf.cpp +++ b/libc/stdio/fsetdefaultbuf.cpp @@ -47,7 +47,7 @@ extern "C" int fsetdefaultbuf(FILE* fp) // Determine the buffering semantics depending on whether the destination is // an interactive device or not. -#ifdef SORTIX_KERNEL +#ifdef __is_sortix_kernel int mode = _IOLBF; // TODO: Detect this? #else int mode = fp->buffer_mode != -1 ? fp->buffer_mode diff --git a/libc/stdlib/abort.cpp b/libc/stdlib/abort.cpp index eb9155cb..b08c3d2d 100644 --- a/libc/stdlib/abort.cpp +++ b/libc/stdlib/abort.cpp @@ -27,7 +27,7 @@ #include #include -#if defined(SORTIX_KERNEL) +#if defined(__is_sortix_kernel) #include #include diff --git a/libc/stdlib/heap.cpp b/libc/stdlib/heap.cpp index b0207de9..30fcfb11 100644 --- a/libc/stdlib/heap.cpp +++ b/libc/stdlib/heap.cpp @@ -24,11 +24,11 @@ #include -#ifdef SORTIX_KERNEL +#ifdef __is_sortix_kernel #define HEAP_GROWS_DOWNWARDS #endif -#ifndef SORTIX_KERNEL +#ifndef __is_sortix_kernel #include #include #include @@ -43,7 +43,7 @@ #define PARANOIA 1 -#ifdef SORTIX_KERNEL +#ifdef __is_sortix_kernel #include #include #include @@ -70,7 +70,7 @@ const size_t NUMBINS = 8UL * sizeof(size_t); static uintptr_t wilderness; -#ifdef SORTIX_KERNEL +#ifdef __is_sortix_kernel static uintptr_t GetHeapStart() { return Sortix::GetHeapUpper(); @@ -205,7 +205,7 @@ inline size_t BSF(size_t Value) struct Chunk; struct Trailer; -#ifdef SORTIX_KERNEL +#ifdef __is_sortix_kernel Sortix::kthread_mutex_t heaplock; #endif @@ -427,7 +427,7 @@ extern "C" void _init_heap() wildernesssize = 0; for ( size_t i = 0; i < NUMBINS; i++ ) { bins[i] = NULL; } bincontainschunks = 0; -#ifdef SORTIX_KERNEL +#ifdef __is_sortix_kernel heaplock = Sortix::KTHREAD_MUTEX_INITIALIZER; #endif } @@ -469,7 +469,7 @@ static bool ExpandWilderness(size_t bytesneeded) extern "C" void* malloc(size_t size) { - #ifdef SORTIX_KERNEL + #ifdef __is_sortix_kernel Sortix::ScopedLock scopedlock(&heaplock); #endif @@ -655,7 +655,7 @@ static void UnifyNeighbors(Chunk** chunk) extern "C" void free(void* addr) { - #ifdef SORTIX_KERNEL + #ifdef __is_sortix_kernel Sortix::ScopedLock scopedlock(&heaplock); #endif @@ -665,7 +665,7 @@ extern "C" void free(void* addr) if ( !addr) { return; } Chunk* chunk = (Chunk*) ((uintptr_t) addr - sizeof(Chunk)); -#ifndef SORTIX_KERNEL +#ifndef __is_sortix_kernel if ( !IsGoodHeapPointer(addr, 1) || !IsGoodHeapPointer(chunk, sizeof(*chunk)) ) { diff --git a/sortix/Makefile b/sortix/Makefile index 8564890c..cf88e4ee 100644 --- a/sortix/Makefile +++ b/sortix/Makefile @@ -13,7 +13,7 @@ CXXFLAGS?=$(OPTLEVEL) # Base compiler options and definitions. -CPPFLAGS:=$(CPPFLAGS) -I. -Iinclude -DSORTIX_KERNEL +CPPFLAGS:=$(CPPFLAGS) -I. -Iinclude -D__is_sortix_kernel CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -ffreestanding -fbuiltin -std=gnu++11 \ -fno-exceptions -fno-rtti diff --git a/sortix/include/sortix/__/types.h b/sortix/include/sortix/__/types.h index 7e6bde0e..8e885e0c 100644 --- a/sortix/include/sortix/__/types.h +++ b/sortix/include/sortix/__/types.h @@ -57,10 +57,10 @@ typedef int __ssize_t; typedef __uintptr_t __timer_t; typedef __SIZE_TYPE__ __socklen_t; -#if defined(SORTIX_KERNEL) || defined(__is_sortix_libc) +#if defined(__is_sortix_kernel) || defined(__is_sortix_libc) #define OFF_MIN __OFF_MIN #endif -#if defined(SORTIX_KERNEL) || defined(__is_sortix_libc) +#if defined(__is_sortix_kernel) || defined(__is_sortix_libc) #define OFF_MAX __OFF_MAX #endif diff --git a/sortix/include/sortix/resource.h b/sortix/include/sortix/resource.h index b6556077..c60a4616 100644 --- a/sortix/include/sortix/resource.h +++ b/sortix/include/sortix/resource.h @@ -55,7 +55,7 @@ struct rlimit #define RLIMIT_STACK 6 #define __RLIMIT_NUM_DECLARED 7 /* index of highest constant plus 1. */ -#if !__STDC_HOSTED__ && defined(SORTIX_KERNEL) +#if !__STDC_HOSTED__ && defined(__is_sortix_kernel) #define RLIMIT_NUM_DECLARED __RLIMIT_NUM_DECLARED #endif