al_hal_common.h revision 285431
1/*- 2******************************************************************************** 3Copyright (C) 2015 Annapurna Labs Ltd. 4 5This file may be licensed under the terms of the Annapurna Labs Commercial 6License Agreement. 7 8Alternatively, this file can be distributed under the terms of the GNU General 9Public License V2 as published by the Free Software Foundation and can be 10found at http://www.gnu.org/licenses/gpl-2.0.html 11 12Alternatively, redistribution and use in source and binary forms, with or 13without modification, are permitted provided that the following conditions are 14met: 15 16 * Redistributions of source code must retain the above copyright notice, 17this list of conditions and the following disclaimer. 18 19 * Redistributions in binary form must reproduce the above copyright 20notice, this list of conditions and the following disclaimer in 21the documentation and/or other materials provided with the 22distribution. 23 24THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 28ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 35*******************************************************************************/ 36 37/** 38 * @defgroup group_common HAL Common Layer 39 * Includes all common header files used by HAL 40 * @{ 41 * @file al_hal_common.h 42 * 43 */ 44 45#ifndef __AL_HAL_COMMON_H__ 46#define __AL_HAL_COMMON_H__ 47 48#include "al_hal_plat_types.h" 49#include "al_hal_plat_services.h" 50 51#include "al_hal_types.h" 52#include "al_hal_reg_utils.h" 53 54/* Get the maximal value out of two typed values */ 55#define al_max_t(type, x, y) ({ \ 56 type __max1 = (x); \ 57 type __max2 = (y); \ 58 __max1 > __max2 ? __max1 : __max2; }) 59 60/* Get the minimal value out of two typed values */ 61#define al_min_t(type, x, y) ({ \ 62 type __min1 = (x); \ 63 type __min2 = (y); \ 64 __min1 < __min2 ? __min1 : __min2; }) 65 66/* Get the number of elements in an array */ 67#define AL_ARR_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 68 69/** @} end of Common group */ 70#endif /* __AL_HAL_COMMON_H__ */ 71