PageRenderTime 19ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcommon/llpreprocessor.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 183 lines | 113 code | 24 blank | 46 comment | 12 complexity | a2a878d27cb31fde18dab4fcb2e39ea8 MD5 | raw file
  1/** 
  2 * @file llpreprocessor.h
  3 * @brief This file should be included in all Linden Lab files and
  4 * should only contain special preprocessor directives
  5 *
  6 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#ifndef LLPREPROCESSOR_H
 29#define LLPREPROCESSOR_H
 30
 31// Figure out endianness of platform
 32#ifdef LL_LINUX
 33#define __ENABLE_WSTRING
 34#include <endian.h>
 35#endif	//	LL_LINUX
 36
 37#if LL_SOLARIS
 38#   ifdef  __sparc     // Since we're talking Solaris 10 and up, only 64 bit is supported.
 39#      define LL_BIG_ENDIAN 1
 40#      define LL_SOLARIS_ALIGNED_CPU 1     //  used to designate issues where SPARC alignment is addressed
 41#      define LL_SOLARIS_NON_MESA_GL 1      //  The SPARC GL does not provide a MESA-based GL API
 42#   endif
 43#   include <sys/isa_defs.h> // ensure we know which end is up
 44#endif // LL_SOLARIS
 45
 46#if (defined(LL_WINDOWS) || (defined(LL_LINUX) && (__BYTE_ORDER == __LITTLE_ENDIAN)) || (defined(LL_DARWIN) && defined(__LITTLE_ENDIAN__)) || (defined(LL_SOLARIS) && defined(__i386)))
 47#define LL_LITTLE_ENDIAN 1
 48#else
 49#define LL_BIG_ENDIAN 1
 50#endif
 51
 52
 53// Per-compiler switches
 54
 55#ifdef __GNUC__
 56#define LL_FORCE_INLINE inline __attribute__((always_inline))
 57#else
 58#define LL_FORCE_INLINE __forceinline
 59#endif
 60
 61// Mark-up expressions with branch prediction hints.  Do NOT use
 62// this with reckless abandon - it's an obfuscating micro-optimization
 63// outside of inner loops or other places where you are OVERWHELMINGLY
 64// sure which way an expression almost-always evaluates.
 65#if __GNUC__ >= 3
 66# define LL_LIKELY(EXPR) __builtin_expect (!!(EXPR), true)
 67# define LL_UNLIKELY(EXPR) __builtin_expect (!!(EXPR), false)
 68#else
 69# define LL_LIKELY(EXPR) (EXPR)
 70# define LL_UNLIKELY(EXPR) (EXPR)
 71#endif
 72
 73
 74// Figure out differences between compilers
 75#if defined(__GNUC__)
 76	#define GCC_VERSION (__GNUC__ * 10000 \
 77						+ __GNUC_MINOR__ * 100 \
 78						+ __GNUC_PATCHLEVEL__)
 79	#ifndef LL_GNUC
 80		#define LL_GNUC 1
 81	#endif
 82#elif defined(__MSVC_VER__) || defined(_MSC_VER)
 83	#ifndef LL_MSVC
 84		#define LL_MSVC 1
 85	#endif
 86	#if _MSC_VER < 1400
 87		#define LL_MSVC7 //Visual C++ 2003 or earlier
 88	#endif
 89#endif
 90
 91// Deal with minor differences on Unixy OSes.
 92#if LL_DARWIN || LL_LINUX
 93	// Different name, same functionality.
 94	#define stricmp strcasecmp
 95	#define strnicmp strncasecmp
 96
 97	// Not sure why this is different, but...
 98	#ifndef MAX_PATH
 99		#define MAX_PATH PATH_MAX
100	#endif	//	not MAX_PATH
101
102#endif
103
104
105// Static linking with apr on windows needs to be declared.
106#if LL_WINDOWS && !LL_COMMON_LINK_SHARED
107#ifndef APR_DECLARE_STATIC
108#define APR_DECLARE_STATIC // For APR on Windows
109#endif
110#ifndef APU_DECLARE_STATIC
111#define APU_DECLARE_STATIC // For APR util on Windows
112#endif
113#endif
114
115#if defined(LL_WINDOWS)
116#define BOOST_REGEX_NO_LIB 1
117#define CURL_STATICLIB 1
118#ifndef XML_STATIC
119#define XML_STATIC
120#endif
121#endif	//	LL_WINDOWS
122
123
124// Deal with VC6 problems
125#if LL_MSVC
126#pragma warning( 3	     : 4701 )	// "local variable used without being initialized"  Treat this as level 3, not level 4.
127#pragma warning( 3	     : 4702 )	// "unreachable code"  Treat this as level 3, not level 4.
128#pragma warning( 3	     : 4189 )	// "local variable initialized but not referenced"  Treat this as level 3, not level 4.
129//#pragma warning( 3	: 4018 )	// "signed/unsigned mismatch"  Treat this as level 3, not level 4.
130#pragma warning( 3      :  4263 )	// 'function' : member function does not override any base class virtual member function
131#pragma warning( 3      :  4264 )	// "'virtual_function' : no override available for virtual member function from base 'class'; function is hidden"
132#pragma warning( 3       : 4265 )	// "class has virtual functions, but destructor is not virtual"
133#pragma warning( 3      :  4266 )	// 'function' : no override available for virtual member function from base 'type'; function is hidden
134#pragma warning (disable : 4180)	// qualifier applied to function type has no meaning; ignored
135#pragma warning( disable : 4284 )	// silly MS warning deep inside their <map> include file
136#pragma warning( disable : 4503 )	// 'decorated name length exceeded, name was truncated'. Does not seem to affect compilation.
137#pragma warning( disable : 4800 )	// 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
138#pragma warning( disable : 4996 )	// warning: deprecated
139
140// Linker optimization with "extern template" generates these warnings
141#pragma warning( disable : 4231 )	// nonstandard extension used : 'extern' before template explicit instantiation
142#pragma warning( disable : 4506 )   // no definition for inline function
143
144// level 4 warnings that we need to disable:
145#pragma warning (disable : 4100) // unreferenced formal parameter
146#pragma warning (disable : 4127) // conditional expression is constant (e.g. while(1) )
147#pragma warning (disable : 4244) // possible loss of data on conversions
148#pragma warning (disable : 4396) // the inline specifier cannot be used when a friend declaration refers to a specialization of a function template
149#pragma warning (disable : 4512) // assignment operator could not be generated
150#pragma warning (disable : 4706) // assignment within conditional (even if((x = y)) )
151
152#pragma warning (disable : 4251) // member needs to have dll-interface to be used by clients of class
153#pragma warning (disable : 4275) // non dll-interface class used as base for dll-interface class
154#pragma warning (disable : 4018) // '<' : signed/unsigned mismatch	
155#endif	//	LL_MSVC
156
157#if LL_WINDOWS
158#define LL_DLLEXPORT __declspec(dllexport)
159#define LL_DLLIMPORT __declspec(dllimport)
160#elif LL_LINUX
161#define LL_DLLEXPORT __attribute__ ((visibility("default")))
162#define LL_DLLIMPORT
163#else
164#define LL_DLLEXPORT
165#define LL_DLLIMPORT
166#endif // LL_WINDOWS
167
168#if LL_COMMON_LINK_SHARED
169// CMake automagically defines llcommon_EXPORTS only when building llcommon
170// sources, and only when llcommon is a shared library (i.e. when
171// LL_COMMON_LINK_SHARED). We must still test LL_COMMON_LINK_SHARED because
172// otherwise we can't distinguish between (non-llcommon source) and (llcommon
173// not shared).
174# if defined(llcommon_EXPORTS)
175#   define LL_COMMON_API LL_DLLEXPORT
176# else //llcommon_EXPORTS
177#   define LL_COMMON_API LL_DLLIMPORT
178# endif //llcommon_EXPORTS
179#else // LL_COMMON_LINK_SHARED
180# define LL_COMMON_API
181#endif // LL_COMMON_LINK_SHARED
182
183#endif	//	not LL_LINDEN_PREPROCESSOR_H