blitz Version 0.10
|
00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * blitz/compiler.h Compiler specific directives and kludges 00004 * 00005 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org> 00006 * 00007 * This file is a part of Blitz. 00008 * 00009 * Blitz is free software: you can redistribute it and/or modify 00010 * it under the terms of the GNU Lesser General Public License 00011 * as published by the Free Software Foundation, either version 3 00012 * of the License, or (at your option) any later version. 00013 * 00014 * Blitz is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with Blitz. If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 * Suggestions: blitz-devel@lists.sourceforge.net 00023 * Bugs: blitz-support@lists.sourceforge.net 00024 * 00025 * For more information, please see the Blitz++ Home Page: 00026 * https://sourceforge.net/projects/blitz/ 00027 * 00028 ***************************************************************************/ 00029 00030 00031 #ifndef BZ_COMPILER_H 00032 #define BZ_COMPILER_H 00033 00034 // The file <blitz/bzconfig.h> is used to select a compiler-specific 00035 // config.h file that is generated automatically by configure. 00036 00037 #include <blitz/bzconfig.h> 00038 00039 /* 00040 * Define some kludges. 00041 */ 00042 00043 #ifndef BZ_HAVE_TEMPLATES 00044 #error In <blitz/config.h>: A working template implementation is required by Blitz++ (you may need to rerun the compiler/bzconfig script) 00045 #endif 00046 00047 #ifndef BZ_HAVE_MEMBER_TEMPLATES 00048 #error In <blitz/config.h>: Your compiler does not support member templates. (you may need to rerun the compiler/bzconfig script) 00049 #endif 00050 00051 #ifndef BZ_HAVE_FULL_SPECIALIZATION_SYNTAX 00052 #error In <blitz/config.h>: Your compiler does not support template<> full specialization syntax. You may need to rerun the compiler/bzconfig script. 00053 #endif 00054 00055 #ifndef BZ_HAVE_PARTIAL_ORDERING 00056 #error In <blitz/config.h>: Your compiler does not support partial ordering (you may need to rerun the compiler/bzconfig script) 00057 #endif 00058 00059 #ifndef BZ_HAVE_PARTIAL_SPECIALIZATION 00060 #error In <blitz/config.h>: Your compiler does not support partial specialization (you may need to rerun the compiler/bzconfig script) 00061 #endif 00062 00063 #ifdef BZ_HAVE_NAMESPACES 00064 #define BZ_NAMESPACE(X) namespace X { 00065 #define BZ_NAMESPACE_END } 00066 #define BZ_USING_NAMESPACE(X) using namespace X; 00067 #else 00068 #define BZ_NAMESPACE(X) 00069 #define BZ_NAMESPACE_END 00070 #define BZ_USING_NAMESPACE(X) 00071 #endif 00072 00073 #ifdef BZ_HAVE_TEMPLATE_QUALIFIED_RETURN_TYPE 00074 #define BZ_USE_NUMTRAIT 00075 #endif 00076 00077 #ifdef BZ_HAVE_DEFAULT_TEMPLATE_PARAMETERS 00078 #define BZ_TEMPLATE_DEFAULT(X) = X 00079 #else 00080 #define BZ_TEMPLATE_DEFAULT(X) 00081 #endif 00082 00083 #ifndef BZ_HAVE_EXPLICIT 00084 #define explicit 00085 #endif 00086 00087 #ifdef BZ_HAVE_TYPENAME 00088 #define _bz_typename typename 00089 #else 00090 #define _bz_typename 00091 #endif 00092 00093 #ifndef BZ_HAVE_MUTABLE 00094 #define mutable 00095 #endif 00096 00097 #ifdef BZ_DISABLE_RESTRICT 00098 #undef BZ_HAVE_NCEG_RESTRICT 00099 #endif 00100 00101 #ifndef BZ_HAVE_NCEG_RESTRICT 00102 #if defined(BZ_HAVE_NCEG_RESTRICT_EGCS) 00103 #define restrict __restrict__ 00104 #else 00105 #define restrict 00106 #endif 00107 #endif 00108 00109 #if !defined(BZ_HAVE_BOOL) && !defined(BZ_NO_BOOL_KLUDGE) 00110 #define bool int 00111 #define true 1 00112 #define false 0 00113 #endif 00114 00115 #ifdef BZ_HAVE_ENUM_COMPUTATIONS_WITH_CAST 00116 #define BZ_ENUM_CAST(X) (int)X 00117 #elif defined(BZ_HAVE_ENUM_COMPUTATIONS) 00118 #define BZ_ENUM_CAST(X) X 00119 #else 00120 #error In <blitz/config.h>: Your compiler does not support enum computations. You may have to rerun compiler/bzconfig. 00121 #endif 00122 00123 #if defined(BZ_MATH_FN_IN_NAMESPACE_STD) 00124 #define BZ_MATHFN_SCOPE(x) std::x 00125 #elif defined(BZ_HAVE_NAMESPACES) 00126 #define BZ_MATHFN_SCOPE(x) ::x 00127 #else 00128 #define BZ_MATHFN_SCOPE(x) x 00129 #endif 00130 00131 #if defined(BZ_MATH_ABSINT_IN_NAMESPACE_STD) 00132 #include <cstdlib> 00133 #else 00134 #include <stdlib.h> 00135 #endif 00136 00137 #if defined(BZ_MATH_ABSINT_IN_NAMESPACE_STD) 00138 #define BZ_MATHABSINT_SCOPE(x) std::x 00139 #elif defined(BZ_HAVE_NAMESPACES) 00140 #define BZ_MATHABSINT_SCOPE(x) ::x 00141 #else 00142 #define BZ_MATHABSINT_SCOPE(x) x 00143 #endif 00144 00145 #if defined(BZ_HAVE_COMPLEX_MATH_IN_NAMESPACE_STD) 00146 #define BZ_CMATHFN_SCOPE(x) std::x 00147 #elif defined(BZ_HAVE_NAMESPACES) 00148 #define BZ_CMATHFN_SCOPE(x) ::x 00149 #else 00150 #define BZ_CMATHFN_SCOPE(x) x 00151 #endif 00152 00153 #if defined(BZ_HAVE_NAMESPACES) 00154 #define BZ_IEEEMATHFN_SCOPE(x) ::x 00155 #else 00156 #define BZ_IEEEMATHFN_SCOPE(x) x 00157 #endif 00158 00159 #if defined(BZ_HAVE_NAMESPACES) 00160 #define BZ_BLITZ_SCOPE(x) blitz::x 00161 #else 00162 #define BZ_BLITZ_SCOPE(x) ::x 00163 #endif 00164 00165 #if defined(BZ_HAVE_NAMESPACES) && defined(BZ_HAVE_STD) 00166 #define BZ_STD_SCOPE(x) std::x 00167 #else 00168 #define BZ_STD_SCOPE(x) ::x 00169 #endif 00170 00171 // These macros are just markers to document the code in the places 00172 // where playing with the processor branch prediction scheme might 00173 // help. For now these are just nops. 00174 00175 #define BZ_LIKELY(x) (x) 00176 #define BZ_UNLIKELY(x) (x) 00177 00178 #endif // BZ_COMPILER_H 00179