1285431Szbb/*-
2285431Szbb********************************************************************************
3285431SzbbCopyright (C) 2015 Annapurna Labs Ltd.
4285431Szbb
5285431SzbbThis file may be licensed under the terms of the Annapurna Labs Commercial
6285431SzbbLicense Agreement.
7285431Szbb
8285431SzbbAlternatively, this file can be distributed under the terms of the GNU General
9285431SzbbPublic License V2 as published by the Free Software Foundation and can be
10285431Szbbfound at http://www.gnu.org/licenses/gpl-2.0.html
11285431Szbb
12285431SzbbAlternatively, redistribution and use in source and binary forms, with or
13285431Szbbwithout modification, are permitted provided that the following conditions are
14285431Szbbmet:
15285431Szbb
16285431Szbb    *     Redistributions of source code must retain the above copyright notice,
17285431Szbbthis list of conditions and the following disclaimer.
18285431Szbb
19285431Szbb    *     Redistributions in binary form must reproduce the above copyright
20285431Szbbnotice, this list of conditions and the following disclaimer in
21285431Szbbthe documentation and/or other materials provided with the
22285431Szbbdistribution.
23285431Szbb
24285431SzbbTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25285431SzbbANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26285431SzbbWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27285431SzbbDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
28285431SzbbANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29285431Szbb(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30285431SzbbLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31285431SzbbANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32285431Szbb(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33285431SzbbSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34285431Szbb
35285431Szbb*******************************************************************************/
36285431Szbb
37285431Szbb/**
38285431Szbb * @defgroup group_common HAL Common Layer
39285431Szbb * Includes all common header files used by HAL
40285431Szbb *  @{
41285431Szbb * @file   al_hal_common.h
42285431Szbb *
43285431Szbb */
44285431Szbb
45285431Szbb#ifndef __AL_HAL_COMMON_H__
46285431Szbb#define __AL_HAL_COMMON_H__
47285431Szbb
48285431Szbb#include "al_hal_plat_types.h"
49285431Szbb#include "al_hal_plat_services.h"
50285431Szbb
51285431Szbb#include "al_hal_types.h"
52285431Szbb#include "al_hal_reg_utils.h"
53285431Szbb
54285431Szbb/* Get the maximal value out of two typed values */
55285431Szbb#define al_max_t(type, x, y) ({		\
56285431Szbb	type __max1 = (x);			\
57285431Szbb	type __max2 = (y);			\
58285431Szbb	__max1 > __max2 ? __max1 : __max2; })
59285431Szbb
60285431Szbb/* Get the minimal value out of two typed values */
61285431Szbb#define al_min_t(type, x, y) ({		\
62285431Szbb	type __min1 = (x);			\
63285431Szbb	type __min2 = (y);			\
64285431Szbb	__min1 < __min2 ? __min1 : __min2; })
65285431Szbb
66285431Szbb/* Get the number of elements in an array */
67285431Szbb#define AL_ARR_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
68285431Szbb
69285431Szbb/** @} end of Common group */
70285431Szbb#endif				/* __AL_HAL_COMMON_H__ */
71