3#ifndef LL_PLATFORM_GENERIC_H
4#define LL_PLATFORM_GENERIC_H
18#define LL_ESP_ARDUINO 0
39#define LL_EMSCRIPTEN 0
54#ifndef LL_GCCHK_VISITED_GROWBY
56 #define LL_GCCHK_VISITED_GROWBY 4096
57 #define LL_GCCHK_STACK_INIT 256
58 #define LL_GCCHK_STACK_GROWBY 8
59 #define LL_GCCHK_STACK_CAP 8192
60 #define LL_GCCHK_VECSTACK_INIT 64
61 #define LL_GCCHK_VECSTACK_GROWBY 8
62 #define LL_GCCHK_VECSTACK_CAP 1024
64 #define LL_GCCHK_VISITED_GROWBY (-1)
65 #define LL_GCCHK_STACK_INIT 256
66 #define LL_GCCHK_STACK_GROWBY 256
67 #define LL_GCCHK_STACK_CAP (1<<20)
68 #define LL_GCCHK_VECSTACK_INIT 64
69 #define LL_GCCHK_VECSTACK_GROWBY 64
70 #define LL_GCCHK_VECSTACK_CAP (1<<16)
74#ifndef LL_EVAL_STACK_BUDGET
81 #define LL_EVAL_STACK_BUDGET (3UL * 1024 * 1024)
83 #define LL_EVAL_STACK_BUDGET (6UL * 1024 * 1024)
85 #define LL_EVAL_STACK_BUDGET (40UL * 1024)
97#ifndef LL_EVAL_STACK_BUDGET_MIN
98#define LL_EVAL_STACK_BUDGET_MIN (16UL * 1024)
112#ifndef LL_NCG_DIRAM_POOL
113 #if LL_ESP32 && LL_XTENSA
114 #define LL_NCG_DIRAM_POOL 1
116 #define LL_NCG_DIRAM_POOL 0
120#ifndef LL_NCG_RISCV_POOL
121 #if LL_RISCV32 && ((defined(LL_C5_PMP_RWX) && LL_C5_PMP_RWX) || \
122 (defined(LL_C5_NCG_ARENA) && LL_C5_NCG_ARENA))
123 #define LL_NCG_RISCV_POOL 1
125 #define LL_NCG_RISCV_POOL 0
130#ifndef LL_NCG_EXEC_FLOOR_DEFAULT
131 #define LL_NCG_EXEC_FLOOR_DEFAULT 24576
134#ifndef LL_NCG_PSRAM_EXEC
135 #if defined(BOARD_HAS_PSRAM) && (LL_ESP32S3 || LL_RISCV32)
136 #define LL_NCG_PSRAM_EXEC 1
138 #define LL_NCG_PSRAM_EXEC 0
143#ifndef LL_EXTRAM_SEPARATE_IBUS
144 #if LL_ESP32 && LL_XTENSA
145 #define LL_EXTRAM_SEPARATE_IBUS 1
147 #define LL_EXTRAM_SEPARATE_IBUS 0
163#ifndef LL_NCG_PSRAM_ALIAS
164 #if LL_NCG_PSRAM_EXEC && LL_ESP32S3
165 #define LL_NCG_PSRAM_ALIAS 1
167 #define LL_NCG_PSRAM_ALIAS 0
173#ifndef LL_WIFI_RESERVE_BYTES
174 #define LL_WIFI_RESERVE_BYTES (48UL * 1024)
196#ifndef LL_GC_BUDGET_WHEN_MAXED
197#define LL_GC_BUDGET_WHEN_MAXED 1
200#ifndef LL_NCG_EXEC_POOL_BYTES
201 #if LL_NCG_RISCV_POOL
202 #define LL_NCG_EXEC_POOL_BYTES (32UL * 1024)
204 #define LL_NCG_EXEC_POOL_BYTES (32UL * 1024)
207 #define LL_NCG_EXEC_POOL_BYTES (32UL * 1024)
209 #define LL_NCG_EXEC_POOL_BYTES (32UL * 1024)
214#ifndef LL_ROOTSTACK_MAX
217 #define LL_ROOTSTACK_MAX 131072
219 #define LL_ROOTSTACK_MAX 262144
221 #define LL_ROOTSTACK_MAX 65536
227#ifndef LL_ROOTSTACK_SLACK
228#define LL_ROOTSTACK_SLACK 256
245#ifndef LL_ROOTSTACK_INIT
246 #define LL_ROOTSTACK_INIT 256
248#ifndef LL_MARKSTACK_INIT
249 #define LL_MARKSTACK_INIT 256
254#ifndef LL_EVAL_ROOT_DEPTH_MAX
255#define LL_EVAL_ROOT_DEPTH_MAX (LL_ROOTSTACK_MAX - 536)
295#ifndef LL_ROOT_HIGH_WATER
297 #define LL_ROOT_HIGH_WATER 1
299 #define LL_ROOT_HIGH_WATER 0
317#ifndef LL_HAVE_BACKTRACE
318 #if defined(__GLIBC__) && !LL_ESP32
319 #define LL_HAVE_BACKTRACE 1
321 #define LL_HAVE_BACKTRACE 0
341#ifndef LL_BIGNUM_LIMB_BITS
342#define LL_BIGNUM_LIMB_BITS 32
345#ifndef LL_BIGNUM_STRICT_RT
346#define LL_BIGNUM_STRICT_RT 0
366#ifndef LL_ESP32_S3_DEVKIT_C
367#define LL_ESP32_S3_DEVKIT_C 0
369#ifndef LL_ESP32S3_N8R2
370#define LL_ESP32S3_N8R2 0
372#ifndef LL_Freenove_4WD_Car_Kit_ESP32
373#define LL_Freenove_4WD_Car_Kit_ESP32 0
375#ifndef LL_Freenove_ESP32_WROVER
376#define LL_Freenove_ESP32_WROVER 0
379#define LL_ESP32_N4R4 0
416 #define LL_NETWORK ((LL_WIFI) || (LL_POSIX))
421#define LL_POSIX_NET ((LL_POSIX) && (LL_NETWORK))
427 #define LL_TERMIOS (LL_POSIX)
468#ifndef LL_AUTOCOMPILE
469 #define LL_AUTOCOMPILE 1
511unsigned long millis();
512unsigned long micros();
525void delay_ms(
unsigned long ms);
527static void delay(
unsigned long ms) { delay_ms(ms); }
541#define INPUT_PULLUP 0x2
544void pinMode(
int pin,
int mode);
545void digitalWrite(
int pin,
int val);
546int digitalRead(
int pin);
547void analogWrite(
int pin,
int val);
548int analogRead(
int pin);
549void tone(
int pin,
unsigned int freq);
550void tone(
int pin,
unsigned int freq,
unsigned long dur);
552void delayMicroseconds(
unsigned long us);
557int ll_llarduino_pin_duty(
int pin);
558int ll_llarduino_pin_tone(
int pin);
559int ll_llarduino_npins();
560const char *ll_llarduino_backend();
587 LL_String() { _init(); set(
""); }
588 LL_String(
const char *other) { _init(); set(other); }
589 LL_String(
const char *other,
int n) { _init(); set(other, n); }
590 LL_String(
const LL_String &other) { _init(); set(other.ptr, other.len); }
592 ~LL_String() {
if (ptr) {
delete[] ptr; ptr = 0; } len = cap = 0; }
594 void set(
const char *s) { set(s, s ? (
int) strlen(s) : 0); }
596 void set(
const char *s,
int n) {
597 if (!s || n <= 0) { _ensure(0); ptr[0] =
'\0'; len = 0;
return; }
598 if (ptr && s >= ptr && s <= ptr + len) {
599 const int off = (int) (s - ptr);
600 memmove(ptr, ptr + off, (
size_t) n);
604 memmove(ptr, s, (
size_t) n);
610 LL_String concat(
const char *s1,
const char *s2) {
612 const int n1 = s1 ? (int) strlen(s1) : 0;
613 const int n2 = s2 ? (int) strlen(s2) : 0;
615 if (n1) memmove(r.ptr, s1, (
size_t) n1);
616 if (n2) memmove(r.ptr + n1, s2, (
size_t) n2);
617 r.ptr[n1 + n2] =
'\0';
624 const int n1 = (int) strlen(s1);
625 const bool self = (ptr && s1 >= ptr && s1 <= ptr + len);
626 const int off = self ? (int) (s1 - ptr) : 0;
628 memmove(ptr + len, self ? ptr + off : s1, (
size_t) n1);
646 LL_String &operator=(
const char *other) { set(other);
return *
this; }
647 LL_String &operator=(
const LL_String &other) {
if (
this != &other) set(other.ptr, other.len);
return *
this; }
649 bool operator==(
const char *other) {
return strcmp(ptr, other) == 0; }
650 bool operator!=(
const char *other) {
return strcmp(ptr, other) != 0; }
651 bool operator==(
const LL_String &other) {
return strcmp(ptr, other.ptr) == 0; }
652 bool operator!=(
const LL_String &other) {
return strcmp(ptr, other.ptr) != 0; }
653 char &operator[](
int ix) {
return ptr[ix]; }
655 LL_String operator+(
const char *other) {
return concat(ptr, other); }
656 LL_String operator+(
const LL_String &other) {
return concat(ptr, other.ptr); }
657 LL_String operator+(
char c) {
char cstr[2]; cstr[0] = c; cstr[1] =
'\0';
return concat(ptr, cstr); }
659 LL_String &operator+=(
const char *other) {
return append(other); }
660 LL_String &operator+=(
const LL_String &other) {
return append(other.ptr); }
661 LL_String &operator+=(
char c) {
return append(c); }
663 char *c_str()
const {
return ptr; }
667 void _init() { ptr = 0; len = 0; cap = 0; }
671 void _ensure(
int need) {
672 if (cap >= need + 1)
return;
673 int ncap = cap ? cap : 16;
674 while (ncap < need + 1) ncap += ncap;
676 char *np =
new char[ncap];
677 if (ptr) { memmove(np, ptr, (
size_t) len + 1);
delete[] ptr; }
678 else { np[0] =
'\0'; }
693#define NOTUSED __attribute__((__unused__))
694#define INLINE __attribute__((__inline__))
695#define NOINLINE __attribute__((__noinline__))
696#define CHECKPRINTF __attribute__((format(printf, 1, 2)))
697#define CHECKPRINTF_pos2 __attribute__((format(printf, 2, 3)))
728 virtual size_t write(uint8_t c) = 0;
729 virtual size_t write(
const uint8_t *buf,
size_t n);
730 size_t write(
const char *s);
731 size_t print(
char c);
732 size_t print(
const char *s);
733 size_t print(
const String &s);
734 size_t print(
int n,
int base = 10);
735 size_t print(
long n,
int base = 10);
736 size_t print(
unsigned long n,
int base = 10);
737 size_t print(
double v,
int digits = 2);
741 size_t println(
const String &s);
742 size_t println(
int n,
int base = 10);
743 size_t println(
long n,
int base = 10);
744 size_t println(
unsigned long n,
int base = 10);
745 size_t println(
double v,
int digits = 2);
746 size_t printf(
const char *fmt, ...) CHECKPRINTF_pos2;
749class Stream :
public Print {
751 virtual int available() = 0;
752 virtual int read() = 0;
753 virtual int peek() = 0;
754 virtual void flush() {}
759class LLArduinoSerial :
public Stream {
762 LLArduinoSerial() : _peeked(-1) {}
763 void begin(
unsigned long baud = 115200);
766 int availableForWrite();
769 void flush()
override;
770 size_t write(uint8_t c)
override;
782#if LL_ARDUINO || LL_ESP_ARDUINO
783const char *ll_llarduino_fmt_int(
long v,
int base);
784const char *ll_llarduino_fmt_real(
double v,
int digits);
785const char *ll_llarduino_eol();
788#define CHECKPRINTF_pos3 __attribute__((format(printf, 3, 4)))
789#define CHECKPRINTF_pos4 __attribute__((format(printf, 4, 5)))
793#if !defined(IRAM_ATTR)
796#if !defined(DRAM_ATTR)
838#ifndef LL_STDIO_RX_BUFSIZE
839#define LL_STDIO_RX_BUFSIZE 0
842const unsigned long toString_MAX_LENGTH = 8192;
845const unsigned long LL_ERRFORM_MAX = 400;
852const unsigned long LL_ENVFRAME_MAX = 32;
869const unsigned long LL_PRINT_LIST_MAX = 4096;
870String toString(
const char *fmt, ...) CHECKPRINTF;
874#define ME(_me_) NOTUSED const char me[] = _me_
875#define ll_isdef(sym) (#sym[0])
877void global_printf(
const char *fmt, ...);
893void global_spill_begin();
908void global_term_quiet(
bool echo,
bool logs);
921void global_term_push_line(
const char *s);
945typedef unsigned char Byte_t;
960typedef int32_t ll_codepoint_t;
962typedef Char_t
const *Charst_t;
963typedef Byte_t
const *Bytest_t;
964typedef Char_t *CharVec_t;
965typedef Byte_t *ByteVec_t;
985void *ll_payload_alloc_bytes(
size_t nbytes);
986void ll_payload_free(
void *p);
989template <
typename T>
static inline T *ll_payload_new(
size_t n)
991 return (T *) ll_payload_alloc_bytes(n *
sizeof(T));
1028void *ll_fastram_alloc_bytes(
size_t nbytes);
1029void ll_fastram_free(
void *p);
1054typedef uintptr_t Word_t;
1056static_assert(
sizeof(Word_t) >=
sizeof(
void *),
1057 "Word_t must hold a pointer; LLP64 (Windows x64) breaks "
1058 "the old `unsigned long` spelling because long is 32 bits there and pointers are 64.");
1060typedef int32_t LL_int32;
1073inline int ll_u8_seqlen(
unsigned char b0)
1075 if (b0 < 0x80)
return 1;
1076 if ((b0 & 0xE0) == 0xC0)
return 2;
1077 if ((b0 & 0xF0) == 0xE0)
return 3;
1078 if ((b0 & 0xF8) == 0xF0)
return 4;
1084inline ll_codepoint_t ll_u8_decode(
const char *p,
int *nb)
1086 unsigned char b0 = (
unsigned char) p[0];
1087 int n = ll_u8_seqlen(b0);
1089 if (n == 1)
return (ll_codepoint_t) b0;
1090 ll_codepoint_t cp = b0 & (0xFF >> (n + 1));
1091 for (
int i = 1; i < n; i++) {
1092 unsigned char c = (
unsigned char) p[i];
1093 if ((c & 0xC0) != 0x80) {
if (nb) *nb = 1;
return (ll_codepoint_t) b0; }
1094 cp = (cp << 6) | (c & 0x3F);
1100inline int ll_u8_encode(ll_codepoint_t cp,
char *out)
1102 if (cp < 0x80) { out[0] = (char) cp;
return 1; }
1103 if (cp < 0x800) { out[0] = (char)(0xC0 | (cp >> 6)); out[1] = (char)(0x80 | (cp & 0x3F));
return 2; }
1104 if (cp < 0x10000) { out[0] = (char)(0xE0 | (cp >> 12)); out[1] = (char)(0x80 | ((cp >> 6) & 0x3F));
1105 out[2] = (char)(0x80 | (cp & 0x3F));
return 3; }
1106 out[0] = (char)(0xF0 | (cp >> 18)); out[1] = (char)(0x80 | ((cp >> 12) & 0x3F));
1107 out[2] = (char)(0x80 | ((cp >> 6) & 0x3F)); out[3] = (char)(0x80 | (cp & 0x3F));
return 4;
1111inline LL_int32 ll_u8_strlen(
const char *s)
1114 for (
const char *p = s; *p; n++) p += ll_u8_seqlen((
unsigned char) *p);
1124inline LL_int32 ll_u8_strlen_n(
const char *s, LL_int32 nbytes)
1127 for (LL_int32 i = 0; i < nbytes; n++) i += ll_u8_seqlen((
unsigned char) s[i]);
1133inline const char *ll_u8_index_n(
const char *s, LL_int32 nbytes, LL_int32 k)
1136 for (LL_int32 c = 0; c < k; c++) {
1137 if (i >= nbytes)
return 0;
1138 i += ll_u8_seqlen((
unsigned char) s[i]);
1140 return (i <= nbytes) ? (s + i) : 0;
1145inline const char *ll_u8_index(
const char *s, LL_int32 k)
1148 for (LL_int32 i = 0; i < k; i++) {
1150 p += ll_u8_seqlen((
unsigned char) *p);
1156typedef int64_t LL_int64;
1157typedef float LL_float32;
1158typedef double LL_float64;
1160static_assert(
sizeof(Word_t) ==
sizeof(Ptr_t),
"Word_t size must be == Ptr_t size\n");
1161static_assert(
sizeof(Word_t) >=
sizeof(LL_int32),
"Word_t size must be >= LL_int32 size\n");
1162static_assert(
sizeof(LL_float32) == 4,
"LL_float32 must be 4 bytes\n");
1163static_assert(
sizeof(LL_float64) == 8,
"LL_float64 must be 8 bytes\n");
1167class AsciiConverter {
1170 char *dec(Word_t n) {
1171 char *ptr = slot_end();
1183 char *dec(LL_int32 n) {
1184 if (n >= 0)
return dec((Word_t) n);
1185 if (n == INT32_MIN)
return dec((LL_int64) n);
1186 char *ptr = dec(-n);
1205 template <
typename T>
1206 typename std::enable_if<std::is_same<T, int>::value && !std::is_same<LL_int32, int>::value,
1208 dec(T n) {
return dec((LL_int32) n); }
1210 char *dec(LL_int64 n) {
1212 char *ptr = slot_end();
1214 uint64_t uv = neg ? (n == INT64_MIN ? (uint64_t) 9223372036854775808ULL : (uint64_t) -n)
1216 do { *--ptr = (char)(
'0' + (uv % 10)); uv /= 10; }
while (uv);
1217 if (neg) *--ptr =
'-';
1221 char *hex(Word_t n) {
1222 char *ptr = slot_end();
1223 LL_int32 nibs =
sizeof(Word_t) * 2;
1227 Word_t d = n & 0x0f;
1229 char c = (d < 10) ? (d +
'0') : (d - 10 +
'a');
1236 char *dec(LL_float32 n) {
1237 char *b = slot_base();
1238 snprintf(b, SLOT,
"%f", (LL_float64) n);
1278 static const LL_int32 SLOTS = 16;
1279 static const LL_int32 SLOT = 64;
1280 static_assert(SLOT >= 3 + 20,
"dec(LL_int64): sign + 20 digits + NUL");
1281 static_assert(SLOT >= 2 +
sizeof(Word_t) * 2,
"hex(Word_t): nibbles + NUL");
1282 static_assert(SLOT >= 48,
"dec(LL_float32): %f of 3.4e38 needs 47 chars");
1283 char buf[SLOTS][SLOT];
1285 char *slot_base() { next = (next + 1) % SLOTS;
return buf[next]; }
1286 char *slot_end() {
char *b = slot_base(); b[SLOT - 1] =
'\0';
return &b[SLOT - 1]; }
1289extern AsciiConverter ascii;
1297 ~LambPlatform() { end(); }
1306 void identification(
void);
1308 LL_int32 free_heap();
1329 LL_int32 free_internal();
1330 LL_int32 free_dma();
1331 LL_int32 largest_free_internal();
1332 LL_int32 largest_free_dma();
1333 LL_int32 cell_pool_free();
1354 void *cell_block_alloc(
unsigned long nbytes);
1355 void cell_block_free(
void *blk);
1366 const char *mem_placement(
void *p);
1380 LL_int64 fs_total();
1382 LL_int32 free_stack();
1383 Bool_t heap_integrity_check(Bool_t complain=
false);
1386 LL_float32 rand11() {
1387 const int max_int = (~((
unsigned int) 0)) >> 1;
1388 const int min_int = -max_int - 1;
1389 const LL_float32 min = (LL_float32) min_int;
1392 rand((
byte *) &n,
sizeof(n));
1396 LL_float32 rand01() {
return (rand11() + 1.0) / 2.0; }
1398 void rand(
byte *buf, LL_int32 len);
1399 void rand11(LL_float32 *buf, LL_int32 n) {
while (n--) *buf++ = rand11(); }
1400 void rand01(LL_float32 *buf, LL_int32 n) {
while (n--) *buf++ = rand01(); }
1402 LL_int32 loop_elapsed_ms() {
return millis() - loop_start_ms; }
1403 LL_int32 loop_elapsed_us() {
return micros() - loop_start_us; }
1408 LL_int32 loop_start_ms;
1409 LL_int32 loop_start_us;
1412extern LambPlatform lambPlatform;
1417#include "LittleFS.h"
1418typedef File File_Native;
1423typedef FILE* File_Native;
1443 bool isOpen() {
return _path !=
""; }
1446 int seek(
unsigned long target,
int whence=SEEK_SET);
1451 int read(
byte *b,
int n) {
1455 if (ch == EOF)
return nread;
1461 int read(
char *s,
int n) {
return read((
byte *) s, n); }
1462 int write(
const byte *b,
int n) {
while (n--) write(*b++);
return n; }
1463 int write(
const char *s,
int n) {
while (n--) write((
byte) *s++);
return n; }
1466 File_Native _theFile;
1504bool ll_fastram_reserve(
const char *tag,
size_t bytes);
1527bool ll_fastram_reserve_pinned(
const char *tag,
size_t bytes);
1530void ll_fastram_release(
const char *tag);
1533void ll_fastram_release_unclaimed();
1559size_t ll_win_self_exe_path(
char *buf,
size_t cap);
1568int ll_win_mkdir(
const char *path,
int mode);
1583int ll_win_set_system_time(
long long utc_seconds);
1624#ifndef LL_PANEL_ST7789_EYE
1625 #define LL_PANEL_ST7789_EYE 0
1633#ifndef LL_PANEL_ST7701_AITRIP
1634 #define LL_PANEL_ST7701_AITRIP 0
1641#if LL_PANEL_ST7789_EYE || LL_PANEL_ST7701_AITRIP
1659 void (*
fill)(
Lamb &lamb,
int x,
int y,
int w,
int h, uint16_t color);
1660 void (*
blit)(
Lamb &lamb,
int x,
int y,
int w,
int h,
const uint16_t *src);
1661 uint16_t *(*fb)(void);
1667const LL_Panel *ll_panel_active(
void);
1670void ll_panel_register(
const LL_Panel *p);
1673bool ll_panel_ready(
void);
1679void ll_panel_blit_rgb565(
Lamb &lamb,
int x,
int y,
int w,
int h,
const uint16_t *src);
1691 LL_File *open(
const char *path,
const char *mode);
1692 bool exists(
const char *path);
1693 int rm(
const char *path);
1694 int mv(
const char *from,
const char *to);
1695 int mkdir(
const char *path);
1707extern TwoWire *LL_Wire;
1712#include "WiFiClientSecure.h"
1725 int setTxBufferSize(
int n);
1726 int setRxBufferSize(
int n);
1736 void begin(
void) { begin(115200); }
1737 void begin(
unsigned long baudrate);
1739 int available(
void);
1740 int availableForWrite(
void);
1742 int write(uint8_t c);
1743 int write(
char c) {
return write((uint8_t) c); }
1747 int read(
byte *buf,
int max) {
1751 if (b == EOF)
break;
1757 int read(
char *s,
int max) {
return read((uint8_t *) s, max); }
1758 int write(
const char *s,
int n) {
return write((uint8_t *) s, n); }
1759 int write(
const byte *b,
size_t n) {
int i=n;
while (i--) write(*b++);
return n; }
1760 int write(
const char *s) {
int i=0;
while (*s) { write(*s++); i++; }
return i; }
1762 operator bool() {
return true; }
1767typedef byte uuid_t[16];
1770#define ll_once(_once_something) do { \
1771 static bool _visited_ = false; \
1774 { _once_something; } \
1781#define ll_every(_every_so_often_ms, _every_something_to_do) do { \
1782 static unsigned long _every_next = 0; \
1783 unsigned long _every_now = millis(); \
1784 if (_every_now >= _every_next) { \
1785 { _every_something_to_do; } \
1786 _every_next = _every_now + (_every_so_often_ms); \
1820void embedded_debug_catcher();
1821#define ll_debug_catcher embedded_debug_catcher()
1826#define LAMB_SETTINGS_PATH "/Settings-Lamb.scm"
1827#define SETTINGS_PATH "/Settings.scm"
1829#define LAMB_SETTINGS_PATH "Settings-Lamb.scm"
1830#define SETTINGS_PATH "Settings.scm"
1840static inline LL_int32 ll_round_up_1k(LL_int32 n)
1842 if (n <= 0)
return n;
1843 if (n > (LL_int32) 0x7FFFFC00)
return (LL_int32) 0x7FFFFC00;
1844 return (n + 1023) & ~((LL_int32) 1023);
1847struct LambPreSettings {
1851 LL_int32 cell_block_size = 0;
1852 LL_int32 extension_block_size = 8 * 1024;
1859 LL_int32 gc_total_marked = 0;
1869 LL_int32 gc_pool_target = 0;
1870 LL_int32 ncg_frame_pool_size = 16;
1877 LL_int32 pool_reserve_pct = 25;
1878 LL_int32 pool_reserve_bytes = 0;
1900 LL_int32 gc_persist = 1;
1916 LL_int32 sint_in_iram = 1;
1917 LL_int32 rootstack_in_iram = 1;
1923 LL_int32 rootstack_max = 0;
1924 LL_int32 rootstack_init = 0;
1925 LL_int32 markstack_init = 0;
1931 LL_int32 va_list_max = (LL_int32) toString_MAX_LENGTH;
1940 LL_int32 boot_pending = 0;
1952 bool apply_key(
const char *key,
long val);
1957void ll_pre_settings_write(LL_int32 boot_pending);
1959void ll_settings_boot_ok(
void);
1969extern LL_int32 _ll_settings_writes_done;
1970extern LL_int32 _ll_settings_writes_skipped;
1972extern LambPreSettings ll_pre_settings;
1997extern LL_int32 ll_cell_block_size_effective;
2005extern LL_int32 ll_va_list_max;
2025extern const void *ll_catch_last_err;
2026extern int ll_catch_repeats;
2027#define LL_CATCH_REPEAT_LIMIT 4
2054#define LL_ERR_IS_USER_RAISE(__e__) \
2055 ((__e__)->type() == Cell::T_ERROR && strcmp((__e__)->error_get_chars(), "__raise__") == 0)
2080#define ll_catch(__code_before_rethrow__) \
2081 catch (std::bad_alloc &) { \
2082 Sexpr_t __err__ = NIL->mk_error("%s out of memory (C++ allocation failed)", me); \
2083 ll_catch_last_err = (const void *) __err__; \
2084 ll_catch_repeats = 1; \
2085 global_printf("\r[%d] %s ll_catch(): %s\n", millis(), me, __err__->error_get_chars()); \
2087 __code_before_rethrow__; \
2090 catch (Sexpr_t __err__) { \
2091 if (__err__->type() != Cell::T_ERROR) \
2092 throw NIL->mk_error("ll_catch() BUG in %s bad type %s", me, __err__->dump().c_str()); \
2094 if (!LL_ERR_IS_USER_RAISE(__err__)) { \
2095 if ((const void *) __err__ != ll_catch_last_err) { \
2096 ll_catch_last_err = (const void *) __err__; \
2097 ll_catch_repeats = 0; \
2099 if (++ll_catch_repeats <= LL_CATCH_REPEAT_LIMIT) \
2100 global_printf("\r[%d] %s ll_catch(): %s\n", millis(), me, __err__->error_get_chars()); \
2101 else if (ll_catch_repeats == LL_CATCH_REPEAT_LIMIT + 1) \
2102 global_printf("\r[%d] %s ll_catch(): ... same error still unwinding; further frames suppressed\n", millis(), me); \
2106 __code_before_rethrow__; \
2111#define ll_catch_terminal \
2112 catch (std::bad_alloc &) { \
2113 global_printf("\r[%d] %s ll_catch_terminal: out of memory (C++ allocation failed)\n", \
2117 catch (Sexpr_t __err__) { \
2122 if (LL_ERR_IS_USER_RAISE(__err__)) \
2123 global_printf("\r[%d] %s ll_catch_terminal: UNCAUGHT raise: %s\n", \
2124 millis(), me, __err__->error_get_irritants()->str().c_str()); \
2127 else if (__err__->type() != Cell::T_ERROR) \
2128 global_printf("\r[%d] %s ll_catch_terminal: non-error type %d\n", \
2129 millis(), me, __err__->type()); \
2131 global_printf("\r[%d] %s ll_catch_terminal: %s\n", \
2132 millis(), me, __err__->error_get_chars()); \
2164bool ll_term_ansi(
void);
2165void ll_term_ansi_set(
bool on);
2166bool ll_term_ansi_detect(
void);
2168int ll_win_enable_vt(
void);
2169void ll_win_yield_ms(
unsigned ms);
Definition ll_platform_generic.h:759
Definition ll_platform_generic.h:1689
Definition ll_platform_generic.h:1437
Definition ll_platform_generic.h:584
LL_String & append(char c)
Definition ll_platform_generic.h:637
void set(const char *s, int n)
Definition ll_platform_generic.h:596
LL_String & append(const char *s1)
Definition ll_platform_generic.h:622
int length() const
O(1): a stored length, not a strlen per call.
Definition ll_platform_generic.h:664
Definition ll_platform_generic.h:1723
bool set_input_callback(void(*cb)())
JIT exception-escape context; opaque to library users (ll_vm_internal.h).
Definition LambLisp.h:1207
Definition ll_platform_generic.h:725
int peek() override
One byte of pushback, which is all Stream promises. LambStdioClass has no peek of its own.
Definition ll_llarduino_print.cpp:130
int ll_llarduino_pin_mode(int pin)
Definition ll_llarduino_null.cpp:250
size_t println()
CRLF, as Arduino does – not "\n".
Definition ll_llarduino_print.cpp:82
size_t printf(const char *fmt,...) CHECKPRINTF_pos2
HardwareSerial::printf, used by LL itself.
Definition ll_llarduino_print.cpp:93
void pinMode(int pin, int mode)
Public Arduino surface – one line each, straight through the table.
Definition ll_llarduino_null.cpp:241
int available() override
Definition ll_llarduino_print.cpp:117
WiFiClass * LL_WiFi
Definition ll_xmop3_WiFi.cpp:31
void ll_wifi_boot_reserve()
Definition ll_xmop3_WiFi.cpp:587
A board's panel: geometry, model, and the five operations. See the note above on NULL.
Definition ll_platform_generic.h:1654
const char * name
"st7789-240x240-spi3", "co5300-410x502-qspi", "rgb565-480x480-par16"
Definition ll_platform_generic.h:1655
bool(* init)(Lamb &lamb)
bring up bus + controller; idempotent
Definition ll_platform_generic.h:1658
LL_PanelModel model
PUSH or SCAN – branch on this, not on the name.
Definition ll_platform_generic.h:1657
void(* set_brightness)(Lamb &lamb, int percent)
0..100, or NULL if the panel has none
Definition ll_platform_generic.h:1662
int h
panel geometry in pixels
Definition ll_platform_generic.h:1656
void(* blit)(Lamb &lamb, int x, int y, int w, int h, const uint16_t *src)
PUSH only; NULL on SCAN.
Definition ll_platform_generic.h:1660
void(* fill)(Lamb &lamb, int x, int y, int w, int h, uint16_t color)
filled rect, RGB565
Definition ll_platform_generic.h:1659
void(* on_off)(Lamb &lamb, bool on)
display on/off, or NULL
Definition ll_platform_generic.h:1663