Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,19 @@
(load "@lib/gcc.l")
(gcc "str" NIL # The 'gcc' function passes all text
'duptest ) # until /**/ to the C compiler
any duptest(any ex) {
any x = evSym(cdr(ex)); // Accept a symbol (string)
char str[bufSize(x)]; // Create a buffer to unpack the name
char *s;
bufString(x, str); // Upack the string
s = strdup(str); // Make a duplicate
x = mkStr(s); // Build a new Lisp string
free(s); // Dispose the duplicate
return x;
}
/**/
(println 'Duplicate (duptest "Hello world!"))

View file

@ -0,0 +1,20 @@
/*
How to create the shared lib/so file:
gcc -c -Wall -Werror -fPIC duptest.c
gcc -shared -o duptest.so duptest.o -Wno-undef
*/
#include <stdlib.h>
#include <string.h>
extern char * duptest(char * str);
char * duptest(char * str) {
static char * s;
free(s); // We simply dispose the result of the last call
return s = strdup(str);
}
int main() {
}

View file

@ -0,0 +1,5 @@
(prinl "Calling custom so/dll library...")
(set 'A NIL)
(set 'A (native "./duptest.so" "duptest" 'S "abc"))
(prinl "A=" A)
(when (not (= A NIL)) (prinl "Success!"))