diff options
Diffstat (limited to 'include/align.h.in')
-rw-r--r-- | include/align.h.in | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/include/align.h.in b/include/align.h.in new file mode 100644 index 0000000..411fec1 --- /dev/null +++ b/include/align.h.in @@ -0,0 +1,84 @@ +/* + * This file has been generated automatically + * by CMake commands. Do not edit. + * + * Original contents from @(#)align_test.c 1.19 03/11/25 Copyright 1995 J. Schilling + * + */ + +#ifndef _UTYPES_H +#include <utypes.h> +#endif + +#define ALIGN_SHORT @SIZE_SHORT@ +#define ALIGN_INT @SIZE_INT@ +#define ALIGN_LONG @SIZE_LONG@ +#define ALIGN_LLONG @SIZE_LLONG@ +#define ALIGN_FLOAT @SIZE_FLOAT@ +#define ALIGN_DOUBLE @SIZE_DOUBLE@ +#define ALIGN_PTR @SIZE_PTR@ + +#define SIZE_SHORT @SIZE_SHORT@ +#define SIZE_INT @SIZE_INT@ +#define SIZE_LONG @SIZE_LONG@ +#define SIZE_LLONG @SIZE_LLONG@ +#define SIZE_FLOAT @SIZE_FLOAT@ +#define SIZE_DOUBLE @SIZE_DOUBLE@ +#define SIZE_PTR @SIZE_PTR@ + + +#define ALIGN_SMASK @SHORTLESS@ +#define ALIGN_IMASK @INTLESS@ +#define ALIGN_LMASK @LONGLESS@ +#define ALIGN_LLMASK @LLONGLESS@ +#define ALIGN_FMASK @FLOATLESS@ +#define ALIGN_DMASK @DOUBLELESS@ +#define ALIGN_PMASK @PTRLESS@ + + +/* + * There used to be a cast to an int but we get a warning from GCC. + * This warning message from GCC is wrong. + * Believe me that this macro would even be usable if I would cast to short. + * In order to avoid this warning, we are now using UIntptr_t + */ +#define xaligned(a, s) ((((UIntptr_t)(a)) & (s)) == 0 ) +#define x2aligned(a, b, s) (((((UIntptr_t)(a)) | ((UIntptr_t)(b))) & (s)) == 0 ) + +#define saligned(a) xaligned(a, ALIGN_SMASK) +#define s2aligned(a, b) x2aligned(a, b, ALIGN_SMASK) + +#define ialigned(a) xaligned(a, ALIGN_IMASK) +#define i2aligned(a, b) x2aligned(a, b, ALIGN_IMASK) + +#define laligned(a) xaligned(a, ALIGN_LMASK) +#define l2aligned(a, b) x2aligned(a, b, ALIGN_LMASK) + +#define llaligned(a) xaligned(a, ALIGN_LLMASK) +#define ll2aligned(a, b) x2aligned(a, b, ALIGN_LLMASK) + +#define faligned(a) xaligned(a, ALIGN_FMASK) +#define f2aligned(a, b) x2aligned(a, b, ALIGN_FMASK) + +#define daligned(a) xaligned(a, ALIGN_DMASK) +#define d2aligned(a, b) x2aligned(a, b, ALIGN_DMASK) + +#define paligned(a) xaligned(a, ALIGN_PMASK) +#define p2aligned(a, b) x2aligned(a, b, ALIGN_PMASK) + + +/* + * There used to be a cast to an int but we get a warning from GCC. + * This warning message from GCC is wrong. + * Believe me that this macro would even be usable if I would cast to short. + * In order to avoid this warning, we are now using UIntptr_t + */ +#define xalign(x, a, m) ( ((char *)(x)) + ( (a) - 1 - ((((UIntptr_t)(x))-1)&(m))) ) + +#define salign(x) xalign((x), ALIGN_SHORT, ALIGN_SMASK) +#define ialign(x) xalign((x), ALIGN_INT, ALIGN_IMASK) +#define lalign(x) xalign((x), ALIGN_LONG, ALIGN_LMASK) +#define llalign(x) xalign((x), ALIGN_LLONG, ALIGN_LLMASK) +#define falign(x) xalign((x), ALIGN_FLOAT, ALIGN_FMASK) +#define dalign(x) xalign((x), ALIGN_DOUBLE, ALIGN_DMASK) +#define palign(x) xalign((x), ALIGN_PTR, ALIGN_PMASK) |