From 85fde9412472bc38265d983f49f67f86f743fbb2 Mon Sep 17 00:00:00 2001 From: retropikzel Date: Wed, 21 Jan 2026 17:39:08 +0200 Subject: [PATCH] Backup --- retropikzel/arena.scm | 23 ++++++++++++++++++++++ retropikzel/arena.sld | 12 ++++++++++++ retropikzel/arena/README.md | 39 +++++++++++++++++++++++++++++++++++++ retropikzel/stdio.scm | 0 retropikzel/stdio.sld | 35 +++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 retropikzel/arena.scm create mode 100644 retropikzel/arena.sld create mode 100644 retropikzel/arena/README.md create mode 100644 retropikzel/stdio.scm create mode 100644 retropikzel/stdio.sld diff --git a/retropikzel/arena.scm b/retropikzel/arena.scm new file mode 100644 index 0000000..1fa22f1 --- /dev/null +++ b/retropikzel/arena.scm @@ -0,0 +1,23 @@ +(define-record-type + (internal-make-arena pointer size fixed?) + arena? + (pointer arena-pointer) + (size arena-size) + (fixed? arena-fixed?)) + +(define make-arena + (lambda options + #t + )) + +(define (call-with-arena arena thunk) + #t + ) + +(define (arena-allocate arena size) + #t + ) + +(define (free-arena arena) + #t + ) diff --git a/retropikzel/arena.sld b/retropikzel/arena.sld new file mode 100644 index 0000000..d136a25 --- /dev/null +++ b/retropikzel/arena.sld @@ -0,0 +1,12 @@ +(define-library + (retropikzel arena) + (import (scheme base) + (scheme write) + (foreign c)) + (export make-arena + arena? + call-with-arena + arena-allocate + free-arena) + (include "arena.scm")) + diff --git a/retropikzel/arena/README.md b/retropikzel/arena/README.md new file mode 100644 index 0000000..e69695c --- /dev/null +++ b/retropikzel/arena/README.md @@ -0,0 +1,39 @@ +## Arenas + +Arena is static or growing size of memory which can be use to allocate +c-bytevectors and then free them all at once. All memory allocated in arenas +is zeroed by default. + +(**make-arena** [options]) + +Creates and returns a new arena. Options is list of pairs. + +Options: + + - (size . N) + - If the size argument is given, that much memory is allocated up front. + - (fixed? . #t/#f) + - #f means the arena grows automatically on allocation, #t means it does not + and any allocation that would go over arena size will throw an error. + - If #t and size is not given error will thrown + +(**arena?** obj) + +Returns #t if obj is arena, #f otherwise. + +(**call-with-arena** arena thunk) + +Call thunk with given arena as first argument. After the thunk returns arena +is freed. If the thunk does not return, for example error occurs, the arena is +not freed. + + +(**arena-allocate** arena size) + +Allocate c-bytevector of given size from the given arena and return it. If +allocation fails, error is signaled. + + +(**free-arena** arena) + +Free the whole arena. diff --git a/retropikzel/stdio.scm b/retropikzel/stdio.scm new file mode 100644 index 0000000..e69de29 diff --git a/retropikzel/stdio.sld b/retropikzel/stdio.sld new file mode 100644 index 0000000..9fbae33 --- /dev/null +++ b/retropikzel/stdio.sld @@ -0,0 +1,35 @@ +(define-library + (retropikzel stdio) + (import (scheme base) + (scheme write) + (foreign c)) + (export fopen + ;fclose + ;feof + ;ferror + ;fgetc + ;fgets + ;fprintf + ;fputc + ;fputs + ;fread + ;fscanf + ;fseek + ;ftell + ;fwrite + ;getc + ;getchar + ;printf + ;putc + ;putchar + ;puts + ;remove + ;rename + ;rewind + ;scanf + ;snprintf + ;sprintf + ;sscanf + ) + (include "stiod.scm")) +