refactor alignment functions

This commit is contained in:
barter-simsum 2023-02-17 14:43:32 -05:00
parent 953b21ae82
commit ba1b0f1e3d
4 changed files with 17 additions and 6 deletions

View File

@ -5,7 +5,10 @@
cc_library(
name = "c3",
srcs = glob(
["*.h"],
[
"*.h",
"*.c",
],
exclude = [
"c3.h",
"*_tests.c",

5
pkg/c3/defs.c Normal file
View File

@ -0,0 +1,5 @@
#include "defs.h"
c3_w c3_align_w(c3_w x, c3_w al, align_dir hilo);
c3_d c3_align_d(c3_d x, c3_d al, align_dir hilo);
void *c3_align_p(void const * p, size_t al, align_dir hilo);

View File

@ -186,10 +186,16 @@
# define c3_rename(a, b) ({ \
rename(a, b);})
/* c3_align: hi or lo align x to al
/* c3_align(
x - the address/quantity to align,
al - the alignment,
hilo - [C3_ALGHI, C3_ALGLO] high or low align
)
hi or lo align x to al
unless effective type of x is c3_w or c3_d, assumes x is a pointer.
*/
*/
#define c3_align(x, al, hilo) \
_Generic((x), \
c3_w : c3_align_w, \

View File

@ -20,9 +20,6 @@ c3_w u3_Code;
//
void u3a_config_loom(c3_w ver_w);
c3_w c3_align_w(c3_w x, c3_w al, align_dir hilo); /* ;;: after rebasing on /vere, these should be declared somewhere else (the align functions) */
c3_d c3_align_d(c3_d x, c3_d al, align_dir hilo);
void *c3_align_p(void const * p, size_t al, align_dir hilo);
void *u3a_into(c3_w x);
c3_w u3a_outa(void *p);
c3_w u3a_to_off(c3_w som);