aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md28
-rw-r--r--moonshine.h2
2 files changed, 29 insertions, 1 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c2378b9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,28 @@
+# moonshine
+This library aims to be a drop-in libc replacement for most C projects, whilst also providing helpful utilies such as variable arrays, bounds checking, better memory allocation, algebraic data types, garbage collection, and more.
+
+It already supports the system calls and library functions which were necessary for its functionality, but more stdlib support should come soon. This library relies upon nothing but the C language itself, not even the standard library headers that C often uses, such as stdlib.h, unistd.h, etc.
+
+Its current features are:
+- Self-defined types such as `var` for `void*`, `string` for `char*`, `u8` for `uint64_t`, and const-correct types such as `car` for `const void*` and `ctring` for `const char*`
+- Global print statement, takes up to 512 arguments of any type, and figures out how to print them out by itself. (Currently does not support custom structs). Example: `print("hello, ", "world!")`, `print("The sum is: ", 2 + 5)`, `print("I have a pointer with size ", pointer_size, " and address ", pointer)`
+- Easy array creation: `new(int)`, `new(char, 4)`, `fill(int, 2, 4, 5)`, `fill(string, "hello", "world")`, `single("string")`, `single(22.4)`
+- Basic type coercion: `auto x = 4; auto y = 9.0; auto z = "Hello!";`
+- Easy system calls: `syscall2(60, 0); // 60 = SYS_exit`
+- Const-correct stdlib functions: `exit`, `fork`, `getchar`, `putchar`, `strlen`, `memset`, `memmove`, etc
+- Made-from-scratch stdout buffer management: `write`, `flush`, etc
+- Deprecation warnings for functions such as `malloc`, `realloc` and `free`
+- Intelligent and safe memory management using `alloc`, `remap` and `release`
+- Pointer ownership trick, using `mine(var ptr)`
+- Easy array manipulation with `push(array, item)`
+- Array bounds checking using `get(array, index)`, `set(array, index, value)`, `count(array)`, `last(array)` and metadata using `element_size(array)`
+- Foreach loops using `foreach(item in array) { print(item); }`
+- Revamped stdlib functions such as `char* strdup(const char* str) -> t(char) strdup(ctring str)`
+- Array manipulation using `reverse_array(array)` which returns the reversed array and also reverses it in-place.
+- Custom `_start` function that initializes moonshine functionality whilst still keeping the ease of use of the libc `main` function.
+
+The roadmap for moonshine is:
+- Adding Algebraic data types
+- Implementing Garbage collection
+- Achieving more libc compatibility
+- Moving common operations to macros for reduced code size and increased conciseness
diff --git a/moonshine.h b/moonshine.h
index ab0ba1a..6a5215e 100644
--- a/moonshine.h
+++ b/moonshine.h
@@ -604,7 +604,7 @@ void clean_pages() {
__attribute__((diagnose_as_builtin(__builtin_malloc, 1))) __attribute__((malloc)) var alloc(const u8 _len)
[[clang::allocating]] {
static int alloc_count = 0;
- if (alloc_count++ == 10) {
+ if (alloc_count++ == 16) {
alloc_count = 0;
clean_pages();
}