diff --git a/AK/Assertions.h b/AK/Assertions.h index 99f9c705b6bc2f..76a2a3d843e6f1 100644 --- a/AK/Assertions.h +++ b/AK/Assertions.h @@ -28,16 +28,17 @@ #ifndef AK_TEST_SUITE -#ifdef KERNEL -# include -#else -# include -# ifndef __serenity__ -# define ASSERT assert -# define ASSERT_NOT_REACHED() assert(false) -# define RELEASE_ASSERT assert +# if defined(KERNEL) +# include +# elif defined(BOOTSTRAPPER) +# include +# else +# include +# ifndef __serenity__ +# define ASSERT assert +# define ASSERT_NOT_REACHED() assert(false) +# define RELEASE_ASSERT assert +# endif # endif -#endif #endif - diff --git a/AK/JsonObject.h b/AK/JsonObject.h index 5e44b5bcb3e413..da7a5d8f46f981 100644 --- a/AK/JsonObject.h +++ b/AK/JsonObject.h @@ -26,11 +26,11 @@ #pragma once -#include #include #include #include #include +#include namespace AK { @@ -119,7 +119,7 @@ inline void JsonObject::serialize(Builder& builder) const { JsonObjectSerializer serializer { builder }; for_each_member([&](auto& key, auto& value) { - serializer.add(key, value); + serializer.add(key, value); }); } @@ -147,7 +147,7 @@ inline void JsonValue::serialize(Builder& builder) const case Type::Bool: builder.append(m_value.as_bool ? "true" : "false"); break; -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) case Type::Double: builder.appendf("%g", m_value.as_double); break; diff --git a/AK/JsonValue.cpp b/AK/JsonValue.cpp index d46d5a4f926170..c78c05c8d9d5f3 100644 --- a/AK/JsonValue.cpp +++ b/AK/JsonValue.cpp @@ -118,7 +118,7 @@ JsonValue::JsonValue(const char* cstring) { } -#ifndef KERNEL +#if !defined(BOOTSTRAPPER) && !defined(KERNEL) JsonValue::JsonValue(double value) : m_type(Type::Double) { diff --git a/AK/JsonValue.h b/AK/JsonValue.h index fca35bbee81c24..a109b671beed35 100644 --- a/AK/JsonValue.h +++ b/AK/JsonValue.h @@ -46,7 +46,7 @@ class JsonValue { UnsignedInt32, Int64, UnsignedInt64, -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) Double, #endif Bool, @@ -71,7 +71,7 @@ class JsonValue { JsonValue(i64); JsonValue(u64); -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) JsonValue(double); #endif JsonValue(bool); @@ -175,7 +175,7 @@ class JsonValue { return *m_value.as_array; } -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) double as_double() const { ASSERT(is_double()); @@ -196,7 +196,7 @@ class JsonValue { bool is_u32() const { return m_type == Type::UnsignedInt32; } bool is_i64() const { return m_type == Type::Int64; } bool is_u64() const { return m_type == Type::UnsignedInt64; } -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) bool is_double() const { return m_type == Type::Double; @@ -214,7 +214,7 @@ class JsonValue { case Type::UnsignedInt32: case Type::Int64: case Type::UnsignedInt64: -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) case Type::Double: #endif return true; @@ -226,7 +226,7 @@ class JsonValue { template T to_number(T default_value = 0) const { -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) if (is_double()) return (T)as_double(); #endif @@ -251,7 +251,7 @@ class JsonValue { StringImpl* as_string { nullptr }; JsonArray* as_array; JsonObject* as_object; -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) double as_double; #endif i32 as_i32; diff --git a/AK/LogStream.cpp b/AK/LogStream.cpp index f1b148cb997c89..b6d2b5396d8129 100644 --- a/AK/LogStream.cpp +++ b/AK/LogStream.cpp @@ -82,7 +82,7 @@ const LogStream& operator<<(const LogStream& stream, const void* value) return stream << String::format("%p", value); } -#if defined(__serenity__) && !defined(KERNEL) +#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER) static TriState got_process_name = TriState::Unknown; static char process_name_buffer[256]; #endif @@ -90,7 +90,7 @@ static char process_name_buffer[256]; DebugLogStream dbg() { DebugLogStream stream; -#if defined(__serenity__) && !defined(KERNEL) +#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER) if (got_process_name == TriState::Unknown) { if (get_process_name(process_name_buffer, sizeof(process_name_buffer)) == 0) got_process_name = TriState::True; @@ -100,11 +100,14 @@ DebugLogStream dbg() if (got_process_name == TriState::True) stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: "; #endif -#if defined(__serenity__) && defined(KERNEL) +#if defined(__serenity__) && defined(KERNEL) && !defined(BOOTSTRAPPER) if (current) stream << "\033[34;1m[" << *current << "]\033[0m: "; else stream << "\033[36;1m[Kernel]\033[0m: "; +#endif +#if defined(BOOTSTRAPPER) && !defined(__serenity__) && !defined(KERNEL) + stream << "\033[36;1m[Bootstrapper]\033[0m: "; #endif return stream; } diff --git a/AK/LogStream.h b/AK/LogStream.h index b254db58914bd4..6cf7b45ddd2529 100644 --- a/AK/LogStream.h +++ b/AK/LogStream.h @@ -29,7 +29,7 @@ #include #include -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) # include # include # include @@ -44,7 +44,7 @@ class StringView; class LogStream { public: LogStream() -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) : m_errno_restorer(errno) #endif { @@ -54,7 +54,7 @@ class LogStream { virtual void write(const char*, int) const = 0; private: -#ifndef KERNEL +#if !defined(KERNEL) && !defined(BOOTSTRAPPER) ScopedValueRollback m_errno_restorer; #endif }; diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index 77842b7af87caa..e7819733f3c75f 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -352,7 +352,7 @@ template ret += print_hex(putch, bufptr, va_arg(ap, u64), false, false, left_pad, zeroPad, 16); break; -#ifndef KERNEL +#if !defined(BOOTSTRAPPER) && !defined(KERNEL) case 'g': case 'f': // FIXME: Print as float! diff --git a/AK/RefCounted.h b/AK/RefCounted.h index 7926de73211723..f45320860166f5 100644 --- a/AK/RefCounted.h +++ b/AK/RefCounted.h @@ -26,8 +26,8 @@ #pragma once -#include "Assertions.h" -#include "StdLibExtras.h" +#include +#include namespace AK { diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 67ad6d3d23ac0b..ff80340bd1ab7d 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -26,8 +26,8 @@ #pragma once -#ifdef KERNEL -# include +#if defined(KERNEL) || defined(BOOTSTRAPPER) +# include #else # include # include @@ -37,13 +37,13 @@ #include -#if defined(__serenity__) && !defined(KERNEL) +#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER) extern "C" void* mmx_memcpy(void* to, const void* from, size_t); #endif [[gnu::always_inline]] inline void fast_u32_copy(u32* dest, const u32* src, size_t count) { -#if defined(__serenity__) && !defined(KERNEL) +#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER) if (count >= 256) { mmx_memcpy(dest, src, count * sizeof(count)); return; @@ -323,12 +323,12 @@ struct IsSame { } using AK::ceil_div; +using AK::clamp; using AK::exchange; using AK::forward; using AK::IsSame; using AK::max; using AK::min; -using AK::clamp; using AK::move; using AK::RemoveConst; using AK::swap; diff --git a/AK/kmalloc.h b/AK/kmalloc.h index 0d071972b49630..634aaf10cc910e 100644 --- a/AK/kmalloc.h +++ b/AK/kmalloc.h @@ -36,8 +36,10 @@ # define AK_MAKE_ETERNAL #endif -#ifdef KERNEL +#if defined(KERNEL) # include +#elif defined(BOOTSTRAPPER) +# include #else # include diff --git a/AK/kstdio.h b/AK/kstdio.h index e1668d7fe1b60d..d0d15068ef4453 100644 --- a/AK/kstdio.h +++ b/AK/kstdio.h @@ -27,7 +27,7 @@ #pragma once #ifdef __serenity__ -#include +# include #else #include #define kprintf printf