Fix inconsistent EOL

This commit is contained in:
2025-01-08 22:27:37 +01:00
parent 57671ac79d
commit 1f7141c517
184 changed files with 13686 additions and 13685 deletions

View File

@@ -1,19 +1,19 @@
#pragma once
#include "../jabyengine_defines.hpp"
namespace JabyEngine {
// Taken from boost endian
static constexpr uint8_t read_be(uint8_t x) {
return x;
}
static constexpr uint16_t read_be(uint16_t x) {
return (x << 8) | (x >> 8);
}
static constexpr uint32_t read_be(uint32_t x) {
const uint32_t step16 = x << 16 | x >> 16;
return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff);
}
#pragma once
#include "../jabyengine_defines.hpp"
namespace JabyEngine {
// Taken from boost endian
static constexpr uint8_t read_be(uint8_t x) {
return x;
}
static constexpr uint16_t read_be(uint16_t x) {
return (x << 8) | (x >> 8);
}
static constexpr uint32_t read_be(uint32_t x) {
const uint32_t step16 = x << 16 | x >> 16;
return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff);
}
}

View File

@@ -1,61 +1,61 @@
#pragma once
#include "array_range.hpp"
namespace JabyEngine {
template<typename T>
class CircularBuffer {
private:
T* start_adr = nullptr;
T* end_adr = nullptr;
T* read_adr = nullptr;
T* write_adr = nullptr;
T* increment(T* cur_element) const {
cur_element += 1;
if(cur_element == this->end_adr) {
return this->start_adr;
}
return cur_element;
}
public:
CircularBuffer() = default;
T* setup(T* buffer_start_adr, size_t elements) {
this->start_adr = buffer_start_adr;
this->end_adr = &buffer_start_adr[elements];
this->read_adr = this->start_adr;
this->write_adr = this->start_adr;
return this->end_adr;
}
T* allocate() {
T* cur_adr = this->write_adr;
T* next_adr = CircularBuffer::increment(cur_adr);
if(next_adr == this->read_adr) {
return nullptr;
}
else {
this->write_adr = next_adr;
return cur_adr;
}
}
T* get_next() const {
return this->read_adr;
}
void pop() {
if(CircularBuffer::has_data()) {
this->read_adr = CircularBuffer::increment(this->read_adr);
}
}
constexpr bool has_data() const {
return (this->read_adr != this->write_adr);
}
};
#pragma once
#include "array_range.hpp"
namespace JabyEngine {
template<typename T>
class CircularBuffer {
private:
T* start_adr = nullptr;
T* end_adr = nullptr;
T* read_adr = nullptr;
T* write_adr = nullptr;
T* increment(T* cur_element) const {
cur_element += 1;
if(cur_element == this->end_adr) {
return this->start_adr;
}
return cur_element;
}
public:
CircularBuffer() = default;
T* setup(T* buffer_start_adr, size_t elements) {
this->start_adr = buffer_start_adr;
this->end_adr = &buffer_start_adr[elements];
this->read_adr = this->start_adr;
this->write_adr = this->start_adr;
return this->end_adr;
}
T* allocate() {
T* cur_adr = this->write_adr;
T* next_adr = CircularBuffer::increment(cur_adr);
if(next_adr == this->read_adr) {
return nullptr;
}
else {
this->write_adr = next_adr;
return cur_adr;
}
}
T* get_next() const {
return this->read_adr;
}
void pop() {
if(CircularBuffer::has_data()) {
this->read_adr = CircularBuffer::increment(this->read_adr);
}
}
constexpr bool has_data() const {
return (this->read_adr != this->write_adr);
}
};
}

View File

@@ -1,14 +1,14 @@
#pragma once
#include <stdio.h>
namespace JabyEngine {
template<typename T>
static inline void dump_to_stdoutln(const T& object) {
const uint8_t* raw_ptr = reinterpret_cast<const uint8_t*>(&object);
for(size_t raw_pos = 0; raw_pos < sizeof(T); raw_pos++) {
printf("[%02X]", raw_ptr[raw_pos]);
}
printf("\n");
}
}
#pragma once
#include <stdio.h>
namespace JabyEngine {
template<typename T>
static inline void dump_to_stdoutln(const T& object) {
const uint8_t* raw_ptr = reinterpret_cast<const uint8_t*>(&object);
for(size_t raw_pos = 0; raw_pos < sizeof(T); raw_pos++) {
printf("[%02X]", raw_ptr[raw_pos]);
}
printf("\n");
}
}

View File

@@ -1,8 +1,8 @@
#pragma once
#include "../../stdint.hpp"
namespace JabyEngine {
uint16_t unaligned_lhu(const uint8_t* adr) {
return (static_cast<uint16_t>(adr[0]) | static_cast<uint16_t>(adr[1]) << 8);
}
#pragma once
#include "../../stdint.hpp"
namespace JabyEngine {
uint16_t unaligned_lhu(const uint8_t* adr) {
return (static_cast<uint16_t>(adr[0]) | static_cast<uint16_t>(adr[1]) << 8);
}
}

View File

@@ -1,15 +1,15 @@
#pragma once
#include <stddef.hpp>
namespace JabyEngine {
using word_t = uint32_t;
static constexpr size_t bytes_to_words(size_t bytes) {
return bytes/sizeof(word_t);
}
static constexpr size_t words_to_bytes(size_t words) {
return words*sizeof(word_t);
}
}
#pragma once
#include <stddef.hpp>
namespace JabyEngine {
using word_t = uint32_t;
static constexpr size_t bytes_to_words(size_t bytes) {
return bytes/sizeof(word_t);
}
static constexpr size_t words_to_bytes(size_t words) {
return words*sizeof(word_t);
}
}