Back to index

lightning-sunbird  0.9+nobinonly
xptc_platforms_unixish_x86.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /* Platform specific #defines to be shared by the various platforms sharing 
00039 *  the unixish_86 code
00040 */
00041 
00042 /*
00043 *  The goal here is to clearly define the binary compatibility parameters for
00044 *  the platforms that will use this code. Rather than switch at compile time
00045 *  based on the compiler that happens to be in use we are forcing implementors
00046 *  to make a conscious decision.
00047 *
00048 *  For some of these platforms the community may choose to have more than one
00049 *  binary model in effect. In that case I suggest that there be explicit sub
00050 *  defines for that platform specifying 'TYPE1', 'TYPE2', etc. The decision on
00051 *  which 'TYPE' to use would be triggered by a setting passed through from the 
00052 *  config system.
00053 *
00054 *  For example we might end up with something like:
00055 *
00056 * #elif defined(NTO) 
00057 * #  if defined(TYPE1)
00058 * #    define CFRONT_STYLE_THIS_ADJUST
00059 * #  elif defined(TYPE1) 
00060 * #    define THUNK_BASED_THIS_ADJUST
00061 * #  else
00062 * #    error "need TYPE1 or TYPE2 for NTO"
00063 * #  endif
00064 * #elif defined(__BEOS__) 
00065 *
00066 *  and so on....
00067 *
00068 */
00069 
00070 #if defined(LINUX)
00071 
00072 #if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 7)
00073 /* Old gcc 2.7.x.x.  What does gcc 2.8.x do?? */
00074 #define CFRONT_STYLE_THIS_ADJUST
00075 #else
00076 /* egcs and later */
00077 #define THUNK_BASED_THIS_ADJUST
00078 #endif
00079 
00080 #elif defined(__FreeBSD__) 
00081 /* System versions of gcc on FreeBSD don't use thunks.  On 3.x, the system
00082  * compiler is gcc 2.7.2.3, which doesn't use thunks by default.  On 4.x and
00083  * 5.x, /usr/src/contrib/gcc/config/freebsd.h explicitly undef's
00084  * DEFAULT_VTABLE_THUNKS.  (The one exception is a brief period (September
00085  * 1999 - Jan 2000) during 4.0-CURRENT, after egcs was merged --
00086  * this was changed before 4.0-RELEASE, but we can handle it anyway.)
00087  *
00088  * Versions of gcc from the ports collection (/usr/ports/lang/egcs),
00089  * however, have DEFAULT_VTABLE_THUNKS #defined to 1, at least
00090  * in all ports collections since the 2.95 merge.  (Supporting optional
00091  * compilers from FreeBSD 3.2 or earlier seems unnecessary).
00092  *
00093  * The easiest way to distinguish the ports collection gcc from the system
00094  * gcc is that the system gcc defines __FreeBSD_cc_version.  This variable
00095  * can also identify versions that use thunks. This includes some 4.x versions
00096  * and now newer 5.x versions.
00097  */
00098 #if defined(__FreeBSD_cc_version) && \
00099     (__FreeBSD_cc_version < 500003) && \
00100     (__FreeBSD_cc_version < 400002 || __FreeBSD_cc_version > 400003)
00101 #define CFRONT_STYLE_THIS_ADJUST
00102 #else
00103 #define THUNK_BASED_THIS_ADJUST
00104 #endif
00105 
00106 #elif defined(__NetBSD__) 
00107 #define THUNK_BASED_THIS_ADJUST
00108 
00109 #elif defined(__OpenBSD__) 
00110 #if __GNUC__ >= 3
00111 #define THUNK_BASED_THIS_ADJUST
00112 #else
00113 /* OpenBSD introduces GCC 2.95.x in late May 1999 */
00114 #include <sys/param.h>
00115 #if OpenBSD <= 199905
00116 #define THUNK_BASED_THIS_ADJUST
00117 #else
00118 #define CFRONT_STYLE_THIS_ADJUST
00119 #endif
00120 #endif
00121 
00122 #elif defined(__bsdi__) 
00123 #include <sys/param.h>
00124 #if _BSDI_VERSION >= 199910
00125 /* BSDI/4.1 ships with egcs, ergo thunk-based */
00126 #define THUNK_BASED_THIS_ADJUST
00127 #else
00128 #define CFRONT_STYLE_THIS_ADJUST
00129 #endif
00130 
00131 #elif defined(NTO) 
00132 #if (__GNUC__ == 2) && (__GNUC_MINOR__ <= 7)
00133 /* Old gcc 2.7.x.x.  What does gcc 2.8.x do?? */
00134 #define CFRONT_STYLE_THIS_ADJUST
00135 #else
00136 /* egcs and later */
00137 #define THUNK_BASED_THIS_ADJUST
00138 #endif
00139 
00140 #elif defined(__BEOS__) 
00141 #define CFRONT_STYLE_THIS_ADJUST
00142 
00143 #elif defined(__sun__) || defined(__sun)
00144 #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
00145 #define THUNK_BASED_THIS_ADJUST
00146 #else
00147 #define CFRONT_STYLE_THIS_ADJUST
00148 #endif
00149 
00150 #elif defined(_WIN32)
00151 #define THUNK_BASED_THIS_ADJUST
00152 
00153 #elif defined(__EMX__)
00154 #define THUNK_BASED_THIS_ADJUST
00155 
00156 #elif defined (__APPLE__) && (__MACH__)
00157 #define THUNK_BASED_THIS_ADJUST
00158 
00159 #else
00160 #error "need a platform define if using unixish x86 code"
00161 #endif
00162 
00163 /***************************************************************************/
00164 
00165 #if !defined(THUNK_BASED_THIS_ADJUST) && !defined(CFRONT_STYLE_THIS_ADJUST)
00166 #error "need to define 'this' adjust scheme"    
00167 #endif
00168 
00169 #if defined(THUNK_BASED_THIS_ADJUST) && defined(CFRONT_STYLE_THIS_ADJUST)
00170 #error "need to define only ONE 'this' adjust scheme"    
00171 #endif
00172 
00173 /* Define KEEP_STACK_16_BYTE_ALIGNED if the stack needs to maintain alignment
00174  * in a CALL for some good reason (like ABI compliance). */
00175 
00176 #if defined(XP_MACOSX) || defined(__QNXNTO__)
00177 /* http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/Articles/IA32.html */
00178 #define KEEP_STACK_16_BYTE_ALIGNED
00179 #endif