makefile: move pdlibc to extlib, add C++ stub standard headers
It now kind of compiles with x86_64-elf gcc (does not link though)
This commit is contained in:
parent
964893b14a
commit
98f92a9958
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
namespace helos {
|
namespace helos {
|
||||||
|
@ -22,8 +22,8 @@ public:
|
|||||||
return backing->BlockSize() * cnt;
|
return backing->BlockSize() * cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
::helos::Permission Permission() const override {
|
::helos::Permission DevicePermission() const override {
|
||||||
return backing->Permission();
|
return backing->DevicePermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ReadBlock(uint64_t blockOffset, void *data, uint64_t blockCount) const override {
|
uint64_t ReadBlock(uint64_t blockOffset, void *data, uint64_t blockCount) const override {
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Permission returns the permission on the entire device (Read, Write, Exec)
|
// Permission returns the permission on the entire device (Read, Write, Exec)
|
||||||
virtual Permission Permission() const {
|
virtual Permission DevicePermission() const {
|
||||||
return PermRead | PermWrite | PermExecute;
|
return PermRead | PermWrite | PermExecute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "ramdisk.hpp"
|
#include "ramdisk.hpp"
|
||||||
#include "../../memory/memory.h"
|
#include "../../memory/memory.h"
|
||||||
#include "../../memory/paging_internal.h"
|
#include "../../memory/paging_internal.h"
|
||||||
#include <cstring>
|
#include <string.h>
|
||||||
|
|
||||||
namespace helos {
|
namespace helos {
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
uint64_t Size() const override { return blockcount; }
|
uint64_t Size() const override { return blockcount; }
|
||||||
uint64_t SizeBytes() const override { return blocksize * blockcount; }
|
uint64_t SizeBytes() const override { return blocksize * blockcount; }
|
||||||
|
|
||||||
::helos::Permission Permission() const override { return perm; }
|
::helos::Permission DevicePermission() const override { return perm; }
|
||||||
|
|
||||||
uint64_t ReadBlock(uint64_t blockOffset, void *data, uint64_t blockCount) const override;
|
uint64_t ReadBlock(uint64_t blockOffset, void *data, uint64_t blockCount) const override;
|
||||||
uint64_t WriteBlock(uint64_t blockOffset, const void *data, uint64_t blockCount) override;
|
uint64_t WriteBlock(uint64_t blockOffset, const void *data, uint64_t blockCount) override;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "fat.hpp"
|
#include "fat.hpp"
|
||||||
#include <cstring>
|
#include <string.h>
|
||||||
|
|
||||||
namespace helos {
|
namespace helos {
|
||||||
namespace filesystem {
|
namespace filesystem {
|
||||||
|
5
libstd/README
Normal file
5
libstd/README
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
This folder is in place for the most standard headers not in the PDLibC extlib.
|
||||||
|
|
||||||
|
Mostly for C++ standard headers.
|
||||||
|
|
25
libstd/__cpp_config.hpp
Normal file
25
libstd/__cpp_config.hpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#define __CXX11
|
||||||
|
#endif
|
||||||
|
#if __cplusplus >= 201402L
|
||||||
|
#define __CXX14
|
||||||
|
#endif
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
|
#define __CXX17
|
||||||
|
#endif
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
#define __CXX20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __CXX11
|
||||||
|
#define __NOTHROW noexcept
|
||||||
|
#define __NOTHROW_SINCECXX11 __NOTHROW
|
||||||
|
#else
|
||||||
|
#define __NOTHROW throw()
|
||||||
|
#define __NOTHROW_SINCECXX11
|
||||||
|
#endif
|
||||||
|
|
23
libstd/exception
Normal file
23
libstd/exception
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <__cpp_config.hpp>
|
||||||
|
|
||||||
|
extern "C++" {
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
|
||||||
|
class exception {
|
||||||
|
public:
|
||||||
|
exception() __NOTHROW {}
|
||||||
|
#ifdef __CXX11
|
||||||
|
exception(const exception &) = default;
|
||||||
|
exception &operator=(const exception &) = default;
|
||||||
|
exception(exception &&) = default;
|
||||||
|
exception &operator=(exception &&) = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
virtual const char *what() const __NOTHROW { return "std::exception"; };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
}
|
51
libstd/new
Normal file
51
libstd/new
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <__cpp_config.hpp>
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
extern "C++" {
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
|
||||||
|
class bad_alloc: public exception {
|
||||||
|
public:
|
||||||
|
bad_alloc() __NOTHROW {}
|
||||||
|
#ifdef __CXX11
|
||||||
|
bad_alloc(const bad_alloc &) = default;
|
||||||
|
bad_alloc &operator=(const bad_alloc &) = default;
|
||||||
|
#endif
|
||||||
|
virtual ~bad_alloc() __NOTHROW {}
|
||||||
|
|
||||||
|
virtual const char *what() const __NOTHROW { return "std::bad_alloc"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __CXX11
|
||||||
|
class bad_array_new_length: public bad_alloc {
|
||||||
|
public:
|
||||||
|
bad_array_new_length() __NOTHROW {}
|
||||||
|
virtual ~bad_array_new_length() __NOTHROW {}
|
||||||
|
|
||||||
|
virtual const char *what() const __NOTHROW { return "std::bad_array_new_length"; }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __CXX17
|
||||||
|
enum class align_val_t : size_t {};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct nothrow_t {
|
||||||
|
#ifdef __CXX11
|
||||||
|
explicit nothrow_t() = default;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
extern const nothrow_t nothrow;
|
||||||
|
|
||||||
|
|
||||||
|
// new_handler omitted
|
||||||
|
|
||||||
|
// new/delete omitted, use memory/memory.hpp
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
}
|
3
main.h
3
main.h
@ -1,3 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "stddef.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include <stddef.h>
|
||||||
#include <limits>
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
@ -30,11 +29,11 @@ public:
|
|||||||
template<typename Other>
|
template<typename Other>
|
||||||
constexpr kAllocator(const kAllocator<Other> &) {}
|
constexpr kAllocator(const kAllocator<Other> &) {}
|
||||||
|
|
||||||
Type *allocate(std::size_t n) {
|
Type *allocate(size_t n) {
|
||||||
return kMalloc(n * sizeof(Type));
|
return kMalloc(n * sizeof(Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(Type *p, std::size_t n) {
|
void deallocate(Type *p, size_t n) {
|
||||||
kFree(p);
|
kFree(p);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -59,25 +58,25 @@ bool operator!=(const kAllocator<T> &, const kAllocator<U> &) {
|
|||||||
//
|
//
|
||||||
// operators new and delete only call kMalloc/kFree, so C++ code
|
// operators new and delete only call kMalloc/kFree, so C++ code
|
||||||
// must stay after paging setup
|
// must stay after paging setup
|
||||||
void *operator new(std::size_t size);
|
void *operator new(size_t size);
|
||||||
void *operator new[](std::size_t size);
|
void *operator new[](size_t size);
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
#if __cplusplus >= 201703L
|
||||||
void *operator new(std::size_t size, std::align_val_t align);
|
void *operator new(size_t size, std::align_val_t align);
|
||||||
void *operator new[](std::size_t size, std::align_val_t align);
|
void *operator new[](size_t size, std::align_val_t align);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void operator delete(void *ptr) noexcept;
|
void operator delete(void *ptr) noexcept;
|
||||||
void operator delete[](void *ptr) noexcept;
|
void operator delete[](void *ptr) noexcept;
|
||||||
#if __cplusplus >= 201402L
|
#if __cplusplus >= 201402L
|
||||||
void operator delete(void *ptr, std::size_t size) noexcept;
|
void operator delete(void *ptr, size_t size) noexcept;
|
||||||
void operator delete[](void *ptr, std::size_t size) noexcept;
|
void operator delete[](void *ptr, size_t size) noexcept;
|
||||||
#endif
|
#endif
|
||||||
#if __cplusplus >= 201703L
|
#if __cplusplus >= 201703L
|
||||||
void operator delete(void *ptr, std::align_val_t align) noexcept;
|
void operator delete(void *ptr, std::align_val_t align) noexcept;
|
||||||
void operator delete[](void *ptr, std::align_val_t align) noexcept;
|
void operator delete[](void *ptr, std::align_val_t align) noexcept;
|
||||||
void operator delete(void *ptr, std::size_t size, std::align_val_t align) noexcept;
|
void operator delete(void *ptr, size_t size, std::align_val_t align) noexcept;
|
||||||
void operator delete[](void *ptr, std::size_t size, std::align_val_t align) noexcept;
|
void operator delete[](void *ptr, size_t size, std::align_val_t align) noexcept;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // HELOS
|
#endif // HELOS
|
||||||
|
@ -3,25 +3,25 @@
|
|||||||
|
|
||||||
#include "../extlib/dlmalloc/malloc-2.8.6.h"
|
#include "../extlib/dlmalloc/malloc-2.8.6.h"
|
||||||
|
|
||||||
void *operator new(std::size_t size) { return kMalloc(size); }
|
void *operator new(size_t size) { return kMalloc(size); }
|
||||||
void *operator new[](std::size_t size) { return kMalloc(size); }
|
void *operator new[](size_t size) { return kMalloc(size); }
|
||||||
|
|
||||||
void operator delete(void *ptr) noexcept { kFree(ptr); }
|
void operator delete(void *ptr) noexcept { kFree(ptr); }
|
||||||
void operator delete[](void *ptr) noexcept { kFree(ptr); }
|
void operator delete[](void *ptr) noexcept { kFree(ptr); }
|
||||||
|
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
#if __cplusplus >= 201703L
|
||||||
void *operator new(std::size_t size, std::align_val_t align) { return dlmemalign((size_t)align, size); }
|
void *operator new(size_t size, std::align_val_t align) { return dlmemalign((size_t)align, size); }
|
||||||
void *operator new[](std::size_t size, std::align_val_t align) { return dlmemalign((size_t)align, size); }
|
void *operator new[](size_t size, std::align_val_t align) { return dlmemalign((size_t)align, size); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201402L
|
#if __cplusplus >= 201402L
|
||||||
void operator delete(void *ptr, std::size_t size) noexcept { kFree(ptr); }
|
void operator delete(void *ptr, size_t size) noexcept { kFree(ptr); }
|
||||||
void operator delete[](void *ptr, std::size_t size) noexcept { kFree(ptr); }
|
void operator delete[](void *ptr, size_t size) noexcept { kFree(ptr); }
|
||||||
#endif
|
#endif
|
||||||
#if __cplusplus >= 201703L
|
#if __cplusplus >= 201703L
|
||||||
void operator delete(void *ptr, std::align_val_t align) noexcept { kFree(ptr); }
|
void operator delete(void *ptr, std::align_val_t align) noexcept { kFree(ptr); }
|
||||||
void operator delete[](void *ptr, std::align_val_t align) noexcept { kFree(ptr); }
|
void operator delete[](void *ptr, std::align_val_t align) noexcept { kFree(ptr); }
|
||||||
void operator delete(void *ptr, std::size_t size, std::align_val_t align) noexcept { kFree(ptr); }
|
void operator delete(void *ptr, size_t size, std::align_val_t align) noexcept { kFree(ptr); }
|
||||||
void operator delete[](void *ptr, std::size_t size, std::align_val_t align) noexcept { kFree(ptr); }
|
void operator delete[](void *ptr, size_t size, std::align_val_t align) noexcept { kFree(ptr); }
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
#include "../runtime/stdio.h"
|
#include "../runtime/stdio.h"
|
||||||
#include <memory.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
void stack_InitBuffered(stack *s, void *buffer, uintptr_t size) {
|
void stack_InitBuffered(stack *s, void *buffer, uintptr_t size) {
|
||||||
|
Loading…
Reference in New Issue
Block a user