aboutsummaryrefslogtreecommitdiffstats
path: root/c89_relo.c
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2024-07-08 19:58:22 -0400
committerGravatar Peter McGoron 2024-07-08 19:58:22 -0400
commit4f7847b2c0219995c4fe2d0858b5030e73581a3c (patch)
tree9b84a1fc5698a4f8b97c0580fccf2b26c000d748 /c89_relo.c
parentdelete for hashtables (diff)
Major API reorganization, test infrastructure
The API is now hidden behind functions. The GC struct can have an unstable layout without affecting any compiled binaries (users of Universal Service or collectors hidden behind the API). The collectors can be called directly if desired. The API now allows for different allocation flags. These will be used in future extensions (like weak pointers). For now none are used. Tests are compiled for each collector. I can't think of a good solution that will encompass everything I want to write, but for now this will work on POSIX systems.
Diffstat (limited to 'c89_relo.c')
-rw-r--r--c89_relo.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/c89_relo.c b/c89_relo.c
deleted file mode 100644
index 6150781..0000000
--- a/c89_relo.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Copyright (C) 2024 Peter McGoron
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program. If not, see
- * <https://www.gnu.org/licenses/>.
-*/
-
-#include <string.h>
-#include <assert.h>
-#include "uns.h"
-#include "internal/c89_relo.h"
-
-typedef struct uns_c89_relo_hdr Hdr;
-
-size_t uns_c89_relo_get_len(void *p)
-{
- Hdr *hdr = uns_c89_relo_get_hdr(p);
-
- return (size_t)(hdr->len < 0 ? -hdr->len : hdr->len);
-}
-
-size_t uns_c89_relo_get_record_len(void *p)
-{
- Hdr *hdr = uns_c89_relo_get_hdr(p);
-
- if (hdr->len > 0)
- return 0;
- return (size_t)(-hdr->len) / sizeof(void *);
-}
-
-void *uns_c89_relo_init(void *p, size_t len_size, int is_record)
-{
- Hdr *hdr = p;
-
- assert(len_size < UNS_SWORD_MAX);
- hdr->relo = NULL;
- hdr->len = (uns_sword)len_size;
- if (is_record)
- hdr->len = -hdr->len;
-
- return hdr + 1;
-}
-
-static void check_len(void *rec, size_t i)
-{
- assert(i * sizeof(void *) < uns_c89_relo_get_len(rec));
-}
-
-void uns_c89_relo_record_set(Uns_ptr rec, size_t i, void *v)
-{
- check_len(rec, i);
- memcpy((unsigned char *)rec + i*sizeof(void*), &v, sizeof(v));
-}
-
-void *uns_c89_relo_record_get(Uns_ptr rec, size_t i)
-{
- void *v;
-
- check_len(rec, i);
- memcpy(&v, (unsigned char *)rec + i*sizeof(void*), sizeof(v));
-
- return v;
-}