summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-08-17 19:17:10 +0200
committerLennart Poettering <lennart@poettering.net>2009-08-17 19:17:10 +0200
commit8f928b2e572cd7bf26517afddd62ceecb78edfdc (patch)
tree4781ad92a9694d96d2b924a38ded8f50d3392c45 /src
parentfe3a21f6a5958a6e54d5bcf7c162767cfdf5f9db (diff)
macro: simplify page/word alignment macros a bit
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/macro.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index aa06359a..3c560bc6 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -59,28 +59,24 @@
#endif
/* Rounds down */
-static inline void* pa_align_ptr(const void *p) {
- return (void*) (((size_t) p) & ~(sizeof(void*)-1));
+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*));
+static inline size_t PA_ALIGN(size_t l) {
+ return ((l + sizeof(void*) - 1) & ~(sizeof(void*) - 1));
}
-#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));
+static inline void* PA_PAGE_ALIGN_PTR(const void *p) {
+ return (void*) (((size_t) p) & ~(PA_PAGE_SIZE - 1));
}
-#define PA_PAGE_ALIGN_PTR(x) (pa_page_align_ptr(x))
/* Rounds up */
-static inline size_t pa_page_align(size_t l) {
- return ((l + PA_PAGE_SIZE - 1) / PA_PAGE_SIZE) * PA_PAGE_SIZE;
+static inline size_t PA_PAGE_ALIGN(size_t l) {
+ return (l + PA_PAGE_SIZE - 1) & ~(PA_PAGE_SIZE - 1);
}
-#define PA_PAGE_ALIGN(x) (pa_page_align(x))
#define PA_ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))