From ff266c88629bc7efc9e73bfdb5afc0c9322027a2 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Thu, 8 Aug 2019 18:19:48 +0300 Subject: [PATCH] Delete attic directory --- attic/s.c | 212 ------------------------------------------------ attic/scrap.c | 107 ------------------------ attic/scrap.lsp | 108 ------------------------ 3 files changed, 427 deletions(-) delete mode 100644 attic/s.c delete mode 100644 attic/scrap.c delete mode 100644 attic/scrap.lsp diff --git a/attic/s.c b/attic/s.c deleted file mode 100644 index 63b2b24..0000000 --- a/attic/s.c +++ /dev/null @@ -1,212 +0,0 @@ -#include - -struct _b { - char a; - short b:9; -}; - -struct _bb { - char a; - int :0; - int b:10; - int :0; - int b0:10; - int :0; - int b1:10; - int :0; - int b2:10; - int :0; - int b4:30; - char c; -}; - -union _cc { - struct { - char a; - int b:1; // bit 8 - int b1:1; // bit 9 - int b2:24; // bits 32..55 - char c; - }; - unsigned long long ull; -}; - -union _cc2 { - struct { - char a; - int b:24; // bit 8 - int b1:1; - int b2:1; - char c; - }; - unsigned long long ull; -}; - -union _dd { - struct { - int a0:10; - int a1:10; - int a2:10; - int a3:10; - int a4:10; - }; - struct { - unsigned long long ull; - }; -}; - -struct _ee { - short s:9; - short j:9; - char c; -}; - -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -typedef int int32_t; -typedef unsigned int uint32_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef char int8_t; -typedef unsigned char uint8_t; - -#define lomask(type,n) (type)((((type)1)<<(n))-1) - -uint64_t get_u_bitfield(char *ptr, int typesz, int boffs, int blen) -{ - uint64_t i8; - uint32_t i4; - uint16_t i2; - uint8_t i1; - - switch (typesz) { - case 8: - i8 = *(uint64_t*)ptr; - return (i8>>boffs) & lomask(uint64_t,blen); - case 4: - i4 = *(uint32_t*)ptr; - return (i4>>boffs) & lomask(uint32_t,blen); - case 2: - i2 = *(uint16_t*)ptr; - return (i2>>boffs) & lomask(uint16_t,blen); - case 1: - i1 = *(uint8_t*)ptr; - return (i1>>boffs) & lomask(uint8_t,blen); - } - //error - return 0; -} - -int64_t get_s_bitfield(char *ptr, int typesz, int boffs, int blen) -{ - int64_t i8; - int32_t i4; - int16_t i2; - int8_t i1; - - switch (typesz) { - case 8: - i8 = *(int64_t*)ptr; - return (i8<<(64-boffs-blen))>>(64-blen); - case 4: - i4 = *(int32_t*)ptr; - return (i4<<(32-boffs-blen))>>(32-blen); - case 2: - i2 = *(int16_t*)ptr; - return (i2<<(16-boffs-blen))>>(16-blen); - case 1: - i1 = *(int8_t*)ptr; - return (i1<<(8-boffs-blen))>>(8-blen); - } - //error - return 0; -} - -void set_bitfield(char *ptr, int typesz, int boffs, int blen, uint64_t v) -{ - uint64_t i8, m8; - uint32_t i4, m4; - uint16_t i2, m2; - uint8_t i1, m1; - - switch (typesz) { - case 8: - m8 = lomask(uint64_t,blen)<\n"); -} - -#else - PUSH(NIL); - PUSH(NIL); - value_t *rest = &Stack[SP-1]; - // build list of rest arguments - // we have to build it forwards, which is tricky - while (iscons(v)) { - v = eval(car_(v)); - PUSH(v); - v = cons_(&Stack[SP-1], &NIL); - POP(); - if (iscons(*rest)) - cdr_(*rest) = v; - else - Stack[SP-2] = v; - *rest = v; - v = Stack[saveSP] = cdr_(Stack[saveSP]); - } - POP(); -#endif - // this version uses collective allocation. about 7-10% - // faster for lists with > 2 elements, but uses more - // stack space - i = SP; - while (iscons(v)) { - v = eval(car_(v)); - PUSH(v); - v = Stack[saveSP] = cdr_(Stack[saveSP]); - } - if ((int)SP==i) { - PUSH(NIL); - } - else { - e = v = cons_reserve(nargs=(SP-i)); - for(; i < (int)SP; i++) { - car_(v) = Stack[i]; - v = cdr_(v); - } - POPN(nargs); - PUSH(e); - } - -value_t list_to_vector(value_t l) -{ - value_t v; - size_t n = llength(l), i=0; - v = alloc_vector(n, 0); - while (iscons(l)) { - vector_elt(v,i) = car_(l); - i++; - l = cdr_(l); - } - return v; -} diff --git a/attic/scrap.lsp b/attic/scrap.lsp deleted file mode 100644 index dadb9d8..0000000 --- a/attic/scrap.lsp +++ /dev/null @@ -1,108 +0,0 @@ -; -*- scheme -*- -; (try expr -; (catch (type-error e) . exprs) -; (catch (io-error e) . exprs) -; (catch (e) . exprs) -; (finally . exprs)) -(define-macro (try expr . forms) - (let* ((e (gensym)) - (reraised (gensym)) - (final (f-body (cdr (or (assq 'finally forms) '(()))))) - (catches (filter (lambda (f) (eq (car f) 'catch)) forms)) - (catchblock `(cond - ,.(map (lambda (catc) - (let* ((specific (cdr (cadr catc))) - (extype (caadr catc)) - (var (if specific (car specific) - extype)) - (todo (cddr catc))) - `(,(if specific - ; exception matching logic - `(or (eq ,e ',extype) - (and (pair? ,e) - (eq (car ,e) - ',extype))) - #t); (catch (e) ...), match anything - (let ((,var ,e)) (begin ,@todo))))) - catches) - (#t (raise ,e))))) ; no matches, reraise - (if final - (if catches - ; form with both catch and finally - `(prog1 (trycatch ,expr - (lambda (,e) - (trycatch ,catchblock - (lambda (,reraised) - (begin ,final - (raise ,reraised)))))) - ,final) - ; finally only; same as unwind-protect - `(prog1 (trycatch ,expr (lambda (,e) - (begin ,final (raise ,e)))) - ,final)) - ; catch, no finally - `(trycatch ,expr (lambda (,e) ,catchblock))))) - -; setf -; expands (setf (place x ...) v) to (mutator (f x ...) v) -; (mutator (identity x ...) v) is interpreted as (mutator x ... v) -(set! *setf-place-list* - ; place mutator f - '((car rplaca identity) - (cdr rplacd identity) - (caar rplaca car) - (cadr rplaca cdr) - (cdar rplacd car) - (cddr rplacd cdr) - (caaar rplaca caar) - (caadr rplaca cadr) - (cadar rplaca cdar) - (caddr rplaca cddr) - (cdaar rplacd caar) - (cdadr rplacd cadr) - (cddar rplacd cdar) - (cdddr rplacd cddr) - (list-ref rplaca nthcdr) - (get put! identity) - (aref aset! identity) - (symbol-syntax set-syntax! identity))) - -(define (setf-place-mutator place val) - (if (symbol? place) - (list 'set! place val) - (let ((mutator (assq (car place) *setf-place-list*))) - (if (null? mutator) - (error "setf: unknown place " (car place)) - (if (eq (caddr mutator) 'identity) - (cons (cadr mutator) (append (cdr place) (list val))) - (list (cadr mutator) - (cons (caddr mutator) (cdr place)) - val)))))) - -(define-macro (setf . args) - (f-body - ((label setf- - (lambda (args) - (if (null? args) - () - (cons (setf-place-mutator (car args) (cadr args)) - (setf- (cddr args)))))) - args))) - -(define-macro (labels binds . body) - (cons (list 'lambda (map car binds) - (f-body - (nconc (map (lambda (b) - (list 'set! (car b) (cons 'lambda (cdr b)))) - binds) - body))) - (map (lambda (x) #f) binds))) - - (define (evalhead e env) - (if (and (symbol? e) - (or (constant? e) - (and (not (memq e env)) - (bound? e) - (builtin? (eval e))))) - (eval e) - e))