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 *  @{
40 * @file   al_hal_types.h
41 *
42 * @brief  macros used by HALs and platform layer
43 *
44 */
45
46#ifndef __AL_HAL_TYPES_H__
47#define __AL_HAL_TYPES_H__
48
49#include "al_hal_plat_types.h"
50#include "al_hal_plat_services.h"
51
52/* *INDENT-OFF* */
53#ifdef __cplusplus
54extern "C" {
55#endif
56/* *INDENT-ON* */
57
58/* Common defines */
59
60#if (!AL_TRUE) || (AL_FALSE)
61#error "AL_TRUE must be non zero and AL_FALSE must be zero"
62#endif
63
64typedef int AL_RETURN;
65
66#if !defined(NULL)
67#define NULL		(void *)0
68#endif
69
70#if !defined(likely)
71#define likely(x)	(__builtin_expect(!!(x), 1))
72#define unlikely(x)	(__builtin_expect(!!(x), 0))
73#endif
74
75
76#ifdef __GNUC__
77#if !defined(__packed)
78#define __packed __attribute__ ((packed))
79#endif
80  /* packed and alinged types */
81#define __packed_a4 __attribute__ ((packed, aligned(4)))
82#define __packed_a8 __attribute__ ((packed, aligned(8)))
83#define __packed_a16 __attribute__ ((packed, aligned(16)))
84
85#else
86#if !defined(__packed)
87#error "__packed is not defined!!"
88#endif
89#endif
90
91#if !defined(__iomem)
92#define __iomem
93#endif
94
95#if !defined(__cache_aligned)
96#ifdef __GNUC__
97#define __cache_aligned __attribute__ ((__aligned__(64)))
98#else
99#define __cache_aligned
100#endif
101#endif
102
103#if !defined(INLINE)
104#ifdef __GNUC__
105#define INLINE inline
106#else
107#define INLINE
108#endif
109#endif
110
111/* *INDENT-OFF* */
112#ifdef __cplusplus
113}
114#endif
115/* *INDENT-ON* */
116/** @} end of Common group */
117#endif				/* __TYPES_H__ */
118