Skip to content

Commit 71ee02a

Browse files
committed
- safe some memory buffers, only 5K free...
- flag to be able to include/not IMACS in common.c - rename stackUsed to stackLeft - rename a.out to esp-lisp - made ./run only run
1 parent fb76fa7 commit 71ee02a

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
lines changed

common.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ int iscomment(char* s) {
326326
}
327327

328328
// line is increased in increments of this
329-
#define MAXLINE 1024
329+
#define MAXLINE 256
330330

331331
int process_file(void* envp, char* filename, process_input process, int verbosity) {
332332
FILE *file = fopen(filename, "r");
@@ -381,15 +381,21 @@ int process_file(void* envp, char* filename, process_input process, int verbosit
381381
return ret;
382382
}
383383

384+
#define IMACS
385+
384386
#undef CTRL // shadows something from ttyefault.h (included termios.h)
385387
#define NO_MAIN
386388
#ifndef UNIX
387389
#define OTA
388390
#endif
389391
#define BUFF_SIZE 1024
392+
393+
#ifdef IMACS
390394
#include "imacs/imacs.c"
395+
#endif
391396

392397
char* editor(char* s, char* title) {
398+
#ifdef IMACS
393399
imacs_buffer b;
394400
imacs_init(&b, s, 0);
395401
b.filename = title ? title : "esp-lisp-data";
@@ -402,6 +408,6 @@ char* editor(char* s, char* title) {
402408
// TODO: a imacs_clean()?
403409
free(b.buff);
404410
b.buff = NULL;
405-
411+
#endif
406412
return s;
407413
}

esplisp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void print_memory_info(int verbose) {
112112
// The value returned is the high water mark in words (for example,
113113
// on a 32 bit machine a return value of 1 would indicate that
114114
// 4 bytes of stack were unused)
115-
printf("stackUsed=%lu ", uxTaskGetStackHighWaterMark(NULL));
115+
printf("stackLeft=%lu ", uxTaskGetStackHighWaterMark(NULL));
116116
if (startMem) printf("startMem=%u ", startMem);
117117
if (startTask) printf("startTask=%u ", startTask);
118118
if (afterInit) printf("afterInit=%u ", afterInit);
@@ -236,6 +236,8 @@ unsigned int randomized() {
236236

237237
// stack = 2048
238238
// used_count=73 cons_count=333 free=21896 USED=16 bytes startMem=37636 startTask=28360 startTask=22604
239+
// stack = 2048 @ 2016-08-22:
240+
// used_count=11 cons_count=1734 free=5336 USED=12 bytes stackUsed=1525 startMem=38780 startTask=26416 afterInit=6460
239241

240242
// stack = 1024
241243
// used_count=72 cons_count=354 free=26612 USED=16 bytes startMem=37636 startTask=32456 startTask=26700
@@ -244,8 +246,8 @@ unsigned int randomized() {
244246
// used_count=72 cons_count=354 free=28660 USED=16 bytes startMem=37636 startTask=34504 startTask=28748
245247
// a recurse -> 52 deep
246248

247-
//(- 31768 28748) = 3020 cost of a task of 512 bytes
248-
//(- 31768 22604) = 9164 cost of a task with 2048 bytes
249+
//(- 31768 28748) = 3020 cost of a task with 512 entries (* 512 4) = 2048 bytes (1k extra)
250+
//(- 31768 22604) = 9164 cost of a task with 2048 entries (* 2048 4) = 8192 bytes (1k extra)
249251
//
250252
//(- 37636 31768) = 5668
251253
//(- 37636 34504) = 3132 for 512

httpd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "compat.h"
1717

18-
#define BUFSIZE 1024
18+
#define BUFSIZE 512
1919
#define MAXQUEUE 10
2020

2121
// consider looking at using something that handles post

imacs

Submodule imacs updated 1 file

lisp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ PRIM funame(lisp f);
177177
lisp* global_envp = NULL;
178178

179179
// big value ok as it's used mostly no inside evaluation but outside at toplevel
180-
#define READLINE_MAXLEN 1024
180+
#define READLINE_MAXLEN 512
181181

182182
// set to 1 to get GC tracing messages
183183
// adding real debugging - http://software-lab.de/doc/tut.html#dbg

run

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ stty sane
3333
popd
3434

3535
echo "--- compiling opt ---"
36-
cp tlisp.ccc tlisp.c && gcc -m32 -O2 -DUNIX=1 tlisp.c common.c httpd.c symbols.c lisp.c -o opt ; rm tlisp.c
36+
#cp tlisp.ccc tlisp.c && gcc -m32 -O2 -DUNIX=1 tlisp.c common.c httpd.c symbols.c lisp.c -o opt ; rm tlisp.c
3737

3838
###cp tlisp.ccc tlisp.c && gcc --enable-checking -v -da -Q -g -O0 -DTEST=1 tlisp.c lisp.c && ./a.out ; rm tlisp.c
3939

40-
echo "--- compile for ESP8266 ---"
41-
echo
42-
echo "----------------------------------------------------------------------"
43-
source add-path && make
44-
echo "----------------------------------------------------------------------"
45-
echo
40+
#echo "--- compile for ESP8266 ---"
41+
#echo
42+
#echo "----------------------------------------------------------------------"
43+
#source add-path && make
44+
#echo "----------------------------------------------------------------------"
45+
#echo

0 commit comments

Comments
 (0)