Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
AnjaneeDevi Kapparapu | 24b52ff | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013 The Linux Foundation. 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. |
Gopichand Nakkala | 9c070ad | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
AnjaneeDevi Kapparapu | 24b52ff | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Gopichand Nakkala | 9c070ad | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 28 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | * Compiler abstraction layer |
| 30 | * |
| 31 | * |
| 32 | * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 33 | * This file tries to abstract the differences among compilers. |
| 34 | * Supported compilers are : |
| 35 | * |
| 36 | * - GNU C/C++ compiler |
| 37 | * - Microsoft C/C++ compiler |
| 38 | * - Intel C/C++ compiler |
| 39 | * |
| 40 | * Written by Ho Lee |
| 41 | */ |
| 42 | |
| 43 | #ifndef __ANI_COMPILER_ABSTRACT_H |
| 44 | #define __ANI_COMPILER_ABSTRACT_H |
| 45 | |
| 46 | /* |
| 47 | * 1. GNU C/C++ Compiler |
| 48 | * |
| 49 | * How to detect gcc : __GNUC__ |
| 50 | * How to detect gcc version : |
| 51 | * major version : __GNUC__ (2 = 2.x, 3 = 3.x, 4 = 4.x) |
| 52 | * minor version : __GNUC_MINOR__ |
| 53 | * |
| 54 | * 2. Microsoft C/C++ Compiler |
| 55 | * |
| 56 | * How to detect msc : _MSC_VER |
| 57 | * How to detect msc version : |
| 58 | * _MSC_VER (1200 = MSVC 6.0, 1300 = MSVC 7.0, ...) |
| 59 | * |
| 60 | * 3. Intel C/C++ Compiler |
| 61 | * |
| 62 | * How to detect icc : __INTEL_COMPILER, __ICC (legacy), __ECC (legacy) |
| 63 | * How to detect icc version : |
| 64 | * __INTEL_COMPILER, __ICC, __ECC (700 = 7.0, 900 = 9.0, ...) |
| 65 | * |
| 66 | * 4. Other compilers (not supported) |
| 67 | * |
| 68 | * Borland : __BORLANDC__ |
| 69 | * Greenhills : __ghs |
| 70 | * Metrowerks : __MWERKS__ |
| 71 | * SGI MIPSpro : __sgi |
| 72 | */ |
| 73 | |
| 74 | /* |
| 75 | * Packing directives : These are used to force compiler to pack bits and |
| 76 | * bytes in the data structure. C standard does not regulate this strictly, |
| 77 | * and many things are to compiler implementation. Many compilers support |
| 78 | * compiler specific directives or options that allow different packing |
| 79 | * and alignment. |
| 80 | * |
| 81 | * Alignment directives : Compiler may think packed data structures have |
| 82 | * no specific alignment requirement. Then compiler may generate multiple |
| 83 | * byte accesses to access two byte or four bytes data structures. This |
| 84 | * affects on performance especially for RISC systems. If some data |
| 85 | * structure is located on specific alignment always, alignment directives |
| 86 | * help compiler generate more efficient codes. |
| 87 | */ |
| 88 | |
| 89 | #undef __ANI_COMPILER_PRAGMA_PACK_STACK |
| 90 | #undef __ANI_COMPILER_PRAGMA_PACK |
| 91 | |
| 92 | #if defined(_MSC_VER) |
| 93 | #define __ANI_COMPILER_PRAGMA_PACK_STACK 1 |
| 94 | #define __ANI_COMPILER_PRAGMA_PACK 1 |
| 95 | #define __ani_attr_pre_packed |
| 96 | #define __ani_attr_packed |
| 97 | #define __ani_attr_aligned_2 |
| 98 | #define __ani_attr_aligned_4 |
| 99 | #define __ani_attr_aligned_8 |
| 100 | #define __ani_attr_aligned_16 |
| 101 | #define __ani_attr_aligned_32 |
| 102 | #elif defined(__INTEL_COMPILER) || defined(__ICC) || defined(__ECC) |
| 103 | #define __ANI_COMPILER_PRAGMA_PACK 1 |
| 104 | #define __ani_attr_pre_packed |
| 105 | #define __ani_attr_packed |
| 106 | #define __ani_attr_aligned_2 |
| 107 | #define __ani_attr_aligned_4 |
| 108 | #define __ani_attr_aligned_8 |
| 109 | #define __ani_attr_aligned_16 |
| 110 | #define __ani_attr_aligned_32 |
| 111 | #elif defined(__GNUC__) |
| 112 | #define __ani_attr_pre_packed |
Madan Mohan Koyyalamudi | 4e31b13 | 2012-11-02 13:13:52 -0700 | [diff] [blame] | 113 | #define __ani_attr_packed __packed |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 114 | #define __ani_attr_aligned_2 __attribute__((aligned(2))) |
| 115 | #define __ani_attr_aligned_4 __attribute__((aligned(4))) |
| 116 | #define __ani_attr_aligned_8 __attribute__((aligned(8))) |
| 117 | #define __ani_attr_aligned_16 __attribute__((aligned(16))) |
| 118 | #define __ani_attr_aligned_32 __attribute__((aligned(32))) |
| 119 | #elif defined(ANI_COMPILER_TYPE_RVCT) |
| 120 | /* Nothing defined so far */ |
| 121 | #define __ani_attr_packed |
| 122 | #define __ani_attr_pre_packed __packed |
| 123 | #define __ani_attr_aligned_2 __align(2) |
| 124 | #define __ani_attr_aligned_4 __align(4) |
| 125 | #define __ani_attr_aligned_8 __align(8) |
| 126 | #define __ani_attr_aligned_16 __align(16) |
| 127 | #define __ani_attr_aligned_32 __align(32) |
| 128 | #else |
| 129 | #error "Unknown compiler" |
| 130 | #endif |
| 131 | |
| 132 | #if defined(ANI_DATAPATH_SECTION) |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 133 | #define __DP_SRC_RX __attribute__((section(".dpsrcrx"))) |
| 134 | #define __DP_SRC_TX __attribute__((section(".dpsrctx"))) |
| 135 | #define __DP_SRC __attribute__((section(".dpsrc"))) |
| 136 | #define __ANIHDD_MODULE __attribute__((section(".anihdd"))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 137 | #else |
| 138 | #define __DP_SRC_RX |
| 139 | #define __DP_SRC_TX |
| 140 | #define __DP_SRC |
| 141 | #define __ANIHDD_MODULE |
| 142 | #endif |
| 143 | |
| 144 | #endif |
| 145 | |