From b685b7a9ebb7fa9c3bdd6fa6791d4eabf9bb1e3d Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 22 Sep 2012 14:14:58 +0200 Subject: [PATCH] Don't include Maxsi:: API in kernel.cpp. Since kernel.cpp is intended to be an example of the current best coding practices within the Sortix kernel, and the Maxsi:: API is deprecated and is being removed, it should rather use the nice C standard library. --- libmaxsi/heap.cpp | 7 +++++++ libmaxsi/include/malloc.h | 38 ++++++++++++++++++++++++++++++++++++++ sortix/kernel.cpp | 14 +++++--------- 3 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 libmaxsi/include/malloc.h diff --git a/libmaxsi/heap.cpp b/libmaxsi/heap.cpp index b6e4c217..acea9df6 100644 --- a/libmaxsi/heap.cpp +++ b/libmaxsi/heap.cpp @@ -40,6 +40,8 @@ #define ASSERT(invariant) assert(invariant) #endif +#include + #define PARANOIA 1 #ifdef SORTIX_KERNEL @@ -431,6 +433,11 @@ namespace Maxsi #endif } + extern "C" void _init_heap() + { + Init(); + } + // Attempts to expand the wilderness such that it contains at least // bytesneeded bytes. This is done by mapping new pages onto into the // virtual address-space. diff --git a/libmaxsi/include/malloc.h b/libmaxsi/include/malloc.h new file mode 100644 index 00000000..fb586b3d --- /dev/null +++ b/libmaxsi/include/malloc.h @@ -0,0 +1,38 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2012. + + This file is part of LibMaxsi. + + LibMaxsi is free software: you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License + along with LibMaxsi. If not, see . + + malloc.h + + +*******************************************************************************/ + +/* TODO: POSIX-1.2008 compliance is only partial */ + +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +#include + +__BEGIN_DECLS + +extern "C" void _init_heap(); + +__END_DECLS + +#endif diff --git a/sortix/kernel.cpp b/sortix/kernel.cpp index 6620982d..5f27b219 100644 --- a/sortix/kernel.cpp +++ b/sortix/kernel.cpp @@ -32,19 +32,17 @@ #include #include #include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include #include "kernelinfo.h" #include "x86-family/gdt.h" #include "x86-family/float.h" #include "time.h" #include "keyboard.h" #include "multiboot.h" -#include #include "thread.h" #include "process.h" #include "scheduler.h" @@ -70,8 +68,6 @@ #include "interrupt.h" #include "fs/devfs.h" -using namespace Maxsi; - // Keep the stack size aligned with $CPU/base.s const size_t STACK_SIZE = 64*1024; extern "C" { size_t stack[STACK_SIZE / sizeof(size_t)] = {0}; } @@ -180,7 +176,7 @@ extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo) Interrupt::Init(); // Initialize the kernel heap. - Maxsi::Memory::Init(); + _init_heap(); // Initialize the interrupt worker. Interrupt::InitWorker();