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 24 #ifndef LOG4CPLUS_CONFIG_HXX 25 #define LOG4CPLUS_CONFIG_HXX 26 27 #if defined (_WIN32) 28 # include <log4cplus/config/win32.h> 29 #elif (defined(__MWERKS__) && defined(__MACOS__)) 30 # include <log4cplus/config/macosx.h> 31 #else 32 # include <log4cplus/config/defines.hxx> 33 #endif 34 35 #if ! defined (UNICODE) && ! defined (LOG4CPLUS_HAVE_VSNPRINTF_S) \ 36 && ! defined (LOG4CPLUS_HAVE__VSNPRINTF_S) \ 37 && ! defined (LOG4CPLUS_HAVE_VSNPRINTF) \ 38 && ! defined (LOG4CPLUS_HAVE__VSNPRINTF) 39 # undef LOG4CPLUS_USE_POOR_MANS_SNPRINTF 40 # define LOG4CPLUS_USE_POOR_MANS_SNPRINTF 41 #endif 42 43 # if ! defined (LOG4CPLUS_WORKING_LOCALE) \ 44 && ! defined (LOG4CPLUS_WORKING_C_LOCALE) \ 45 && ! defined (LOG4CPLUS_WITH_ICONV) 46 # define LOG4CPLUS_POOR_MANS_CHCONV 47 #endif 48 49 #ifndef LOG4CPLUS_DECLSPEC_EXPORT 50 #define LOG4CPLUS_DECLSPEC_EXPORT /* empty */ 51 #endif 52 53 #ifndef LOG4CPLUS_DECLSPEC_IMPORT 54 #define LOG4CPLUS_DECLSPEC_IMPORT /* empty */ 55 #endif 56 57 #ifndef LOG4CPLUS_DECLSPEC_PRIVATE 58 #define LOG4CPLUS_DECLSPEC_PRIVATE /* empty */ 59 #endif 60 61 #define LOG4CPLUS_PRIVATE LOG4CPLUS_DECLSPEC_PRIVATE 62 63 #if !defined(_WIN32) 64 # define LOG4CPLUS_USE_BSD_SOCKETS 65 # if !defined(LOG4CPLUS_SINGLE_THREADED) 66 # define LOG4CPLUS_USE_PTHREADS 67 # endif 68 # if defined (INSIDE_LOG4CPLUS) 69 # define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_EXPORT 70 # else 71 # define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_IMPORT 72 # endif // defined (INSIDE_LOG4CPLUS) 73 74 #endif // !_WIN32 75 76 #if defined (LOG4CPLUS_INLINES_ARE_EXPORTED) \ 77 && defined (LOG4CPLUS_BUILD_DLL) 78 # define LOG4CPLUS_INLINE_EXPORT inline 79 #else 80 # define LOG4CPLUS_INLINE_EXPORT 81 #endif 82 83 #if defined (UNICODE) 84 # if defined (_MSC_VER) && _MSC_VER >= 1400 85 # define LOG4CPLUS_FSTREAM_ACCEPTS_WCHAR_T 86 # endif 87 # if defined (_MSC_VER) && _MSC_VER >= 1600 88 # define LOG4CPLUS_HAVE_CODECVT_UTF8_FACET 89 # define LOG4CPLUS_HAVE_CODECVT_UTF16_FACET 90 # endif 91 #endif 92 93 // C++11 stuff 94 95 #if ! defined (__has_feature) 96 //! __has_feature(X) is Clangs way for testing features. 97 //! Define it to 0 if it does not exist. 98 # define __has_feature(X) 0 99 #endif 100 101 #if (defined (_MSC_VER) && _MSC_VER >= 1600) \ 102 || defined (__GXX_EXPERIMENTAL_CXX0X__) \ 103 || __cplusplus >= 201103L 104 # define LOG4CPLUS_HAVE_CXX11_SUPPORT 105 #endif 106 107 #if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) \ 108 || __has_feature (cxx_rvalue_references) 109 # define LOG4CPLUS_HAVE_RVALUE_REFS 110 #endif 111 112 #if ! defined (UNICODE) && defined (__GNUC__) && __GNUC__ >= 3 113 # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, format_index, first_arg_index) \ 114 __attribute__ ((format (archetype, format_index, first_arg_index))) 115 #else 116 # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, fmt_index, first_arg_index) \ 117 /* empty */ 118 #endif 119 120 #if defined (__GNUC__) && __GNUC__ >= 3 121 # define LOG4CPLUS_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) 122 # define LOG4CPLUS_ATTRIBUTE_PURE __attribute__ ((__pure__)) 123 # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) __builtin_expect ((exp), (c)) 124 #else 125 # if ! defined (LOG4CPLUS_ATTRIBUTE_NORETURN) 126 # define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */ 127 # endif 128 # define LOG4CPLUS_ATTRIBUTE_PURE /* empty */ 129 # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) (exp) 130 #endif 131 132 #define LOG4CPLUS_LIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 1) 133 #define LOG4CPLUS_UNLIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 0) 134 135 #if defined (_MSC_VER) \ 136 || (defined (__BORLANDC__) && __BORLANDC__ >= 0x0650) \ 137 || (defined (__COMO__) && __COMO_VERSION__ >= 400) /* ??? */ \ 138 || (defined (__DMC__) && __DMC__ >= 0x700) /* ??? */ \ 139 || (defined (__clang__) && __clang_major__ >= 3) \ 140 || (defined (__GNUC__) && (__GNUC__ >= 4 \ 141 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))) 142 # define LOG4CPLUS_HAVE_PRAGMA_ONCE 143 # pragma once 144 #endif 145 146 #include <log4cplus/helpers/thread-config.h> 147 148 #if defined(__cplusplus) 149 namespace log4cplus 150 { 151 152 //! Per thread cleanup function. Users should call this function before 153 //! a thread ends its execution. It frees resources allocated in thread local 154 //! storage. It is important only for multi-threaded static library builds 155 //! of log4cplus and user threads. In all other cases the clean up is provided 156 //! automatically by other means. 157 LOG4CPLUS_EXPORT void threadCleanup (); 158 159 //! Initializes log4cplus. 160 LOG4CPLUS_EXPORT void initialize (); 161 162 } // namespace log4cplus 163 164 #endif 165 166 #endif // LOG4CPLUS_CONFIG_HXX 167