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 *  @{
40285431Szbb * @file   al_hal_types.h
41285431Szbb *
42285431Szbb * @brief  macros used by HALs and platform layer
43285431Szbb *
44285431Szbb */
45285431Szbb
46285431Szbb#ifndef __AL_HAL_TYPES_H__
47285431Szbb#define __AL_HAL_TYPES_H__
48285431Szbb
49285431Szbb#include "al_hal_plat_types.h"
50285431Szbb#include "al_hal_plat_services.h"
51285431Szbb
52285431Szbb/* *INDENT-OFF* */
53285431Szbb#ifdef __cplusplus
54285431Szbbextern "C" {
55285431Szbb#endif
56285431Szbb/* *INDENT-ON* */
57285431Szbb
58285431Szbb/* Common defines */
59285431Szbb
60285431Szbb#if (!AL_TRUE) || (AL_FALSE)
61285431Szbb#error "AL_TRUE must be non zero and AL_FALSE must be zero"
62285431Szbb#endif
63285431Szbb
64285431Szbbtypedef int AL_RETURN;
65285431Szbb
66285431Szbb#if !defined(NULL)
67285431Szbb#define NULL		(void *)0
68285431Szbb#endif
69285431Szbb
70285431Szbb#if !defined(likely)
71285431Szbb#define likely(x)	(__builtin_expect(!!(x), 1))
72285431Szbb#define unlikely(x)	(__builtin_expect(!!(x), 0))
73285431Szbb#endif
74285431Szbb
75285431Szbb
76285431Szbb#ifdef __GNUC__
77285431Szbb#if !defined(__packed)
78285431Szbb#define __packed __attribute__ ((packed))
79285431Szbb#endif
80285431Szbb  /* packed and alinged types */
81285431Szbb#define __packed_a4 __attribute__ ((packed, aligned(4)))
82285431Szbb#define __packed_a8 __attribute__ ((packed, aligned(8)))
83285431Szbb#define __packed_a16 __attribute__ ((packed, aligned(16)))
84285431Szbb
85285431Szbb#else
86285431Szbb#if !defined(__packed)
87285431Szbb#error "__packed is not defined!!"
88285431Szbb#endif
89285431Szbb#endif
90285431Szbb
91285431Szbb#if !defined(__iomem)
92285431Szbb#define __iomem
93285431Szbb#endif
94285431Szbb
95285431Szbb#if !defined(__cache_aligned)
96285431Szbb#ifdef __GNUC__
97285431Szbb#define __cache_aligned __attribute__ ((__aligned__(64)))
98285431Szbb#else
99285431Szbb#define __cache_aligned
100285431Szbb#endif
101285431Szbb#endif
102285431Szbb
103285431Szbb#if !defined(INLINE)
104285431Szbb#ifdef __GNUC__
105285431Szbb#define INLINE inline
106285431Szbb#else
107285431Szbb#define INLINE
108285431Szbb#endif
109285431Szbb#endif
110285431Szbb
111285431Szbb/* *INDENT-OFF* */
112285431Szbb#ifdef __cplusplus
113285431Szbb}
114285431Szbb#endif
115285431Szbb/* *INDENT-ON* */
116285431Szbb/** @} end of Common group */
117285431Szbb#endif				/* __TYPES_H__ */
118