mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
AK: Apply changes for the Bootstrapper environment
This commit is contained in:
parent
88cf46dc98
commit
8bdb08c354
11 changed files with 43 additions and 37 deletions
|
@ -28,16 +28,17 @@
|
||||||
|
|
||||||
#ifndef AK_TEST_SUITE
|
#ifndef AK_TEST_SUITE
|
||||||
|
|
||||||
#ifdef KERNEL
|
# if defined(KERNEL)
|
||||||
# include <Kernel/Assertions.h>
|
# include <Kernel/Assertions.h>
|
||||||
#else
|
# elif defined(BOOTSTRAPPER)
|
||||||
# include <assert.h>
|
# include <Bootstrapper/Output/Assertions.h>
|
||||||
# ifndef __serenity__
|
# else
|
||||||
# define ASSERT assert
|
# include <assert.h>
|
||||||
# define ASSERT_NOT_REACHED() assert(false)
|
# ifndef __serenity__
|
||||||
# define RELEASE_ASSERT assert
|
# define ASSERT assert
|
||||||
|
# define ASSERT_NOT_REACHED() assert(false)
|
||||||
|
# define RELEASE_ASSERT assert
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/String.h>
|
|
||||||
#include <AK/HashMap.h>
|
#include <AK/HashMap.h>
|
||||||
#include <AK/JsonArray.h>
|
#include <AK/JsonArray.h>
|
||||||
#include <AK/JsonObjectSerializer.h>
|
#include <AK/JsonObjectSerializer.h>
|
||||||
#include <AK/JsonValue.h>
|
#include <AK/JsonValue.h>
|
||||||
|
#include <AK/String.h>
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ inline void JsonObject::serialize(Builder& builder) const
|
||||||
{
|
{
|
||||||
JsonObjectSerializer serializer { builder };
|
JsonObjectSerializer serializer { builder };
|
||||||
for_each_member([&](auto& key, auto& value) {
|
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:
|
case Type::Bool:
|
||||||
builder.append(m_value.as_bool ? "true" : "false");
|
builder.append(m_value.as_bool ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
case Type::Double:
|
case Type::Double:
|
||||||
builder.appendf("%g", m_value.as_double);
|
builder.appendf("%g", m_value.as_double);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -118,7 +118,7 @@ JsonValue::JsonValue(const char* cstring)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef KERNEL
|
#if !defined(BOOTSTRAPPER) && !defined(KERNEL)
|
||||||
JsonValue::JsonValue(double value)
|
JsonValue::JsonValue(double value)
|
||||||
: m_type(Type::Double)
|
: m_type(Type::Double)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
UnsignedInt32,
|
UnsignedInt32,
|
||||||
Int64,
|
Int64,
|
||||||
UnsignedInt64,
|
UnsignedInt64,
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
Double,
|
Double,
|
||||||
#endif
|
#endif
|
||||||
Bool,
|
Bool,
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
JsonValue(i64);
|
JsonValue(i64);
|
||||||
JsonValue(u64);
|
JsonValue(u64);
|
||||||
|
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
JsonValue(double);
|
JsonValue(double);
|
||||||
#endif
|
#endif
|
||||||
JsonValue(bool);
|
JsonValue(bool);
|
||||||
|
@ -175,7 +175,7 @@ public:
|
||||||
return *m_value.as_array;
|
return *m_value.as_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
double as_double() const
|
double as_double() const
|
||||||
{
|
{
|
||||||
ASSERT(is_double());
|
ASSERT(is_double());
|
||||||
|
@ -196,7 +196,7 @@ public:
|
||||||
bool is_u32() const { return m_type == Type::UnsignedInt32; }
|
bool is_u32() const { return m_type == Type::UnsignedInt32; }
|
||||||
bool is_i64() const { return m_type == Type::Int64; }
|
bool is_i64() const { return m_type == Type::Int64; }
|
||||||
bool is_u64() const { return m_type == Type::UnsignedInt64; }
|
bool is_u64() const { return m_type == Type::UnsignedInt64; }
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
bool is_double() const
|
bool is_double() const
|
||||||
{
|
{
|
||||||
return m_type == Type::Double;
|
return m_type == Type::Double;
|
||||||
|
@ -214,7 +214,7 @@ public:
|
||||||
case Type::UnsignedInt32:
|
case Type::UnsignedInt32:
|
||||||
case Type::Int64:
|
case Type::Int64:
|
||||||
case Type::UnsignedInt64:
|
case Type::UnsignedInt64:
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
case Type::Double:
|
case Type::Double:
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
@ -226,7 +226,7 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T to_number(T default_value = 0) const
|
T to_number(T default_value = 0) const
|
||||||
{
|
{
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
if (is_double())
|
if (is_double())
|
||||||
return (T)as_double();
|
return (T)as_double();
|
||||||
#endif
|
#endif
|
||||||
|
@ -251,7 +251,7 @@ private:
|
||||||
StringImpl* as_string { nullptr };
|
StringImpl* as_string { nullptr };
|
||||||
JsonArray* as_array;
|
JsonArray* as_array;
|
||||||
JsonObject* as_object;
|
JsonObject* as_object;
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
double as_double;
|
double as_double;
|
||||||
#endif
|
#endif
|
||||||
i32 as_i32;
|
i32 as_i32;
|
||||||
|
|
|
@ -82,7 +82,7 @@ const LogStream& operator<<(const LogStream& stream, const void* value)
|
||||||
return stream << String::format("%p", 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 TriState got_process_name = TriState::Unknown;
|
||||||
static char process_name_buffer[256];
|
static char process_name_buffer[256];
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,7 +90,7 @@ static char process_name_buffer[256];
|
||||||
DebugLogStream dbg()
|
DebugLogStream dbg()
|
||||||
{
|
{
|
||||||
DebugLogStream stream;
|
DebugLogStream stream;
|
||||||
#if defined(__serenity__) && !defined(KERNEL)
|
#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
if (got_process_name == TriState::Unknown) {
|
if (got_process_name == TriState::Unknown) {
|
||||||
if (get_process_name(process_name_buffer, sizeof(process_name_buffer)) == 0)
|
if (get_process_name(process_name_buffer, sizeof(process_name_buffer)) == 0)
|
||||||
got_process_name = TriState::True;
|
got_process_name = TriState::True;
|
||||||
|
@ -100,11 +100,14 @@ DebugLogStream dbg()
|
||||||
if (got_process_name == TriState::True)
|
if (got_process_name == TriState::True)
|
||||||
stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: ";
|
stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: ";
|
||||||
#endif
|
#endif
|
||||||
#if defined(__serenity__) && defined(KERNEL)
|
#if defined(__serenity__) && defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
if (current)
|
if (current)
|
||||||
stream << "\033[34;1m[" << *current << "]\033[0m: ";
|
stream << "\033[34;1m[" << *current << "]\033[0m: ";
|
||||||
else
|
else
|
||||||
stream << "\033[36;1m[Kernel]\033[0m: ";
|
stream << "\033[36;1m[Kernel]\033[0m: ";
|
||||||
|
#endif
|
||||||
|
#if defined(BOOTSTRAPPER) && !defined(__serenity__) && !defined(KERNEL)
|
||||||
|
stream << "\033[36;1m[Bootstrapper]\033[0m: ";
|
||||||
#endif
|
#endif
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <AK/kstdio.h>
|
#include <AK/kstdio.h>
|
||||||
|
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
# include <AK/ScopedValueRollback.h>
|
# include <AK/ScopedValueRollback.h>
|
||||||
# include <AK/StringView.h>
|
# include <AK/StringView.h>
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
|
@ -44,7 +44,7 @@ class StringView;
|
||||||
class LogStream {
|
class LogStream {
|
||||||
public:
|
public:
|
||||||
LogStream()
|
LogStream()
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
: m_errno_restorer(errno)
|
: m_errno_restorer(errno)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ public:
|
||||||
virtual void write(const char*, int) const = 0;
|
virtual void write(const char*, int) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifndef KERNEL
|
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
ScopedValueRollback<int> m_errno_restorer;
|
ScopedValueRollback<int> m_errno_restorer;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -352,7 +352,7 @@ template<typename PutChFunc>
|
||||||
ret += print_hex(putch, bufptr, va_arg(ap, u64), false, false, left_pad, zeroPad, 16);
|
ret += print_hex(putch, bufptr, va_arg(ap, u64), false, false, left_pad, zeroPad, 16);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifndef KERNEL
|
#if !defined(BOOTSTRAPPER) && !defined(KERNEL)
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'f':
|
case 'f':
|
||||||
// FIXME: Print as float!
|
// FIXME: Print as float!
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Assertions.h"
|
#include <AK/Assertions.h>
|
||||||
#include "StdLibExtras.h"
|
#include <AK/StdLibExtras.h>
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef KERNEL
|
#if defined(KERNEL) || defined(BOOTSTRAPPER)
|
||||||
# include <Kernel/StdLib.h>
|
# include <LibBareMetal/StdLib.h>
|
||||||
#else
|
#else
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
@ -37,13 +37,13 @@
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
#if defined(__serenity__) && !defined(KERNEL)
|
#if defined(__serenity__) && !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||||
extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
|
extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[gnu::always_inline]] inline void fast_u32_copy(u32* dest, const u32* src, size_t count)
|
[[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) {
|
if (count >= 256) {
|
||||||
mmx_memcpy(dest, src, count * sizeof(count));
|
mmx_memcpy(dest, src, count * sizeof(count));
|
||||||
return;
|
return;
|
||||||
|
@ -323,12 +323,12 @@ struct IsSame<T, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
using AK::ceil_div;
|
using AK::ceil_div;
|
||||||
|
using AK::clamp;
|
||||||
using AK::exchange;
|
using AK::exchange;
|
||||||
using AK::forward;
|
using AK::forward;
|
||||||
using AK::IsSame;
|
using AK::IsSame;
|
||||||
using AK::max;
|
using AK::max;
|
||||||
using AK::min;
|
using AK::min;
|
||||||
using AK::clamp;
|
|
||||||
using AK::move;
|
using AK::move;
|
||||||
using AK::RemoveConst;
|
using AK::RemoveConst;
|
||||||
using AK::swap;
|
using AK::swap;
|
||||||
|
|
|
@ -36,8 +36,10 @@
|
||||||
# define AK_MAKE_ETERNAL
|
# define AK_MAKE_ETERNAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef KERNEL
|
#if defined(KERNEL)
|
||||||
# include <Kernel/Heap/kmalloc.h>
|
# include <Kernel/Heap/kmalloc.h>
|
||||||
|
#elif defined(BOOTSTRAPPER)
|
||||||
|
# include <Bootstrapper/Memory/malloc.h>
|
||||||
#else
|
#else
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __serenity__
|
#ifdef __serenity__
|
||||||
#include <Kernel/kstdio.h>
|
# include <Libraries/LibBareMetal/Output/kstdio.h>
|
||||||
#else
|
#else
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define kprintf printf
|
#define kprintf printf
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue