From 2ca24f83c35b253593b5aa8775d37923c8383149 Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 3 Jun 2023 21:51:28 +0200 Subject: abi lowering pass --- common.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'common.h') diff --git a/common.h b/common.h index bd78a26..0bdd21a 100644 --- a/common.h +++ b/common.h @@ -68,7 +68,7 @@ popcnt(uvlong x) { } static inline bool ispo2(uvlong x) { - return x & ((x & (x - 1)) == 0); + return (x != 0) & ((x & (x - 1)) == 0); } static inline uint ilog2(uint x) { /* assumes x is a power of 2 */ @@ -306,6 +306,11 @@ struct arena { struct arena *newarena(uint chunksiz); void *alloc(struct arena **, uint siz, uint align); +static inline void * +alloccopy(struct arena **arena, const void *src, uint siz, uint align) +{ + return memcpy(alloc(arena, siz, align), src, siz); +} void freearena(struct arena *); void vinit_(void **p, int *pcap, void *inlbuf, int cap, uint siz); void vpush_(void **p, int *pcap, uint *pn, uint siz); -- cgit v1.2.3