some silly math functions
This commit is contained in:
@ -33,7 +33,7 @@ private:
|
|||||||
struct free_block* find_previous_block(struct free_block*);
|
struct free_block* find_previous_block(struct free_block*);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LinkedListAllocator() {}
|
LinkedListAllocator() {};
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void dump_free_memory();
|
void dump_free_memory();
|
||||||
|
|||||||
26
c_os/lib/Math.cc
Normal file
26
c_os/lib/Math.cc
Normal 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
c_os/lib/Math.h
Normal file
11
c_os/lib/Math.h
Normal 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
|
||||||
Reference in New Issue
Block a user