} else
return -EBADMSG;
- total = sizeof(struct bus_header) + ALIGN_TO(fs, 8) + bs;
+ total = sizeof(struct bus_header) + ALIGN8(fs) + bs;
if (length != total)
return -EBADMSG;
m->sealed = true;
m->header = h;
m->fields = (uint8_t*) buffer + sizeof(struct bus_header);
- m->body = (uint8_t*) buffer + sizeof(struct bus_header) + ALIGN_TO(fs, 8);
+ m->body = (uint8_t*) buffer + sizeof(struct bus_header) + ALIGN8(fs);
m->fds = fds;
m->n_fds = n_fds;
#define STRINGIFY(x) XSTRINGIFY(x)
/* Rounds up */
-#define ALIGN(l) ALIGN_TO((l), sizeof(void*))
+
+#define ALIGN4(l) (((l) + 3) & ~3)
+#define ALIGN8(l) (((l) + 7) & ~7)
+
+#if __SIZEOF_POINTER__ == 8
+#define ALIGN(l) ALIGN8(l)
+#elif __SIZEOF_POINTER__ == 4
+#define ALIGN(l) ALIGN4(l)
+#else
+#error "Wut? Pointers are neither 4 nor 8 bytes long?"
+#endif
+
static inline size_t ALIGN_TO(size_t l, size_t ali) {
return ((l + ali - 1) & ~(ali - 1));
}