diff options
| author | 2023-06-03 21:51:28 +0200 | |
|---|---|---|
| committer | 2023-06-04 10:20:19 +0200 | |
| commit | 2ca24f83c35b253593b5aa8775d37923c8383149 (patch) | |
| tree | 09fc86a228b81ac574233a922758953c4c460861 /common.h | |
| parent | 65ace14e184807df026e985e073b3b5c5aaf576c (diff) | |
abi lowering pass
Diffstat (limited to 'common.h')
| -rw-r--r-- | common.h | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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); |