mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-18 01:01:57 -04:00
Replace memset with std fill
This commit is contained in:
parent
ab5369b15a
commit
fc1a82ab97
@ -12,7 +12,7 @@
|
||||
|
||||
namespace paging {
|
||||
|
||||
const int PAGE_SIZE = 4096;
|
||||
constexpr const int PAGE_SIZE = 4096;
|
||||
|
||||
void* physical_address(void* virt);
|
||||
bool page_present(void* virt);
|
||||
|
@ -10,6 +10,26 @@
|
||||
|
||||
#include "types.hpp"
|
||||
|
||||
namespace std {
|
||||
|
||||
template<typename ForwardIterator, typename T>
|
||||
void fill(ForwardIterator it, ForwardIterator end, const T& value){
|
||||
while(it != end){
|
||||
*it = value;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ForwardIterator, typename T>
|
||||
void fill_n(ForwardIterator it, size_t n, const T& value){
|
||||
while(n--){
|
||||
*it = value;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
} //end of namespace std
|
||||
|
||||
template<typename CharT>
|
||||
struct basic_string;
|
||||
typedef basic_string<char> string;
|
||||
@ -20,7 +40,6 @@ uint64_t parse(const string& str);
|
||||
|
||||
uint64_t str_len(const char* a);
|
||||
|
||||
void memset(void * ptr, uint8_t value, size_t num);
|
||||
int memcmp(const void* s1, const void* s2, size_t n);
|
||||
void memcopy(void* destination, const void* source, size_t n);
|
||||
|
||||
|
@ -19,17 +19,18 @@ typedef pt_t* pdt_t;
|
||||
typedef pdt_t* pdpt_t;
|
||||
typedef pdpt_t* pml4t_t;
|
||||
|
||||
constexpr int PRESENT = 0x1;
|
||||
constexpr int WRITEABLE = 0x2;
|
||||
constexpr int USER = 0x4;
|
||||
constexpr const int PRESENT = 0x1;
|
||||
constexpr const int WRITEABLE = 0x2;
|
||||
constexpr const int USER = 0x4;
|
||||
|
||||
//Memory from 0x70000 can be used for pages
|
||||
uintptr_t last_page = 0x73000;
|
||||
|
||||
uintptr_t init_new_page(){
|
||||
auto new_page = last_page + paging::PAGE_SIZE;
|
||||
auto it = reinterpret_cast<size_t*>(new_page);
|
||||
|
||||
memset(reinterpret_cast<void*>(new_page), 0, paging::PAGE_SIZE);
|
||||
std::fill(it, it + paging::PAGE_SIZE / sizeof(size_t), 0);
|
||||
|
||||
last_page = new_page;
|
||||
|
||||
|
@ -25,9 +25,9 @@
|
||||
namespace {
|
||||
|
||||
#ifdef CONFIG_HISTORY
|
||||
static constexpr bool History = true;
|
||||
static constexpr const bool History = true;
|
||||
#else
|
||||
static constexpr bool History = false;
|
||||
static constexpr const bool History = false;
|
||||
#endif
|
||||
|
||||
vector<string> history;
|
||||
|
@ -8,16 +8,6 @@
|
||||
#include "utils.hpp"
|
||||
#include "string.hpp"
|
||||
|
||||
void memset(void* ptr, unsigned char value, size_t num){
|
||||
auto p = static_cast<unsigned char*>(ptr);
|
||||
|
||||
--p;
|
||||
|
||||
while(num--){
|
||||
*++p = value;
|
||||
}
|
||||
}
|
||||
|
||||
int memcmp(const void* s1, const void* s2, size_t n){
|
||||
auto p1 = static_cast<const unsigned char*>(s1);
|
||||
auto p2 = static_cast<const unsigned char*>(s2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user