diff --git a/build/ConversionNamespace.o b/build/ConversionNamespace.o new file mode 100644 index 0000000..7438566 Binary files /dev/null and b/build/ConversionNamespace.o differ diff --git a/build/RandomNamespace.o b/build/RandomNamespace.o new file mode 100644 index 0000000..74e9cc7 Binary files /dev/null and b/build/RandomNamespace.o differ diff --git a/build/brk.o b/build/brk.o new file mode 100644 index 0000000..6ae8e26 Binary files /dev/null and b/build/brk.o differ diff --git a/build/closeOpen.o b/build/closeOpen.o new file mode 100644 index 0000000..178904c Binary files /dev/null and b/build/closeOpen.o differ diff --git a/build/exithandle.o b/build/exithandle.o new file mode 100644 index 0000000..a083c27 Binary files /dev/null and b/build/exithandle.o differ diff --git a/build/main.o b/build/main.o new file mode 100644 index 0000000..bd4f373 Binary files /dev/null and b/build/main.o differ diff --git a/build/mkdir.o b/build/mkdir.o new file mode 100644 index 0000000..c155efe Binary files /dev/null and b/build/mkdir.o differ diff --git a/build/printing.o b/build/printing.o new file mode 100644 index 0000000..8f85337 Binary files /dev/null and b/build/printing.o differ diff --git a/build/printingNamespace.o b/build/printingNamespace.o new file mode 100644 index 0000000..8b6e30a Binary files /dev/null and b/build/printingNamespace.o differ diff --git a/build/randcoice.o b/build/randcoice.o new file mode 100644 index 0000000..5364699 Binary files /dev/null and b/build/randcoice.o differ diff --git a/build/readWrite.o b/build/readWrite.o new file mode 100644 index 0000000..a19cec8 Binary files /dev/null and b/build/readWrite.o differ diff --git a/build/syscall.o b/build/syscall.o new file mode 100644 index 0000000..e63303d Binary files /dev/null and b/build/syscall.o differ diff --git a/build/time.o b/build/time.o new file mode 100644 index 0000000..1563f71 Binary files /dev/null and b/build/time.o differ diff --git a/build/typeConvert.o b/build/typeConvert.o new file mode 100644 index 0000000..135a8cb Binary files /dev/null and b/build/typeConvert.o differ diff --git a/build/xorshift.o b/build/xorshift.o new file mode 100644 index 0000000..94b4eca Binary files /dev/null and b/build/xorshift.o differ diff --git a/buildSoLib b/buildSoLib new file mode 100755 index 0000000..3b4bfa1 --- /dev/null +++ b/buildSoLib @@ -0,0 +1,73 @@ +#!/bin/bash + +set -e + +CC="gcc" +CFLAGS="-DWRATHINT -I./include -fPIC" +OBJ_BUILD="build/" +BIN_DIR="bin/" +HED_DIR="include" + +build() { + echo "Building stdWullie..." + + # Find all C source files + mapfile -t SRC < <(find src -type f -name '*.c') + + # Compile each source file + OBJ=() + + for src in "${SRC[@]}"; do + obj="${src%.c}.o" + + echo "Compiling $src -> $obj" + "$CC" $CFLAGS -c "$src" -o "$obj" + + OBJ+=("$obj") + done + + # Create output directories + mkdir "$OBJ_BUILD" + mkdir "$BIN_DIR" + + # Link shared library + echo "Linking libstdWullie.so..." + "$CC" -nostdlib -shared -o libstdWullie.so \ + -fno-stack-protector \ + "${OBJ[@]}" + + # Move object files + mv "${OBJ[@]}" "$OBJ_BUILD" + + # Move library + mv libstdWullie.so "$BIN_DIR" + + # Copy header + cp "$HED_DIR/stdWullie.h" "$BIN_DIR" + + # Copy header directory + cp -r "$HED_DIR/stdWullie/" "$BIN_DIR" + + echo "Build complete." +} + +clean() { + echo "Cleaning..." + + rm -rf "$OBJ_BUILD" "$BIN_DIR" + + build +} + +case "${1:-build}" in + build|stdWullie) + build + ;; + clean) + clean + ;; + *) + echo "Usage: $0 {build|stdWullie|clean}" + exit 1 + ;; +esac diff --git a/include/LocalHeader.h b/include/LocalHeader.h index 190ec58..44117bf 100644 --- a/include/LocalHeader.h +++ b/include/LocalHeader.h @@ -12,6 +12,7 @@ #define SYS_write 1 #define SYS_open 2 #define SYS_close 3 +#define SYS_brk 12 #define SYS_sleep 35 #define SYS_exit 60 #define SYS_mkdir 83 diff --git a/include/stdWullie.h b/include/stdWullie.h index e3d7906..6900f67 100644 --- a/include/stdWullie.h +++ b/include/stdWullie.h @@ -6,7 +6,6 @@ #define STDWULLIE_H // import everything - //types #include "stdWullie/definitions/int.h" #include "stdWullie/definitions/typeNull.h" @@ -29,6 +28,8 @@ #include "stdWullie/filehandle/readWrite.h" #include "stdWullie/filehandle/mkdir.h" +// # i cant believe its just a burning memory# +#include "stdWullie/memory/brk.h" // string #include "stdWullie/String/colours.h" diff --git a/include/stdWullie/definitions/int.h b/include/stdWullie/definitions/int.h index fb8635a..6c2c9b0 100644 --- a/include/stdWullie/definitions/int.h +++ b/include/stdWullie/definitions/int.h @@ -4,8 +4,8 @@ //defined like stdint to avoid confilict -#ifndef _STDINT_H -#define _STDINT_H 1 +#ifndef _STDWULLIEINT_H +#define _STDWULLIEINT_H 1 // create the types for signed ints using base structures typedef signed char int8_t; @@ -22,10 +22,14 @@ typedef unsigned long long int uint64_t; // misc int types typedef unsigned long size_t; +// intptr +typedef long int intptr_t; +typedef unsigned long int uintptr_t; + // macros for long long, unsigned and unsigned long long -#define U unsigned -#define LL long long -#define ULL unsigned long long +#define U unsigned +#define LL long long +#define ULL unsigned long long // int max values #define INT8_MAX ((int8_t)0x7F) @@ -50,5 +54,10 @@ typedef unsigned long size_t; #define INT16_MIN ((int16_t)(-INT16_MAX - 1)) #define INT32_MIN ((int32_t)(-INT32_MAX - 1)) #define INT64_MIN ((int64_t)(-INT64_MAX - 1)) -#endif +// intptr and uintptr min and max because its just a fucking int +#define INTPTR_MIN (INT64_MIN -1) +#define INTPTR_MAX (INT64_MAX) +#define UINTPTR_MIN (UINT64_MIN) +#define UINTPTR_MAX (UINT64_MAX) +#endif diff --git a/include/stdWullie/memory/brk.h b/include/stdWullie/memory/brk.h new file mode 100644 index 0000000..c89c30c --- /dev/null +++ b/include/stdWullie/memory/brk.h @@ -0,0 +1,15 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef WRATHBRK_H +#define WRATHBRK_H + +#include "stdWullie/definitions/int.h" + +// just give me a brk +int brk(void *address); +void *sbrk(intptr_t addrIncrament); + + +#endif diff --git a/include/stdWullie/namespaces/random.h b/include/stdWullie/namespaces/random.h index 8990380..422052e 100644 --- a/include/stdWullie/namespaces/random.h +++ b/include/stdWullie/namespaces/random.h @@ -10,7 +10,7 @@ typedef struct{ uint32_t (*xor32)(void); uint64_t (*xor64)(void); - int (*choice)(int min, int max) + int (*choice)(int min, int max); }RandomNameSpace; extern const RandomNameSpace random; diff --git a/src/main.c b/src/main.c index 549850f..a7470da 100644 --- a/src/main.c +++ b/src/main.c @@ -3,7 +3,7 @@ // please see attached licence for full usage and rights #include "LocalHeader.h" #include "stdWullie.h" - +#define WRATHINT 1 // decleration for random int randomTest(); diff --git a/src/memory/brk.c b/src/memory/brk.c new file mode 100644 index 0000000..08370e8 --- /dev/null +++ b/src/memory/brk.c @@ -0,0 +1,37 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "stdWullie/memory/brk.h" +#include "stdWullie/exit.h" +#include "LocalHeader.h" + +int brk(void *address){ + + long result = syscall1(SYS_brk, (long)address); + if((void*)result == address){ + return 0; + } + return -1; +} + +void *sbrk(intptr_t incrament){ + + // gets the last break point and checks whether we just wanted that or do something else + void *prevBrk = (void *)syscall1(SYS_brk, 0); + if(incrament == 0){ + return prevBrk; + } + + // something else + void *newBrk = (char *)prevBrk + incrament; + + long result = syscall1(SYS_brk, (long)newBrk); + + if((void *)result != newBrk){ + safeError("FAULT IN ALLOCATING NEW BREAK"); + } + + // pointer to the start of the new memory + return prevBrk; +}