You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
5.7 KiB

  1. // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved.
  2. //
  3. // Redistribution and use in source and binary forms, with or without modifica-
  4. // tion, are permitted provided that the following conditions are met:
  5. //
  6. // 1. Redistributions of source code must retain the above copyright notice,
  7. // this list of conditions and the following disclaimer.
  8. //
  9. // 2. Redistributions in binary form must reproduce the above copyright notice,
  10. // this list of conditions and the following disclaimer in the documentation
  11. // and/or other materials provided with the distribution.
  12. //
  13. // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  14. // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  15. // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  16. // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  17. // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  18. // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  19. // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. #ifndef LOG4CPLUS_CONFIG_HXX
  24. #define LOG4CPLUS_CONFIG_HXX
  25. #if defined (_WIN32)
  26. # include <log4cplus/config/win32.h>
  27. #elif (defined(__MWERKS__) && defined(__MACOS__))
  28. # include <log4cplus/config/macosx.h>
  29. #else
  30. # include <log4cplus/config/defines.hxx>
  31. #endif
  32. #if ! defined (UNICODE) && ! defined (LOG4CPLUS_HAVE_VSNPRINTF_S) \
  33. && ! defined (LOG4CPLUS_HAVE__VSNPRINTF_S) \
  34. && ! defined (LOG4CPLUS_HAVE_VSNPRINTF) \
  35. && ! defined (LOG4CPLUS_HAVE__VSNPRINTF)
  36. # undef LOG4CPLUS_USE_POOR_MANS_SNPRINTF
  37. # define LOG4CPLUS_USE_POOR_MANS_SNPRINTF
  38. #endif
  39. # if ! defined (LOG4CPLUS_WORKING_LOCALE) \
  40. && ! defined (LOG4CPLUS_WORKING_C_LOCALE) \
  41. && ! defined (LOG4CPLUS_WITH_ICONV)
  42. # define LOG4CPLUS_POOR_MANS_CHCONV
  43. #endif
  44. #ifndef LOG4CPLUS_DECLSPEC_EXPORT
  45. #define LOG4CPLUS_DECLSPEC_EXPORT /* empty */
  46. #endif
  47. #ifndef LOG4CPLUS_DECLSPEC_IMPORT
  48. #define LOG4CPLUS_DECLSPEC_IMPORT /* empty */
  49. #endif
  50. #ifndef LOG4CPLUS_DECLSPEC_PRIVATE
  51. #define LOG4CPLUS_DECLSPEC_PRIVATE /* empty */
  52. #endif
  53. #define LOG4CPLUS_PRIVATE LOG4CPLUS_DECLSPEC_PRIVATE
  54. #if !defined(_WIN32)
  55. # define LOG4CPLUS_USE_BSD_SOCKETS
  56. # if !defined(LOG4CPLUS_SINGLE_THREADED)
  57. # define LOG4CPLUS_USE_PTHREADS
  58. # endif
  59. # if defined (INSIDE_LOG4CPLUS)
  60. # define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_EXPORT
  61. # else
  62. # define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_IMPORT
  63. # endif // defined (INSIDE_LOG4CPLUS)
  64. #endif // !_WIN32
  65. #if defined (LOG4CPLUS_INLINES_ARE_EXPORTED) \
  66. && defined (LOG4CPLUS_BUILD_DLL)
  67. # define LOG4CPLUS_INLINE_EXPORT inline
  68. #else
  69. # define LOG4CPLUS_INLINE_EXPORT
  70. #endif
  71. #if defined (UNICODE)
  72. # if defined (_MSC_VER) && _MSC_VER >= 1400
  73. # define LOG4CPLUS_FSTREAM_ACCEPTS_WCHAR_T
  74. # endif
  75. # if defined (_MSC_VER) && _MSC_VER >= 1600
  76. # define LOG4CPLUS_HAVE_CODECVT_UTF8_FACET
  77. # define LOG4CPLUS_HAVE_CODECVT_UTF16_FACET
  78. # endif
  79. #endif
  80. // C++11 stuff
  81. #if ! defined (__has_feature)
  82. //! __has_feature(X) is Clangs way for testing features.
  83. //! Define it to 0 if it does not exist.
  84. # define __has_feature(X) 0
  85. #endif
  86. #if (defined (_MSC_VER) && _MSC_VER >= 1600) \
  87. || defined (__GXX_EXPERIMENTAL_CXX0X__) \
  88. || __cplusplus >= 201103L
  89. # define LOG4CPLUS_HAVE_CXX11_SUPPORT
  90. #endif
  91. #if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) \
  92. || __has_feature (cxx_rvalue_references)
  93. # define LOG4CPLUS_HAVE_RVALUE_REFS
  94. #endif
  95. #if ! defined (UNICODE) && defined (__GNUC__) && __GNUC__ >= 3
  96. # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, format_index, first_arg_index) \
  97. __attribute__ ((format (archetype, format_index, first_arg_index)))
  98. #else
  99. # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, fmt_index, first_arg_index) \
  100. /* empty */
  101. #endif
  102. #if defined (__GNUC__) && __GNUC__ >= 3
  103. # define LOG4CPLUS_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
  104. # define LOG4CPLUS_ATTRIBUTE_PURE __attribute__ ((__pure__))
  105. # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) __builtin_expect ((exp), (c))
  106. #else
  107. # if ! defined (LOG4CPLUS_ATTRIBUTE_NORETURN)
  108. # define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */
  109. # endif
  110. # define LOG4CPLUS_ATTRIBUTE_PURE /* empty */
  111. # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) (exp)
  112. #endif
  113. #define LOG4CPLUS_LIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 1)
  114. #define LOG4CPLUS_UNLIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 0)
  115. #if defined (_MSC_VER) \
  116. || (defined (__BORLANDC__) && __BORLANDC__ >= 0x0650) \
  117. || (defined (__COMO__) && __COMO_VERSION__ >= 400) /* ??? */ \
  118. || (defined (__DMC__) && __DMC__ >= 0x700) /* ??? */ \
  119. || (defined (__clang__) && __clang_major__ >= 3) \
  120. || (defined (__GNUC__) && (__GNUC__ >= 4 \
  121. || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)))
  122. # define LOG4CPLUS_HAVE_PRAGMA_ONCE
  123. # pragma once
  124. #endif
  125. #include <log4cplus/helpers/thread-config.h>
  126. #if defined(__cplusplus)
  127. namespace log4cplus
  128. {
  129. //! Per thread cleanup function. Users should call this function before
  130. //! a thread ends its execution. It frees resources allocated in thread local
  131. //! storage. It is important only for multi-threaded static library builds
  132. //! of log4cplus and user threads. In all other cases the clean up is provided
  133. //! automatically by other means.
  134. LOG4CPLUS_EXPORT void threadCleanup ();
  135. //! Initializes log4cplus.
  136. LOG4CPLUS_EXPORT void initialize ();
  137. } // namespace log4cplus
  138. #endif
  139. #endif // LOG4CPLUS_CONFIG_HXX