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