feat: add portable panic, I/O hooks and configurable memory sizes

Co-authored-by: aider (openrouter/moonshotai/kimi-k2.6) <aider@aider.chat>
This commit is contained in:
2026-05-03 22:38:29 +03:00
parent f033187c6c
commit dcc88bc8ca
+37
View File
@@ -11,6 +11,43 @@
// Configuration (all hard limits removed) // Configuration (all hard limits removed)
#define MAX_NAME_LEN 31 #define MAX_NAME_LEN 31
/* Portable panic hook. Override for bare-metal reset/handling. */
#ifndef forth_panic
#define forth_panic() do { for (;;) ; } while (0)
#endif
/* Portable I/O hooks. Define FORTH_CUSTOM_IO before including this header
* to provide bare-metal UART (or other) implementations. */
#ifndef FORTH_CUSTOM_IO
#define forth_putchar(c) putchar(c)
#define forth_getchar() getchar()
#define forth_printf(...) printf(__VA_ARGS__)
#define forth_fflush() fflush(stdout)
#endif
/* Static memory sizes (override before including forth.h) */
#ifndef FORTH_DATA_STACK_SIZE
#define FORTH_DATA_STACK_SIZE 128
#endif
#ifndef FORTH_RET_STACK_SIZE
#define FORTH_RET_STACK_SIZE 128
#endif
#ifndef FORTH_COMPILE_STACK_SIZE
#define FORTH_COMPILE_STACK_SIZE 64
#endif
#ifndef FORTH_COMPILE_BUF_SIZE
#define FORTH_COMPILE_BUF_SIZE 256
#endif
#ifndef FORTH_USER_MEM_CELLS
#define FORTH_USER_MEM_CELLS (1024 * 1024)
#endif
#ifndef FORTH_MAX_WORDS
#define FORTH_MAX_WORDS 256
#endif
#ifndef FORTH_MAX_WORD_BODY_CELLS
#define FORTH_MAX_WORD_BODY_CELLS 4096
#endif
#define F_IMMEDIATE (1 << 7) #define F_IMMEDIATE (1 << 7)
#define F_HIDDEN (1 << 6) #define F_HIDDEN (1 << 6)