shithub: femtolisp

Download patch

ref: 1ce1997d95f84d23e1dd9de7e391230d84e32883
parent: 6c30f50bd33ba6675ca81981a734cfc0697394c2
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Dec 24 12:48:17 EST 2024

symbols, ctype_sizeof: remove useless "align"

--- a/cvalues.c
+++ b/cvalues.c
@@ -556,16 +556,13 @@
 	return cv_len(cv)/cv_class(cv)->elsz;
 }
 
-// *palign is an output argument giving the alignment required by type
 size_t
-ctype_sizeof(value_t type, int *palign)
+ctype_sizeof(value_t type)
 {
 	symbol_t *s;
 
-	if(issymbol(type) && (s = ptr(type)) != nil && valid_numtype(s->numtype)){
-		 *palign = s->align;
+	if(issymbol(type) && (s = ptr(type)) != nil && valid_numtype(s->numtype))
 		return s->size;
-	}
 
 	if(iscons(type)){
 		value_t hed = car_(type);
@@ -575,7 +572,7 @@
 				lerrorf(FL(ArgError), "incomplete type");
 			value_t n = car_(cdr_(cdr_(type)));
 			size_t sz = tosize(n);
-			return sz * ctype_sizeof(t, palign);
+			return sz * ctype_sizeof(t);
 		}
 	}
 
@@ -612,9 +609,8 @@
 BUILTIN("sizeof", sizeof)
 {
 	argcount(nargs, 1);
-	int a;
 	if(issymbol(args[0]) || iscons(args[0]))
-		return size_wrap(ctype_sizeof(args[0], &a));
+		return size_wrap(ctype_sizeof(args[0]));
 	size_t n;
 	uint8_t *data;
 	to_sized_ptr(args[0], &data, &n);
@@ -878,7 +874,6 @@
 			s = ptr(FL(tok##sym)); \
 			s->numtype = nt; \
 			s->size = sizeof(ctype); \
-			s->align = offsetof(struct{char c; ctype x;}, x); \
 		} \
 	}while(0)
 
--- a/cvalues.h
+++ b/cvalues.h
@@ -35,7 +35,7 @@
 int isarray(value_t v);
 int cvalue_array_init(fltype_t *ft, value_t arg, void *dest);
 size_t cvalue_arraylen(value_t v);
-size_t ctype_sizeof(value_t type, int *palign);
+size_t ctype_sizeof(value_t type);
 void to_sized_ptr(value_t v, uint8_t **pdata, size_t *psz);
 value_t cvalue_relocate(value_t v);
 value_t cvalue_copy(value_t v);
--- a/flisp.h
+++ b/flisp.h
@@ -66,7 +66,6 @@
 	uint32_t hash;
 	uint8_t numtype;
 	uint8_t size;
-	uint8_t align;
 	uint8_t flags;
 }symbol_t;
 
--- a/print.c
+++ b/print.c
@@ -739,8 +739,7 @@
 				elsize = cnt ? len/cnt : 0;
 			}else{
 				// incomplete array type
-				int junk;
-				elsize = ctype_sizeof(eltype, &junk);
+				elsize = ctype_sizeof(eltype);
 				cnt = elsize ? len/elsize : 0;
 			}
 			if(eltype == FL(bytesym)){
--- a/types.c
+++ b/types.c
@@ -22,7 +22,7 @@
 		// special case: incomplete array type
 		sz = 0;
 	}else{
-		sz = ctype_sizeof(t, &align);
+		sz = ctype_sizeof(t);
 	}
 
 	ft = calloc(1, sizeof(fltype_t));