diff --git a/docs/Nodes-threads-locks-links.md b/docs/Nodes-threads-locks-links.md index 8108168..1f2a9dd 100644 --- a/docs/Nodes-threads-locks-links.md +++ b/docs/Nodes-threads-locks-links.md @@ -119,7 +119,7 @@ We don't currently have any other mutable objects, but in future at least lazy o Secondly, reading from a namespace does not happen in a single clock tick, it takes quite a long time. So it's no good setting a lock bit on the namespace object itself and then immediately assuming that it's now mutable. A reading process could already have started, and be proceeding. -So what I think is, that we have a single top level function, `(::substrate:search-store key store return-key?)` (which we already sort of have in the 0.0.6 prototype, [here](https://www.journeyman.cc/post-scarcity/doc/html/intern_8c.html#a2189c0ab60e57a70adeb32aca99dbc43)). This searches a store (hashmap, namespace, association list, or hybrid association list) to find a binding for a key, and, having found that binding, then, if there is a namespace on the search path, checks whether the lock on the any namespace on the search path is set, and if it is, aborts the search and tries again; but otherwise returns either the key found (if `return-key?` is non-`nil`), or the value found otherwise. +So what I think is, that we have a single top level function, `(::substrate:search-store key store return-key?)` (which we already sort of have in the 0.0.6 prototype, [here](https://www.journeyman.cc/post-scarcity/doc/html/intern_8c.html#a2189c0ab60e57a70adeb32aca99dbc43)). This searches a store (hashmap, namespace, association list, or hybrid association list) to find a binding for a key, and, having found that binding, then, if there is a namespace on the search path, checks whether the lock on the any namespace on the search path is set, and it it is, aborts the search and tries again; but otherwise returns either the key found (if `return-key?` is non-`nil`), or the value found otherwise. This function implements the user-level Lisp functions `assoc`, `interned`, and `interned?`. It also implements *hashmap-in-function-position* and *keyword-in-function-position*, in so far as both of these are treated as calls to `assoc`. diff --git a/src/c/debug.h b/src/c/debug.h index 1f66a9f..dc833dd 100644 --- a/src/c/debug.h +++ b/src/c/debug.h @@ -17,11 +17,6 @@ #include #include -/* - * wide characters - */ -#include -#include /** * @brief Print messages debugging memory allocation. diff --git a/src/c/memory/header.h b/src/c/memory/header.h index 42fa488..429cda1 100644 --- a/src/c/memory/header.h +++ b/src/c/memory/header.h @@ -29,7 +29,7 @@ struct pso_header { char mnemonic[TAGLENGTH]; /** size class for this object */ uint8_t size_class; - } bytes; + } tag; /** the tag considered as a number */ uint32_t value; } tag; diff --git a/src/c/memory/memory.h b/src/c/memory/memory.h index 33e9d39..fc242c2 100644 --- a/src/c/memory/memory.h +++ b/src/c/memory/memory.h @@ -21,7 +21,7 @@ * since managed objects require a two word header; it's unlikely that * these undersized size classes will be used at all. */ -#define MAX_SIZE_CLASS 0xf +#define MAX_SIZE_CLASS = 0xf int initialise_memory( ); diff --git a/src/c/memory/page.c b/src/c/memory/page.c index 2fdaf79..1486301 100644 --- a/src/c/memory/page.c +++ b/src/c/memory/page.c @@ -9,10 +9,7 @@ #include #include -#include -#include -#include "debug.h" #include "memory/memory.h" #include "memory/node.h" #include "memory/page.h" @@ -39,13 +36,13 @@ * to hold the number of pages we *might* create at start up time. We need a * way to grow the number of pages, while keeping access to them cheap. */ -union page * pages[NPAGES]; +struct page * pages[NPAGES]; /** * @brief the number of pages which have thus far been allocated. * */ -uint32_t npages_allocated = 0; +uint32_t npages_allocated = 0 /** * @brief private to allocate_page; do not use. @@ -54,11 +51,10 @@ uint32_t npages_allocated = 0; * @param page_index its location in the pages[] array; * @param size_class the size class of objects in this page; * @param freelist the freelist for objects of this size class. - * @return struct pso_pointer the new head for the freelist for this size_class, + * @return struct cons_pointer the new head for the freelist for this size_class, */ -struct pso_pointer initialise_page( union page* page_addr, uint16_t page_index, - uint8_t size_class, struct pso_pointer freelist) { - struct pso_pointer result = freelist; +struct cons_pointer initialise_page( struct page * page_addr, uint16_t page_index, uint8_t size_class, pso_pointer freelist) { + struct cons_pointer result = freelist; int obj_size = pow(2, size_class); int obj_bytes = obj_size * sizeof(uint64_t); int objs_in_page = PAGE_BYTES/obj_bytes; @@ -68,14 +64,16 @@ struct pso_pointer initialise_page( union page* page_addr, uint16_t page_index, // `nil` and the next on for `t`. for (int i = objs_in_page - 1; i >= 0; i--) { // it should be safe to cast any pso object to a pso2 - struct pso2* object = (struct pso2 *)(page_addr + (i * obj_bytes)); + struct pso2* object = (pso2 *)(page_addr + (i * obj_bytes)); - object->header.tag.bytes.size_class = size_class; - strncpy( (char *)(object->header.tag.bytes.mnemonic), FREETAG, TAGLENGTH); + object->header.tag.size_class = size_class; + strncpy( (char *)(object->header.tag.mnemonic), FREETAG, TAGLENGTH); object->payload.free.next = result; result = make_pointer( node_index, page_index, (uint16_t)( i * obj_size)); } + + return result; } /** @@ -91,8 +89,8 @@ struct pso_pointer initialise_page( union page* page_addr, uint16_t page_index, * @param size_class an integer in the range 0...MAX_SIZE_CLASS. * @return t on success, an exception if an error occurred. */ -struct pso_pointer allocate_page( uint8_t size_class ) { - struct pso_pointer result = t; +struct cons_pointer allocate_page( uint8_t size_class ) { + struct cons_pointer result = t; if ( npages_allocated == 0) { for (int i = 0; i < NPAGES; i++) { @@ -103,17 +101,17 @@ struct pso_pointer allocate_page( uint8_t size_class ) { if ( npages_allocated < NPAGES) { if ( size_class >= 2 && size_class <= MAX_SIZE_CLASS ) { - void* pg = malloc( sizeof( union page ) ); + result = malloc( sizeof( page ) ); - if ( pg != NULL ) { - memset( pg, 0, sizeof( union page ) ); - pages[ npages_allocated] = pg; + if ( result != NULL ) { + memset( result, 0, sizeof( page ) ); + pages[ npages_allocated] = result; debug_printf( DEBUG_ALLOC, 0, L"Allocated page %d for objects of size class %x.\n", npages_allocated, size_class); freelists[size_class] = - initialise_page( (union page*)pg, npages_allocated, size_class, freelists[size_class] ); + initialise_page( result, npages_allocated, size_class, freelists[size_class] ); debug_printf( DEBUG_ALLOC, 0, L"Initialised page %d; freelist for size class %x updated.\n", diff --git a/src/c/memory/page.h b/src/c/memory/page.h index b5285f5..522b2fa 100644 --- a/src/c/memory/page.h +++ b/src/c/memory/page.h @@ -10,7 +10,6 @@ #ifndef __psse_memory_page_h #define __psse_memory_page_h -#include "memory/pointer.h" #include "memory/pso2.h" #include "memory/pso3.h" #include "memory/pso4.h" @@ -39,7 +38,7 @@ */ #define NPAGES 64 -extern union page *pages[NPAGES]; +extern struct page *pages[NPAGES]; /** * @brief A page is a megabyte of memory which contains objects all of which @@ -54,25 +53,22 @@ extern union page *pages[NPAGES]; * collection they will be returned to that freelist. */ union page { - uint8_t bytes[PAGE_BYTES]; - uint64_t words[PAGE_BYTES / 8]; - struct pso2 pso2s[PAGE_BYTES / 32]; - struct pso3 pso3s[PAGE_BYTES / 64]; - struct pso4 pso4s[PAGE_BYTES / 128]; - struct pso5 pso5s[PAGE_BYTES / 256]; - struct pso6 pso6s[PAGE_BYTES / 512]; - struct pso7 pso7s[PAGE_BYTES / 1024]; - struct pso8 pso8s[PAGE_BYTES / 2048]; - struct pso9 pso9s[PAGE_BYTES / 4096]; - struct psoa psoas[PAGE_BYTES / 8192]; - struct psob psobs[PAGE_BYTES / 16384]; - struct psoc psocs[PAGE_BYTES / 32768]; - struct psod psods[PAGE_BYTES / 65536]; - struct psoe psoes[PAGE_BYTES / 131072]; - struct psof psofs[PAGE_BYTES / 262144]; + uint8_t[PAGE_BYTES] bytes; + uint64_t[PAGE_BYTES / 8] words; + struct pso2[PAGE_BYTES / 32] pso2s; + struct pso3[PAGE_BYTES / 64] pso3s; + struct pso4[PAGE_BYTES / 128] pso4s; + struct pso5[PAGE_BYTES / 256] pso5s; + struct pso6[PAGE_BYTES / 512] pso6s; + struct pso7[PAGE_BYTES / 1024] pso7s; + struct pso8[PAGE_BYTES / 2048] pso8s; + struct pso9[PAGE_BYTES / 4096] pso9s; + struct psoa[PAGE_BYTES / 8192] psoas; + struct psob[PAGE_BYTES / 16384] psobs; + struct psoc[PAGE_BYTES / 32768] psocs; + struct psod[PAGE_BYTES / 65536] psods; + struct psoe[PAGE_BYTES / 131072] psoes; + struct psof[PAGE_BYTES / 262144] psofs; }; -struct pso_pointer initialise_page( union page * page_addr, uint16_t page_index, - uint8_t size_class, struct pso_pointer freelist); - #endif diff --git a/src/c/memory/pso.h b/src/c/memory/pso.h index 5f91bca..9fd7cc1 100644 --- a/src/c/memory/pso.h +++ b/src/c/memory/pso.h @@ -14,234 +14,234 @@ #include "memory/header.h" #include "memory/pointer.h" -// #include "payloads/cons.h" -// #include "payloads/exception.h" -// #include "payloads/free.h" -// #include "payloads/function.h" -// #include "payloads/hashtable.h" -// #include "payloads/integer.h" -// #include "payloads/keyword.h" -// #include "payloads/lambda.h" -// #include "payloads/mutex.h" -// #include "payloads/namespace.h" -// #include "payloads/nlambda.h" -// #include "payloads/read_stream.h" -// #include "payloads/special.h" -// #include "payloads/stack.h" -// #include "payloads/string.h" -// #include "payloads/symbol.h" -// #include "payloads/time.h" -// #include "payloads/vector_pointer.h" -// #include "payloads/write_stream.h" +#include "payloads/cons.h" +#include "payloads/exception.h" +#include "payloads/free.h" +#include "payloads/function.h" +#include "payloads/hashtable.h" +#include "payloads/integer.h" +#include "payloads/keyword.h" +#include "payloads/lambda.h" +#include "payloads/mutex.h" +#include "payloads/namespace.h" +#include "payloads/nlambda.h" +#include "payloads/read_stream.h" +#include "payloads/special.h" +#include "payloads/stack.h" +#include "payloads/string.h" +#include "payloads/symbol.h" +#include "payloads/time.h" +#include "payloads/vector_pointer.h" +#include "payloads/write_stream.h" -// /** -// * @brief A paged space object of size class 2, four words total, two words -// * payload. -// * -// */ -// struct pso2 { -// struct pso_header header; -// union { -// char bytes[16]; -// uint64_t words[2]; -// struct cons_payload cons; -// struct free_payload free; -// struct function_payload function; -// struct integer_payload integer; -// struct lambda_payload lambda; -// struct special_payload special; -// struct stream_payload stream; -// struct time_payload time; -// struct vectorp_payload vectorp; -// } payload; -// }; +/** + * @brief A paged space object of size class 2, four words total, two words + * payload. + * + */ +struct pso2 { + struct pso_header header; + union { + char bytes[16]; + uint64_t words[2]; + struct cons_payload cons; + struct free_payload free; + struct function_payload function; + struct integer_payload integer; + struct lambda_payload lambda; + struct special_payload special; + struct stream_payload stream; + struct time_payload time; + struct vectorp_payload vectorp; + } payload; +}; -// /** -// * @brief A paged space object of size class 3, 8 words total, 6 words -// * payload. -// * -// */ -// struct pso3 { -// struct pso_header header; -// union { -// char bytes[48]; -// uint64_t words[6]; -// struct exception_payload exception; -// struct free_payload free; -// struct mutex_payload mutex; -// } payload; -// }; +/** + * @brief A paged space object of size class 3, 8 words total, 6 words + * payload. + * + */ +struct pso3 { + struct pso_header header; + union { + char bytes[48]; + uint64_t words[6]; + struct exception_payload exception; + struct free_payload free; + struct mutex_payload mutex; + } payload; +}; -// /** -// * @brief A paged space object of size class 4, 16 words total, 14 words -// * payload. -// * -// */ -// struct pso4 { -// struct pso_header header; -// union { -// char bytes[112]; -// uint64_t words[14]; -// struct free_payload free; -// struct stack_frame_payload stack_frame; -// } payload; -// }; +/** + * @brief A paged space object of size class 4, 16 words total, 14 words + * payload. + * + */ +struct pso4 { + struct pso_header header; + union { + char bytes[112]; + uint64_t words[14]; + struct free_payload free; + struct stack_frame_payload stack_frame; + } payload; +}; -// /** -// * @brief A paged space object of size class 5, 32 words total, 30 words -// * payload. -// * -// */ -// struct pso5 { -// struct pso_header header; -// union { -// char bytes[240]; -// uint64_t words[30]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class 5, 32 words total, 30 words + * payload. + * + */ +struct pso5 { + struct pso_header header; + union { + char bytes[240]; + uint64_t words[30]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class 6, 64 words total, 62 words -// * payload. -// * -// */ -// struct pso6 { -// struct pso_header header; -// union { -// char bytes[496]; -// uint64_t words[62]; -// struct free_payload free; -// struct hashtable_payload hashtable; -// struct namespace_payload namespace; -// } payload; -// }; +/** + * @brief A paged space object of size class 6, 64 words total, 62 words + * payload. + * + */ +struct pso6 { + struct pso_header header; + union { + char bytes[496]; + uint64_t words[62]; + struct free_payload free; + struct hashtable_payload hashtable; + struct namespace_payload namespace; + } payload; +}; -// /** -// * @brief A paged space object of size class 7, 128 words total, 126 words -// * payload. -// * -// */ -// struct pso7 { -// struct pso_header header; -// union { -// char bytes[1008]; -// uint64_t words[126]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class 7, 128 words total, 126 words + * payload. + * + */ +struct pso7 { + struct pso_header header; + union { + char bytes[1008]; + uint64_t words[126]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class 8, 256 words total, 254 words -// * payload. -// * -// */ -// struct pso8 { -// struct pso_header header; -// union { -// char bytes[2032]; -// uint64_t words[254]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class 8, 256 words total, 254 words + * payload. + * + */ +struct pso8 { + struct pso_header header; + union { + char bytes[2032]; + uint64_t words[254]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class 9, 512 words total, 510 words -// * payload. -// * -// */ -// struct pso9 { -// struct pso_header header; -// union { -// char bytes[4080]; -// uint64_t words[510]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class 9, 512 words total, 510 words + * payload. + * + */ +struct pso9 { + struct pso_header header; + union { + char bytes[4080]; + uint64_t words[510]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class a, 1024 words total, 1022 words -// * payload. -// * -// */ -// struct psoa { -// struct pso_header header; -// union { -// char bytes[8176]; -// uint64_t words[1022]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class a, 1024 words total, 1022 words + * payload. + * + */ +struct psoa { + struct pso_header header; + union { + char bytes[8176]; + uint64_t words[1022]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class b, 2048 words total, 2046 words -// * payload. -// * -// */ -// struct psob { -// struct pso_header header; -// union { -// char bytes[16368]; -// uint64_t words[2046]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class b, 2048 words total, 2046 words + * payload. + * + */ +struct psob { + struct pso_header header; + union { + char bytes[16368]; + uint64_t words[2046]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class c, 4096 words total, 4094 words -// * payload. -// * -// */ -// struct psoc { -// struct pso_header header; -// union { -// char bytes[32752]; -// uint64_t words[4094]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class c, 4096 words total, 4094 words + * payload. + * + */ +struct psoc { + struct pso_header header; + union { + char bytes[32752]; + uint64_t words[4094]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class d, 8192 words total, 8190 words -// * payload. -// * -// */ -// struct psod { -// struct pso_header header; -// union { -// char bytes[65520]; -// uint64_t words[8190]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class d, 8192 words total, 8190 words + * payload. + * + */ +struct psod { + struct pso_header header; + union { + char bytes[65520]; + uint64_t words[8190]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class e, 16384 words total, 16382 words -// * payload. -// * -// */ -// struct psoe { -// struct pso_header header; -// union { -// char bytes[131056]; -// uint64_t words[16382]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class e, 16384 words total, 16382 words + * payload. + * + */ +struct psoe { + struct pso_header header; + union { + char bytes[131056]; + uint64_t words[16382]; + struct free_payload free; + } payload; +}; -// /** -// * @brief A paged space object of size class f, 32768 words total, 32766 words -// * payload. -// * -// */ -// struct psof { -// struct pso_header header; -// union { -// char bytes[262128]; -// uint64_t words[32766]; -// struct free_payload free; -// } payload; -// }; +/** + * @brief A paged space object of size class f, 32768 words total, 32766 words + * payload. + * + */ +struct psof { + struct pso_header header; + union { + char bytes[262128]; + uint64_t words[32766]; + struct free_payload free; + } payload; +}; struct pso_pointer allocate( char* tag, uint8_t size_class); diff --git a/src/c/memory/pso2.h b/src/c/memory/pso2.h deleted file mode 100644 index e8305d0..0000000 --- a/src/c/memory/pso2.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * memory/pso2.h - * - * Paged space object of size class 2, four words total, two words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_pso2_h -#define __psse_memory_pso2_h - -#include - -#include "memory/header.h" -#include "payloads/cons.h" -#include "payloads/free.h" -#include "payloads/function.h" -#include "payloads/integer.h" -#include "payloads/keyword.h" -#include "payloads/lambda.h" -#include "payloads/nlambda.h" -#include "payloads/read_stream.h" -#include "payloads/special.h" -#include "payloads/string.h" -#include "payloads/symbol.h" -// #include "payloads/time.h" -#include "payloads/vector_pointer.h" -#include "payloads/write_stream.h" - -/** - * @brief A paged space object of size class 2, four words total, two words - * payload. - * - */ -struct pso2 { - struct pso_header header; - union { - char bytes[16]; - uint64_t words[2]; - struct cons_payload cons; - struct free_payload free; - struct function_payload function; - struct integer_payload integer; - struct lambda_payload lambda; -// struct special_payload special; - struct stream_payload stream; -// struct time_payload time; - struct vectorp_payload vectorp; - } payload; -}; - -#endif diff --git a/src/c/memory/pso3.h b/src/c/memory/pso3.h deleted file mode 100644 index c4975b1..0000000 --- a/src/c/memory/pso3.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * memory/pso3.h - * - * Paged space object of size class 3, 8 words total, 6 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_pso3_h -#define __psse_memory_pso3_h - -#include - -#include "memory/header.h" -#include "payloads/exception.h" -#include "payloads/free.h" -#include "payloads/mutex.h" - - -/** - * @brief A paged space object of size class 3, 8 words total, 6 words - * payload. - * - */ -struct pso3 { - struct pso_header header; - union { - char bytes[48]; - uint64_t words[6]; - struct exception_payload exception; - struct free_payload free; - struct mutex_payload mutex; - } payload; -}; - -#endif diff --git a/src/c/memory/pso4.h b/src/c/memory/pso4.h deleted file mode 100644 index 9ffc337..0000000 --- a/src/c/memory/pso4.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * memory/pso4.h - * - * Paged space object of size class 4, 16 words total, 14 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_pso4_h -#define __psse_memory_pso4_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" -#include "payloads/stack.h" - -/** - * @brief A paged space object of size class 4, 16 words total, 14 words - * payload. - * - */ -struct pso4 { - struct pso_header header; - union { - char bytes[112]; - uint64_t words[14]; - struct free_payload free; - struct stack_frame_payload stack_frame; - } payload; -}; - -#endif diff --git a/src/c/memory/pso5.h b/src/c/memory/pso5.h deleted file mode 100644 index 585332c..0000000 --- a/src/c/memory/pso5.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/pso5.h - * - * Paged space object of size class 5, 32 words total, 30 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_pso5_h -#define __psse_memory_pso5_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class 5, 32 words total, 30 words - * payload. - * - */ -struct pso5 { - struct pso_header header; - union { - char bytes[240]; - uint64_t words[30]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/pso6.h b/src/c/memory/pso6.h deleted file mode 100644 index 3bd9290..0000000 --- a/src/c/memory/pso6.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/pso6.h - * - * Paged space object of size class 6, 64 words total, 62 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_pso6_h -#define __psse_memory_pso6_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class 6, 64 words total, 62 words - * payload. - * - */ -struct pso6 { - struct pso_header header; - union { - char bytes[496]; - uint64_t words[62]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/pso7.h b/src/c/memory/pso7.h deleted file mode 100644 index 04ee61b..0000000 --- a/src/c/memory/pso7.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/pso7.h - * - * Paged space object of size class 7, 128 words total, 126 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_pso7_h -#define __psse_memory_pso7_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class 7, 128 words total, 126 words - * payload. - * - */ -struct pso7 { - struct pso_header header; - union { - char bytes[1008]; - uint64_t words[126]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/pso8.h b/src/c/memory/pso8.h deleted file mode 100644 index b3a00bc..0000000 --- a/src/c/memory/pso8.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/pso8.h - * - * Paged space object of size class 8, 256 words total, 254 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_pso8_h -#define __psse_memory_pso8_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class 8, 256 words total, 254 words - * payload. - * - */ -struct pso8 { - struct pso_header header; - union { - char bytes[2032]; - uint64_t words[254]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/pso9.h b/src/c/memory/pso9.h deleted file mode 100644 index 3fa5eab..0000000 --- a/src/c/memory/pso9.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/pso9.h - * - * Paged space object of size class 9, 512 words total, 510 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_pso9_h -#define __psse_memory_pso9_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class 9, 512 words total, 510 words - * payload. - * - */ -struct pso9 { - struct pso_header header; - union { - char bytes[4080]; - uint64_t words[510]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/psoa.h b/src/c/memory/psoa.h deleted file mode 100644 index 1c8e9c7..0000000 --- a/src/c/memory/psoa.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/psoa.h - * - * Paged space object of size class a, 1024 words total, 1022 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_psoa_h -#define __psse_memory_psoa_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class a, 1024 words total, 1022 words - * payload. - * - */ -struct psoa { - struct pso_header header; - union { - char bytes[8176]; - uint64_t words[1022]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/psob.h b/src/c/memory/psob.h deleted file mode 100644 index d6b235a..0000000 --- a/src/c/memory/psob.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/psob.h - * - * Paged space object of size class b, 2048 words total, 2046 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_psob_h -#define __psse_memory_psob_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class b, 2048 words total, 2046 words - * payload. - * - */ -struct psob { - struct pso_header header; - union { - char bytes[16368]; - uint64_t words[2046]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/psoc.h b/src/c/memory/psoc.h deleted file mode 100644 index 934c8b3..0000000 --- a/src/c/memory/psoc.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/psoc.h - * - * Paged space object of size class c, 4096 words total, 4094 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_psoc_h -#define __psse_memory_psoc_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class c, 4096 words total, 4094 words - * payload. - * - */ -struct psoc { - struct pso_header header; - union { - char bytes[32752]; - uint64_t words[4094]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/psod.h b/src/c/memory/psod.h deleted file mode 100644 index 5ed7711..0000000 --- a/src/c/memory/psod.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/psod.h - * - * Paged space object of size class d, 8192 words total, 8190 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_psod_h -#define __psse_memory_psod_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class d, 8192 words total, 8190 words - * payload. - * - */ -struct psod { - struct pso_header header; - union { - char bytes[65520]; - uint64_t words[8190]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/psoe.h b/src/c/memory/psoe.h deleted file mode 100644 index 5f2b619..0000000 --- a/src/c/memory/psoe.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/psoe.h - * - * Paged space object of size class e, 16384 words total, 16382 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_psoe_h -#define __psse_memory_psoe_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class e, 16384 words total, 16382 words - * payload. - * - */ -struct psoe { - struct pso_header header; - union { - char bytes[131056]; - uint64_t words[16382]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/memory/psof.h b/src/c/memory/psof.h deleted file mode 100644 index 58615de..0000000 --- a/src/c/memory/psof.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * memory/psof.h - * - * Paged space object of size class f, 32768 words total, 32766 words payload. - * - * (c) 2026 Simon Brooke - * Licensed under GPL version 2.0, or, at your option, any later version. - */ - -#ifndef __psse_memory_psof_h -#define __psse_memory_psof_h - -#include - -#include "memory/header.h" -#include "payloads/free.h" - -/** - * @brief A paged space object of size class f, 32768 words total, 32766 words - * payload. - * - */ -struct psof { - struct pso_header header; - union { - char bytes[262128]; - uint64_t words[32766]; - struct free_payload free; - } payload; -}; - -#endif diff --git a/src/c/payloads/cons.c b/src/c/payloads/cons.c index 6a002c8..5eaf2b6 100644 --- a/src/c/payloads/cons.c +++ b/src/c/payloads/cons.c @@ -12,7 +12,6 @@ #include "memory/node.h" #include "memory/pointer.h" #include "memory/pso.h" -#include "memory/pso2.h" #include "payloads/cons.h" /** diff --git a/src/c/payloads/function.h b/src/c/payloads/function.h index 2f43bef..2ef45c4 100644 --- a/src/c/payloads/function.h +++ b/src/c/payloads/function.h @@ -11,7 +11,7 @@ #define __psse_payloads_function_h #include "memory/pointer.h" -#include "memory/pso4.h" +#include "memory/pso.h" /** * @brief Tag for an ordinary Lisp function - one whose arguments are pre-evaluated. @@ -41,7 +41,7 @@ struct function_payload { * a cons pointer (representing its result). * \todo check this documentation is current! */ - struct pso_pointer ( *executable ) ( struct pso4*, + struct pso_pointer ( *executable ) ( struct pso4 *, struct pso_pointer, struct pso_pointer ); }; diff --git a/src/c/payloads/hashtable.h b/src/c/payloads/hashtable.h index 3619847..86664e5 100644 --- a/src/c/payloads/hashtable.h +++ b/src/c/payloads/hashtable.h @@ -45,11 +45,11 @@ * i.e. either an assoc list or a further hashtable. */ struct hashtable_payload { - struct pso_pointer hash_fn; /* function for hashing values in this hashtable, or `NIL` to use + struct cons_pointer hash_fn; /* function for hashing values in this hashtable, or `NIL` to use the default hashing function */ uint32_t n_buckets; /* number of hash buckets */ - struct pso_pointer buckets[]; /* actual hash buckets, which should be `NIL` + struct cons_pointer buckets[]; /* actual hash buckets, which should be `NIL` * or assoc lists or (possibly) further hashtables. */ }; -#endif +#endif \ No newline at end of file diff --git a/src/c/payloads/namespace.h b/src/c/payloads/namespace.h index bb1b1b3..b494e93 100644 --- a/src/c/payloads/namespace.h +++ b/src/c/payloads/namespace.h @@ -48,17 +48,17 @@ * i.e. either an assoc list or a further namespace. */ struct namespace_payload { - struct pso_pointer hash_fn; /* function for hashing values in this namespace, or + struct cons_pointer hash_fn; /* function for hashing values in this namespace, or * `NIL` to use the default hashing function */ uint32_t n_buckets; /* number of hash buckets */ uint32_t unused; /* for word alignment and possible later expansion */ - struct pso_pointer write_acl; /* it seems to me that it is likely that the + struct cons_pointer write_acl; /* it seems to me that it is likely that the * principal difference between a hashtable and a * namespace is that a hashtable has a write ACL * of `NIL`, meaning not writeable by anyone */ - struct pso_pointer mutex; /* the mutex to lock when modifying this namespace.*/ - struct pso_pointer buckets[]; /* actual hash buckets, which should be `NIL` + struct cons_pointer mutex; /* the mutex to lock when modifying this namespace.*/ + struct cons_pointer buckets[]; /* actual hash buckets, which should be `NIL` * or assoc lists or (possibly) further hashtables. */ }; -#endif +#endif \ No newline at end of file diff --git a/src/c/payloads/read_stream.h b/src/c/payloads/read_stream.h index ef2f5cc..e271489 100644 --- a/src/c/payloads/read_stream.h +++ b/src/c/payloads/read_stream.h @@ -14,7 +14,6 @@ #include -#include "io/fopen.h" #include "memory/pointer.h" /** @@ -32,7 +31,7 @@ struct stream_payload { /** metadata on the stream (e.g. its file attributes if a file, its HTTP * headers if a URL, etc). Expected to be an association, or nil. Not yet * implemented. */ - struct pso_pointer meta; + struct cons_pointer meta; }; #endif diff --git a/src/c/payloads/special.h b/src/c/payloads/special.h index 4dcf7c2..4c64545 100644 --- a/src/c/payloads/special.h +++ b/src/c/payloads/special.h @@ -11,7 +11,6 @@ #define __psse_payloads_special_h #include "memory/pointer.h" -#include "memory/pso4.h" /** * A special form - one whose arguments are not pre-evaluated but passed as @@ -21,25 +20,25 @@ #define SPECIALTAG "SFM" #define SPECIALTV 5064275 -// /** -// * @brief Payload of a special form cell. -// * -// * Currently identical to the payload of a function cell. -// * \see function_payload -// */ -// struct special_payload { -// /** -// * pointer to the source from which the special form was compiled, or NIL -// * if it is a primitive. -// */ -// struct pso_pointer meta; -// /** pointer to a function which takes a cons pointer (representing -// * its argument list) and a cons pointer (representing its environment) and a -// * stack frame (representing the previous stack frame) as arguments and returns -// * a cons pointer (representing its result). */ -// struct pso_pointer ( *executable ) ( struct pso4*, -// struct pso_pointer, -// struct pso_pointer ); -// }; +/** + * @brief Payload of a special form cell. + * + * Currently identical to the payload of a function cell. + * \see function_payload + */ +struct special_payload { + /** + * pointer to the source from which the special form was compiled, or NIL + * if it is a primitive. + */ + struct pso_pointer meta; + /** pointer to a function which takes a cons pointer (representing + * its argument list) and a cons pointer (representing its environment) and a + * stack frame (representing the previous stack frame) as arguments and returns + * a cons pointer (representing its result). */ + struct pso_pointer ( *executable ) ( struct pso4 *, + struct pso_pointer, + struct pso_pointer ); +}; #endif diff --git a/src/c/payloads/stack.c b/src/c/payloads/stack.c index 5cb2113..a814699 100644 --- a/src/c/payloads/stack.c +++ b/src/c/payloads/stack.c @@ -8,8 +8,7 @@ */ #include "memory/node.h" -#include "memory/pso2.h" -#include "memory/pso4.h" +#include "memory/pso.h" #include "payloads/stack.h" /** diff --git a/src/c/payloads/stack.h b/src/c/payloads/stack.h index 4225dbc..ba0abd8 100644 --- a/src/c/payloads/stack.h +++ b/src/c/payloads/stack.h @@ -14,9 +14,6 @@ #include "memory/pointer.h" -#define STACKTAG "STK" -#define STACKTV 4936787 - /* * number of arguments stored in a stack frame */ diff --git a/src/c/payloads/time.h b/src/c/payloads/time.h index cc1ef0a..d9870b4 100644 --- a/src/c/payloads/time.h +++ b/src/c/payloads/time.h @@ -10,8 +10,6 @@ #ifndef __psse_payloads_cons_h #define __psse_payloads_cons_h -#include - #include "memory/pointer.h" /** @@ -26,7 +24,7 @@ * convenience, 14Bn years before 1st Jan 1970 (the UNIX epoch)) */ struct time_payload { - unsigned __int128_t value; + unsigned __int128 value; }; #endif diff --git a/src/c/payloads/vector_pointer.h b/src/c/payloads/vector_pointer.h index 8fda0f3..b5e5f1c 100644 --- a/src/c/payloads/vector_pointer.h +++ b/src/c/payloads/vector_pointer.h @@ -16,7 +16,6 @@ * A pointer to an object in vector space. */ #define VECTORPOINTTAG "VSP" -#define VECTORPOINTTV 5264214 /** * @brief payload of a vector pointer cell. diff --git a/src/c/payloads/write_stream.h b/src/c/payloads/write_stream.h index 1197d73..deda598 100644 --- a/src/c/payloads/write_stream.h +++ b/src/c/payloads/write_stream.h @@ -10,7 +10,6 @@ #ifndef __psse_payloads_write_stream_h #define __psse_payloads_write_stream_h -#include "io/fopen.h" #include "memory/pointer.h" /** diff --git a/src/c/psse.c b/src/c/psse.c index 5f5f2fb..5c67b6f 100644 --- a/src/c/psse.c +++ b/src/c/psse.c @@ -99,7 +99,7 @@ int main( int argc, char *argv[] ) { initialise_node( 0 ); - // repl( ); + repl( ); exit( 0 ); } diff --git a/src/c/psse.h b/src/c/psse.h index 0fe9b43..0c57020 100644 --- a/src/c/psse.h +++ b/src/c/psse.h @@ -24,7 +24,7 @@ #include "debug.h" #include "memory/memory.h" -#include "payloads/stack.h" +#include "memory/stack.h" #include "version.h" #endif