[all] Remove dependencies on non-freestanding libc
This is the first of two rather big changes to clean up includes throughout the project. In this commit, the implicit semi-dependency on libc that bonnibel adds to every module is removed. Previously, I was sloppy with includes of libc headers and include directory order. Now, the freestanding headers from libc are split out into libc_free, and an implicit real dependency is added onto this module, unless `no_libc` is set to `True`. The full libc needs to be explicitly specified as a dependency to be used. Several things needed to change in order to do this: - Many places use `memset` or `memcpy` that cannot depend on libc. The kernel has basic implementations of them itself for this reason. Now those functions are moved into the lower-level `j6/memutils.h`, and libc merely references them. Other modules are now free to reference those functions from libj6 instead. - The kernel's `assert.h` was renamed kassert.h (matching its `kassert` function) so that the new `util/assert.h` can use `__has_include` to detect it and make sure the `assert` macro is usable in libutil code. - Several implementation header files under `__libj6/` also moved under the new libc_free. - A new `include_phase` property has been added to modules for Bonnibel, which can be "normal" (default) or "late" which uses `-idirafter` instead of `-I` for includes. - Since `<utility>` and `<new>` are not freestanding, implementations of `remove_reference`, `forward`, `move`, and `swap` were added to the `util` namespace to replace those from `std`, and `util/new.h` was added to declare `operator new` and `operator delete`.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "apic.h"
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "clock.h"
|
||||
#include "interrupts.h"
|
||||
#include "io.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
|
||||
using __exit_func = void (*)(void *);
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#include <new>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <j6/memutils.h>
|
||||
#include <util/bitset.h>
|
||||
#include <util/no_construct.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "cpu.h"
|
||||
#include "device_manager.h"
|
||||
#include "gdt.h"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include <new>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <util/misc.h> // for checksum
|
||||
#include <util/pointers.h>
|
||||
#include <arch/acpi/tables.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "apic.h"
|
||||
#include "clock.h"
|
||||
#include "device_manager.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <bootproto/kernel.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "debugcon.h"
|
||||
#include "frame_allocator.h"
|
||||
#include "logger.h"
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <j6/memutils.h>
|
||||
#include <util/no_construct.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "cpu.h"
|
||||
#include "gdt.h"
|
||||
#include "logger.h"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include <new>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <j6/memutils.h>
|
||||
#include <util/pointers.h>
|
||||
#include <util/util.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "heap_allocator.h"
|
||||
#include "memory.h"
|
||||
#include "objects/vm_area.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "device_manager.h"
|
||||
#include "hpet.h"
|
||||
#include "io.h"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <j6/memutils.h>
|
||||
#include <util/no_construct.h>
|
||||
|
||||
#include "cpu.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/// \file idt.h
|
||||
/// Definitions relating to a CPU's IDT table
|
||||
#include <stdint.h>
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
|
||||
class IDT
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include <util/format.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "cpu.h"
|
||||
#include "device_manager.h"
|
||||
#include "idt.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "idt.h"
|
||||
|
||||
namespace panic {
|
||||
@@ -10,7 +10,7 @@ kernel = module("kernel",
|
||||
ld_script = "kernel.ld",
|
||||
sources = [
|
||||
"apic.cpp",
|
||||
"assert.cpp",
|
||||
"kassert.cpp",
|
||||
"boot.s",
|
||||
"capabilities.cpp",
|
||||
"clock.cpp",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <j6/memutils.h>
|
||||
#include <bootproto/kernel.h>
|
||||
#include <util/vector.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "capabilities.h"
|
||||
#include "cpu.h"
|
||||
#include "debugcon.h"
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#include <new>
|
||||
#include <string.h>
|
||||
|
||||
#include <j6/memutils.h>
|
||||
#include <util/format.h>
|
||||
#include <util/no_construct.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "logger.h"
|
||||
#include "objects/system.h"
|
||||
#include "objects/thread.h"
|
||||
|
||||
@@ -2,27 +2,4 @@
|
||||
|
||||
namespace std {
|
||||
enum class __attribute__ ((__type_visibility("default"))) align_val_t : size_t { };
|
||||
}
|
||||
|
||||
// Implementation of memset and memcpy because we're not
|
||||
// linking libc into the kernel
|
||||
extern "C" {
|
||||
|
||||
void *
|
||||
memset(void *s, uint8_t v, size_t n)
|
||||
{
|
||||
uint8_t *p = reinterpret_cast<uint8_t *>(s);
|
||||
for (size_t i = 0; i < n; ++i) p[i] = v;
|
||||
return s;
|
||||
}
|
||||
|
||||
void *
|
||||
memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
const uint8_t *s = reinterpret_cast<const uint8_t *>(src);
|
||||
uint8_t *d = reinterpret_cast<uint8_t *>(dest);
|
||||
for (size_t i = 0; i < n; ++i) d[i] = s[i];
|
||||
return d;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
#include <new>
|
||||
#include <utility>
|
||||
|
||||
#include <arch/memory.h>
|
||||
#include <bootproto/kernel.h>
|
||||
#include <util/no_construct.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "capabilities.h"
|
||||
#include "device_manager.h"
|
||||
#include "frame_allocator.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <j6/errors.h>
|
||||
#include <j6/types.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "logger.h"
|
||||
#include "objects/kobject.h"
|
||||
#include "objects/thread.h"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include <new>
|
||||
|
||||
#include <util/no_construct.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "capabilities.h"
|
||||
#include "cpu.h"
|
||||
#include "objects/process.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <util/pointers.h>
|
||||
|
||||
#include "kassert.h"
|
||||
#include "capabilities.h"
|
||||
#include "cpu.h"
|
||||
#include "logger.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "frame_allocator.h"
|
||||
#include "memory.h"
|
||||
#include "objects/vm_area.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <j6/memutils.h>
|
||||
#include <util/pointers.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "memory.h"
|
||||
#include "frame_allocator.h"
|
||||
#include "page_table.h"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <j6/memutils.h>
|
||||
#include <arch/memory.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "frame_allocator.h"
|
||||
#include "page_tree.h"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <new>
|
||||
#include <util/new.h>
|
||||
#include <util/no_construct.h>
|
||||
|
||||
#include "cpu.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <util/spinlock.h>
|
||||
|
||||
#include "apic.h"
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "clock.h"
|
||||
#include "cpu.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
/// \file slab_allocated.h
|
||||
/// A parent template class for slab-allocated objects
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <j6/memutils.h>
|
||||
#include <util/pointers.h>
|
||||
#include <util/vector.h>
|
||||
|
||||
#include "kassert.h"
|
||||
#include "memory.h"
|
||||
|
||||
template <typename T, size_t N>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// vim: ft=cpp
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <j6/memutils.h>
|
||||
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <j6/errors.h>
|
||||
#include <util/basic_types.h>
|
||||
#include <util/node_map.h>
|
||||
#include <util/spinlock.h>
|
||||
|
||||
@@ -20,11 +21,11 @@ struct futex
|
||||
futex() = default;
|
||||
futex(futex &&other) :
|
||||
address {other.address},
|
||||
queue {std::move(other.queue)} {}
|
||||
queue {util::move(other.queue)} {}
|
||||
|
||||
futex & operator=(futex &&other) {
|
||||
address = other.address;
|
||||
queue = std::move(other.queue);
|
||||
queue = util::move(other.queue);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <j6/types.h>
|
||||
#include <util/vector.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "logger.h"
|
||||
#include "objects/thread.h"
|
||||
#include "syscalls/helpers.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <string.h>
|
||||
#include <j6/memutils.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "cpu.h"
|
||||
#include "frame_allocator.h"
|
||||
#include "memory.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <j6/memutils.h>
|
||||
#include <util/no_construct.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "cpu.h"
|
||||
#include "logger.h"
|
||||
#include "memory.h"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <j6/memutils.h>
|
||||
#include <arch/memory.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "kassert.h"
|
||||
#include "frame_allocator.h"
|
||||
#include "logger.h"
|
||||
#include "memory.h"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <utility>
|
||||
#include <util/basic_types.h>
|
||||
#include "objects/thread.h"
|
||||
#include "wait_queue.h"
|
||||
|
||||
wait_queue::wait_queue(wait_queue &&other) :
|
||||
m_threads {std::move(other.m_threads)} {}
|
||||
m_threads {util::move(other.m_threads)} {}
|
||||
|
||||
wait_queue::~wait_queue() { clear(); }
|
||||
|
||||
@@ -11,7 +11,7 @@ wait_queue &
|
||||
wait_queue::operator=(wait_queue &&other)
|
||||
{
|
||||
clear();
|
||||
m_threads = std::move(other.m_threads);
|
||||
m_threads = util::move(other.m_threads);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user