summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-04-29 01:52:11 +0200
committerLennart Poettering <lennart@poettering.net>2009-04-29 01:52:11 +0200
commit68f3ca9831a0ede7439348d0cd952f7730305bca (patch)
tree4c13e12c08e5aeaa500019757fb79beb5dab0294 /src
parent8247e4555b267ff85a386712633427dd689d2aa1 (diff)
macro: add new macro pa_align_ptr()
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/macro.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index a5ca6964..2f6ee90b 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -57,11 +57,19 @@
#define PA_PAGE_SIZE ((size_t) 4096)
#endif
+/* Rounds down */
+static inline void* pa_align_ptr(const void *p) {
+ return (void*) (((size_t) p) & ~(sizeof(void*)-1));
+}
+#define PA_ALIGN_PTR(x) (pa_align_ptr(x))
+
+/* Rounds up */
static inline size_t pa_align(size_t l) {
return (((l + sizeof(void*) - 1) / sizeof(void*)) * sizeof(void*));
}
#define PA_ALIGN(x) (pa_align(x))
+/* Rounds down */
static inline void* pa_page_align_ptr(const void *p) {
return (void*) (((size_t) p) & ~(PA_PAGE_SIZE-1));
}