xref: /freebsd-src/sys/arm/include/_align.h (revision 29363fb446372cb3f10bc98664e9767c53fbb457)
1a254d1f1SPoul-Henning Kamp /*-
2*df57947fSPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
3*df57947fSPedro F. Giffuni  *
443b96a4eSWarner Losh  * Copyright (c) 2001 David E. O'Brien
5a254d1f1SPoul-Henning Kamp  * Copyright (c) 1990 The Regents of the University of California.
6a254d1f1SPoul-Henning Kamp  * All rights reserved.
7a254d1f1SPoul-Henning Kamp  *
8a254d1f1SPoul-Henning Kamp  * This code is derived from software contributed to Berkeley by
9a254d1f1SPoul-Henning Kamp  * William Jolitz.
10a254d1f1SPoul-Henning Kamp  *
11a254d1f1SPoul-Henning Kamp  * Redistribution and use in source and binary forms, with or without
12a254d1f1SPoul-Henning Kamp  * modification, are permitted provided that the following conditions
13a254d1f1SPoul-Henning Kamp  * are met:
14a254d1f1SPoul-Henning Kamp  * 1. Redistributions of source code must retain the above copyright
15a254d1f1SPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer.
16a254d1f1SPoul-Henning Kamp  * 2. Redistributions in binary form must reproduce the above copyright
17a254d1f1SPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer in the
18a254d1f1SPoul-Henning Kamp  *    documentation and/or other materials provided with the distribution.
1943b96a4eSWarner Losh  * 3. All advertising materials mentioning features or use of this software
2043b96a4eSWarner Losh  *    must display the following acknowledgement:
2143b96a4eSWarner Losh  *	This product includes software developed by the University of
2243b96a4eSWarner Losh  *	California, Berkeley and its contributors.
2343b96a4eSWarner Losh  * 4. Neither the name of the University nor the names of its contributors
24a254d1f1SPoul-Henning Kamp  *    may be used to endorse or promote products derived from this software
25a254d1f1SPoul-Henning Kamp  *    without specific prior written permission.
26a254d1f1SPoul-Henning Kamp  *
27a254d1f1SPoul-Henning Kamp  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28a254d1f1SPoul-Henning Kamp  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29a254d1f1SPoul-Henning Kamp  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30a254d1f1SPoul-Henning Kamp  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31a254d1f1SPoul-Henning Kamp  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32a254d1f1SPoul-Henning Kamp  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33a254d1f1SPoul-Henning Kamp  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34a254d1f1SPoul-Henning Kamp  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35a254d1f1SPoul-Henning Kamp  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36a254d1f1SPoul-Henning Kamp  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37a254d1f1SPoul-Henning Kamp  * SUCH DAMAGE.
38a254d1f1SPoul-Henning Kamp  */
39a254d1f1SPoul-Henning Kamp 
4043b96a4eSWarner Losh #ifndef _ARM_INCLUDE__ALIGN_H_
4143b96a4eSWarner Losh #define	_ARM_INCLUDE__ALIGN_H_
42a254d1f1SPoul-Henning Kamp 
43a254d1f1SPoul-Henning Kamp /*
4443b96a4eSWarner Losh  * Round p (pointer or byte index) up to the hardware-required alignment which
4543b96a4eSWarner Losh  * is sufficient for any data type, pointer or numeric.  The resulting type
4643b96a4eSWarner Losh  * is equivelent to arm's uintptr_t (but is purposely spelled "unsigned" here).
47a254d1f1SPoul-Henning Kamp  */
4843b96a4eSWarner Losh #define	_ALIGNBYTES	(sizeof(int) - 1)
4943b96a4eSWarner Losh #define	_ALIGN(p)	(((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
50a254d1f1SPoul-Henning Kamp 
5143b96a4eSWarner Losh #endif /* !_ARM_INCLUDE__ALIGN_H_ */
52