Makefile refactorin'

This commit is contained in:
2024-10-18 17:18:24 +02:00
parent 63ecaec569
commit 958625b798
17 changed files with 175 additions and 150 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ size_t fread(void* ptr, size_t size, size_t count, FILE* stream) {
int fd = stream->_file;
while (readEl != count) {
if (read(fd, (void*)(ptr + offset), size) != size) break;
if (read(fd, (void*)(ptr + offset), size) != (int)size) break;
offset += size;
readEl++;
}
@@ -44,7 +44,7 @@ size_t fwrite(const void* ptr, size_t size, size_t count, FILE* stream) {
int fd = stream->_file;
while (writtenEl != count) {
if (write(fd, (void*)(ptr + offset), size) != size) break;
if (write(fd, (void*)(ptr + offset), size) != (int)size) break;
offset += size;
writtenEl++;
}
+14
View File
@@ -0,0 +1,14 @@
#
# C Standard library
#
include make.defaults
$(LIBC): $(LIBC_SRC)
@echo "Building $(LIBC)..."
for f in $(LIBC_SRC); do\
filename=$$(basename $$f .c);\
$(CC) $(CFLAGS) -I$(LIBC_INC) -o $(BIN)/libc/$$filename.o -c $$f;\
done
$(LD) $(LDFLAGS) -r -o $(LIBC) $(BIN)/libc/**.o
+2 -14
View File
@@ -1,16 +1,4 @@
#ifndef MATH_H
#define MATH_H
#include <math.h>
// Constants
#define PI 3.141592653589 // Should be good enough
#define E 2.718281828459
/* TODO */
// Macros
#define abs(x) ( (x) > 0 ? (x) : -(x) )
#define sign(x) ( (x) == 0 ? 0 : ((x) < 0 ? -1 : 1 ) )
#define floor(x) ( (int)(x) ) // C floors floats when converting to ints
#define round(x) ( (int)((x) + 0.5) ) // Normal rounding
#define ceil(x) ( (int)((x) + 1) ) // Always rounds up
#endif
-8
View File
@@ -1,8 +0,0 @@
#ifndef BOOL_H
#define BOOL_H
#define bool _Bool
#define true 1
#define false 0
#endif