summaryrefslogtreecommitdiff
path: root/include/align.h.in
blob: 411fec1d8679b22198c4b3c6a7726437098b1f41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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)