some silly math functions

This commit is contained in:
churl
2022-05-09 01:26:06 +02:00
parent 9145466a15
commit 333d5930a5
3 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ private:
struct free_block* find_previous_block(struct free_block*);
public:
LinkedListAllocator() {}
LinkedListAllocator() {};
void init();
void dump_free_memory();
+26
View File
@@ -0,0 +1,26 @@
#include "Math.h"
// NOTE: I added this file
int min(int a, int b) {
if (a < b) { return a; }
return b;
}
int max(int a, int b) {
if (a < b) { return b; }
return a;
}
int abs(int a) {
if (a < 0) { return -a; }
return a;
}
int pow(int a, unsigned int b) {
int result = 1;
for (unsigned int i = 0; i < b; ++i) {
result = result * a;
}
return result;
}
+11
View File
@@ -0,0 +1,11 @@
#ifndef __MATH_INCLUDE_H_
#define __MATH_INCLUDE_H_
// NOTE: I added this file
int min(int, int);
int max(int, int);
int abs(int);
int pow(int, unsigned int);
#endif