| 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|---|
| 2 | /* ***** BEGIN LICENSE BLOCK ***** |
|---|
| 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
|---|
| 4 | * |
|---|
| 5 | * The contents of this file are subject to the Mozilla Public License Version |
|---|
| 6 | * 1.1 (the "License"); you may not use this file except in compliance with |
|---|
| 7 | * the License. You may obtain a copy of the License at |
|---|
| 8 | * http://www.mozilla.org/MPL/ |
|---|
| 9 | * |
|---|
| 10 | * Software distributed under the License is distributed on an "AS IS" basis, |
|---|
| 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
|---|
| 12 | * for the specific language governing rights and limitations under the |
|---|
| 13 | * License. |
|---|
| 14 | * |
|---|
| 15 | * The Original Code is mozilla.org code. |
|---|
| 16 | * |
|---|
| 17 | * The Initial Developer of the Original Code is |
|---|
| 18 | * Netscape Communications Corporation. |
|---|
| 19 | * Portions created by the Initial Developer are Copyright (C) 1999 |
|---|
| 20 | * the Initial Developer. All Rights Reserved. |
|---|
| 21 | * |
|---|
| 22 | * Contributor(s): |
|---|
| 23 | * |
|---|
| 24 | * Alternatively, the contents of this file may be used under the terms of |
|---|
| 25 | * either of the GNU General Public License Version 2 or later (the "GPL"), |
|---|
| 26 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
|---|
| 27 | * in which case the provisions of the GPL or the LGPL are applicable instead |
|---|
| 28 | * of those above. If you wish to allow use of your version of this file only |
|---|
| 29 | * under the terms of either the GPL or the LGPL, and not to allow others to |
|---|
| 30 | * use your version of this file under the terms of the MPL, indicate your |
|---|
| 31 | * decision by deleting the provisions above and replace them with the notice |
|---|
| 32 | * and other provisions required by the GPL or the LGPL. If you do not delete |
|---|
| 33 | * the provisions above, a recipient may use your version of this file under |
|---|
| 34 | * the terms of any one of the MPL, the GPL or the LGPL. |
|---|
| 35 | * |
|---|
| 36 | * ***** END LICENSE BLOCK ***** */ |
|---|
| 37 | |
|---|
| 38 | /* Platform specific #defines to be shared by the various platforms sharing |
|---|
| 39 | * the unixish_86 code |
|---|
| 40 | */ |
|---|
| 41 | |
|---|
| 42 | /* |
|---|
| 43 | * The goal here is to clearly define the binary compatibility parameters for |
|---|
| 44 | * the platforms that will use this code. Rather than switch at compile time |
|---|
| 45 | * based on the compiler that happens to be in use we are forcing implementors |
|---|
| 46 | * to make a conscious decision. |
|---|
| 47 | * |
|---|
| 48 | * For some of these platforms the community may choose to have more than one |
|---|
| 49 | * binary model in effect. In that case I suggest that there be explicit sub |
|---|
| 50 | * defines for that platform specifying 'TYPE1', 'TYPE2', etc. The decision on |
|---|
| 51 | * which 'TYPE' to use would be triggered by a setting passed through from the |
|---|
| 52 | * config system. |
|---|
| 53 | * |
|---|
| 54 | * For example we might end up with something like: |
|---|
| 55 | * |
|---|
| 56 | * #elif defined(NTO) |
|---|
| 57 | * # if defined(TYPE1) |
|---|
| 58 | * # define CFRONT_STYLE_THIS_ADJUST |
|---|
| 59 | * # elif defined(TYPE1) |
|---|
| 60 | * # define THUNK_BASED_THIS_ADJUST |
|---|
| 61 | * # else |
|---|
| 62 | * # error "need TYPE1 or TYPE2 for NTO" |
|---|
| 63 | * # endif |
|---|
| 64 | * #elif defined(__BEOS__) |
|---|
| 65 | * |
|---|
| 66 | * and so on.... |
|---|
| 67 | * |
|---|
| 68 | */ |
|---|
| 69 | |
|---|
| 70 | #if defined(LINUX) || (defined(__GLIBC__) && (defined(__FreeBSD_kernel__) || defined(__GNU__))) |
|---|
| 71 | |
|---|
| 72 | #if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 7) |
|---|
| 73 | /* Old gcc 2.7.x.x. What does gcc 2.8.x do?? */ |
|---|
| 74 | #define CFRONT_STYLE_THIS_ADJUST |
|---|
| 75 | #else |
|---|
| 76 | /* egcs and later */ |
|---|
| 77 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 78 | #endif |
|---|
| 79 | |
|---|
| 80 | #elif defined(__FreeBSD__) |
|---|
| 81 | /* System versions of gcc on FreeBSD don't use thunks. On 3.x, the system |
|---|
| 82 | * compiler is gcc 2.7.2.3, which doesn't use thunks by default. On 4.x and |
|---|
| 83 | * 5.x, /usr/src/contrib/gcc/config/freebsd.h explicitly undef's |
|---|
| 84 | * DEFAULT_VTABLE_THUNKS. (The one exception is a brief period (September |
|---|
| 85 | * 1999 - Jan 2000) during 4.0-CURRENT, after egcs was merged -- |
|---|
| 86 | * this was changed before 4.0-RELEASE, but we can handle it anyway.) |
|---|
| 87 | * |
|---|
| 88 | * Versions of gcc from the ports collection (/usr/ports/lang/egcs), |
|---|
| 89 | * however, have DEFAULT_VTABLE_THUNKS #defined to 1, at least |
|---|
| 90 | * in all ports collections since the 2.95 merge. (Supporting optional |
|---|
| 91 | * compilers from FreeBSD 3.2 or earlier seems unnecessary). |
|---|
| 92 | * |
|---|
| 93 | * The easiest way to distinguish the ports collection gcc from the system |
|---|
| 94 | * gcc is that the system gcc defines __FreeBSD_cc_version. This variable |
|---|
| 95 | * can also identify versions that use thunks. This includes some 4.x versions |
|---|
| 96 | * and now newer 5.x versions. |
|---|
| 97 | */ |
|---|
| 98 | #if defined(__FreeBSD_cc_version) && \ |
|---|
| 99 | (__FreeBSD_cc_version < 500003) && \ |
|---|
| 100 | (__FreeBSD_cc_version < 400002 || __FreeBSD_cc_version > 400003) |
|---|
| 101 | #define CFRONT_STYLE_THIS_ADJUST |
|---|
| 102 | #else |
|---|
| 103 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 104 | #endif |
|---|
| 105 | |
|---|
| 106 | #elif defined(__NetBSD__) |
|---|
| 107 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 108 | |
|---|
| 109 | #elif defined(__OpenBSD__) |
|---|
| 110 | #if __GNUC__ >= 3 |
|---|
| 111 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 112 | #else |
|---|
| 113 | /* OpenBSD introduces GCC 2.95.x in late May 1999 */ |
|---|
| 114 | #include <sys/param.h> |
|---|
| 115 | #if OpenBSD <= 199905 |
|---|
| 116 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 117 | #else |
|---|
| 118 | #define CFRONT_STYLE_THIS_ADJUST |
|---|
| 119 | #endif |
|---|
| 120 | #endif |
|---|
| 121 | |
|---|
| 122 | #elif defined(__bsdi__) |
|---|
| 123 | #include <sys/param.h> |
|---|
| 124 | #if _BSDI_VERSION >= 199910 |
|---|
| 125 | /* BSDI/4.1 ships with egcs, ergo thunk-based */ |
|---|
| 126 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 127 | #else |
|---|
| 128 | #define CFRONT_STYLE_THIS_ADJUST |
|---|
| 129 | #endif |
|---|
| 130 | |
|---|
| 131 | #elif defined(NTO) |
|---|
| 132 | #if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 7) |
|---|
| 133 | /* Old gcc 2.7.x.x. What does gcc 2.8.x do?? */ |
|---|
| 134 | #define CFRONT_STYLE_THIS_ADJUST |
|---|
| 135 | #else |
|---|
| 136 | /* egcs and later */ |
|---|
| 137 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 138 | #endif |
|---|
| 139 | |
|---|
| 140 | #elif defined(__BEOS__) |
|---|
| 141 | #define CFRONT_STYLE_THIS_ADJUST |
|---|
| 142 | |
|---|
| 143 | #elif defined(__sun__) || defined(__sun) |
|---|
| 144 | #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */ |
|---|
| 145 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 146 | #else |
|---|
| 147 | #define CFRONT_STYLE_THIS_ADJUST |
|---|
| 148 | #endif |
|---|
| 149 | |
|---|
| 150 | #elif defined(_WIN32) |
|---|
| 151 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 152 | |
|---|
| 153 | #elif defined(__EMX__) |
|---|
| 154 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 155 | |
|---|
| 156 | #elif defined (__APPLE__) && (__MACH__) |
|---|
| 157 | #define THUNK_BASED_THIS_ADJUST |
|---|
| 158 | |
|---|
| 159 | #else |
|---|
| 160 | #error "need a platform define if using unixish x86 code" |
|---|
| 161 | #endif |
|---|
| 162 | |
|---|
| 163 | /***************************************************************************/ |
|---|
| 164 | |
|---|
| 165 | #if !defined(THUNK_BASED_THIS_ADJUST) && !defined(CFRONT_STYLE_THIS_ADJUST) |
|---|
| 166 | #error "need to define 'this' adjust scheme" |
|---|
| 167 | #endif |
|---|
| 168 | |
|---|
| 169 | #if defined(THUNK_BASED_THIS_ADJUST) && defined(CFRONT_STYLE_THIS_ADJUST) |
|---|
| 170 | #error "need to define only ONE 'this' adjust scheme" |
|---|
| 171 | #endif |
|---|
| 172 | |
|---|
| 173 | #if defined(__QNXNTO__) |
|---|
| 174 | /* Define KEEP_STACK_16_BYTE_ALIGNED if the stack needs to maintain alignment |
|---|
| 175 | * in a CALL for some good reason (like ABI compliance). */ |
|---|
| 176 | #define KEEP_STACK_16_BYTE_ALIGNED |
|---|
| 177 | #endif |
|---|