PageRenderTime 31ms CodeModel.GetById 1ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LLPREPROCESSOR_H
  28. #define LLPREPROCESSOR_H
  29. // Figure out endianness of platform
  30. #ifdef LL_LINUX
  31. #define __ENABLE_WSTRING
  32. #include <endian.h>
  33. #endif // LL_LINUX
  34. #if LL_SOLARIS
  35. # ifdef __sparc // Since we're talking Solaris 10 and up, only 64 bit is supported.
  36. # define LL_BIG_ENDIAN 1
  37. # define LL_SOLARIS_ALIGNED_CPU 1 // used to designate issues where SPARC alignment is addressed
  38. # define LL_SOLARIS_NON_MESA_GL 1 // The SPARC GL does not provide a MESA-based GL API
  39. # endif
  40. # include <sys/isa_defs.h> // ensure we know which end is up
  41. #endif // LL_SOLARIS
  42. #if (defined(LL_WINDOWS) || (defined(LL_LINUX) && (__BYTE_ORDER == __LITTLE_ENDIAN)) || (defined(LL_DARWIN) && defined(__LITTLE_ENDIAN__)) || (defined(LL_SOLARIS) && defined(__i386)))
  43. #define LL_LITTLE_ENDIAN 1
  44. #else
  45. #define LL_BIG_ENDIAN 1
  46. #endif
  47. // Per-compiler switches
  48. #ifdef __GNUC__
  49. #define LL_FORCE_INLINE inline __attribute__((always_inline))
  50. #else
  51. #define LL_FORCE_INLINE __forceinline
  52. #endif
  53. // Mark-up expressions with branch prediction hints. Do NOT use
  54. // this with reckless abandon - it's an obfuscating micro-optimization
  55. // outside of inner loops or other places where you are OVERWHELMINGLY
  56. // sure which way an expression almost-always evaluates.
  57. #if __GNUC__ >= 3
  58. # define LL_LIKELY(EXPR) __builtin_expect (!!(EXPR), true)
  59. # define LL_UNLIKELY(EXPR) __builtin_expect (!!(EXPR), false)
  60. #else
  61. # define LL_LIKELY(EXPR) (EXPR)
  62. # define LL_UNLIKELY(EXPR) (EXPR)
  63. #endif
  64. // Figure out differences between compilers
  65. #if defined(__GNUC__)
  66. #define GCC_VERSION (__GNUC__ * 10000 \
  67. + __GNUC_MINOR__ * 100 \
  68. + __GNUC_PATCHLEVEL__)
  69. #ifndef LL_GNUC
  70. #define LL_GNUC 1
  71. #endif
  72. #elif defined(__MSVC_VER__) || defined(_MSC_VER)
  73. #ifndef LL_MSVC
  74. #define LL_MSVC 1
  75. #endif
  76. #if _MSC_VER < 1400
  77. #define LL_MSVC7 //Visual C++ 2003 or earlier
  78. #endif
  79. #endif
  80. // Deal with minor differences on Unixy OSes.
  81. #if LL_DARWIN || LL_LINUX
  82. // Different name, same functionality.
  83. #define stricmp strcasecmp
  84. #define strnicmp strncasecmp
  85. // Not sure why this is different, but...
  86. #ifndef MAX_PATH
  87. #define MAX_PATH PATH_MAX
  88. #endif // not MAX_PATH
  89. #endif
  90. // Static linking with apr on windows needs to be declared.
  91. #if LL_WINDOWS && !LL_COMMON_LINK_SHARED
  92. #ifndef APR_DECLARE_STATIC
  93. #define APR_DECLARE_STATIC // For APR on Windows
  94. #endif
  95. #ifndef APU_DECLARE_STATIC
  96. #define APU_DECLARE_STATIC // For APR util on Windows
  97. #endif
  98. #endif
  99. #if defined(LL_WINDOWS)
  100. #define BOOST_REGEX_NO_LIB 1
  101. #define CURL_STATICLIB 1
  102. #ifndef XML_STATIC
  103. #define XML_STATIC
  104. #endif
  105. #endif // LL_WINDOWS
  106. // Deal with VC6 problems
  107. #if LL_MSVC
  108. #pragma warning( 3 : 4701 ) // "local variable used without being initialized" Treat this as level 3, not level 4.
  109. #pragma warning( 3 : 4702 ) // "unreachable code" Treat this as level 3, not level 4.
  110. #pragma warning( 3 : 4189 ) // "local variable initialized but not referenced" Treat this as level 3, not level 4.
  111. //#pragma warning( 3 : 4018 ) // "signed/unsigned mismatch" Treat this as level 3, not level 4.
  112. #pragma warning( 3 : 4263 ) // 'function' : member function does not override any base class virtual member function
  113. #pragma warning( 3 : 4264 ) // "'virtual_function' : no override available for virtual member function from base 'class'; function is hidden"
  114. #pragma warning( 3 : 4265 ) // "class has virtual functions, but destructor is not virtual"
  115. #pragma warning( 3 : 4266 ) // 'function' : no override available for virtual member function from base 'type'; function is hidden
  116. #pragma warning (disable : 4180) // qualifier applied to function type has no meaning; ignored
  117. #pragma warning( disable : 4284 ) // silly MS warning deep inside their <map> include file
  118. #pragma warning( disable : 4503 ) // 'decorated name length exceeded, name was truncated'. Does not seem to affect compilation.
  119. #pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
  120. #pragma warning( disable : 4996 ) // warning: deprecated
  121. // Linker optimization with "extern template" generates these warnings
  122. #pragma warning( disable : 4231 ) // nonstandard extension used : 'extern' before template explicit instantiation
  123. #pragma warning( disable : 4506 ) // no definition for inline function
  124. // level 4 warnings that we need to disable:
  125. #pragma warning (disable : 4100) // unreferenced formal parameter
  126. #pragma warning (disable : 4127) // conditional expression is constant (e.g. while(1) )
  127. #pragma warning (disable : 4244) // possible loss of data on conversions
  128. #pragma warning (disable : 4396) // the inline specifier cannot be used when a friend declaration refers to a specialization of a function template
  129. #pragma warning (disable : 4512) // assignment operator could not be generated
  130. #pragma warning (disable : 4706) // assignment within conditional (even if((x = y)) )
  131. #pragma warning (disable : 4251) // member needs to have dll-interface to be used by clients of class
  132. #pragma warning (disable : 4275) // non dll-interface class used as base for dll-interface class
  133. #pragma warning (disable : 4018) // '<' : signed/unsigned mismatch
  134. #endif // LL_MSVC
  135. #if LL_WINDOWS
  136. #define LL_DLLEXPORT __declspec(dllexport)
  137. #define LL_DLLIMPORT __declspec(dllimport)
  138. #elif LL_LINUX
  139. #define LL_DLLEXPORT __attribute__ ((visibility("default")))
  140. #define LL_DLLIMPORT
  141. #else
  142. #define LL_DLLEXPORT
  143. #define LL_DLLIMPORT
  144. #endif // LL_WINDOWS
  145. #if LL_COMMON_LINK_SHARED
  146. // CMake automagically defines llcommon_EXPORTS only when building llcommon
  147. // sources, and only when llcommon is a shared library (i.e. when
  148. // LL_COMMON_LINK_SHARED). We must still test LL_COMMON_LINK_SHARED because
  149. // otherwise we can't distinguish between (non-llcommon source) and (llcommon
  150. // not shared).
  151. # if defined(llcommon_EXPORTS)
  152. # define LL_COMMON_API LL_DLLEXPORT
  153. # else //llcommon_EXPORTS
  154. # define LL_COMMON_API LL_DLLIMPORT
  155. # endif //llcommon_EXPORTS
  156. #else // LL_COMMON_LINK_SHARED
  157. # define LL_COMMON_API
  158. #endif // LL_COMMON_LINK_SHARED
  159. #endif // not LL_LINDEN_PREPROCESSOR_H