blob: 91b6b1e9019f525e748084969a06e9acae235ab8 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * Compiler abstraction layer
24 *
25 *
26 *
27 * Copyright (C) 2005-2006 Airgo Networks, Inc
28 * This file tries to abstract the differences among compilers.
29 * Supported compilers are :
30 *
31 * - GNU C/C++ compiler
32 * - Microsoft C/C++ compiler
33 * - Intel C/C++ compiler
34 *
35 * Written by Ho Lee
36 */
37
38#ifndef __ANI_COMPILER_ABSTRACT_H
39#define __ANI_COMPILER_ABSTRACT_H
40
41/*
42 * 1. GNU C/C++ Compiler
43 *
44 * How to detect gcc : __GNUC__
45 * How to detect gcc version :
46 * major version : __GNUC__ (2 = 2.x, 3 = 3.x, 4 = 4.x)
47 * minor version : __GNUC_MINOR__
48 *
49 * 2. Microsoft C/C++ Compiler
50 *
51 * How to detect msc : _MSC_VER
52 * How to detect msc version :
53 * _MSC_VER (1200 = MSVC 6.0, 1300 = MSVC 7.0, ...)
54 *
55 * 3. Intel C/C++ Compiler
56 *
57 * How to detect icc : __INTEL_COMPILER, __ICC (legacy), __ECC (legacy)
58 * How to detect icc version :
59 * __INTEL_COMPILER, __ICC, __ECC (700 = 7.0, 900 = 9.0, ...)
60 *
61 * 4. Other compilers (not supported)
62 *
63 * Borland : __BORLANDC__
64 * Greenhills : __ghs
65 * Metrowerks : __MWERKS__
66 * SGI MIPSpro : __sgi
67 */
68
69/*
70 * Packing directives : These are used to force compiler to pack bits and
71 * bytes in the data structure. C standard does not regulate this strictly,
72 * and many things are to compiler implementation. Many compilers support
73 * compiler specific directives or options that allow different packing
74 * and alignment.
75 *
76 * Alignment directives : Compiler may think packed data structures have
77 * no specific alignment requirement. Then compiler may generate multiple
78 * byte accesses to access two byte or four bytes data structures. This
79 * affects on performance especially for RISC systems. If some data
80 * structure is located on specific alignment always, alignment directives
81 * help compiler generate more efficient codes.
82 */
83
84#undef __ANI_COMPILER_PRAGMA_PACK_STACK
85#undef __ANI_COMPILER_PRAGMA_PACK
86
87#if defined(_MSC_VER)
88#define __ANI_COMPILER_PRAGMA_PACK_STACK 1
89#define __ANI_COMPILER_PRAGMA_PACK 1
90#define __ani_attr_pre_packed
91#define __ani_attr_packed
92#define __ani_attr_aligned_2
93#define __ani_attr_aligned_4
94#define __ani_attr_aligned_8
95#define __ani_attr_aligned_16
96#define __ani_attr_aligned_32
97#elif defined(__INTEL_COMPILER) || defined(__ICC) || defined(__ECC)
98#define __ANI_COMPILER_PRAGMA_PACK 1
99#define __ani_attr_pre_packed
100#define __ani_attr_packed
101#define __ani_attr_aligned_2
102#define __ani_attr_aligned_4
103#define __ani_attr_aligned_8
104#define __ani_attr_aligned_16
105#define __ani_attr_aligned_32
106#elif defined(__GNUC__)
107#define __ani_attr_pre_packed
108#define __ani_attr_packed __attribute__((packed))
109#define __ani_attr_aligned_2 __attribute__((aligned(2)))
110#define __ani_attr_aligned_4 __attribute__((aligned(4)))
111#define __ani_attr_aligned_8 __attribute__((aligned(8)))
112#define __ani_attr_aligned_16 __attribute__((aligned(16)))
113#define __ani_attr_aligned_32 __attribute__((aligned(32)))
114#elif defined(ANI_COMPILER_TYPE_RVCT)
115/* Nothing defined so far */
116#define __ani_attr_packed
117#define __ani_attr_pre_packed __packed
118#define __ani_attr_aligned_2 __align(2)
119#define __ani_attr_aligned_4 __align(4)
120#define __ani_attr_aligned_8 __align(8)
121#define __ani_attr_aligned_16 __align(16)
122#define __ani_attr_aligned_32 __align(32)
123#else
124#error "Unknown compiler"
125#endif
126
127#if defined(ANI_DATAPATH_SECTION)
128#define __DP_SRC_RX __attribute__ ((section(".dpsrcrx")))
129#define __DP_SRC_TX __attribute__ ((section(".dpsrctx")))
130#define __DP_SRC __attribute__ ((section(".dpsrc")))
131#define __ANIHDD_MODULE __attribute__ ((section(".anihdd")))
132#else
133#define __DP_SRC_RX
134#define __DP_SRC_TX
135#define __DP_SRC
136#define __ANIHDD_MODULE
137#endif
138
139#endif
140