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)
186#ifndef LL_GC_BUDGET_WHEN_MAXED
187#define LL_GC_BUDGET_WHEN_MAXED 0
190#ifndef LL_NCG_EXEC_POOL_BYTES
191 #if LL_NCG_RISCV_POOL
192 #define LL_NCG_EXEC_POOL_BYTES (32UL * 1024)
194 #define LL_NCG_EXEC_POOL_BYTES (32UL * 1024)
197 #define LL_NCG_EXEC_POOL_BYTES (32UL * 1024)
199 #define LL_NCG_EXEC_POOL_BYTES (32UL * 1024)
204#ifndef LL_ROOTSTACK_MAX
207 #define LL_ROOTSTACK_MAX 131072
209 #define LL_ROOTSTACK_MAX 262144
211 #define LL_ROOTSTACK_MAX 65536
217#ifndef LL_ROOTSTACK_SLACK
218#define LL_ROOTSTACK_SLACK 256
232#ifndef LL_ROOTSTACK_INIT
233 #define LL_ROOTSTACK_INIT 256
235#ifndef LL_MARKSTACK_INIT
236 #define LL_MARKSTACK_INIT 256
241#ifndef LL_EVAL_ROOT_DEPTH_MAX
242#define LL_EVAL_ROOT_DEPTH_MAX (LL_ROOTSTACK_MAX - 536)
283#ifndef LL_ROOT_HIGH_WATER
285 #define LL_ROOT_HIGH_WATER 1
287 #define LL_ROOT_HIGH_WATER 0
317#ifndef LL_ROOT_BALANCE
319 #define LL_ROOT_BALANCE 1
321 #define LL_ROOT_BALANCE 0
338#ifndef LL_HAVE_BACKTRACE
339 #if defined(__GLIBC__) && !LL_ESP32
340 #define LL_HAVE_BACKTRACE 1
342 #define LL_HAVE_BACKTRACE 0
364#ifndef LL_BIGNUM_LIMB_BITS
365#define LL_BIGNUM_LIMB_BITS 32
368#ifndef LL_BIGNUM_STRICT_RT
369#define LL_BIGNUM_STRICT_RT 0
389#ifndef LL_ESP32_S3_DEVKIT_C
390#define LL_ESP32_S3_DEVKIT_C 0
392#ifndef LL_ESP32S3_N8R2
393#define LL_ESP32S3_N8R2 0
395#ifndef LL_Freenove_4WD_Car_Kit_ESP32
396#define LL_Freenove_4WD_Car_Kit_ESP32 0
398#ifndef LL_Freenove_ESP32_WROVER
399#define LL_Freenove_ESP32_WROVER 0
402#define LL_ESP32_N4R4 0
439 #define LL_NETWORK ((LL_WIFI) || (LL_POSIX))
444#define LL_POSIX_NET ((LL_POSIX) && (LL_NETWORK))
450 #define LL_TERMIOS (LL_POSIX)
542#ifndef LL_AUTOCOMPILE
543 #define LL_AUTOCOMPILE 1
594unsigned long millis();
595unsigned long micros();
609void delay_ms(
unsigned long ms);
611static void delay(
unsigned long ms) { delay_ms(ms); }
625#define INPUT_PULLUP 0x2
628void pinMode(
int pin,
int mode);
629void digitalWrite(
int pin,
int val);
630int digitalRead(
int pin);
631void analogWrite(
int pin,
int val);
632int analogRead(
int pin);
633void tone(
int pin,
unsigned int freq);
634void tone(
int pin,
unsigned int freq,
unsigned long dur);
636void delayMicroseconds(
unsigned long us);
641int ll_llarduino_pin_duty(
int pin);
642int ll_llarduino_pin_tone(
int pin);
643int ll_llarduino_npins();
644const char *ll_llarduino_backend();
701 LL_String() { _init(); set(
""); }
702 LL_String(
const char *other) { _init(); set(other); }
703 LL_String(
const char *other,
int n) { _init(); set(other, n); }
704 LL_String(
const LL_String &other) { _init(); set(other.ptr, other.len); }
706 ~LL_String() {
if (ptr) {
delete[] ptr; ptr = 0; } len = cap = 0; }
708 void set(
const char *s) { set(s, s ? (
int) strlen(s) : 0); }
710 void set(
const char *s,
int n) {
711 if (!s || n <= 0) { _ensure(0); ptr[0] =
'\0'; len = 0;
return; }
712 if (ptr && s >= ptr && s <= ptr + len) {
713 const int off = (int) (s - ptr);
714 memmove(ptr, ptr + off, (
size_t) n);
718 memmove(ptr, s, (
size_t) n);
724 LL_String concat(
const char *s1,
const char *s2) {
726 const int n1 = s1 ? (int) strlen(s1) : 0;
727 const int n2 = s2 ? (int) strlen(s2) : 0;
729 if (n1) memmove(r.ptr, s1, (
size_t) n1);
730 if (n2) memmove(r.ptr + n1, s2, (
size_t) n2);
731 r.ptr[n1 + n2] =
'\0';
738 const int n1 = (int) strlen(s1);
739 const bool self = (ptr && s1 >= ptr && s1 <= ptr + len);
740 const int off = self ? (int) (s1 - ptr) : 0;
742 memmove(ptr + len, self ? ptr + off : s1, (
size_t) n1);
760 LL_String &operator=(
const char *other) { set(other);
return *
this; }
761 LL_String &operator=(
const LL_String &other) {
if (
this != &other) set(other.ptr, other.len);
return *
this; }
763 bool operator==(
const char *other) {
return strcmp(ptr, other) == 0; }
764 bool operator!=(
const char *other) {
return strcmp(ptr, other) != 0; }
765 bool operator==(
const LL_String &other) {
return strcmp(ptr, other.ptr) == 0; }
766 bool operator!=(
const LL_String &other) {
return strcmp(ptr, other.ptr) != 0; }
767 char &operator[](
int ix) {
return ptr[ix]; }
769 LL_String operator+(
const char *other) {
return concat(ptr, other); }
770 LL_String operator+(
const LL_String &other) {
return concat(ptr, other.ptr); }
771 LL_String operator+(
char c) {
char cstr[2]; cstr[0] = c; cstr[1] =
'\0';
return concat(ptr, cstr); }
773 LL_String &operator+=(
const char *other) {
return append(other); }
774 LL_String &operator+=(
const LL_String &other) {
return append(other.ptr); }
775 LL_String &operator+=(
char c) {
return append(c); }
777 char *c_str()
const {
return ptr; }
781 void _init() { ptr = 0; len = 0; cap = 0; }
785 void _ensure(
int need) {
786 if (cap >= need + 1)
return;
787 int ncap = cap ? cap : 16;
788 while (ncap < need + 1) ncap += ncap;
790 char *np =
new char[ncap];
791 if (ptr) { memmove(np, ptr, (
size_t) len + 1);
delete[] ptr; }
792 else { np[0] =
'\0'; }
807#define NOTUSED __attribute__((__unused__))
808#define INLINE __attribute__((__inline__))
809#define NOINLINE __attribute__((__noinline__))
810#define CHECKPRINTF __attribute__((format(printf, 1, 2)))
811#define CHECKPRINTF_pos2 __attribute__((format(printf, 2, 3)))
842 virtual size_t write(uint8_t c) = 0;
843 virtual size_t write(
const uint8_t *buf,
size_t n);
844 size_t write(
const char *s);
845 size_t print(
char c);
846 size_t print(
const char *s);
847 size_t print(
const String &s);
848 size_t print(
int n,
int base = 10);
849 size_t print(
long n,
int base = 10);
850 size_t print(
unsigned long n,
int base = 10);
851 size_t print(
double v,
int digits = 2);
855 size_t println(
const String &s);
856 size_t println(
int n,
int base = 10);
857 size_t println(
long n,
int base = 10);
858 size_t println(
unsigned long n,
int base = 10);
859 size_t println(
double v,
int digits = 2);
860 size_t printf(
const char *fmt, ...) CHECKPRINTF_pos2;
863class Stream :
public Print {
865 virtual int available() = 0;
866 virtual int read() = 0;
867 virtual int peek() = 0;
868 virtual void flush() {}
873class LLArduinoSerial :
public Stream {
876 LLArduinoSerial() : _peeked(-1) {}
877 void begin(
unsigned long baud = 115200);
880 int availableForWrite();
883 void flush()
override;
884 size_t write(uint8_t c)
override;
896#if LL_ARDUINO || LL_ESP_ARDUINO
897const char *ll_llarduino_fmt_int(
long v,
int base);
898const char *ll_llarduino_fmt_real(
double v,
int digits);
899const char *ll_llarduino_eol();
902#define CHECKPRINTF_pos3 __attribute__((format(printf, 3, 4)))
903#define CHECKPRINTF_pos4 __attribute__((format(printf, 4, 5)))
907#if !defined(IRAM_ATTR)
910#if !defined(DRAM_ATTR)
951#ifndef LL_STDIO_RX_BUFSIZE
952#define LL_STDIO_RX_BUFSIZE 0
955const unsigned long toString_MAX_LENGTH = 8192;
958const unsigned long LL_ERRFORM_MAX = 400;
965const unsigned long LL_ENVFRAME_MAX = 32;
982const unsigned long LL_PRINT_LIST_MAX = 4096;
983String toString(
const char *fmt, ...) CHECKPRINTF;
987#define ME(_me_) NOTUSED const char me[] = _me_
988#define ll_isdef(sym) (#sym[0])
990void global_printf(
const char *fmt, ...);
1006void global_spill_begin();
1021void global_term_quiet(
bool echo,
bool logs);
1034void global_term_push_line(
const char *s);
1058typedef unsigned char Byte_t;
1070typedef int32_t ll_codepoint_t;
1072typedef Char_t
const *Charst_t;
1073typedef Byte_t
const *Bytest_t;
1074typedef Char_t *CharVec_t;
1075typedef Byte_t *ByteVec_t;
1094void *ll_payload_alloc_bytes(
size_t nbytes);
1095void ll_payload_free(
void *p);
1098template <
typename T>
static inline T *ll_payload_new(
size_t n)
1100 return (T *) ll_payload_alloc_bytes(n *
sizeof(T));
1136void *ll_dram_alloc_bytes(
size_t nbytes);
1137void ll_dram_free(
void *p);
1162typedef uintptr_t Word_t;
1164static_assert(
sizeof(Word_t) >=
sizeof(
void *),
1165 "Word_t must hold a pointer -- see the P174 note above; LLP64 (Windows x64) breaks "
1166 "the old `unsigned long` spelling because long is 32 bits there and pointers are 64.");
1168typedef int32_t LL_int32;
1181inline int ll_u8_seqlen(
unsigned char b0)
1183 if (b0 < 0x80)
return 1;
1184 if ((b0 & 0xE0) == 0xC0)
return 2;
1185 if ((b0 & 0xF0) == 0xE0)
return 3;
1186 if ((b0 & 0xF8) == 0xF0)
return 4;
1192inline ll_codepoint_t ll_u8_decode(
const char *p,
int *nb)
1194 unsigned char b0 = (
unsigned char) p[0];
1195 int n = ll_u8_seqlen(b0);
1197 if (n == 1)
return (ll_codepoint_t) b0;
1198 ll_codepoint_t cp = b0 & (0xFF >> (n + 1));
1199 for (
int i = 1; i < n; i++) {
1200 unsigned char c = (
unsigned char) p[i];
1201 if ((c & 0xC0) != 0x80) {
if (nb) *nb = 1;
return (ll_codepoint_t) b0; }
1202 cp = (cp << 6) | (c & 0x3F);
1208inline int ll_u8_encode(ll_codepoint_t cp,
char *out)
1210 if (cp < 0x80) { out[0] = (char) cp;
return 1; }
1211 if (cp < 0x800) { out[0] = (char)(0xC0 | (cp >> 6)); out[1] = (char)(0x80 | (cp & 0x3F));
return 2; }
1212 if (cp < 0x10000) { out[0] = (char)(0xE0 | (cp >> 12)); out[1] = (char)(0x80 | ((cp >> 6) & 0x3F));
1213 out[2] = (char)(0x80 | (cp & 0x3F));
return 3; }
1214 out[0] = (char)(0xF0 | (cp >> 18)); out[1] = (char)(0x80 | ((cp >> 12) & 0x3F));
1215 out[2] = (char)(0x80 | ((cp >> 6) & 0x3F)); out[3] = (char)(0x80 | (cp & 0x3F));
return 4;
1219inline LL_int32 ll_u8_strlen(
const char *s)
1222 for (
const char *p = s; *p; n++) p += ll_u8_seqlen((
unsigned char) *p);
1232inline LL_int32 ll_u8_strlen_n(
const char *s, LL_int32 nbytes)
1235 for (LL_int32 i = 0; i < nbytes; n++) i += ll_u8_seqlen((
unsigned char) s[i]);
1241inline const char *ll_u8_index_n(
const char *s, LL_int32 nbytes, LL_int32 k)
1244 for (LL_int32 c = 0; c < k; c++) {
1245 if (i >= nbytes)
return 0;
1246 i += ll_u8_seqlen((
unsigned char) s[i]);
1248 return (i <= nbytes) ? (s + i) : 0;
1253inline const char *ll_u8_index(
const char *s, LL_int32 k)
1256 for (LL_int32 i = 0; i < k; i++) {
1258 p += ll_u8_seqlen((
unsigned char) *p);
1264typedef int64_t LL_int64;
1265typedef float LL_float32;
1266typedef double LL_float64;
1268static_assert(
sizeof(Word_t) ==
sizeof(Ptr_t),
"Word_t size must be == Ptr_t size\n");
1269static_assert(
sizeof(Word_t) >=
sizeof(LL_int32),
"Word_t size must be >= LL_int32 size\n");
1270static_assert(
sizeof(LL_float32) == 4,
"LL_float32 must be 4 bytes\n");
1271static_assert(
sizeof(LL_float64) == 8,
"LL_float64 must be 8 bytes\n");
1275class AsciiConverter {
1278 char *dec(Word_t n) {
1279 char *ptr = slot_end();
1291 char *dec(LL_int32 n) {
1292 if (n >= 0)
return dec((Word_t) n);
1293 if (n == INT32_MIN)
return dec((LL_int64) n);
1294 char *ptr = dec(-n);
1313 template <
typename T>
1314 typename std::enable_if<std::is_same<T, int>::value && !std::is_same<LL_int32, int>::value,
1316 dec(T n) {
return dec((LL_int32) n); }
1318 char *dec(LL_int64 n) {
1320 char *ptr = slot_end();
1322 uint64_t uv = neg ? (n == INT64_MIN ? (uint64_t) 9223372036854775808ULL : (uint64_t) -n)
1324 do { *--ptr = (char)(
'0' + (uv % 10)); uv /= 10; }
while (uv);
1325 if (neg) *--ptr =
'-';
1329 char *hex(Word_t n) {
1330 char *ptr = slot_end();
1331 LL_int32 nibs =
sizeof(Word_t) * 2;
1335 Word_t d = n & 0x0f;
1337 char c = (d < 10) ? (d +
'0') : (d - 10 +
'a');
1344 char *dec(LL_float32 n) {
1345 char *b = slot_base();
1346 snprintf(b, SLOT,
"%f", (LL_float64) n);
1385 static const LL_int32 SLOTS = 16;
1386 static const LL_int32 SLOT = 64;
1387 static_assert(SLOT >= 3 + 20,
"dec(LL_int64): sign + 20 digits + NUL");
1388 static_assert(SLOT >= 2 +
sizeof(Word_t) * 2,
"hex(Word_t): nibbles + NUL");
1389 static_assert(SLOT >= 48,
"dec(LL_float32): %f of 3.4e38 needs 47 chars");
1390 char buf[SLOTS][SLOT];
1392 char *slot_base() { next = (next + 1) % SLOTS;
return buf[next]; }
1393 char *slot_end() {
char *b = slot_base(); b[SLOT - 1] =
'\0';
return &b[SLOT - 1]; }
1396extern AsciiConverter ascii;
1404 ~LambPlatform() { end(); }
1413 void identification(
void);
1415 LL_int32 free_heap();
1424 LL_int32 free_internal();
1425 LL_int32 free_dma();
1426 LL_int32 largest_free_internal();
1427 LL_int32 largest_free_dma();
1428 LL_int32 cell_pool_free();
1448 void *cell_block_alloc(
unsigned long nbytes);
1449 void cell_block_free(
void *blk);
1459 const char *mem_placement(
void *p);
1472 LL_int64 fs_total();
1474 LL_int32 free_stack();
1475 Bool_t heap_integrity_check(Bool_t complain=
false);
1478 LL_float32 rand11() {
1479 const int max_int = (~((
unsigned int) 0)) >> 1;
1480 const int min_int = -max_int - 1;
1481 const LL_float32 min = (LL_float32) min_int;
1484 rand((
byte *) &n,
sizeof(n));
1488 LL_float32 rand01() {
return (rand11() + 1.0) / 2.0; }
1490 void rand(
byte *buf, LL_int32 len);
1491 void rand11(LL_float32 *buf, LL_int32 n) {
while (n--) *buf++ = rand11(); }
1492 void rand01(LL_float32 *buf, LL_int32 n) {
while (n--) *buf++ = rand01(); }
1494 LL_int32 loop_elapsed_ms() {
return millis() - loop_start_ms; }
1495 LL_int32 loop_elapsed_us() {
return micros() - loop_start_us; }
1500 LL_int32 loop_start_ms;
1501 LL_int32 loop_start_us;
1504extern LambPlatform lambPlatform;
1509#include "LittleFS.h"
1510typedef File File_Native;
1515typedef FILE* File_Native;
1535 bool isOpen() {
return _path !=
""; }
1538 int seek(
unsigned long target,
int whence=SEEK_SET);
1543 int read(
byte *b,
int n) {
1547 if (ch == EOF)
return nread;
1553 int read(
char *s,
int n) {
return read((
byte *) s, n); }
1554 int write(
const byte *b,
int n) {
while (n--) write(*b++);
return n; }
1555 int write(
const char *s,
int n) {
while (n--) write((
byte) *s++);
return n; }
1558 File_Native _theFile;
1595bool ll_fastram_reserve(
const char *tag,
size_t bytes);
1618bool ll_fastram_reserve_pinned(
const char *tag,
size_t bytes);
1621void ll_fastram_release(
const char *tag);
1624void ll_fastram_release_unclaimed();
1648size_t ll_win_self_exe_path(
char *buf,
size_t cap);
1657int ll_win_mkdir(
const char *path,
int mode);
1672int ll_win_set_system_time(
long long utc_seconds);
1711#ifndef LL_PANEL_ST7789_EYE
1712 #define LL_PANEL_ST7789_EYE 0
1720#ifndef LL_PANEL_ST7701_AITRIP
1721 #define LL_PANEL_ST7701_AITRIP 0
1728#if LL_PANEL_ST7789_EYE || LL_PANEL_ST7701_AITRIP
1746 void (*
fill)(
Lamb &lamb,
int x,
int y,
int w,
int h, uint16_t color);
1747 void (*
blit)(
Lamb &lamb,
int x,
int y,
int w,
int h,
const uint16_t *src);
1748 uint16_t *(*fb)(void);
1754const LL_Panel *ll_panel_active(
void);
1757void ll_panel_register(
const LL_Panel *p);
1760bool ll_panel_ready(
void);
1766void ll_panel_blit_rgb565(
Lamb &lamb,
int x,
int y,
int w,
int h,
const uint16_t *src);
1778 LL_File *open(
const char *path,
const char *mode);
1779 bool exists(
const char *path);
1780 int rm(
const char *path);
1781 int mv(
const char *from,
const char *to);
1782 int mkdir(
const char *path);
1794extern TwoWire *LL_Wire;
1799#include "WiFiClientSecure.h"
1812 int setTxBufferSize(
int n);
1813 int setRxBufferSize(
int n);
1823 void begin(
void) { begin(115200); }
1824 void begin(
unsigned long baudrate);
1826 int available(
void);
1827 int availableForWrite(
void);
1829 int write(uint8_t c);
1830 int write(
char c) {
return write((uint8_t) c); }
1834 int read(
byte *buf,
int max) {
1838 if (b == EOF)
break;
1844 int read(
char *s,
int max) {
return read((uint8_t *) s, max); }
1845 int write(
const char *s,
int n) {
return write((uint8_t *) s, n); }
1846 int write(
const byte *b,
size_t n) {
int i=n;
while (i--) write(*b++);
return n; }
1847 int write(
const char *s) {
int i=0;
while (*s) { write(*s++); i++; }
return i; }
1849 operator bool() {
return true; }
1854typedef byte uuid_t[16];
1857#define ll_once(_once_something) do { \
1858 static bool _visited_ = false; \
1861 { _once_something; } \
1868#define ll_every(_every_so_often_ms, _every_something_to_do) do { \
1869 static unsigned long _every_next = 0; \
1870 unsigned long _every_now = millis(); \
1871 if (_every_now >= _every_next) { \
1872 { _every_something_to_do; } \
1873 _every_next = _every_now + (_every_so_often_ms); \
1905void embedded_debug_catcher();
1906#define ll_debug_catcher embedded_debug_catcher()
1911#define LAMB_SETTINGS_PATH "/Settings-Lamb.scm"
1912#define SETTINGS_PATH "/Settings.scm"
1914#define LAMB_SETTINGS_PATH "Settings-Lamb.scm"
1915#define SETTINGS_PATH "Settings.scm"
1957 LL_int32 rootstack_in_iram = 1;
1986void ll_pre_settings_write(LL_int32 boot_pending);
1988void ll_settings_boot_ok(
void);
2016extern LL_int32 ll_cell_block_size_effective;
2024extern LL_int32 ll_va_list_max;
2044extern const void *ll_catch_last_err;
2045extern int ll_catch_repeats;
2046#define LL_CATCH_REPEAT_LIMIT 4
2091#define LL_ERR_IS_USER_RAISE(__e__) \
2092 ((__e__)->type() == Cell::T_ERROR && strcmp((__e__)->error_get_chars(), "__raise__") == 0)
2117#define ll_catch(__code_before_rethrow__) \
2118 catch (std::bad_alloc &) { \
2119 Sexpr_t __err__ = NIL->mk_error("%s out of memory (C++ allocation failed)", me); \
2120 ll_catch_last_err = (const void *) __err__; \
2121 ll_catch_repeats = 1; \
2122 global_printf("\r[%d] %s ll_catch(): %s\n", millis(), me, __err__->error_get_chars()); \
2124 __code_before_rethrow__; \
2127 catch (Sexpr_t __err__) { \
2128 if (__err__->type() != Cell::T_ERROR) \
2129 throw NIL->mk_error("ll_catch() BUG in %s bad type %s", me, __err__->dump().c_str()); \
2131 if (!LL_ERR_IS_USER_RAISE(__err__)) { \
2132 if ((const void *) __err__ != ll_catch_last_err) { \
2133 ll_catch_last_err = (const void *) __err__; \
2134 ll_catch_repeats = 0; \
2136 if (++ll_catch_repeats <= LL_CATCH_REPEAT_LIMIT) \
2137 global_printf("\r[%d] %s ll_catch(): %s\n", millis(), me, __err__->error_get_chars()); \
2138 else if (ll_catch_repeats == LL_CATCH_REPEAT_LIMIT + 1) \
2139 global_printf("\r[%d] %s ll_catch(): ... same error still unwinding; further frames suppressed\n", millis(), me); \
2143 __code_before_rethrow__; \
2148#define ll_catch_terminal \
2149 catch (std::bad_alloc &) { \
2150 global_printf("\r[%d] %s ll_catch_terminal: out of memory (C++ allocation failed)\n", \
2154 catch (Sexpr_t __err__) { \
2159 if (LL_ERR_IS_USER_RAISE(__err__)) \
2160 global_printf("\r[%d] %s ll_catch_terminal: UNCAUGHT raise: %s\n", \
2161 millis(), me, __err__->error_get_irritants()->str().c_str()); \
2164 else if (__err__->type() != Cell::T_ERROR) \
2165 global_printf("\r[%d] %s ll_catch_terminal: non-error type %d\n", \
2166 millis(), me, __err__->type()); \
2168 global_printf("\r[%d] %s ll_catch_terminal: %s\n", \
2169 millis(), me, __err__->error_get_chars()); \
2201bool ll_term_ansi(
void);
2202void ll_term_ansi_set(
bool on);
2203bool ll_term_ansi_detect(
void);
2205int ll_win_enable_vt(
void);
2206void ll_win_yield_ms(
unsigned ms);
Definition ll_platform_generic.h:873
Definition ll_platform_generic.h:1776
Definition ll_platform_generic.h:1529
Definition ll_platform_generic.h:698
LL_String & append(char c)
Definition ll_platform_generic.h:751
void set(const char *s, int n)
Definition ll_platform_generic.h:710
LL_String & append(const char *s1)
Definition ll_platform_generic.h:736
int length() const
O(1) since [B834]; was a strlen on every call.
Definition ll_platform_generic.h:778
Definition ll_platform_generic.h:1810
bool set_input_callback(void(*cb)())
JIT exception-escape context; opaque to library users (ll_vm_internal.h).
Definition LambLisp.h:1367
Definition ll_platform_generic.h:839
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:251
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:242
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:589
A board's panel: geometry, model, and the five operations. See the note above on NULL.
Definition ll_platform_generic.h:1741
const char * name
"st7789-240x240-spi3", "co5300-410x502-qspi", "rgb565-480x480-par16"
Definition ll_platform_generic.h:1742
bool(* init)(Lamb &lamb)
bring up bus + controller; idempotent
Definition ll_platform_generic.h:1745
LL_PanelModel model
PUSH or SCAN – branch on this, not on the name.
Definition ll_platform_generic.h:1744
void(* set_brightness)(Lamb &lamb, int percent)
0..100, or NULL if the panel has none
Definition ll_platform_generic.h:1749
int h
panel geometry in pixels
Definition ll_platform_generic.h:1743
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:1747
void(* fill)(Lamb &lamb, int x, int y, int w, int h, uint16_t color)
filled rect, RGB565
Definition ll_platform_generic.h:1746
void(* on_off)(Lamb &lamb, bool on)
display on/off, or NULL
Definition ll_platform_generic.h:1750
Definition ll_platform_generic.h:1924
LL_int32 va_list_max
Definition ll_platform_generic.h:1963
LL_int32 extension_block_size
Definition ll_platform_generic.h:1926
LL_int32 gc_total_marked
Definition ll_platform_generic.h:1933
bool apply_key(const char *key, long val)
LL_int32 gc_pool_target
Definition ll_platform_generic.h:1942
LL_int32 cell_block_size
Cells in the initial GC block (8K default; perf pushes 16K to match comps).
Definition ll_platform_generic.h:1925
LL_int32 sint_in_iram
Definition ll_platform_generic.h:1956
LL_int32 boot_pending
Definition ll_platform_generic.h:1971
LL_int32 ncg_frame_pool_size
Definition ll_platform_generic.h:1943