llpreprocessor.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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=viewergpl$
  7. *
  8. * Copyright (c) 2001-2009, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #ifndef LLPREPROCESSOR_H
  34. #define LLPREPROCESSOR_H
  35. // Figure out endianness of platform
  36. #ifdef LL_LINUX
  37. # define __ENABLE_WSTRING
  38. # include <endian.h>
  39. #endif // LL_LINUX
  40. #if (defined(LL_WINDOWS) || (defined(LL_LINUX) && (__BYTE_ORDER == __LITTLE_ENDIAN)) || (defined(LL_DARWIN) && defined(__LITTLE_ENDIAN__)))
  41. # define LL_BIG_ENDIAN 0
  42. #else
  43. # define LL_BIG_ENDIAN 1
  44. #endif
  45. // Mark-up expressions with branch prediction hints. Do NOT use this with
  46. // reckless abandon: it is an obfuscating micro-optimization outside of inner
  47. // loops or other places where you are OVERWHELMINGLY sure which way an
  48. // expression almost-always evaluates.
  49. #if __GNUC__
  50. # define LL_LIKELY(EXPR) __builtin_expect ((bool)(EXPR), true)
  51. # define LL_UNLIKELY(EXPR) __builtin_expect ((bool)(EXPR), false)
  52. #else
  53. # define LL_LIKELY(EXPR) (EXPR)
  54. # define LL_UNLIKELY(EXPR) (EXPR)
  55. #endif
  56. // Figure out differences between compilers
  57. #if defined(__clang__)
  58. #ifndef LL_CLANG
  59. #define LL_CLANG 1
  60. #endif
  61. #ifndef CLANG_VERSION
  62. #define CLANG_VERSION (__clang_major__ * 10000 + \
  63. __clang_minor__ * 100 + \
  64. __clang_patchlevel__)
  65. #endif
  66. #elif defined(__GNUC__)
  67. #ifndef LL_GNUC
  68. #define LL_GNUC 1
  69. #endif
  70. #ifndef GCC_VERSION
  71. #define GCC_VERSION (__GNUC__ * 10000 + \
  72. __GNUC_MINOR__ * 100 + \
  73. __GNUC_PATCHLEVEL__)
  74. #endif
  75. #elif defined(__MSVC_VER__) || defined(_MSC_VER)
  76. #ifndef LL_MSVC
  77. #define LL_MSVC 1
  78. #endif
  79. #endif
  80. // No force-inlining for debug builds (letting the compiler options decide)
  81. #if LL_DEBUG || LL_NO_FORCE_INLINE
  82. # define LL_INLINE inline
  83. #elif LL_GNUC || LL_CLANG
  84. # define LL_INLINE inline __attribute__((always_inline))
  85. #elif LL_MSVC
  86. # define LL_INLINE __forceinline
  87. #else
  88. # define LL_INLINE inline
  89. #endif
  90. #if LL_GNUC || LL_CLANG
  91. # define LL_NO_INLINE __attribute__((noinline))
  92. #elif LL_MSVC
  93. # define LL_NO_INLINE __declspec(noinline)
  94. #else
  95. # define LL_NO_INLINE
  96. #endif
  97. #if !defined(__x86_64__) && !(LL_MSVC && _M_X64) && !SSE2NEON
  98. # error "Only 64 builds are now supported, sorry !"
  99. #endif
  100. // Handy function name macro for std::cerr messages, for when we cannot use
  101. // llinfos & Co (e.g. in plugins).
  102. #ifdef LL_MSVC
  103. # define LL_FUNC __FUNCSIG__
  104. #else
  105. # define LL_FUNC __PRETTY_FUNCTION__
  106. #endif
  107. // Deal with minor differences between OSes.
  108. #if LL_DARWIN || LL_LINUX
  109. // Different name, same functionality.
  110. # define stricmp strcasecmp
  111. # define strnicmp strncasecmp
  112. // Not sure why this is different, but...
  113. # ifndef MAX_PATH
  114. # define MAX_PATH PATH_MAX
  115. # endif
  116. #endif
  117. // Deal with Visual Studio problems
  118. #if LL_MSVC
  119. // Warning: deprecated
  120. # pragma warning(disable : 4996)
  121. // Conditional expression is constant (e.g. while(1) )
  122. # pragma warning(disable : 4127)
  123. // Possible loss of data on conversions
  124. # pragma warning(disable : 4244)
  125. // Conversion from 'type1' to 'type2' of greater size
  126. # pragma warning(disable : 4312)
  127. // The inline specifier cannot be used when a friend declaration refers to a
  128. // specialization of a function template
  129. # pragma warning(disable : 4396)
  130. // Assignment operator could not be generated
  131. # pragma warning(disable : 4512)
  132. // Assignment within conditional (even if((x = y)) )
  133. # pragma warning(disable : 4706)
  134. // Member needs to have dll-interface to be used by clients of class
  135. # pragma warning(disable : 4251)
  136. // Non dll-interface class used as base for dll-interface class
  137. # pragma warning(disable : 4275)
  138. // 'var': conversion from 'size_t' to 'type', possible loss of data)
  139. # pragma warning(disable : 4267)
  140. #endif // LL_MSVC
  141. #endif // LLPREPROCESSOR_H