log4cplus  2.1.0
config.hxx
Go to the documentation of this file.
1 // Copyright (C) 2009-2017, 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 (LOG4CPLUS_WORKING_LOCALE) \
36  && ! defined (LOG4CPLUS_WORKING_C_LOCALE) \
37  && ! defined (LOG4CPLUS_WITH_ICONV)
38 # define LOG4CPLUS_POOR_MANS_CHCONV
39 #endif
40 
41 #ifndef LOG4CPLUS_DECLSPEC_EXPORT
42 #define LOG4CPLUS_DECLSPEC_EXPORT /* empty */
43 #endif
44 
45 #ifndef LOG4CPLUS_DECLSPEC_IMPORT
46 #define LOG4CPLUS_DECLSPEC_IMPORT /* empty */
47 #endif
48 
49 #ifndef LOG4CPLUS_DECLSPEC_PRIVATE
50 #define LOG4CPLUS_DECLSPEC_PRIVATE /* empty */
51 #endif
52 
53 #define LOG4CPLUS_PRIVATE LOG4CPLUS_DECLSPEC_PRIVATE
54 
55 #if !defined(_WIN32)
56 # define LOG4CPLUS_USE_BSD_SOCKETS
57 # if !defined(LOG4CPLUS_SINGLE_THREADED)
58 # define LOG4CPLUS_USE_PTHREADS
59 # endif
60 # if defined (INSIDE_LOG4CPLUS)
61 # define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_EXPORT
62 # else
63 # define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_IMPORT
64 # endif // defined (INSIDE_LOG4CPLUS)
65 
66 #endif // !_WIN32
67 
68 #if defined (LOG4CPLUS_INLINES_ARE_EXPORTED) \
69  && defined (LOG4CPLUS_BUILD_DLL)
70 # define LOG4CPLUS_INLINE_EXPORT inline
71 #else
72 # define LOG4CPLUS_INLINE_EXPORT
73 #endif
74 
75 #if defined (UNICODE)
76 # if defined (_MSC_VER) && _MSC_VER >= 1400
77 # define LOG4CPLUS_FSTREAM_ACCEPTS_WCHAR_T
78 # endif
79 # if defined (_MSC_VER) && _MSC_VER >= 1600
80 # define LOG4CPLUS_HAVE_CODECVT_UTF8_FACET
81 # define LOG4CPLUS_HAVE_CODECVT_UTF16_FACET
82 # endif
83 #endif
84 
85 // C++11 stuff
86 
87 #if ! defined (__has_feature)
90 # define __has_feature(X) 0
91 #endif
92 
93 #if __has_feature (cxx_noexcept) \
94  || (defined (__GNUC__) \
95  && (__GNUC__ > 4 \
96  || __GNUC__ == 4 && __GNUC_MINOR__ >= 6)) \
97  || (defined (_MSC_VER) && _MSC_VER >= 1900)
98 # define LOG4CPLUS_NOEXCEPT noexcept
99 # define LOG4CPLUS_NOEXCEPT_FALSE noexcept(false)
100 #else
101 # define LOG4CPLUS_NOEXCEPT /* empty */
102 # define LOG4CPLUS_NOEXCEPT_FALSE /* empty */
103 #endif
104 
105 #if ! defined (UNICODE) && defined (__GNUC__) && __GNUC__ >= 3
106 # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, format_index, first_arg_index) \
107  __attribute__ ((format (archetype, format_index, first_arg_index)))
108 #else
109 # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, fmt_index, first_arg_index) \
110  /* empty */
111 #endif
112 
113 #if defined (__GNUC__) \
114  && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) \
115  && ! defined (__INTEL_COMPILER) \
116  && ! defined (__CUDACC__)
117 # define LOG4CPLUS_CALLER_FILE() __builtin_FILE ()
118 # define LOG4CPLUS_CALLER_LINE() __builtin_LINE ()
119 # define LOG4CPLUS_CALLER_FUNCTION() __builtin_FUNCTION ()
120 #else
121 # define LOG4CPLUS_CALLER_FILE() (nullptr)
122 # define LOG4CPLUS_CALLER_LINE() (-1)
123 # define LOG4CPLUS_CALLER_FUNCTION() (nullptr)
124 #endif
125 
126 #if defined (__GNUC__) && __GNUC__ >= 3
127 # define LOG4CPLUS_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
128 # define LOG4CPLUS_ATTRIBUTE_PURE __attribute__ ((__pure__))
129 # define LOG4CPLUS_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
130 # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) __builtin_expect ((exp), (c))
131 #else
132 # if ! defined (LOG4CPLUS_ATTRIBUTE_NORETURN)
133 # define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */
134 # endif
135 # define LOG4CPLUS_ATTRIBUTE_PURE /* empty */
136 # define LOG4CPLUS_ATTRIBUTE_DEPRECATED /* empty */
137 # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) (exp)
138 #endif
139 
140 #define LOG4CPLUS_LIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 1)
141 #define LOG4CPLUS_UNLIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 0)
142 
143 #if defined (_MSC_VER) \
144  || (defined (__BORLANDC__) && __BORLANDC__ >= 0x0650) \
145  || (defined (__COMO__) && __COMO_VERSION__ >= 400) /* ??? */ \
146  || (defined (__DMC__) && __DMC__ >= 0x700) /* ??? */ \
147  || (defined (__clang__) && __clang_major__ >= 3) \
148  || (defined (__GNUC__) && (__GNUC__ >= 4 \
149  || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)))
150 # define LOG4CPLUS_HAVE_PRAGMA_ONCE
151 # pragma once
152 #endif
153 
154 #if defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY)
155 # define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \
156  __attribute__ ((__constructor__ ((prio))))
157 #elif defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR)
158 # define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \
159  __attribute__ ((__constructor__))
160 #else
161 # define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) /* empty */
162 #endif
163 
164 #if defined (LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY)
165 # define LOG4CPLUS_INIT_PRIORITY(prio) \
166  __attribute__ ((__init_priority__ ((prio))))
167 #else
168 # define LOG4CPLUS_INIT_PRIORITY(prio) /* empty */
169 #endif
170 
171 #define LOG4CPLUS_INIT_PRIORITY_BASE (65535 / 2)
172 
174 
175 #if defined (LOG4CPLUS_SINGLE_THREADED)
176 #define LOG4CPLUS_THREADED(x)
177 #else
178 #define LOG4CPLUS_THREADED(x) x
179 #endif
180 
181 #if defined(__cplusplus)
182 #include <cstddef>
183 
184 namespace log4cplus
185 {
186 
192 LOG4CPLUS_EXPORT void threadCleanup ();
193 
197 LOG4CPLUS_EXPORT void initialize ();
198 
202 LOG4CPLUS_EXPORT void deinitialize ();
203 
205 LOG4CPLUS_EXPORT void setThreadPoolSize (std::size_t pool_size);
206 
207 } // namespace log4cplus
208 
209 #endif
210 
211 #endif // LOG4CPLUS_CONFIG_HXX
#define LOG4CPLUS_EXPORT
Definition: win32.h:141