1 /* 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2020 SRI International 5 * 6 * This software was developed by SRI International and the University of 7 * Cambridge Computer Laboratory (Department of Computer Science and 8 * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the 9 * DARPA SSITH research programme. 10 */ 11 #ifndef _SYS__ALIGN_H_ 12 #define _SYS__ALIGN_H_ 13 14 /* 15 * Round p up to the alignment of the largest, non-floating point, type 16 * that fits in a register. In practice this has always been the size 17 * of a pointer (but spelled in a wide varity of ways) and with CHERI 18 * that needs to remain true to support file descriptor passing within 19 * the kernel. 20 * 21 * Unlike historic implementations, _ALIGN macro preserves both the type 22 * and provenance of p. 23 * 24 * These interfaces are ambigiously defined and should be considred 25 * obsolete. New code that requires alignment adjustments should replace 26 * _ALIGNBYTES with alignof(appropriate type) and _ALIGN with 27 * __align_up(p, alignof(appropriate type)). 28 */ 29 #define _ALIGNBYTES (sizeof(void *) - 1) 30 #define _ALIGN(p) __align_up((p), _ALIGNBYTES + 1) 31 32 #endif /* !_SYS__ALIGN_H_ */ 33