1

merged cleanup

This commit is contained in:
2022-07-24 21:12:31 +02:00
parent 5ff3d72bfd
commit 6481bae5f6
92 changed files with 663 additions and 755 deletions

View File

@ -3,7 +3,6 @@
void ArrayDemo::run() {
bse::array<int, 10> arr1 {};
bse::array<int, 10> arr2 {};
bse::array<Thread*, 10> arr3 {};
kout.lock();
kout.clear();

View File

@ -1,14 +1,13 @@
#ifndef __ArrayDemo_include__
#define __ArrayDemo_include__
#ifndef ArrayDemo_include__
#define ArrayDemo_include__
#include "kernel/Globals.h"
#include "user/lib/Array.h"
class ArrayDemo : public Thread {
private:
public:
ArrayDemo(const ArrayDemo& copy) = delete;
public:
ArrayDemo() : Thread("ArrayDemo") {}
void run() override;

View File

@ -1,14 +1,13 @@
#ifndef __BlueScreenDemo_include__
#define __BlueScreenDemo_include__
#ifndef BlueScreenDemo_include__
#define BlueScreenDemo_include__
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
class BlueScreenDemo : public Thread {
private:
public:
BlueScreenDemo(const BlueScreenDemo& copy) = delete;
public:
BlueScreenDemo() : Thread("BlueScreenDemo") {}
void run() override;

View File

@ -7,8 +7,8 @@
* *
* Autor: Michael Schoettner, HHU, 25.9.2016 *
*****************************************************************************/
#ifndef __HeapDemo_include__
#define __HeapDemo_include__
#ifndef HeapDemo_include__
#define HeapDemo_include__
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
@ -21,10 +21,9 @@ public:
};
class HeapDemo : public Thread {
private:
public:
HeapDemo(const HeapDemo& copy) = delete;
public:
HeapDemo() : Thread("HeapDemo") {}
void run() override;

View File

@ -8,8 +8,8 @@
* Autor: Michael Schoettner, HHU, 26.10.2018 *
*****************************************************************************/
#ifndef __KeyboardDemo_include__
#define __KeyboardDemo_include__
#ifndef KeyboardDemo_include__
#define KeyboardDemo_include__
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
@ -17,13 +17,13 @@
class KeyboardDemo : public Thread {
private:
KeyboardDemo(const KeyboardDemo& copy) = delete;
KeyEventListener listener;
public:
KeyboardDemo() : Thread("KeyboardDemo"), listener(this->tid) {
kevman.subscribe(this->listener);
KeyboardDemo(const KeyboardDemo& copy) = delete;
KeyboardDemo() : Thread("KeyboardDemo"), listener(tid) {
kevman.subscribe(listener);
}
// Base class destructor will be called automatically
@ -35,7 +35,7 @@ public:
// thread set it (so use nice_kill)
kout.unlock();
}
kevman.unsubscribe(this->listener);
kevman.unsubscribe(listener);
}
void run() override;

View File

@ -6,7 +6,7 @@ void PCSPKdemo::run() {
kout << "Playing..." << endl;
kout.unlock();
(pcspk.*this->melody)(); // This syntax is confusing as hell
(pcspk.*melody)(); // This syntax is confusing as hell
kout.lock();
kout << "Finished" << endl;

View File

@ -1,20 +1,20 @@
#ifndef __PCSPKdemo_INCLUDE_H_
#define __PCSPKdemo_INCLUDE_H_
#ifndef PCSPKdemo_INCLUDE_H_
#define PCSPKdemo_INCLUDE_H_
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
class PCSPKdemo : public Thread {
private:
PCSPKdemo(const PCSPKdemo& copy) = delete;
void (PCSPK::*melody)(void); // Allow to pass a melody to play when initializing the demo
void (PCSPK::*melody)(); // Allow to pass a melody to play when initializing the demo
public:
PCSPKdemo(void (PCSPK::*melody)(void)) : Thread("PCSPKdemo"), melody(melody) {}
PCSPKdemo(const PCSPKdemo& copy) = delete;
explicit PCSPKdemo(void (PCSPK::*melody)()) : Thread("PCSPKdemo"), melody(melody) {}
~PCSPKdemo() override {
pcspk.off();
PCSPK::off();
}
void run() override;

View File

@ -8,8 +8,8 @@ void PreemptiveLoopThread::run() {
kout.lock();
// Saving + restoring kout position doesn't help much as preemption still occurs
kout.setpos(55, this->id);
kout << fillw(3) << this->id << fillw(0) << ": " << dec << cnt++ << endl;
CGA_Stream::setpos(55, id);
kout << fillw(3) << id << fillw(0) << ": " << dec << cnt++ << endl;
kout.unlock();
}
@ -24,7 +24,7 @@ void PreemptiveThreadDemo::run() {
kout << "Preemptive Thread Demo:" << endl;
kout << "Readying LoopThreads" << endl;
for (unsigned int i = 0; i < this->number_of_threads; ++i) {
for (unsigned int i = 0; i < number_of_threads; ++i) {
scheduler.ready<PreemptiveLoopThread>(i);
}

View File

@ -1,5 +1,5 @@
#ifndef __preemptive_thread_include__
#define __preemptive_thread_include__
#ifndef preemptive_thread_include__
#define preemptive_thread_include__
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
@ -8,9 +8,10 @@
class PreemptiveLoopThread : public Thread {
private:
int id;
PreemptiveLoopThread(const PreemptiveLoopThread& copy) = delete; // Verhindere Kopieren
public:
PreemptiveLoopThread(const PreemptiveLoopThread& copy) = delete; // Verhindere Kopieren
// Gibt der Loop einen Stack und eine Id.
PreemptiveLoopThread(int i) : Thread("LoopThread"), id(i) {}
@ -20,11 +21,11 @@ public:
class PreemptiveThreadDemo : public Thread {
private:
PreemptiveThreadDemo(const PreemptiveThreadDemo& copy) = delete; // Verhindere Kopieren
unsigned int number_of_threads;
public:
PreemptiveThreadDemo(const PreemptiveThreadDemo& copy) = delete; // Verhindere Kopieren
PreemptiveThreadDemo(unsigned int n) : Thread("PreemptiveThreadDemo"), number_of_threads(n) {}
// Thread-Startmethode

View File

@ -21,10 +21,10 @@ void SmartPointerDemo::run() {
bse::unique_ptr<int> ptr1 = bse::make_unique<int>(1);
bse::unique_ptr<int> ptr2;
log.info() << "*ptr1 == " << *ptr1 << ", (bool)ptr2 == " << (bool)ptr2 << endl;
log.info() << "*ptr1 == " << *ptr1 << ", (bool)ptr2 == " << static_cast<bool>(ptr2) << endl;
log.info() << "Moving ptr1 => ptr2 (no allocations should happen)..." << endl;
ptr2 = std::move(ptr1);
log.info() << "(bool)ptr1 == " << (bool)ptr1 << ", *ptr2 == " << *ptr2 << endl;
log.info() << "(bool)ptr1 == " << static_cast<bool>(ptr1) << ", *ptr2 == " << *ptr2 << endl;
log.info() << "Leaving scope..." << endl;
}

View File

@ -1,13 +1,12 @@
#ifndef __SmartPointerDemo_include__
#define __SmartPointerDemo_include__
#ifndef SmartPointerDemo_include__
#define SmartPointerDemo_include__
#include "kernel/Globals.h"
class SmartPointerDemo : public Thread {
private:
public:
SmartPointerDemo(const SmartPointerDemo& copy) = delete;
public:
SmartPointerDemo() : Thread("SmartPointerDemo") {}
void run() override;

View File

@ -40,14 +40,14 @@ void StringDemo::run() {
log.info() << "Reassign str2" << endl;
str2 = "Hello";
bse::array<char, 5> arr;
bse::array<char, 5> arr{};
arr[0] = 'H';
arr[1] = 'e';
arr[2] = 'l';
arr[3] = 'l';
arr[4] = 'o';
kout << "bse::array<char, 5> to bse::string: " << arr << ", size: " << ((bse::string)arr).size() << endl;
kout << "(bse::string)arr (" << arr << ") == str2 (" << str2 << "): " << static_cast<int>((bse::string)arr == str2) << endl;
kout << "bse::array<char, 5> to bse::string: " << static_cast<bse::string>(arr) << ", size: " << (bse::string(arr)).size() << endl;
kout << "(bse::string)arr (" << static_cast<bse::string>(arr) << ") == str2 (" << str2 << "): " << static_cast<int>(bse::string(arr) == str2) << endl;
kout.unlock();
scheduler.exit();

View File

@ -1,13 +1,12 @@
#ifndef __StringDemo_include__
#define __StringDemo_include__
#ifndef StringDemo_include__
#define StringDemo_include__
#include "kernel/Globals.h"
class StringDemo : public Thread {
private:
public:
StringDemo(const StringDemo& copy) = delete;
public:
StringDemo() : Thread("StringDemo") {}
void run() override;

View File

@ -8,17 +8,16 @@
* Autor: Michael Schoettner, HHU, 26.10.2018 *
*****************************************************************************/
#ifndef __TextDemo_include__
#define __TextDemo_include__
#ifndef TextDemo_include__
#define TextDemo_include__
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
class TextDemo : public Thread {
private:
public:
TextDemo(const TextDemo& copy) = delete;
public:
TextDemo() : Thread("TextDemo") {}
void run() override;

View File

@ -59,7 +59,7 @@ void VBEdemo::drawBitmap() {
unsigned int sprite_width = hhu.width;
unsigned int sprite_height = hhu.height;
unsigned int sprite_bpp = hhu.bytes_per_pixel;
unsigned char* sprite_pixel = (unsigned char*)hhu.pixel_data;
const unsigned char* sprite_pixel = reinterpret_cast<const unsigned char*>(hhu.pixel_data);
/* Hier muss Code eingefuegt werden */

View File

@ -7,27 +7,27 @@
* *
* Autor: Michael Schoettner, HHU, 26.12.2016 *
*****************************************************************************/
#ifndef __VBEdemo_include__
#define __VBEdemo_include__
#ifndef VBEdemo_include__
#define VBEdemo_include__
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
class VBEdemo : public Thread {
private:
VBEdemo(const VBEdemo& copy) = delete; // Verhindere Kopieren
// Hilfsfunktionen fuer drawColors()
int linInterPol1D(int x, int xr, int l, int r);
int linInterPol2D(int x, int y, int lt, int rt, int lb, int rb);
static int linInterPol1D(int x, int xr, int l, int r);
static int linInterPol2D(int x, int y, int lt, int rt, int lb, int rb);
public:
VBEdemo(const VBEdemo& copy) = delete; // Verhindere Kopieren
// Gib dem Anwendungsthread einen Stack.
VBEdemo() : Thread("VBEdemo") {}
~VBEdemo() override {
vesa.initTextMode();
allocator.free(reinterpret_cast<void*>(vesa.hfb)); // Memory is allocated after every start and never deleted, so add that
VESA::initTextMode();
}
// Thread-Startmethode
@ -37,10 +37,10 @@ public:
void drawColors();
// Bitmap aus GIMP ausgeben
void drawBitmap();
static void drawBitmap();
// Fonts ausgeben
void drawFonts();
static void drawFonts();
};
#endif

View File

@ -18,7 +18,7 @@ void VectorDemo::run() {
log.info() << "Initial list size: " << dec << list.size() << endl;
log.info() << "Adding elements in order" << endl;
for (unsigned int i = 0; i < 5; ++i) {
for (int i = 0; i < 5; ++i) {
list.push_back(i);
}
print(log.info(), list);
@ -32,7 +32,7 @@ void VectorDemo::run() {
// ============================================================
log.info() << "Adding elements in order with realloc" << endl;
for (unsigned int i = 0; i < 10; ++i) {
for (int i = 0; i < 10; ++i) {
log.info() << "Add " << dec << i << endl;
list.push_back(i);
}
@ -46,7 +46,7 @@ void VectorDemo::run() {
// ============================================================
for (unsigned int i = 0; i < 5; ++i) {
for (int i = 0; i < 5; ++i) {
list.push_back(i);
}
print(log.info(), list);

View File

@ -1,15 +1,14 @@
#ifndef __VectorDemo_include__
#define __VectorDemo_include__
#ifndef VectorDemo_include__
#define VectorDemo_include__
#include "kernel/Globals.h"
#include "kernel/threads/Thread.h"
#include "user/lib/Vector.h"
class VectorDemo : public Thread {
private:
public:
VectorDemo(const VectorDemo& copy) = delete;
public:
VectorDemo() : Thread("VectorDemo") {}
void run() override;