summaryrefslogtreecommitdiff
path: root/src/shared/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/util.h')
-rw-r--r--src/shared/util.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/shared/util.h b/src/shared/util.h
index 08d556fc92..a1d5657237 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -852,6 +852,22 @@ int unlink_noerrno(const char *path);
(void *) memset(_new_, 0, _len_); \
})
+#define alloca_align(size, align) \
+ ({ \
+ void *_ptr_; \
+ size_t _mask_ = (align) - 1; \
+ _ptr_ = alloca((size) + _mask_); \
+ (void*)(((uintptr_t)_ptr_ + _mask_) & ~_mask_); \
+ })
+
+#define alloca0_align(size, align) \
+ ({ \
+ void *_new_; \
+ size_t _size_ = (size); \
+ _new_ = alloca_align(_size_, (align)); \
+ (void*)memset(_new_, 0, _size_); \
+ })
+
#define strappenda(a, ...) \
({ \
int _len = strlen(a); \