From 8491643e9885f9926adaa18d66c456254c881d8b Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 11 Oct 2012 21:29:49 +0200 Subject: [PATCH 001/226] .bzrignore: Improve. --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index f5e8d596f..45e3f5276 100644 --- a/.bzrignore +++ b/.bzrignore @@ -7,3 +7,5 @@ autom4te.cache objdir* Win32 x64 +docs/webpage_docs-1.1.0 +docs/log4cplus-1.1.0/docs From 9b674821dd0296c4c0eea713c703664a853371b9 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 11 Oct 2012 21:32:05 +0200 Subject: [PATCH 002/226] Merge from trunk. version.cxx: Remove version suffix. --- src/version.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.cxx b/src/version.cxx index 8f848d717..e96839586 100644 --- a/src/version.cxx +++ b/src/version.cxx @@ -28,7 +28,7 @@ namespace log4cplus { #if ! defined (LOG4CPLUS_VERSION_STR_SUFFIX) -#define LOG4CPLUS_VERSION_STR_SUFFIX "-RC5" +#define LOG4CPLUS_VERSION_STR_SUFFIX "" #endif unsigned const version = LOG4CPLUS_VERSION; From d853ecba6eb27b8a44fe98a430a711f0ed760160 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 11 Oct 2012 21:35:35 +0200 Subject: [PATCH 003/226] Merge from trunk. layout.h: Document PatternLayout properties. --- include/log4cplus/layout.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/layout.h b/include/log4cplus/layout.h index 56964c1a6..beac3d8b4 100644 --- a/include/log4cplus/layout.h +++ b/include/log4cplus/layout.h @@ -223,10 +223,9 @@ namespace log4cplus { * character. In the example above the conversion specifier * "%-5p" means the LogLevel of the logging event should be left * justified to a width of five characters. - * + * * The recognized conversion characters are * - * * * * @@ -554,6 +553,18 @@ namespace log4cplus { * The above text is largely inspired from Peter A. Darnell and * Philip E. Margolis' highly recommended book "C -- a Software * Engineering Approach", ISBN 0-387-97389-3. + * + *

Properties

+ * + *
+ *
NDCMaxDepth
+ *
This property limits how many deepest NDC components will + * be printed by %%x specifier.
+ * + *
ConversionPattern
+ *
This property specifies conversion pattern.
+ *
+ * */ class LOG4CPLUS_EXPORT PatternLayout : public Layout From fd74dc3b8c3b888e786709a6150f49511e01b9eb Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 11 Oct 2012 21:49:12 +0200 Subject: [PATCH 004/226] Merge from trunk. log4judpappender.h: Fix documentation. --- include/log4cplus/log4judpappender.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/log4cplus/log4judpappender.h b/include/log4cplus/log4judpappender.h index 5aaabb39d..0783af6bc 100644 --- a/include/log4cplus/log4judpappender.h +++ b/include/log4cplus/log4judpappender.h @@ -36,14 +36,11 @@ namespace log4cplus { * The Log4jUdpAppender has the following properties: * *
    - * *
  • Remote logging is non-intrusive as far as the log event * is concerned. In other words, the event will be logged with * the same time stamp, NDC, location info as if it were logged * locally by the client.
  • * - *
  • Log4jUdpAppender do not use a layout.
  • - * *
  • Remote logging uses the UDP protocol.
  • *
* From 3d57f5f0451f030aa6e553909c6225d22b81fee9 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:05:57 +0100 Subject: [PATCH 005/226] tstring.h (towstring, tostring): Add "identity" overloads with lvalue reference to non-const. Add rvalue ref overloads for tow?string() functions. --- include/log4cplus/tstring.h | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/include/log4cplus/tstring.h b/include/log4cplus/tstring.h index 92832bb5d..dd2833878 100644 --- a/include/log4cplus/tstring.h +++ b/include/log4cplus/tstring.h @@ -49,7 +49,6 @@ tostring (char const * str) return std::string (str); } - inline std::string tostring (std::string const & str) @@ -57,6 +56,23 @@ tostring (std::string const & str) return str; } +inline +std::string const & +tostring (std::string & str) +{ + return str; +} + +#ifdef LOG4CPLUS_HAVE_RVALUE_REFS +inline +std::string +tostring (std::string && str) +{ + return std::move (str); +} + +#endif + inline @@ -73,6 +89,23 @@ towstring (std::wstring const & str) return str; } +inline +std::wstring const & +towstring (std::wstring & str) +{ + return str; +} + +#ifdef LOG4CPLUS_HAVE_RVALUE_REFS +inline +std::wstring +towstring (std::wstring && str) +{ + return std::move (str); +} + +#endif + LOG4CPLUS_EXPORT std::string tostring(const std::wstring&); LOG4CPLUS_EXPORT std::string tostring(wchar_t const *); From cf5c542c4deac08b683494c11f6f1b113e43b813 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:09:16 +0100 Subject: [PATCH 006/226] socket-unix.cxx: Fix -DUNICODE builds. --- src/socket-unix.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socket-unix.cxx b/src/socket-unix.cxx index ca84b7948..c76c5bbff 100644 --- a/src/socket-unix.cxx +++ b/src/socket-unix.cxx @@ -165,7 +165,7 @@ openSocket(unsigned short port, SocketState& state) int ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, &optval, optlen ); if (ret != 0) { - helpers::getLogLog ().warn ("setsockopt() failed: " + helpers::getLogLog ().warn (LOG4CPLUS_TEXT ("setsockopt() failed: ") + helpers::convertIntegerToString (errno)); } From 861de5a8ad1a8307a3a27f167cad90f8940da94c Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:10:21 +0100 Subject: [PATCH 007/226] appender.h: Improve Appender documentation. --- include/log4cplus/appender.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/log4cplus/appender.h b/include/log4cplus/appender.h index 5c8041653..e09de5c4b 100644 --- a/include/log4cplus/appender.h +++ b/include/log4cplus/appender.h @@ -86,6 +86,25 @@ namespace log4cplus { * *

Properties

*
+ * + *
layout
+ *
This property specifies message layout used by + * Appender. + * \sa Layout + *
+ * + *
filters
+ *
This property specifies possibly multiple filters used by + * Appender. Each of multple filters and its properties is under a + * numbered subkey of filters key. E.g.: + * filters.1=log4cplus::spi::LogLevelMatchFilter. Filter + * subkey numbers must be consecutive.
+ * + *
Threshold
+ *
This property specifies log level threshold. Events with + * lower log level than the threshold will not be logged by + * appender.
+ * *
UseLockFile
*
Set this property to true if you want your output * through this appender to be synchronized between multiple From 23f905c4adc0e77d262b0decad3f744829d80406 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:11:27 +0100 Subject: [PATCH 008/226] msvc10/log4cplusS.vcxproj: Include syslogappender.cxx in the build. --- msvc10/log4cplusS.vcxproj | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/msvc10/log4cplusS.vcxproj b/msvc10/log4cplusS.vcxproj index 5981bf5f3..0a0519dac 100755 --- a/msvc10/log4cplusS.vcxproj +++ b/msvc10/log4cplusS.vcxproj @@ -649,16 +649,7 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) - - true - true - true - true - true - true - true - true - + @@ -1016,16 +1007,7 @@ - - true - true - true - true - true - true - true - true - + From 9e99cbb32b7c45a1207f025d34fe88c5cf7b9982 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:11:55 +0100 Subject: [PATCH 009/226] loggingmacros.h: Suppress MSVC warning 4127 for do { } while(0). Patch provided by: Chris Steenwyk --- include/log4cplus/loggingmacros.h | 88 ++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/include/log4cplus/loggingmacros.h b/include/log4cplus/loggingmacros.h index 2efc456be..48274851a 100644 --- a/include/log4cplus/loggingmacros.h +++ b/include/log4cplus/loggingmacros.h @@ -38,6 +38,26 @@ #include #include +#define LOG4CPLUS_DISABLE_FATAL + +#if defined(_MSC_VER) +#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ + __pragma (warning (push)) \ + __pragma (warning (disable:4127)) + +#define LOG4CPLUS_RESTORE_DOWHILE_WARNING() \ + __pragma (warning (pop)) + +#else +#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() /* empty */ +#define LOG4CPLUS_RESTORE_DOWHILE_WARNING() /* empty */ + +#endif + +#define LOG4CPLUS_DOWHILE_NOTHING() \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ + do { } while (0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #if defined(LOG4CPLUS_DISABLE_FATAL) && !defined(LOG4CPLUS_DISABLE_ERROR) #define LOG4CPLUS_DISABLE_ERROR @@ -162,6 +182,7 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, #define LOG4CPLUS_MACRO_BODY(logger, logEvent, logLevel) \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ = log4cplus::detail::macros_get_logger (logger); \ @@ -174,10 +195,12 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, log4cplus::logLevel, _log4cplus_buf.str(), \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ } \ - } while (0) + } while (0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #define LOG4CPLUS_MACRO_STR_BODY(logger, logEvent, logLevel) \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ = log4cplus::detail::macros_get_logger (logger); \ @@ -187,10 +210,12 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, log4cplus::logLevel, logEvent, \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ } \ - } while(0) + } while(0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) #define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, logFmt, ...) \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ = log4cplus::detail::macros_get_logger (logger); \ @@ -203,11 +228,13 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, log4cplus::detail::macro_forced_log (_l, \ log4cplus::logLevel, _logEvent, \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ - } \ - } while(0) + } \ + } while(0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) #define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, logFmt, logArgs...) \ + LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ = log4cplus::detail::macros_get_logger (logger); \ @@ -221,7 +248,8 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, log4cplus::logLevel, _logEvent, \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ } \ - } while(0) + } while(0) \ + LOG4CPLUS_RESTORE_DOWHILE_WARNING() #endif @@ -250,13 +278,13 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, #endif #else -#define LOG4CPLUS_TRACE_METHOD(logger, logEvent) do { } while (0) -#define LOG4CPLUS_TRACE(logger, logEvent) do { } while (0) -#define LOG4CPLUS_TRACE_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_TRACE_METHOD(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_TRACE(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_TRACE_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_TRACE_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_TRACE_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_TRACE_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_TRACE_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -281,12 +309,12 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, #endif #else -#define LOG4CPLUS_DEBUG(logger, logEvent) do { } while (0) -#define LOG4CPLUS_DEBUG_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_DEBUG(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_DEBUG_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -311,12 +339,12 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, #endif #else -#define LOG4CPLUS_INFO(logger, logEvent) do { } while (0) -#define LOG4CPLUS_INFO_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_INFO(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_INFO_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_INFO_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_INFO_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -341,12 +369,12 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, #endif #else -#define LOG4CPLUS_WARN(logger, logEvent) do { } while (0) -#define LOG4CPLUS_WARN_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_WARN(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_WARN_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_WARN_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_WARN_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -371,12 +399,12 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, #endif #else -#define LOG4CPLUS_ERROR(logger, logEvent) do { } while (0) -#define LOG4CPLUS_ERROR_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_ERROR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_ERROR_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_ERROR_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_ERROR_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -401,12 +429,12 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, #endif #else -#define LOG4CPLUS_FATAL(logger, logEvent) do { } while (0) -#define LOG4CPLUS_FATAL_STR(logger, logEvent) do { } while (0) +#define LOG4CPLUS_FATAL(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_FATAL_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, ...) do { } while (0) +#define LOG4CPLUS_FATAL_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, logArgs...) do { } while (0) +#define LOG4CPLUS_FATAL_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif From c479055711621a740357f4ec2682b9fd917a20a1 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:20:08 +0100 Subject: [PATCH 010/226] configure.ac: Check also for _vsnwprintf(). snprintf.cxx: Use _vsnwprintf(). --- configure | 13 +++++++++++++ configure.ac | 1 + include/log4cplus/config.h.in | 6 ++++++ include/log4cplus/config/defines.hxx.cmake.in | 3 +++ include/log4cplus/config/defines.hxx.in | 3 +++ src/snprintf.cxx | 5 ++++- 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 0b9aa268b..da1318dd3 100755 --- a/configure +++ b/configure @@ -9868,6 +9868,19 @@ fi done + for ac_func in vsnwprintf +do : + ac_fn_cxx_check_func "$LINENO" "vsnwprintf" "ac_cv_func_vsnwprintf" +if test "x$ac_cv_func_vsnwprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VSNWPRINTF 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_VSNWPRINTF 1" >>confdefs.h + +fi +done + + for ac_func in _vsnprintf do : ac_fn_cxx_check_func "$LINENO" "_vsnprintf" "ac_cv_func__vsnprintf" diff --git a/configure.ac b/configure.ac index 3fd7c1c2c..a820f1a45 100644 --- a/configure.ac +++ b/configure.ac @@ -441,6 +441,7 @@ AS_IF([test "x$with_iconv" = "xyes"], dnl Various functions used by snprintf.cxx. LOG4CPLUS_CHECK_FUNCS([vsnprintf], [LOG4CPLUS_HAVE_VSNPRINTF]) +LOG4CPLUS_CHECK_FUNCS([vsnwprintf], [LOG4CPLUS_HAVE_VSNWPRINTF]) LOG4CPLUS_CHECK_FUNCS([_vsnprintf], [LOG4CPLUS_HAVE__VSNPRINTF]) LOG4CPLUS_CHECK_FUNCS([vsprintf_s], [LOG4CPLUS_HAVE_VSPRINTF_S]) LOG4CPLUS_CHECK_FUNCS([vswprintf_s], [LOG4CPLUS_HAVE_VSWPRINTF_S]) diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index 8a703c5fe..9c9315e15 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -151,6 +151,9 @@ /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF +/* Define to 1 if you have the `vsnwprintf' function. */ +#undef HAVE_VSNWPRINTF + /* Define to 1 if you have the `vsprintf_s' function. */ #undef HAVE_VSPRINTF_S @@ -367,6 +370,9 @@ /* */ #undef LOG4CPLUS_HAVE_VSNPRINTF +/* */ +#undef LOG4CPLUS_HAVE_VSNWPRINTF + /* */ #undef LOG4CPLUS_HAVE_VSPRINTF_S diff --git a/include/log4cplus/config/defines.hxx.cmake.in b/include/log4cplus/config/defines.hxx.cmake.in index 697ac33dd..0f4dee954 100644 --- a/include/log4cplus/config/defines.hxx.cmake.in +++ b/include/log4cplus/config/defines.hxx.cmake.in @@ -182,6 +182,9 @@ /* */ #cmakedefine LOG4CPLUS_HAVE_VSNPRINTF 1 +/* Define to 1 if you have the `vsnwprintf' function. */ +#cmakedefine LOG4CPLUS_HAVE_VSNWPRINTF 1 + /* */ #cmakedefine LOG4CPLUS_HAVE__VSNPRINTF 1 diff --git a/include/log4cplus/config/defines.hxx.in b/include/log4cplus/config/defines.hxx.in index 53142895a..0270ffacb 100644 --- a/include/log4cplus/config/defines.hxx.in +++ b/include/log4cplus/config/defines.hxx.in @@ -184,6 +184,9 @@ /* */ #undef LOG4CPLUS_HAVE_VSNPRINTF +/* Define to 1 if you have the `vsnwprintf' function. */ +#undef LOG4CPLUS_HAVE_VSNWPRINTF + /* */ #undef LOG4CPLUS_HAVE__VSNPRINTF diff --git a/src/snprintf.cxx b/src/snprintf.cxx index 8dbb5a9a5..bc54b1912 100644 --- a/src/snprintf.cxx +++ b/src/snprintf.cxx @@ -127,8 +127,11 @@ vsntprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, #if defined (UNICODE) # if defined (LOG4CPLUS_HAVE__VSNWPRINTF_S) && defined (_TRUNCATE) ret = _vsnwprintf_s (dest, dest_size, _TRUNCATE, fmt, args); +# elif defined (LOG4CPLUS_HAVE_VSNWPRINTF) + ret = vsnwprintf (dest, dest_size, fmt, args); # else - ret = std::vswprintf (dest, dest_size, fmt, args); + using namespace std; + ret = vswprintf (dest, dest_size, fmt, args); # endif #else # if defined (LOG4CPLUS_HAVE_VSNPRINTF_S) && defined (_TRUNCATE) From e8c6334248d92d5ecee97ceaae7953c7051ae924 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:20:26 +0100 Subject: [PATCH 011/226] configure.ac: Check also for _vsnwprintf(). snprintf.cxx: Use _vsnwprintf(). Previous commit should have had this change log: configure.ac: Detect vsnwprintf(). snprintf.cxx: Use vsnwprintf() when available. *: Regenerate and accommodate. --- configure | 10 +++++----- configure.ac | 2 +- include/log4cplus/config.h.in | 6 ++++++ include/log4cplus/config/defines.hxx.cmake.in | 3 +++ include/log4cplus/config/defines.hxx.in | 3 +++ src/snprintf.cxx | 2 ++ 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/configure b/configure index da1318dd3..62ab11073 100755 --- a/configure +++ b/configure @@ -9881,14 +9881,14 @@ fi done - for ac_func in _vsnprintf + for ac_func in _vsnwprintf do : - ac_fn_cxx_check_func "$LINENO" "_vsnprintf" "ac_cv_func__vsnprintf" -if test "x$ac_cv_func__vsnprintf" = xyes; then : + ac_fn_cxx_check_func "$LINENO" "_vsnwprintf" "ac_cv_func__vsnwprintf" +if test "x$ac_cv_func__vsnwprintf" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE__VSNPRINTF 1 +#define HAVE__VSNWPRINTF 1 _ACEOF - $as_echo "#define LOG4CPLUS_HAVE__VSNPRINTF 1" >>confdefs.h + $as_echo "#define LOG4CPLUS_HAVE__VSNWPRINTF 1" >>confdefs.h fi done diff --git a/configure.ac b/configure.ac index a820f1a45..d03708180 100644 --- a/configure.ac +++ b/configure.ac @@ -442,7 +442,7 @@ dnl Various functions used by snprintf.cxx. LOG4CPLUS_CHECK_FUNCS([vsnprintf], [LOG4CPLUS_HAVE_VSNPRINTF]) LOG4CPLUS_CHECK_FUNCS([vsnwprintf], [LOG4CPLUS_HAVE_VSNWPRINTF]) -LOG4CPLUS_CHECK_FUNCS([_vsnprintf], [LOG4CPLUS_HAVE__VSNPRINTF]) +LOG4CPLUS_CHECK_FUNCS([_vsnwprintf], [LOG4CPLUS_HAVE__VSNWPRINTF]) LOG4CPLUS_CHECK_FUNCS([vsprintf_s], [LOG4CPLUS_HAVE_VSPRINTF_S]) LOG4CPLUS_CHECK_FUNCS([vswprintf_s], [LOG4CPLUS_HAVE_VSWPRINTF_S]) LOG4CPLUS_CHECK_FUNCS([vfprintf_s], [LOG4CPLUS_HAVE_VFPRINTF_S]) diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index 9c9315e15..1b61b1bd7 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -169,6 +169,9 @@ /* Define to 1 if you have the `_vsnprintf_s' function. */ #undef HAVE__VSNPRINTF_S +/* Define to 1 if you have the `_vsnwprintf' function. */ +#undef HAVE__VSNWPRINTF + /* Define to 1 if you have the `_vsnwprintf_s' function. */ #undef HAVE__VSNWPRINTF_S @@ -391,6 +394,9 @@ /* */ #undef LOG4CPLUS_HAVE__VSNPRINTF_S +/* */ +#undef LOG4CPLUS_HAVE__VSNWPRINTF + /* */ #undef LOG4CPLUS_HAVE__VSNWPRINTF_S diff --git a/include/log4cplus/config/defines.hxx.cmake.in b/include/log4cplus/config/defines.hxx.cmake.in index 0f4dee954..87678ca72 100644 --- a/include/log4cplus/config/defines.hxx.cmake.in +++ b/include/log4cplus/config/defines.hxx.cmake.in @@ -185,6 +185,9 @@ /* Define to 1 if you have the `vsnwprintf' function. */ #cmakedefine LOG4CPLUS_HAVE_VSNWPRINTF 1 +/* Define to 1 if you have the `_vsnwprintf' function. */ +#cmakedefine LOG4CPLUS_HAVE__VSNWPRINTF 1 + /* */ #cmakedefine LOG4CPLUS_HAVE__VSNPRINTF 1 diff --git a/include/log4cplus/config/defines.hxx.in b/include/log4cplus/config/defines.hxx.in index 0270ffacb..05a5f874b 100644 --- a/include/log4cplus/config/defines.hxx.in +++ b/include/log4cplus/config/defines.hxx.in @@ -187,6 +187,9 @@ /* Define to 1 if you have the `vsnwprintf' function. */ #undef LOG4CPLUS_HAVE_VSNWPRINTF +/* Define to 1 if you have the `_vsnwprintf' function. */ +#undef LOG4CPLUS_HAVE__VSNWPRINTF + /* */ #undef LOG4CPLUS_HAVE__VSNPRINTF diff --git a/src/snprintf.cxx b/src/snprintf.cxx index bc54b1912..feba1fbe0 100644 --- a/src/snprintf.cxx +++ b/src/snprintf.cxx @@ -129,6 +129,8 @@ vsntprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, ret = _vsnwprintf_s (dest, dest_size, _TRUNCATE, fmt, args); # elif defined (LOG4CPLUS_HAVE_VSNWPRINTF) ret = vsnwprintf (dest, dest_size, fmt, args); +# elif defined (LOG4CPLUS_HAVE__VSNWPRINTF) + ret = _vsnwprintf (dest, dest_size, fmt, args); # else using namespace std; ret = vswprintf (dest, dest_size, fmt, args); From 24a26d833c46f50cf0f1b5062b70e7d3e97415c1 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:21:29 +0100 Subject: [PATCH 012/226] win32.h: Define LOG4CPLUS_HAVE__TSOPEN_S and LOG4CPLUS_HAVE__TSOPEN. lockfile.cxx: Use _tsopen() when _tsopen_s() is not available. --- include/log4cplus/config/win32.h | 7 ++++++- src/lockfile.cxx | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index a9c65ee29..e62f83538 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -68,7 +68,7 @@ #define LOG4CPLUS_HAVE_VSNPRINTF #define LOG4CPLUS_HAVE__VSNPRINTF -#if defined (_MSC_VER) || defined (__MINGW32__) +#if defined (_MSC_VER) // MS secure versions of vprintf(). # define LOG4CPLUS_HAVE_VSPRINTF_S # define LOG4CPLUS_HAVE_VSWPRINTF_S @@ -81,8 +81,13 @@ # define LOG4CPLUS_HAVE_VSNPRINTF_S # define LOG4CPLUS_HAVE__VSNPRINTF_S # define LOG4CPLUS_HAVE__VSNWPRINTF_S + +// MS secure version of _tsopen(). +# define LOG4CPLUS_HAVE__TSOPEN_S #endif +#define LOG4CPLUS_HAVE__TSOPEN + #define LOG4CPLUS_DLLMAIN_HINSTANCE HINSTANCE #define LOG4CPLUS_HAVE_NT_EVENT_LOG diff --git a/src/lockfile.cxx b/src/lockfile.cxx index 5d597868e..0183ec7a1 100644 --- a/src/lockfile.cxx +++ b/src/lockfile.cxx @@ -166,9 +166,17 @@ LockFile::open (int open_flags) const LogLog & loglog = getLogLog (); #if defined (_WIN32) +# if defined (LOG4CPLUS_HAVE__TSOPEN_S) errno_t eno = _tsopen_s (&data->fd, lock_file_name.c_str (), open_flags, OPEN_SHFLAGS, OPEN_MODE); if (eno != 0) +# elif defined (LOG4CPLUS_HAVE__TSOPEN) + data->fd = _tsopen (lock_file_name.c_str (), open_flags, OPEN_SHFLAGS, + OPEN_MODE); + if (data->fd == -1) +# else +# error "Neither _tsopen_s() nor _tsopen() is available." +# endif loglog.error (tstring (LOG4CPLUS_TEXT("could not open or create file ")) + lock_file_name, true); From 67cf591244c05905362966bf31f1ff992a95ad75 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:21:53 +0100 Subject: [PATCH 013/226] win32.h: Define LOG4CPLUS_HAVE__VSNWPRINTF. --- include/log4cplus/config/win32.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index e62f83538..dd053aae7 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -67,6 +67,7 @@ // MSVC has both and so does MinGW. #define LOG4CPLUS_HAVE_VSNPRINTF #define LOG4CPLUS_HAVE__VSNPRINTF +#define LOG4CPLUS_HAVE__VSNWPRINTF #if defined (_MSC_VER) // MS secure versions of vprintf(). From e12c734fd7894b9beac0aeaf578a6fc8ad617f6b Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:22:27 +0100 Subject: [PATCH 014/226] property.cxx: Use codecvt for WIN32 UNICODE case until we get a "null" codecvt facet for conversion between wchar_t's read as bytes (chars) from a file stream. --- src/property.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/property.cxx b/src/property.cxx index e2dd7ce13..cdd25291d 100644 --- a/src/property.cxx +++ b/src/property.cxx @@ -153,7 +153,9 @@ Properties::Properties(const tstring& inputFile, unsigned flags) case fUTF16: file.imbue ( std::locale (file.getloc (), - new std::codecvt)); + // TODO: This should actually be a custom "null" facet + // that just copies the chars to wchar_t buffer. + new std::codecvt)); break; #endif From bdff198db74f8f754dfaf34e253b318fcfa11427 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:22:53 +0100 Subject: [PATCH 015/226] win32.h: Do not define LOG4CPLUS_HAVE_INTRIN_H for MinGW as there are still people using older versions that do not have it. --- include/log4cplus/config/win32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index dd053aae7..5065f09fb 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -30,7 +30,7 @@ #ifdef _WIN32 -#if (defined (_MSC_VER) && _MSC_VER >= 1400) || defined (__MINGW32__) +#if defined (_MSC_VER) && _MSC_VER >= 1400 # define LOG4CPLUS_HAVE_INTRIN_H #endif From 38d9d4a1d1c118e4305ab497b2f414ec450c5b7f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:23:13 +0100 Subject: [PATCH 016/226] AUTHORS: Mention Chris Steenwyk. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index e75e4e034..c117cefae 100644 --- a/AUTHORS +++ b/AUTHORS @@ -17,3 +17,4 @@ Andreas Bießmann Jens Rehsack Siva Chandran P Chernyshev Vyacheslav +Chris Steenwyk From 3da975fd79ecae3d9aea120365c6030e70b9f208 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:23:48 +0100 Subject: [PATCH 017/226] loggingmacros.h: Revert unintended definition of LOG4CPLUS_DISABLE_FATAL. --- include/log4cplus/loggingmacros.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/log4cplus/loggingmacros.h b/include/log4cplus/loggingmacros.h index 48274851a..df8e3372f 100644 --- a/include/log4cplus/loggingmacros.h +++ b/include/log4cplus/loggingmacros.h @@ -38,7 +38,6 @@ #include #include -#define LOG4CPLUS_DISABLE_FATAL #if defined(_MSC_VER) #define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ From b1e13e05e9f6e644d21e646baa3f637be8843704 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:24:10 +0100 Subject: [PATCH 018/226] property.cxx (Properties ctor): Fix encoding flag check, use fEncodingShift. --- src/property.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/property.cxx b/src/property.cxx index cdd25291d..91c5868db 100644 --- a/src/property.cxx +++ b/src/property.cxx @@ -130,7 +130,7 @@ Properties::Properties(const tstring& inputFile, unsigned flags) tifstream file; - switch (flags & fEncodingMask) + switch (flags & (fEncodingMask << fEncodingShift)) { #if defined (LOG4CPLUS_HAVE_CODECVT_UTF8_FACET) && defined (UNICODE) case fUTF8: From fb83447431b2efa48a77faac70c0e5d70a0ae615 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:24:44 +0100 Subject: [PATCH 019/226] Add propertyconfig_test Visual Studio 2010 project and add it to solution. --- msvc10/log4cplus.sln | 19 + msvc10/tests/propertyconfig_test.vcxproj | 463 ++++++++++++++++++ .../tests/propertyconfig_test.vcxproj.filters | 14 + 3 files changed, 496 insertions(+) create mode 100755 msvc10/tests/propertyconfig_test.vcxproj create mode 100755 msvc10/tests/propertyconfig_test.vcxproj.filters diff --git a/msvc10/log4cplus.sln b/msvc10/log4cplus.sln index 9f28fc29a..4d38577ca 100755 --- a/msvc10/log4cplus.sln +++ b/msvc10/log4cplus.sln @@ -49,6 +49,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CLFSAppender", "CLFSAppende EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Qt4DebugAppender", "Qt4DebugAppender.vcxproj", "{18B64AA1-A2F7-46BE-8D48-7882AA471FA9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "propertyconfig_test", "tests\propertyconfig_test.vcxproj", "{44D4D0A3-FAFA-4134-9806-BCB830594E28}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_Unicode|Win32 = Debug_Unicode|Win32 @@ -381,6 +383,22 @@ Global {18B64AA1-A2F7-46BE-8D48-7882AA471FA9}.Release|Win32.Build.0 = Release|Win32 {18B64AA1-A2F7-46BE-8D48-7882AA471FA9}.Release|x64.ActiveCfg = Release|x64 {18B64AA1-A2F7-46BE-8D48-7882AA471FA9}.Release|x64.Build.0 = Release|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug_Unicode|Win32.ActiveCfg = Debug_Unicode|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug_Unicode|Win32.Build.0 = Debug_Unicode|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug_Unicode|x64.ActiveCfg = Debug_Unicode|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug_Unicode|x64.Build.0 = Debug_Unicode|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug|Win32.ActiveCfg = Debug|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug|Win32.Build.0 = Debug|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug|x64.ActiveCfg = Debug|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Debug|x64.Build.0 = Debug|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release_Unicode|Win32.ActiveCfg = Release_Unicode|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release_Unicode|Win32.Build.0 = Release_Unicode|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release_Unicode|x64.ActiveCfg = Release_Unicode|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release_Unicode|x64.Build.0 = Release_Unicode|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release|Win32.ActiveCfg = Release|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release|Win32.Build.0 = Release|Win32 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release|x64.ActiveCfg = Release|x64 + {44D4D0A3-FAFA-4134-9806-BCB830594E28}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -401,5 +419,6 @@ Global {F83D31E0-B607-4D3E-AF53-BA2A19BE17ED} = {92DEA81D-81ED-4283-BBC7-41975647F69E} {7EFABA06-71CD-498F-BF10-C41A7D2DCF3B} = {92DEA81D-81ED-4283-BBC7-41975647F69E} {AE4CF05D-9770-4BF2-BB73-1DA37E2A1508} = {92DEA81D-81ED-4283-BBC7-41975647F69E} + {44D4D0A3-FAFA-4134-9806-BCB830594E28} = {92DEA81D-81ED-4283-BBC7-41975647F69E} EndGlobalSection EndGlobal diff --git a/msvc10/tests/propertyconfig_test.vcxproj b/msvc10/tests/propertyconfig_test.vcxproj new file mode 100755 index 000000000..283121de8 --- /dev/null +++ b/msvc10/tests/propertyconfig_test.vcxproj @@ -0,0 +1,463 @@ + + + + + Debug_Unicode + Win32 + + + Debug_Unicode + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release_Unicode + Win32 + + + Release_Unicode + x64 + + + Release + Win32 + + + Release + x64 + + + + {44D4D0A3-FAFA-4134-9806-BCB830594E28} + + + + Application + false + Unicode + true + + + Application + false + Unicode + + + Application + false + MultiByte + + + Application + false + MultiByte + + + Application + false + Unicode + true + + + Application + false + Unicode + + + Application + false + MultiByte + + + Application + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + true + true + false + false + true + true + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + $(OutDir)propertyconfig_test.tlb + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + $(IntDir)propertyconfig_test.pch + true + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusd.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + true + $(OutDir)propertyconfig_test.pdb + Console + MachineX86 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + X64 + $(OutDir)propertyconfig_test.tlb + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + $(IntDir)propertyconfig_test.pch + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusd.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + true + $(OutDir)propertyconfig_test.pdb + Console + MachineX64 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + $(OutDir)propertyconfig_test.tlb + + + + + MaxSpeed + OnlyExplicitInline + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + $(IntDir)propertyconfig_test.pch + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplus.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(OutDir)propertyconfig_test.pdb + Console + MachineX86 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + X64 + $(OutDir)propertyconfig_test.tlb + + + + + MaxSpeed + OnlyExplicitInline + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + $(IntDir)propertyconfig_test.pch + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplus.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(OutDir)propertyconfig_test.pdb + Console + MachineX64 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + $(OutDir)propertyconfig_test.tlb + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + $(IntDir)propertyconfig_test.pch + true + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusud.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + true + $(OutDir)propertyconfig_test.pdb + Console + MachineX86 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + X64 + $(OutDir)propertyconfig_test.tlb + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + $(IntDir)propertyconfig_test.pch + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusud.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + true + $(OutDir)propertyconfig_test.pdb + Console + MachineX64 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + $(OutDir)propertyconfig_test.tlb + + + + + MaxSpeed + OnlyExplicitInline + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + $(IntDir)propertyconfig_test.pch + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusu.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(OutDir)propertyconfig_test.pdb + Console + MachineX86 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + X64 + $(OutDir)propertyconfig_test.tlb + + + + + MaxSpeed + OnlyExplicitInline + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + $(IntDir)propertyconfig_test.pch + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + log4cplusu.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(OutDir)propertyconfig_test.pdb + Console + MachineX64 + + + true + $(IntDir)propertyconfig_test.bsc + + + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + + + {917836a4-0ddc-47be-b930-1b3bfdf6c940} + false + + + + + + \ No newline at end of file diff --git a/msvc10/tests/propertyconfig_test.vcxproj.filters b/msvc10/tests/propertyconfig_test.vcxproj.filters new file mode 100755 index 000000000..67cef8e30 --- /dev/null +++ b/msvc10/tests/propertyconfig_test.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + {34631475-FC1B-4856-9E3F-95323D5701B7} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + + + Source Files + + + \ No newline at end of file From b34396c8bb50e1d53b397ebe11dd49770b609ac8 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:25:26 +0100 Subject: [PATCH 020/226] Implement include directive for properties files. Initial patch provided by: Jukka Lantto --- AUTHORS | 1 + include/log4cplus/configurator.h | 9 ++- include/log4cplus/helpers/property.h | 2 + src/property.cxx | 93 ++++++++++++++++++---------- 4 files changed, 70 insertions(+), 35 deletions(-) diff --git a/AUTHORS b/AUTHORS index c117cefae..71f60ea2b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,3 +18,4 @@ Jens Rehsack Siva Chandran P Chernyshev Vyacheslav Chris Steenwyk +Jukka Lantto diff --git a/include/log4cplus/configurator.h b/include/log4cplus/configurator.h index 20f4ccb6c..b8b222b9f 100644 --- a/include/log4cplus/configurator.h +++ b/include/log4cplus/configurator.h @@ -46,18 +46,23 @@ namespace log4cplus /** * Provides configuration from an external file. See configure() for * the expected format. - * + * * All option values admit variable substitution. For * example, if userhome environment property is set to * /home/xyz and the File option is set to the string * ${userhome}/test.log, then File option will be * interpreted as the string /home/xyz/test.log. - * + * * The syntax of variable substitution is similar to that of UNIX * shells. The string between an opening "${" and * closing "}" is interpreted as a key. Its value is * searched in the environment properties. The corresponding value replaces * the ${variableName} sequence. + * + * Configuration files also recognize include + * file.properties directive that allow composing + * configuration from multiple files. There is no cyclic includes + * detection mechanism to stop unbound recursion. */ class LOG4CPLUS_EXPORT PropertyConfigurator { diff --git a/include/log4cplus/helpers/property.h b/include/log4cplus/helpers/property.h index d418801c9..909a9cd7a 100644 --- a/include/log4cplus/helpers/property.h +++ b/include/log4cplus/helpers/property.h @@ -39,6 +39,7 @@ namespace log4cplus { namespace helpers { + //! \sa log4cplus::PropertyConfigurator class LOG4CPLUS_EXPORT Properties { public: enum PFlags @@ -141,6 +142,7 @@ namespace log4cplus { // Data StringMap data; + unsigned flags; private: template diff --git a/src/property.cxx b/src/property.cxx index 91c5868db..1b0d92eb8 100644 --- a/src/property.cxx +++ b/src/property.cxx @@ -102,38 +102,13 @@ trim_ws (tstring & str) } -} // namespace - - - -/////////////////////////////////////////////////////////////////////////////// -// Properties ctors and dtor -/////////////////////////////////////////////////////////////////////////////// - -Properties::Properties() -{ -} - - - -Properties::Properties(tistream& input) -{ - init(input); -} - - - -Properties::Properties(const tstring& inputFile, unsigned flags) +void +imbue_file_from_flags (tistream & file, unsigned flags) { - if (inputFile.empty ()) - return; - - tifstream file; - - switch (flags & (fEncodingMask << fEncodingShift)) + switch (flags & (Properties::fEncodingMask << Properties::fEncodingShift)) { #if defined (LOG4CPLUS_HAVE_CODECVT_UTF8_FACET) && defined (UNICODE) - case fUTF8: + case Properties::fUTF8: file.imbue ( std::locale (file.getloc (), new std::codecvt_utf8= 7 + 1 + 1 + && is_space (buffer[7])) + { + tstring included (buffer, 8) ; + trim_ws (included); + + tifstream file; + imbue_file_from_flags (file, flags); + + file.open (LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(included).c_str(), + std::ios::binary); + if (! file.good ()) + helpers::getLogLog ().error ( + LOG4CPLUS_TEXT ("could not open file ") + included); + + init (file); + } } } From 4e2bfe09ce2a4f56dbf701ab1b7aa0d483464f3c Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:27:38 +0100 Subject: [PATCH 021/226] win32.h: Re-enable intrin.h and *printf_s() function for MinGW64 using __MINGW64_VERSION_MAJOR symbol as guard. --- include/log4cplus/config/win32.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index 5065f09fb..08cefc08c 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -30,7 +30,8 @@ #ifdef _WIN32 -#if defined (_MSC_VER) && _MSC_VER >= 1400 +#if (defined (_MSC_VER) && _MSC_VER >= 1400) \ + || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3) # define LOG4CPLUS_HAVE_INTRIN_H #endif @@ -69,7 +70,8 @@ #define LOG4CPLUS_HAVE__VSNPRINTF #define LOG4CPLUS_HAVE__VSNWPRINTF -#if defined (_MSC_VER) +#if defined (_MSC_VER) \ + || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3) // MS secure versions of vprintf(). # define LOG4CPLUS_HAVE_VSPRINTF_S # define LOG4CPLUS_HAVE_VSWPRINTF_S From 8ea57542963261964003b785375e2ed36e9e106b Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:28:12 +0100 Subject: [PATCH 022/226] win32.h: Include _mingw.h when compiling under MinGW32 or MinGW64 tool chains. (LOG4CPLUS_HAVE__VSPRINTF_P): Define on recent enough MinGW64. (LOG4CPLUS_HAVE__VSWPRINTF_P): Ditto. snprintf.cxx: Use _vswprintf_p() or _vsprintf_p() when available. --- include/log4cplus/config/win32.h | 8 ++++++++ src/snprintf.cxx | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index 08cefc08c..0139b2da4 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -28,6 +28,10 @@ #pragma once #endif +#if defined (__MINGW32__) || defined (__MINGW64__) +# include <_mingw.h> +#endif + #ifdef _WIN32 #if (defined (_MSC_VER) && _MSC_VER >= 1400) \ @@ -85,6 +89,10 @@ # define LOG4CPLUS_HAVE__VSNPRINTF_S # define LOG4CPLUS_HAVE__VSNWPRINTF_S +// MS printf-like functions supporting positional parameters. +# define LOG4CPLUS_HAVE__VSPRINTF_P +# define LOG4CPLUS_HAVE__VSWPRINTF_P + // MS secure version of _tsopen(). # define LOG4CPLUS_HAVE__TSOPEN_S #endif diff --git a/src/snprintf.cxx b/src/snprintf.cxx index feba1fbe0..96b2d988a 100644 --- a/src/snprintf.cxx +++ b/src/snprintf.cxx @@ -125,7 +125,9 @@ vsntprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, int ret; #if defined (UNICODE) -# if defined (LOG4CPLUS_HAVE__VSNWPRINTF_S) && defined (_TRUNCATE) +# if defined (LOG4CPLUS_HAVE__VSWPRINTF_P) + ret = _vswprintf_p (dest, dest_size, fmt, args); +# elif defined (LOG4CPLUS_HAVE__VSNWPRINTF_S) && defined (_TRUNCATE) ret = _vsnwprintf_s (dest, dest_size, _TRUNCATE, fmt, args); # elif defined (LOG4CPLUS_HAVE_VSNWPRINTF) ret = vsnwprintf (dest, dest_size, fmt, args); @@ -136,7 +138,9 @@ vsntprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, ret = vswprintf (dest, dest_size, fmt, args); # endif #else -# if defined (LOG4CPLUS_HAVE_VSNPRINTF_S) && defined (_TRUNCATE) +# if defined (LOG4CPLUS_HAVE__VSPRINTF_P) + ret = _vsprintf_p (dest, dest_size, fmt, args); +# elif defined (LOG4CPLUS_HAVE_VSNPRINTF_S) && defined (_TRUNCATE) ret = vsnprintf_s (dest, dest_size, _TRUNCATE, fmt, args); # elif defined (LOG4CPLUS_HAVE__VSNPRINTF_S) && defined (_TRUNCATE) ret = _vsnprintf_s (dest, dest_size, _TRUNCATE, fmt, args); From 0b5f330142c893491ab20e4be8dd80385c4089bc Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:28:53 +0100 Subject: [PATCH 023/226] TODO: Add two more items. --- TODO | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TODO b/TODO index 6b73ca694..6cce370dd 100644 --- a/TODO +++ b/TODO @@ -32,3 +32,9 @@ order: - ConsoleAppender or specialized appender with colored output per log level. + +- Make ServerSocket::accept() interruptible. + +- Graylog2/GELF appender. See + . + From f621b2bc4482c8ed452767c810505e9844a460e5 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:34:31 +0100 Subject: [PATCH 024/226] win32.h: Define LOG4CPLUS_ATTRIBUTE_NORETURN for Visual Studio. config.hxx: Define empty LOG4CPLUS_ATTRIBUTE_NORETURN unless already defined. syncprims-impl.h: Fix LOG4CPLUS_ATTRIBUTE_NORETURN placement to fix compilation. --- include/log4cplus/config.hxx | 4 +++- include/log4cplus/config/win32.h | 1 + include/log4cplus/thread/impl/syncprims-impl.h | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index fb5a30f33..b717a8f08 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -121,7 +121,9 @@ # define LOG4CPLUS_ATTRIBUTE_PURE __attribute__ ((__pure__)) # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) __builtin_expect ((exp), (c)) #else -# define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */ +# if ! defined (LOG4CPLUS_ATTRIBUTE_NORETURN) +# define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */ +# endif # define LOG4CPLUS_ATTRIBUTE_PURE /* empty */ # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) (exp) #endif diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index 0139b2da4..e154653fc 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -151,6 +151,7 @@ # define LOG4CPLUS_HAVE_FUNCTION_MACRO # define LOG4CPLUS_HAVE_FUNCSIG_MACRO # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS +# define LOG4CPLUS_ATTRIBUTE_NORETURN __declspec(noreturn) # endif #endif diff --git a/include/log4cplus/thread/impl/syncprims-impl.h b/include/log4cplus/thread/impl/syncprims-impl.h index 5c4b8d140..ba608e3dc 100644 --- a/include/log4cplus/thread/impl/syncprims-impl.h +++ b/include/log4cplus/thread/impl/syncprims-impl.h @@ -65,8 +65,9 @@ namespace log4cplus { namespace thread { namespace impl { -LOG4CPLUS_EXPORT void syncprims_throw_exception (char const * const msg, - char const * const file, int line) LOG4CPLUS_ATTRIBUTE_NORETURN; +LOG4CPLUS_EXPORT void LOG4CPLUS_ATTRIBUTE_NORETURN + syncprims_throw_exception (char const * const msg, + char const * const file, int line); #define LOG4CPLUS_THROW_RTE(msg) \ From 8de27ae3846d132658e6c554e893efa5c08a3314 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:35:44 +0100 Subject: [PATCH 025/226] Improve Win32ConsoleAppender: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - logToStdErr (bool): similar to the generic ConsoleAppender; default value: use stdout - TextColor (int): allow to specify the text (foreground & background color) of the printed text; default value: don’t change colors Patch provided by: Konstantin Baumann --- AUTHORS | 1 + include/log4cplus/win32consoleappender.h | 14 ++++- src/win32consoleappender.cxx | 72 ++++++++++++++++++++++-- 3 files changed, 80 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 71f60ea2b..2913fd858 100644 --- a/AUTHORS +++ b/AUTHORS @@ -19,3 +19,4 @@ Siva Chandran P Chernyshev Vyacheslav Chris Steenwyk Jukka Lantto +Konstantin Baumann diff --git a/include/log4cplus/win32consoleappender.h b/include/log4cplus/win32consoleappender.h index b2d0dc151..df51a3152 100644 --- a/include/log4cplus/win32consoleappender.h +++ b/include/log4cplus/win32consoleappender.h @@ -49,13 +49,23 @@ namespace log4cplus * will try to allocate new console using the * AllocConsole() Win32 function.
* + *
logToStdErr
+ *
When it is set true, the output will be into + * STD_ERROR_HANDLE instead of STD_OUTPUT_HANDLE. + *
+ * + *
logToStdErr
+ *
See MSDN documentation for + * + * Character Attributes. *
*/ class LOG4CPLUS_EXPORT Win32ConsoleAppender : public Appender { public: - explicit Win32ConsoleAppender (bool allocConsole = true); + explicit Win32ConsoleAppender (bool allocConsole = true, + bool logToStdErr = false, unsigned int textColor = 0); Win32ConsoleAppender (helpers::Properties const & properties); virtual ~Win32ConsoleAppender (); @@ -68,6 +78,8 @@ namespace log4cplus void write_console (void *, tchar const *, std::size_t); bool alloc_console; + bool log_to_std_err; + unsigned int text_color; private: Win32ConsoleAppender (Win32ConsoleAppender const &); diff --git a/src/win32consoleappender.cxx b/src/win32consoleappender.cxx index 8afbd43b3..4f9688272 100644 --- a/src/win32consoleappender.cxx +++ b/src/win32consoleappender.cxx @@ -33,13 +33,29 @@ #include #include +/* list of available colors which can be OR'ed together and provided as an INT in the config file, e.g.: + log4cplus.appender.INFO_MSGS.TextColor=36 + for red text on green background + +#define FOREGROUND_BLUE 0x0001 // text color contains blue. +#define FOREGROUND_GREEN 0x0002 // text color contains green. +#define FOREGROUND_RED 0x0004 // text color contains red. +#define FOREGROUND_INTENSITY 0x0008 // text color is intensified. +#define BACKGROUND_BLUE 0x0010 // background color contains blue. +#define BACKGROUND_GREEN 0x0020 // background color contains green. +#define BACKGROUND_RED 0x0040 // background color contains red. +#define BACKGROUND_INTENSITY 0x0080 // background color is intensified. +*/ + namespace log4cplus { -Win32ConsoleAppender::Win32ConsoleAppender (bool allocConsole) +Win32ConsoleAppender::Win32ConsoleAppender (bool allocConsole, bool logToStdErr, unsigned int textColor) : alloc_console (allocConsole) + , log_to_std_err (logToStdErr) + , text_color (textColor) { } @@ -47,8 +63,12 @@ Win32ConsoleAppender::Win32ConsoleAppender ( helpers::Properties const & properties) : Appender (properties) , alloc_console (true) + , log_to_std_err (false) + , text_color (0) { properties.getBool (alloc_console, LOG4CPLUS_TEXT ("AllocConsole")); + properties.getBool (log_to_std_err, LOG4CPLUS_TEXT ("logToStdErr")); + properties.getUInt (text_color, LOG4CPLUS_TEXT ("TextColor")); } @@ -73,7 +93,8 @@ Win32ConsoleAppender::append (spi::InternalLoggingEvent const & event) // it will fail. AllocConsole (); - HANDLE const console_out = GetStdHandle (STD_OUTPUT_HANDLE); + HANDLE const console_out = GetStdHandle ( + log_to_std_err ? STD_ERROR_HANDLE : STD_OUTPUT_HANDLE); if (console_out == INVALID_HANDLE_VALUE) { helpers::getLogLog ().error ( @@ -153,28 +174,67 @@ Win32ConsoleAppender::write_console (void * console_void, tchar const * s, HANDLE console_out = static_cast(console_void); DWORD const total_to_write = static_cast(str_len); DWORD total_written = 0; + BOOL ret = FALSE; + unsigned int oldColor = 0; + + if (text_color) + { + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + ret = GetConsoleScreenBufferInfo (console_out, &csbiInfo); + if (! ret) + { + helpers::getLogLog().error( + LOG4CPLUS_TEXT("Win32ConsoleAppender::write_console:") + LOG4CPLUS_TEXT(" GetConsoleScreenBufferInfo failed")); + // fallback to standard gray on black + oldColor = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED; + goto output; + } + + // store old color first + oldColor = csbiInfo.wAttributes; + + // set new color + ret = SetConsoleTextAttribute (console_out, text_color); + if (! ret) + { + helpers::getLogLog().error( + LOG4CPLUS_TEXT("Win32ConsoleAppender::write_console:") + LOG4CPLUS_TEXT(" SetConsoleTextAttribute failed")); + } + } +output:; do { DWORD const to_write = (std::min) (64*1024 - 1, total_to_write - total_written); DWORD written = 0; - BOOL ret = WriteConsole (console_out, s + total_written, to_write, - &written, 0); + ret = WriteConsole (console_out, s + total_written, to_write, &written, + 0); if (! ret) { helpers::getLogLog ().error ( LOG4CPLUS_TEXT ("Win32ConsoleAppender::write_console") LOG4CPLUS_TEXT ("- WriteConsole has failed.")); - return; + break; } total_written += written; } while (total_written != total_to_write); -} + if (text_color) + { + // restore old color again + ret = SetConsoleTextAttribute (console_out, oldColor); + if (! ret) + helpers::getLogLog().error( + LOG4CPLUS_TEXT("Win32ConsoleAppender::write_console:") + LOG4CPLUS_TEXT(" SetConsoleTextAttribute failed")); + } +} } // namespace log4cplus From ec8bde78684f7fb49314cf87ea3a9923e3267176 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:36:00 +0100 Subject: [PATCH 026/226] win32consoleappender.h: Fix documentation typo. --- include/log4cplus/win32consoleappender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/log4cplus/win32consoleappender.h b/include/log4cplus/win32consoleappender.h index df51a3152..ebbfebe5b 100644 --- a/include/log4cplus/win32consoleappender.h +++ b/include/log4cplus/win32consoleappender.h @@ -54,7 +54,7 @@ namespace log4cplus * STD_ERROR_HANDLE instead of STD_OUTPUT_HANDLE. * * - *
logToStdErr
+ *
TextColor
*
See MSDN documentation for * * Character Attributes. From 1869ad5a5f36e50cbb303a2eb5d140245e2ca34f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:36:25 +0100 Subject: [PATCH 027/226] (Re)Introduce Embarcadero C++Builder XE3 compiler support. win32.h: Define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS for C++Builder XE3. fileappender.cxx (get_locale_by_name): Avoid function try-catch. lockfile.cxx: Use SH_DENYNO instead of _SH_DENYNO, etc., for C++Builder builds. patternlayout.cxx: Use qualified call to formatRelativeTimestamp(). socket-win32.cxx: Silence signed/unsigned comparison warning. --- include/log4cplus/config/win32.h | 4 ++++ src/fileappender.cxx | 5 +++-- src/lockfile.cxx | 6 ++++++ src/patternlayout.cxx | 2 +- src/socket-win32.cxx | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index e154653fc..f48ec39ab 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -173,6 +173,10 @@ # endif #endif +#if defined (__BORLANDC__) && __BORLANDC__ >= 0x0650 +# define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS +#endif // __BORLANDC__ + #endif // _WIN32 #endif // LOG4CPLUS_CONFIG_WIN32_HEADER_ diff --git a/src/fileappender.cxx b/src/fileappender.cxx index b681dd008..04928d67c 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -187,7 +187,8 @@ rolloverFiles(const tstring& filename, unsigned int maxBackupIndex) static std::locale -get_locale_by_name (tstring const & locale_name) try +get_locale_by_name (tstring const & locale_name) +{try { spi::LocaleFactoryRegistry & reg = spi::getLocaleFactoryRegistry (); spi::LocaleFactory * fact = reg.get (locale_name); @@ -205,7 +206,7 @@ catch (std::runtime_error const &) helpers::getLogLog ().error ( LOG4CPLUS_TEXT ("Failed to create locale " + locale_name)); return std::locale (); -} +}} } // namespace diff --git a/src/lockfile.cxx b/src/lockfile.cxx index 0183ec7a1..2db103dac 100644 --- a/src/lockfile.cxx +++ b/src/lockfile.cxx @@ -91,9 +91,15 @@ namespace log4cplus { namespace helpers { #if defined (_WIN32) +#if defined (__BORLANDC__) +int const OPEN_FLAGS = O_RDWR | O_CREAT | O_NOINHERIT; +int const OPEN_SHFLAGS = SH_DENYNO; +int const OPEN_MODE = S_IREAD | S_IWRITE; +#else int const OPEN_FLAGS = _O_RDWR | _O_CREAT /*| _O_TEMPORARY*/ | _O_NOINHERIT; int const OPEN_SHFLAGS = _SH_DENYNO; int const OPEN_MODE = _S_IREAD | _S_IWRITE; +#endif namespace { diff --git a/src/patternlayout.cxx b/src/patternlayout.cxx index 2771d081f..d0d03d7e3 100644 --- a/src/patternlayout.cxx +++ b/src/patternlayout.cxx @@ -540,7 +540,7 @@ RelativeTimestampConverter::convert (tstring & result, { tostringstream & oss = internal::get_ptd ()->layout_oss; detail::clear_tostringstream (oss); - formatRelativeTimestamp (oss, event); + log4cplus::formatRelativeTimestamp (oss, event); oss.str ().swap (result); } diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index 0f74dccf5..b6dc35583 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -223,7 +223,7 @@ connectSocket(const tstring& hostn, unsigned short port, bool udp, SocketState& INT ret = WSAStringToAddress (const_cast(hostn.c_str ()), AF_INET, 0, reinterpret_cast(&insock), &insock_size); - if (ret == SOCKET_ERROR || insock_size != sizeof (insock)) + if (ret == SOCKET_ERROR || insock_size != static_cast(sizeof (insock))) { state = bad_address; goto error; From 9b7d6e9bd9d5f9681815465d96d650dac2b43774 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:36:48 +0100 Subject: [PATCH 028/226] config.hxx: Pragma once support for C++Builder builds. win32.h: __FUNCTION__ macro is supported by C++Builder. --- include/log4cplus/config.hxx | 1 + include/log4cplus/config/win32.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index b717a8f08..33443f930 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -132,6 +132,7 @@ #define LOG4CPLUS_UNLIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 0) #if defined (_MSC_VER) \ + || (defined (__BORLANDC__) && __BORLANDC__ >= 0x0650) \ || (defined (__COMO__) && __COMO_VERSION__ >= 400) /* ??? */ \ || (defined (__DMC__) && __DMC__ >= 0x700) /* ??? */ \ || (defined (__clang__) && __clang_major__ >= 3) \ diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index f48ec39ab..e80b492af 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -174,6 +174,7 @@ #endif #if defined (__BORLANDC__) && __BORLANDC__ >= 0x0650 +# define LOG4CPLUS_HAVE_FUNCTION_MACRO # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS #endif // __BORLANDC__ From 46e1ea3723846938fbe6f3b54b5d38562a4ccad9 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:38:47 +0100 Subject: [PATCH 029/226] socket-win32.cxx (acceptSocket): Change implementation to use select() to allow timeouts. --- src/socket-win32.cxx | 65 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index b6dc35583..15838c804 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -28,6 +28,7 @@ #include #include #include +#include ///////////////////////////////////////////////////////////////////////////// @@ -261,12 +262,68 @@ acceptSocket(SOCKET_TYPE sock, SocketState & state) { init_winsock (); - SOCKET connected_socket = ::accept (to_os_socket (sock), NULL, NULL); + SOCKET osSocket = to_os_socket (sock); - if (connected_socket != INVALID_OS_SOCKET_VALUE) - state = ok; + // Check that the socket is ok. - return to_log4cplus_socket (connected_socket); + int val = 0; + int optlen = sizeof (val); + int ret = getsockopt (osSocket, SOL_SOCKET, SO_TYPE, + reinterpret_cast(&val), &optlen); + if (ret == SOCKET_ERROR) + goto error; + + // Now that we know the socket is working ok we can wait for + // either a new connection or for a transition to bad state. + + while (1) + { + fd_set readSet; + timeval timeout; + + FD_ZERO (&readSet); + FD_SET (osSocket, &readSet); + timeout.tv_sec = 0; + timeout.tv_usec = 200 * 1000; + + int selectResponse = ::select (1, &readSet, NULL, NULL, &timeout); + if (selectResponse < 0) + { + DWORD const eno = WSAGetLastError (); + if (eno == WSAENOTSOCK || eno == WSAEINVAL) + WSASetLastError (ERROR_NO_DATA); + + goto error; + } + else if (selectResponse == 0) + // Timeout. + continue; + else if (selectResponse == 1) + { + SOCKET connected_socket = ::accept (osSocket, NULL, NULL); + + if (connected_socket != INVALID_OS_SOCKET_VALUE) + state = ok; + else + goto error; + + return to_log4cplus_socket (connected_socket); + } + else + { + helpers::getLogLog ().error ( + LOG4CPLUS_TEXT ("unexpected select() return value: ") + + helpers::convertIntegerToString (selectResponse)); + WSASetLastError (ERROR_UNSUPPORTED_TYPE); + goto error; + } + } + +error: + DWORD eno = WSAGetLastError (); + set_last_socket_error (eno); + + return to_log4cplus_socket (INVALID_SOCKET); } From 704e3ec4afb1afbd8fcf9eac5374c1fa3153e783 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:45:22 +0100 Subject: [PATCH 030/226] log4cplus-1.1.0-1.cygport: Rename from log4cplus-1.1.0-rc8-1.cygport. Update for 1.1.0 release. --- ...1.1.0-rc8-1.cygport => log4cplus-1.1.0-1.cygport} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename cygport/{log4cplus-1.1.0-rc8-1.cygport => log4cplus-1.1.0-1.cygport} (73%) diff --git a/cygport/log4cplus-1.1.0-rc8-1.cygport b/cygport/log4cplus-1.1.0-1.cygport similarity index 73% rename from cygport/log4cplus-1.1.0-rc8-1.cygport rename to cygport/log4cplus-1.1.0-1.cygport index 3ae5aa275..43c4fc120 100644 --- a/cygport/log4cplus-1.1.0-rc8-1.cygport +++ b/cygport/log4cplus-1.1.0-1.cygport @@ -3,18 +3,18 @@ SUMMARY="C++ logging library" DESCRIPTION="log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API." -HOMEPAGE="http://log4cplus.sourceforge.net/" +HOMEPAGE="http://log4cplus.sourceforge.net/"xq SRC_URI="mirror://sourceforge/log4cplus/log4cplus-stable/${PV%-rc*}/${P}.tar.xz" PATCH_URI="configure.ac-relax-libtool-version.patch configure.ac-disable-__thread-keyword.patch" -PKG_NAMES="lib${PN}1.1_4 lib${PN}qt4debugappender1.1_4 +PKG_NAMES="lib${PN}1.1_5 lib${PN}qt4debugappender1.1_5 lib${PN}-devel lib${PN}qt4debugappender-devel" -liblog4cplus1_1_4_SUMMARY="${SUMMARY} (runtime)" -liblog4cplus1_1_4_CONTENTS="usr/bin/cyglog4cplus-1-1-4.dll" -liblog4cplusqt4debugappender1_1_4_SUMMARY="${SUMMARY} (Qt4 runtime)" -liblog4cplusqt4debugappender1_1_4_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-4.dll" +liblog4cplus1_1_5_SUMMARY="${SUMMARY} (runtime)" +liblog4cplus1_1_5_CONTENTS="usr/bin/cyglog4cplus-1-1-5.dll" +liblog4cplusqt4debugappender1_1_5_SUMMARY="${SUMMARY} (Qt4 runtime)" +liblog4cplusqt4debugappender1_1_5_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-5.dll" liblog4cplus_devel_SUMMARY="${SUMMARY} (development)" liblog4cplus_devel_CONTENTS="--exclude=*qt4* usr/include/ usr/lib/ usr/share/doc/" liblog4cplusqt4debugappender_devel_SUMMARY="${SUMMARY} (Qt4 development)" From 9b8d5ee5c6b9997c61caa691f999869ab176434b Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 11:53:14 +0100 Subject: [PATCH 031/226] Update to Automake 1.12.6. --- Makefile.in | 2 +- aclocal.m4 | 6 +- config.guess | 19 ++++-- config.sub | 38 ++++++++---- depcomp | 86 ++++++++++++++++++++++++++- include/Makefile.in | 2 +- include/log4cplus/config.h.in | 6 -- loggingserver/Makefile.in | 2 +- qt4debugappender/Makefile.in | 2 +- scripts/doautoreconf.sh | 2 +- src/Makefile.in | 2 +- tests/Makefile.in | 2 +- tests/appender_test/Makefile.in | 2 +- tests/configandwatch_test/Makefile.in | 2 +- tests/customloglevel_test/Makefile.in | 2 +- tests/fileappender_test/Makefile.in | 2 +- tests/filter_test/Makefile.in | 2 +- tests/hierarchy_test/Makefile.in | 2 +- tests/loglog_test/Makefile.in | 2 +- tests/ndc_test/Makefile.in | 2 +- tests/ostream_test/Makefile.in | 2 +- tests/patternlayout_test/Makefile.in | 2 +- tests/performance_test/Makefile.in | 2 +- tests/priority_test/Makefile.in | 2 +- tests/propertyconfig_test/Makefile.in | 2 +- tests/socket_test/Makefile.in | 2 +- tests/thread_test/Makefile.in | 2 +- tests/timeformat_test/Makefile.in | 2 +- 28 files changed, 148 insertions(+), 53 deletions(-) diff --git a/Makefile.in b/Makefile.in index 54773692a..541430433 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/aclocal.m4 b/aclocal.m4 index b44d7314d..4494e858f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.12.3 -*- Autoconf -*- +# generated automatically by aclocal 1.12.6 -*- Autoconf -*- # Copyright (C) 1996-2012 Free Software Foundation, Inc. @@ -34,7 +34,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.12' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.12.3], [], +m4_if([$1], [1.12.6], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -50,7 +50,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.12.3])dnl +[AM_AUTOMAKE_VERSION([1.12.6])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) diff --git a/config.guess b/config.guess index d622a44e5..872b96a16 100755 --- a/config.guess +++ b/config.guess @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. -timestamp='2012-02-10' +timestamp='2012-09-25' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -200,6 +200,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} @@ -302,7 +306,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -801,6 +805,9 @@ EOF i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; @@ -1201,6 +1208,9 @@ EOF BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1256,7 +1266,7 @@ EOF NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; - NSE-?:NONSTOP_KERNEL:*:*) + NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) @@ -1330,9 +1340,6 @@ EOF exit ;; esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - eval $set_cc_for_build cat >$dummy.c <&2; rm -rf $lockdir" 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0 ; do + # mkdir is a portable test-and-set. + if mkdir $lockdir 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rm -rf $lockdir + break + else + ## the lock is being held by a different process, + ## wait until the winning process is done or we timeout + while test -d $lockdir && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option diff --git a/include/Makefile.in b/include/Makefile.in index 460e75823..6bc275ce1 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index 1b61b1bd7..e8af46748 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -163,9 +163,6 @@ /* Define to 1 if you have the `wcstombs' function. */ #undef HAVE_WCSTOMBS -/* Define to 1 if you have the `_vsnprintf' function. */ -#undef HAVE__VSNPRINTF - /* Define to 1 if you have the `_vsnprintf_s' function. */ #undef HAVE__VSNPRINTF_S @@ -388,9 +385,6 @@ /* */ #undef LOG4CPLUS_HAVE_WCSTOMBS -/* */ -#undef LOG4CPLUS_HAVE__VSNPRINTF - /* */ #undef LOG4CPLUS_HAVE__VSNPRINTF_S diff --git a/loggingserver/Makefile.in b/loggingserver/Makefile.in index 656e3bc60..bb41b4ea5 100644 --- a/loggingserver/Makefile.in +++ b/loggingserver/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/qt4debugappender/Makefile.in b/qt4debugappender/Makefile.in index 89e5710d2..175dac5ec 100644 --- a/qt4debugappender/Makefile.in +++ b/qt4debugappender/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/scripts/doautoreconf.sh b/scripts/doautoreconf.sh index 9063d6392..1523f65ea 100755 --- a/scripts/doautoreconf.sh +++ b/scripts/doautoreconf.sh @@ -1,6 +1,6 @@ #!/bin/sh -export AUTOMAKE_SUFFIX=-1.12.3 +export AUTOMAKE_SUFFIX=-1.12.6 export AUTOCONF_SUFFIX=-2.69 export LIBTOOL_SUFFIX=-2.4.2 diff --git a/src/Makefile.in b/src/Makefile.in index cb8e3eb1a..404a50d03 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/Makefile.in b/tests/Makefile.in index a5edde4de..bf958a192 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/appender_test/Makefile.in b/tests/appender_test/Makefile.in index 4524c299a..9e42a4d0f 100644 --- a/tests/appender_test/Makefile.in +++ b/tests/appender_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/configandwatch_test/Makefile.in b/tests/configandwatch_test/Makefile.in index 1303455fd..8629b499a 100644 --- a/tests/configandwatch_test/Makefile.in +++ b/tests/configandwatch_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/customloglevel_test/Makefile.in b/tests/customloglevel_test/Makefile.in index cf3d08fbb..894da3359 100644 --- a/tests/customloglevel_test/Makefile.in +++ b/tests/customloglevel_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/fileappender_test/Makefile.in b/tests/fileappender_test/Makefile.in index 8d4834e51..9068a0769 100644 --- a/tests/fileappender_test/Makefile.in +++ b/tests/fileappender_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/filter_test/Makefile.in b/tests/filter_test/Makefile.in index 668f2fec1..6b4b6b495 100644 --- a/tests/filter_test/Makefile.in +++ b/tests/filter_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/hierarchy_test/Makefile.in b/tests/hierarchy_test/Makefile.in index c3c32923b..d116f991c 100644 --- a/tests/hierarchy_test/Makefile.in +++ b/tests/hierarchy_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/loglog_test/Makefile.in b/tests/loglog_test/Makefile.in index 69e3d825b..ba32ea080 100644 --- a/tests/loglog_test/Makefile.in +++ b/tests/loglog_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/ndc_test/Makefile.in b/tests/ndc_test/Makefile.in index 03eaf1ece..33432b8dc 100644 --- a/tests/ndc_test/Makefile.in +++ b/tests/ndc_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/ostream_test/Makefile.in b/tests/ostream_test/Makefile.in index c30e5f9b6..477159c83 100644 --- a/tests/ostream_test/Makefile.in +++ b/tests/ostream_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/patternlayout_test/Makefile.in b/tests/patternlayout_test/Makefile.in index 7478fb91a..aeea34fb1 100644 --- a/tests/patternlayout_test/Makefile.in +++ b/tests/patternlayout_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/performance_test/Makefile.in b/tests/performance_test/Makefile.in index 70430ab2a..e80e08046 100644 --- a/tests/performance_test/Makefile.in +++ b/tests/performance_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/priority_test/Makefile.in b/tests/priority_test/Makefile.in index da971e2d8..f0ca22024 100644 --- a/tests/priority_test/Makefile.in +++ b/tests/priority_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/propertyconfig_test/Makefile.in b/tests/propertyconfig_test/Makefile.in index 9d4aa4fbe..18047da56 100644 --- a/tests/propertyconfig_test/Makefile.in +++ b/tests/propertyconfig_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/socket_test/Makefile.in b/tests/socket_test/Makefile.in index 6c72efe9b..0cbb4fa26 100644 --- a/tests/socket_test/Makefile.in +++ b/tests/socket_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/thread_test/Makefile.in b/tests/thread_test/Makefile.in index 2fa041df5..caead4d33 100644 --- a/tests/thread_test/Makefile.in +++ b/tests/thread_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. diff --git a/tests/timeformat_test/Makefile.in b/tests/timeformat_test/Makefile.in index 9babaa335..2100fc076 100644 --- a/tests/timeformat_test/Makefile.in +++ b/tests/timeformat_test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.12.3 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2012 Free Software Foundation, Inc. From be2e797386a6c9266cc1fff77c3980b1f2c54ea2 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 12:02:37 +0100 Subject: [PATCH 032/226] Bump LT_VERSION to 6:0:0. --- configure | 2 +- configure.ac | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 62ab11073..7f28c0391 100755 --- a/configure +++ b/configure @@ -4210,7 +4210,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=5:0:0 +LT_VERSION=6:0:0 LT_RELEASE=1.1 diff --git a/configure.ac b/configure.ac index d03708180..0ba65c4b5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl This version of log4cplus requires the follwing autotools versions: dnl autoconf-2.69 -dnl automake-1.12 +dnl automake-1.12.6 dnl libtool-2.4.2 AC_INIT([log4cplus],[1.1.0]) @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=5:0:0 +LT_VERSION=6:0:0 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) From 908bb413c139a13ad800ab90776d47682696db3c Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 20:06:59 +0100 Subject: [PATCH 033/226] Update for 1.1.1. --- ...lus-1.1.0-1.cygport => log4cplus-1.1.1-1.cygport} | 12 ++++++------ include/log4cplus/version.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) rename cygport/{log4cplus-1.1.0-1.cygport => log4cplus-1.1.1-1.cygport} (73%) diff --git a/cygport/log4cplus-1.1.0-1.cygport b/cygport/log4cplus-1.1.1-1.cygport similarity index 73% rename from cygport/log4cplus-1.1.0-1.cygport rename to cygport/log4cplus-1.1.1-1.cygport index 43c4fc120..167baabce 100644 --- a/cygport/log4cplus-1.1.0-1.cygport +++ b/cygport/log4cplus-1.1.1-1.cygport @@ -3,18 +3,18 @@ SUMMARY="C++ logging library" DESCRIPTION="log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API." -HOMEPAGE="http://log4cplus.sourceforge.net/"xq +HOMEPAGE="http://log4cplus.sourceforge.net/" SRC_URI="mirror://sourceforge/log4cplus/log4cplus-stable/${PV%-rc*}/${P}.tar.xz" PATCH_URI="configure.ac-relax-libtool-version.patch configure.ac-disable-__thread-keyword.patch" -PKG_NAMES="lib${PN}1.1_5 lib${PN}qt4debugappender1.1_5 +PKG_NAMES="lib${PN}1.1_6 lib${PN}qt4debugappender1.1_6 lib${PN}-devel lib${PN}qt4debugappender-devel" -liblog4cplus1_1_5_SUMMARY="${SUMMARY} (runtime)" -liblog4cplus1_1_5_CONTENTS="usr/bin/cyglog4cplus-1-1-5.dll" -liblog4cplusqt4debugappender1_1_5_SUMMARY="${SUMMARY} (Qt4 runtime)" -liblog4cplusqt4debugappender1_1_5_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-5.dll" +liblog4cplus1_1_6_SUMMARY="${SUMMARY} (runtime)" +liblog4cplus1_1_6_CONTENTS="usr/bin/cyglog4cplus-1-1-6.dll" +liblog4cplusqt4debugappender1_1_6_SUMMARY="${SUMMARY} (Qt4 runtime)" +liblog4cplusqt4debugappender1_1_6_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-6.dll" liblog4cplus_devel_SUMMARY="${SUMMARY} (development)" liblog4cplus_devel_CONTENTS="--exclude=*qt4* usr/include/ usr/lib/ usr/share/doc/" liblog4cplusqt4debugappender_devel_SUMMARY="${SUMMARY} (Qt4 development)" diff --git a/include/log4cplus/version.h b/include/log4cplus/version.h index 0f9b2296e..242eb159a 100644 --- a/include/log4cplus/version.h +++ b/include/log4cplus/version.h @@ -38,8 +38,8 @@ #define LOG4CPLUS_MAKE_VERSION_STR(major, minor, point) \ #major "." #minor "." #point -#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 0) -#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 0) +#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 1) +#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 1) namespace log4cplus From 04aa8bb101e4c87c18eee4c4606c64ff966633e1 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Dec 2012 20:33:35 +0100 Subject: [PATCH 034/226] ChangeLog: Update for 1.1.1-RC1. --- ChangeLog | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ChangeLog b/ChangeLog index dc83dbacb..5c56aa1bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +log4cplus 1.1.1-rc1 + +- Improved documentation for various classes. + +- Cherry-picked various small improvements from trunk. + +- Fixed Unicode builds on *NIX. + +- Fixed static library builds from Visual Studio project. + +- Suppressed warning C4127 from MSVC. (Chris Steenwyk) + +- Improved MinGW32 and MinGW64 toolchains compatiblity. + +- Fixed encoding handling in Properties class. + +- Added include directive for properties files. (Jukka Lantto) + +- Added colored output for Win32ConsoleAppender. (Konstantin Baumann) + +- (Re)Introduced support for C++Builder (XE3) + +- Reimplemented acceptSocket() using select() on Windows to allow + interrupting the accept() call from different thread. + + log4cplus 1.1.0 - Fixed MacOS X support - Reimplemented semaphores using named ones From d398148604c8c5f790e972d604234d3c7d4fc5dd Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:06:56 +0100 Subject: [PATCH 035/226] loggingmacros.h: Allow to disable TLS usage in macros through LOG4CPLUS_MACRO_DISABLE_TLS preprocessor symbol. --- include/log4cplus/loggingmacros.h | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/include/log4cplus/loggingmacros.h b/include/log4cplus/loggingmacros.h index df8e3372f..8fe55993c 100644 --- a/include/log4cplus/loggingmacros.h +++ b/include/log4cplus/loggingmacros.h @@ -180,6 +180,27 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_ ## logLevel (pred) +// Either use temporary instances of ostringstream +// and snprintf_buf, or use thread-local instances. +#if defined (LOG4CPLUS_MACRO_DISABLE_TLS) +# define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM(var) \ + log4cplus::tostringstream var + +# define LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF(var) \ + log4cplus::helpers::snprintf_buf var + +#else +# define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM(var) \ + log4cplus::tostringstream & var \ + = log4cplus::detail::get_macro_body_oss () + +# define LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF(var) \ + log4cplus::helpers::snprintf_buf & var \ + = log4cplus::detail::get_macro_body_snprintf_buf () + +#endif + + #define LOG4CPLUS_MACRO_BODY(logger, logEvent, logLevel) \ LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ @@ -187,8 +208,7 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, = log4cplus::detail::macros_get_logger (logger); \ if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \ _l.isEnabledFor (log4cplus::logLevel), logLevel)) { \ - log4cplus::tostringstream & _log4cplus_buf \ - = log4cplus::detail::get_macro_body_oss (); \ + LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM (_log4cplus_buf); \ _log4cplus_buf << logEvent; \ log4cplus::detail::macro_forced_log (_l, \ log4cplus::logLevel, _log4cplus_buf.str(), \ @@ -220,8 +240,7 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, = log4cplus::detail::macros_get_logger (logger); \ if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \ _l.isEnabledFor (log4cplus::logLevel), logLevel)) { \ - log4cplus::helpers::snprintf_buf & _snpbuf \ - = log4cplus::detail::get_macro_body_snprintf_buf (); \ + LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \ log4cplus::tchar const * _logEvent \ = _snpbuf.print (logFmt, __VA_ARGS__); \ log4cplus::detail::macro_forced_log (_l, \ @@ -239,8 +258,7 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, = log4cplus::detail::macros_get_logger (logger); \ if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \ _l.isEnabledFor (log4cplus::logLevel), logLevel)) { \ - log4cplus::helpers::snprintf_buf & _snpbuf \ - = log4cplus::detail::get_macro_body_snprintf_buf (); \ + LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \ log4cplus::tchar const * _logEvent \ = _snpbuf.print (logFmt, logArgs); \ log4cplus::detail::macro_forced_log (_l, \ From c537d14b72999625bfd80f5afd9c8aa39bab2e5c Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:07:57 +0100 Subject: [PATCH 036/226] socket-win32.cxx: Prevent infinite loop in read() when recv() returns 0. Patch provided by: Chris Steenwyk --- src/socket-win32.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index 15838c804..efd236825 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -340,10 +340,11 @@ long read(SOCKET_TYPE sock, SocketBuffer& buffer) { long res, read = 0; - + os_socket_type const osSocket = to_os_socket (sock); + do { - res = ::recv(to_os_socket (sock), + res = ::recv(osSocket, buffer.getBuffer() + read, static_cast(buffer.getMaxSize() - read), 0); @@ -352,6 +353,12 @@ read(SOCKET_TYPE sock, SocketBuffer& buffer) set_last_socket_error (WSAGetLastError ()); return res; } + + // A return of 0 indicates the socket is closed, + // return to prevent an infinite loop. + if (res == 0) + return read; + read += res; } while (read < static_cast(buffer.getMaxSize())); From a8fd754ac822a6aa80f39ae8d2317d279e617487 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:08:57 +0100 Subject: [PATCH 037/226] cygwin-win32.cxx: Work around missing _X86_ symbol in Clang builds. --- src/cygwin-win32.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cygwin-win32.cxx b/src/cygwin-win32.cxx index 0badce539..766dc520b 100644 --- a/src/cygwin-win32.cxx +++ b/src/cygwin-win32.cxx @@ -27,6 +27,12 @@ // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined (__CYGWIN__) + +// Work around missing _X86_ symbol with Clang on Cygwin. +#if ! defined (_X86_) && defined (__i386__) +# define _X86_ 1 +#endif + #include // This is intentionally included directly instead of through From acc39982d4af53a78f51de1fc981c12d6c4ff20e Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:09:50 +0100 Subject: [PATCH 038/226] timehelper.cxx: Avoid unnecessary floating-point multiplication. Fix comment. --- src/timehelper.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/timehelper.cxx b/src/timehelper.cxx index e19d7778e..afc7cddd5 100644 --- a/src/timehelper.cxx +++ b/src/timehelper.cxx @@ -269,10 +269,11 @@ Time::getFormattedTime(const log4cplus::tstring& fmt_orig, bool use_gmtime) cons gft_sp.reset (); gft_sp.fmt.assign (fmt_orig); - gft_sp.ret.reserve (static_cast(gft_sp.fmt.size () * 1.35)); + std::size_t const fmt_orig_size = gft_sp.fmt.size (); + gft_sp.ret.reserve (fmt_orig_size + fmt_orig_size / 3); State state = TEXT; - // Walk the format string and process all occurences of %q and %Q. + // Walk the format string and process all occurences of %q, %Q and %s. for (log4cplus::tstring::const_iterator fmt_it = gft_sp.fmt.begin (); fmt_it != gft_sp.fmt.end (); ++fmt_it) From 85cd4ebc895f9f816b7dfc225f24c9eff2288cc8 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:12:55 +0100 Subject: [PATCH 039/226] configure.ac: Disable -fstack-protector and -fstack-check on MinGW to fix SIGSEGV in DllMain(). --- configure | 11 ++++++++--- configure.ac | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 7f28c0391..1773e979f 100755 --- a/configure +++ b/configure @@ -6205,7 +6205,11 @@ case ".$var" in ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fstack-check" >&5 + case "$target_os" in #( + mingw32) : + ;; #( + *) : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fstack-check" >&5 $as_echo_n "checking CXXFLAGS for gcc -fstack-check... " >&6; } if ${ax_cv_cxxflags_gcc_option__fstack_check+:} false; then : $as_echo_n "(cached) " >&6 @@ -6269,7 +6273,7 @@ case ".$var" in ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fstack-protector" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fstack-protector" >&5 $as_echo_n "checking CXXFLAGS for gcc -fstack-protector... " >&6; } if ${ax_cv_cxxflags_gcc_option__fstack_protector+:} false; then : $as_echo_n "(cached) " >&6 @@ -6332,7 +6336,8 @@ case ".$var" in fi ;; esac - + ;; +esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -ftrapv" >&5 $as_echo_n "checking CXXFLAGS for gcc -ftrapv... " >&6; } if ${ax_cv_cxxflags_gcc_option__ftrapv+:} false; then : diff --git a/configure.ac b/configure.ac index 0ba65c4b5..1c34d5eb4 100644 --- a/configure.ac +++ b/configure.ac @@ -179,8 +179,12 @@ AS_CASE([$ax_cv_cxx_compiler_vendor], AS_IF([test "x$enable_debugging" = "xyes"], [AX_CXXFLAGS_GCC_OPTION([-g3]) AX_CXXFLAGS_GCC_OPTION([-fkeep-inline-functions]) - AX_CXXFLAGS_GCC_OPTION([-fstack-check]) - AX_CXXFLAGS_GCC_OPTION([-fstack-protector]) + AS_CASE(["$target_os"], + dnl Disable these for MinGW32 as it seems to generate DLLs that + dnl segfault in DllMain(). + [mingw32], [], + [AX_CXXFLAGS_GCC_OPTION([-fstack-check]) + AX_CXXFLAGS_GCC_OPTION([-fstack-protector])]) dnl -Wstack-protector results into not too interesting warnings. dnl AX_CXXFLAGS_GCC_OPTION([-Wstack-protector]) AX_CXXFLAGS_GCC_OPTION([-ftrapv])], From 0a860cb79b7e8b08f9cc35d29b8ebcd46afe09f3 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:13:29 +0100 Subject: [PATCH 040/226] win32.h: Fix build failure caused by -march=i386. --- include/log4cplus/config/win32.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index e80b492af..280c2b222 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -159,8 +159,11 @@ # undef LOG4CPLUS_INLINES_ARE_EXPORTED # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) # define LOG4CPLUS_INLINES_ARE_EXPORTED -# define LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH -# define LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH +# if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) +# define LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH +# define LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH +# endif +# endif # endif # define LOG4CPLUS_HAVE_FUNCTION_MACRO # define LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS From 2721a6eec54ef84b755a4e5feb00298b2a8d9bb1 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:14:08 +0100 Subject: [PATCH 041/226] config.hxx: Assume C++11 support when __cplusplus >= 201103L. --- include/log4cplus/config.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index 33443f930..4c508effe 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -99,7 +99,8 @@ #endif #if (defined (_MSC_VER) && _MSC_VER >= 1600) \ - || defined (__GXX_EXPERIMENTAL_CXX0X__) + || defined (__GXX_EXPERIMENTAL_CXX0X__) \ + || __cplusplus >= 201103L # define LOG4CPLUS_HAVE_CXX11_SUPPORT #endif From 49a64e776f696e90d853784ce38ffe53ec985fcc Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:14:33 +0100 Subject: [PATCH 042/226] win32.h: GCC has __func__ and __PRETTY_FUNCTION__ symbols at least since version 3.1. --- include/log4cplus/config/win32.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index 280c2b222..ac0691482 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -168,8 +168,9 @@ # define LOG4CPLUS_HAVE_FUNCTION_MACRO # define LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) # define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO +# define LOG4CPLUS_HAVE_FUNC_SYMBOL # endif # if defined (__MINGW32__) # define LOG4CPLUS_WORKING_C_LOCALE From 8969c96e2707011d2bc476a820df6ffc7bee4643 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:15:46 +0100 Subject: [PATCH 043/226] global-init.cxx: Implement thread callback using .CRT$XLX section for static library build with MSVC. --- src/global-init.cxx | 64 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/src/global-init.cxx b/src/global-init.cxx index 10726b6a6..90fe75d63 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -385,16 +385,10 @@ threadCleanup () } -} // namespace log4cplus - - -#if defined (_WIN32) && defined (LOG4CPLUS_BUILD_DLL) - -extern "C" -BOOL -WINAPI -DllMain (LOG4CPLUS_DLLMAIN_HINSTANCE /*hinstDLL*/, DWORD fdwReason, - LPVOID /*lpReserved*/) +#if defined (_WIN32) +static +void NTAPI +thread_callback (LPVOID /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpReserved*/) { // Perform actions based on the reason for calling. switch( fdwReason ) @@ -438,13 +432,60 @@ DllMain (LOG4CPLUS_DLLMAIN_HINSTANCE /*hinstDLL*/, DWORD fdwReason, break; } - } + } // switch +} + +#endif + + +} // namespace log4cplus + + +#if defined (_WIN32) && defined (LOG4CPLUS_BUILD_DLL) + +extern "C" +BOOL +WINAPI +DllMain (LOG4CPLUS_DLLMAIN_HINSTANCE hinstDLL, DWORD fdwReason, + LPVOID lpReserved) +{ + log4cplus::thread_callback (hinstDLL, fdwReason, lpReserved); return TRUE; // Successful DLL_PROCESS_ATTACH. } #else +#if defined (_MSC_VER) && _MSC_VER >= 1400 + +extern "C" +{ + +// This magic has been pieced together from several sources: +// - +// - + +#pragma data_seg (push, old_seg) +#ifdef _WIN64 +#pragma const_seg (".CRT$XLX") +extern const +#else +#pragma data_seg (".CRT$XLX") +#endif +PIMAGE_TLS_CALLBACK p_thread_callback = log4cplus::thread_callback; +#pragma data_seg (pop, old_seg) +#ifdef _WIN64 +#pragma comment (linker, "/INCLUDE:_tls_used") +#pragma comment (linker, "/INCLUDE:p_thread_callback") +#else +#pragma comment (linker, "/INCLUDE:__tls_used") +#pragma comment (linker, "/INCLUDE:_p_thread_callback") +#endif + +} // extern "C" + +#else + namespace { struct _static_log4cplus_initializer @@ -462,5 +503,6 @@ namespace { } static initializer; } +#endif #endif From 3498ad009ccfbea56f01aaef3be202fd27670d4f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 8 Jan 2013 20:21:08 +0100 Subject: [PATCH 044/226] Bump SO revision number. Fix package version number to 1.1.1. --- configure | 22 +++++++++++----------- configure.ac | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/configure b/configure index 1773e979f..d2fa8b04b 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for log4cplus 1.1.0. +# Generated by GNU Autoconf 2.69 for log4cplus 1.1.1. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='log4cplus' PACKAGE_TARNAME='log4cplus' -PACKAGE_VERSION='1.1.0' -PACKAGE_STRING='log4cplus 1.1.0' +PACKAGE_VERSION='1.1.1' +PACKAGE_STRING='log4cplus 1.1.1' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1346,7 +1346,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures log4cplus 1.1.0 to adapt to many kinds of systems. +\`configure' configures log4cplus 1.1.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1417,7 +1417,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of log4cplus 1.1.0:";; + short | recursive ) echo "Configuration of log4cplus 1.1.1:";; esac cat <<\_ACEOF @@ -1541,7 +1541,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -log4cplus configure 1.1.0 +log4cplus configure 1.1.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2088,7 +2088,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by log4cplus $as_me 1.1.0, which was +It was created by log4cplus $as_me 1.1.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3024,7 +3024,7 @@ fi # Define the identity of the package. PACKAGE='log4cplus' - VERSION='1.1.0' + VERSION='1.1.1' # Some tools Automake needs. @@ -4210,7 +4210,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=6:0:0 +LT_VERSION=6:1:0 LT_RELEASE=1.1 @@ -21556,7 +21556,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by log4cplus $as_me 1.1.0, which was +This file was extended by log4cplus $as_me 1.1.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21622,7 +21622,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -log4cplus config.status 1.1.0 +log4cplus config.status 1.1.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 1c34d5eb4..e6bb38703 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl autoconf-2.69 dnl automake-1.12.6 dnl libtool-2.4.2 -AC_INIT([log4cplus],[1.1.0]) +AC_INIT([log4cplus],[1.1.1]) AC_CANONICAL_TARGET AC_CONFIG_SRCDIR([src/logger.cxx]) AC_CONFIG_MACRO_DIR([m4]) @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=6:0:0 +LT_VERSION=6:1:0 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) From a96f7f16e5bb624e3c14c6007d1659967edc461a Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 15 Jan 2013 00:03:04 +0100 Subject: [PATCH 045/226] socket-win32.cxx: Call init_winsock() in getHostname(). Fixes bug #154 --- src/socket-win32.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index efd236825..f05eb4001 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -393,6 +393,8 @@ write(SOCKET_TYPE sock, const std::string & buffer) tstring getHostname (bool fqdn) { + init_winsock (); + char const * hostname = "unknown"; int ret; std::vector hn (1024, 0); From 727ff20e1aea7f31dc9d905300b85334854397e3 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 15 Jan 2013 21:06:06 +0100 Subject: [PATCH 046/226] ax_tls_support.m4: Fix detection of C++11 thread_local keyword. configure.ac: Use C++11 thread_local when available. --- configure | 15 +++++++++++---- configure.ac | 13 ++++++++----- m4/ax_tls_support.m4 | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/configure b/configure index d2fa8b04b..440c593bc 100755 --- a/configure +++ b/configure @@ -9372,7 +9372,7 @@ x = 2; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv__thread_local=yes + ac_cv_thread_local=yes ax_tls_support=yes else ac_cv_thread_local=no @@ -9498,17 +9498,24 @@ fi - if test "x$ac_cv_declspec_thread" = "xyes"; then : + if test "x$ac_cv_thread_local" = "xyes"; then : $as_echo "#define LOG4CPLUS_HAVE_TLS_SUPPORT 1" >>confdefs.h - $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR __declspec(thread)" >>confdefs.h + $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR thread_local" >>confdefs.h + +else + if test "x$ac_cv_declspec_thread" = "xyes"; then : + $as_echo "#define LOG4CPLUS_HAVE_TLS_SUPPORT 1" >>confdefs.h + + $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR __declspec(thread)" >>confdefs.h else if test "x$ac_cv__thread_keyword" = "xyes"; then : $as_echo "#define LOG4CPLUS_HAVE_TLS_SUPPORT 1" >>confdefs.h - $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR __thread" >>confdefs.h + $as_echo "#define LOG4CPLUS_THREAD_LOCAL_VAR __thread" >>confdefs.h +fi fi fi else diff --git a/configure.ac b/configure.ac index e6bb38703..07ff1a44d 100644 --- a/configure.ac +++ b/configure.ac @@ -396,12 +396,15 @@ dnl Multi threaded library. AX_TLS_SUPPORT AH_TEMPLATE([LOG4CPLUS_HAVE_TLS_SUPPORT]) AH_TEMPLATE([LOG4CPLUS_THREAD_LOCAL_VAR]) - AS_IF([test "x$ac_cv_declspec_thread" = "xyes"], + AS_IF([test "x$ac_cv_thread_local" = "xyes"], [AC_DEFINE([LOG4CPLUS_HAVE_TLS_SUPPORT]) - AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [__declspec(thread)])], - [AS_IF([test "x$ac_cv__thread_keyword" = "xyes"], - [AC_DEFINE([LOG4CPLUS_HAVE_TLS_SUPPORT]) - AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [__thread])])])], + AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [thread_local])], + [AS_IF([test "x$ac_cv_declspec_thread" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_TLS_SUPPORT]) + AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [__declspec(thread)])], + [AS_IF([test "x$ac_cv__thread_keyword" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_TLS_SUPPORT]) + AC_DEFINE([LOG4CPLUS_THREAD_LOCAL_VAR], [__thread])])])])], dnl Single threaded library. [AC_MSG_NOTICE([Creating a single-threaded library]) diff --git a/m4/ax_tls_support.m4 b/m4/ax_tls_support.m4 index b410488d7..641068971 100644 --- a/m4/ax_tls_support.m4 +++ b/m4/ax_tls_support.m4 @@ -22,7 +22,7 @@ AC_CACHE_CHECK([for thread_local], [ac_cv_thread_local], ]], [[x = 2; foo ();]])], - [ac_cv__thread_local=yes + [ac_cv_thread_local=yes ax_tls_support=yes], [ac_cv_thread_local=no], [ac_cv_thread_local=no]) From b54be86933074b3019a0d1b5cd89c4c02ae6b793 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 16 Jan 2013 21:02:23 +0100 Subject: [PATCH 047/226] win32.h: Move LOG4CPLUS_INLINES_ARE_EXPORTED from GCC 3.1+ section to GCC 4.7+ section to fix builds with Ruby's DevKit-tdm-32-4.5.2-20111229-1559-sfx. Sort GCC version sections. --- include/log4cplus/config/win32.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index ac0691482..cbd833db5 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -74,8 +74,6 @@ #define LOG4CPLUS_HAVE__VSNPRINTF #define LOG4CPLUS_HAVE__VSNWPRINTF -#if defined (_MSC_VER) \ - || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3) // MS secure versions of vprintf(). # define LOG4CPLUS_HAVE_VSPRINTF_S # define LOG4CPLUS_HAVE_VSWPRINTF_S @@ -157,21 +155,24 @@ #if defined (__GNUC__) # undef LOG4CPLUS_INLINES_ARE_EXPORTED +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +# define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO +# define LOG4CPLUS_HAVE_FUNC_SYMBOL +# endif # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) -# define LOG4CPLUS_INLINES_ARE_EXPORTED # if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) # define LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH # define LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH # endif # endif +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) +# define LOG4CPLUS_HAVE___ATOMIC_ADD_FETCH +# define LOG4CPLUS_HAVE___ATOMIC_SUB_FETCH +# define LOG4CPLUS_INLINES_ARE_EXPORTED # endif # define LOG4CPLUS_HAVE_FUNCTION_MACRO # define LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) -# define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO -# define LOG4CPLUS_HAVE_FUNC_SYMBOL -# endif # if defined (__MINGW32__) # define LOG4CPLUS_WORKING_C_LOCALE # endif From af986a94d7f667672ae28973617fce44390a7d15 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 16 Jan 2013 21:03:58 +0100 Subject: [PATCH 048/226] configure.ac: Detect GCC's -fdiagnostics-show-caret. Detect GCC's -ftrack-macro-expansion when configured with --enable-debugging. --- configure | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++- configure.ac | 6 ++- 2 files changed, 133 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 440c593bc..5b067ffa6 100755 --- a/configure +++ b/configure @@ -5172,7 +5172,71 @@ $as_echo "$ac_cv_path_GREP" >&6; } case $ax_cv_cxx_compiler_vendor in #( gnu|clang) : - if test "x$enable_warnings" = "xyes"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fdiagnostics-show-caret" >&5 +$as_echo_n "checking CXXFLAGS for gcc -fdiagnostics-show-caret... " >&6; } +if ${ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret+:} false; then : + $as_echo_n "(cached) " >&6 +else + ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret="no, unknown" + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + ac_save_CXXFLAGS="$CXXFLAGS" +for ac_arg in "-pedantic -Werror % -fdiagnostics-show-caret" "-pedantic % -fdiagnostics-show-caret %% no, obsolete" # +do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret=`echo $ac_arg | sed -e 's,.*% *,,'`; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done + CXXFLAGS="$ac_save_CXXFLAGS" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret" >&5 +$as_echo "$ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret" >&6; } +var=$ax_cv_cxxflags_gcc_option__fdiagnostics_show_caret +case ".$var" in + .ok|.ok,*) ;; + .|.no|.no,*) ;; + *) + if echo " $CXXFLAGS " | grep " $var " 2>&1 >/dev/null + then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS does contain \$var"; } >&5 + (: CXXFLAGS does contain $var) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS=\"\$CXXFLAGS \$var\""; } >&5 + (: CXXFLAGS="$CXXFLAGS $var") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + CXXFLAGS="$CXXFLAGS $var" + fi + ;; +esac + + if test "x$enable_warnings" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -Wextra" >&5 $as_echo_n "checking CXXFLAGS for gcc -Wextra... " >&6; } if ${ax_cv_cxxflags_gcc_option__Wextra+:} false; then : @@ -6382,6 +6446,70 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__ftrapv" >&5 $as_echo "$ax_cv_cxxflags_gcc_option__ftrapv" >&6; } var=$ax_cv_cxxflags_gcc_option__ftrapv +case ".$var" in + .ok|.ok,*) ;; + .|.no|.no,*) ;; + *) + if echo " $CXXFLAGS " | grep " $var " 2>&1 >/dev/null + then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS does contain \$var"; } >&5 + (: CXXFLAGS does contain $var) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS=\"\$CXXFLAGS \$var\""; } >&5 + (: CXXFLAGS="$CXXFLAGS $var") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + CXXFLAGS="$CXXFLAGS $var" + fi + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -ftrack-macro-expansion" >&5 +$as_echo_n "checking CXXFLAGS for gcc -ftrack-macro-expansion... " >&6; } +if ${ax_cv_cxxflags_gcc_option__ftrack_macro_expansion+:} false; then : + $as_echo_n "(cached) " >&6 +else + ax_cv_cxxflags_gcc_option__ftrack_macro_expansion="no, unknown" + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + ac_save_CXXFLAGS="$CXXFLAGS" +for ac_arg in "-pedantic -Werror % -ftrack-macro-expansion" "-pedantic % -ftrack-macro-expansion %% no, obsolete" # +do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxxflags_gcc_option__ftrack_macro_expansion=`echo $ac_arg | sed -e 's,.*% *,,'`; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done + CXXFLAGS="$ac_save_CXXFLAGS" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__ftrack_macro_expansion" >&5 +$as_echo "$ax_cv_cxxflags_gcc_option__ftrack_macro_expansion" >&6; } +var=$ax_cv_cxxflags_gcc_option__ftrack_macro_expansion case ".$var" in .ok|.ok,*) ;; .|.no|.no,*) ;; diff --git a/configure.ac b/configure.ac index 07ff1a44d..2d1b09b63 100644 --- a/configure.ac +++ b/configure.ac @@ -148,7 +148,8 @@ AS_IF([test "x$enable_warnings" = "xyes"], AS_CASE([$ax_cv_cxx_compiler_vendor], [gnu|clang], - [AS_IF([test "x$enable_warnings" = "xyes"], + [AX_CXXFLAGS_GCC_OPTION([-fdiagnostics-show-caret]) + AS_IF([test "x$enable_warnings" = "xyes"], [AX_CXXFLAGS_GCC_OPTION([-Wextra]) dnl The -ansi switch sets __STRICT_ANSI__ which disables some dnl useful function declarations in MinGW and Cygwin headers. @@ -187,7 +188,8 @@ AS_CASE([$ax_cv_cxx_compiler_vendor], AX_CXXFLAGS_GCC_OPTION([-fstack-protector])]) dnl -Wstack-protector results into not too interesting warnings. dnl AX_CXXFLAGS_GCC_OPTION([-Wstack-protector]) - AX_CXXFLAGS_GCC_OPTION([-ftrapv])], + AX_CXXFLAGS_GCC_OPTION([-ftrapv]) + AX_CXXFLAGS_GCC_OPTION([-ftrack-macro-expansion])], [AC_REQUIRE([AC_PROG_GREP]) AS_IF([AS_ECHO_N(["$CXXFLAGS"]) dnl | $GREP -e ['\(^\|[[:space:]]\)-O\([^[:space:]]*\([[:space:]]\|$\)\)'] >/dev/null], From 7c2d45a3aeee00f0c50835d760cca52735db5d03 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 16 Jan 2013 21:13:55 +0100 Subject: [PATCH 049/226] ChangeLog: Update for 1.1.1-RC2. --- ChangeLog | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5c56aa1bf..8b29fe3af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,26 @@ -log4cplus 1.1.1-rc1 +log4cplus 1.1.1-RC2 + +- Allow to disable TLS usage in macros through + LOG4CPLUS_MACRO_DISABLE_TLS preprocessor symbol. + +- Fixed compilation with Clang on Cygwin. + +- Fixed SIGSEGV when built with some MinGW distributions. + +- Fixed build failure when using -march=i386. + +- Implemented thread callback to initialize log4cplus for Visual + Studio builds of static library. + +- Fixed bug #154 - getHostname() failure because of uninitialized + WinSock. + +- Fixed detection of C++11 thread_local keyword. + +- Fixed builds using DevKit-tdm-32-4.5.2-20111229-1559. + + +log4cplus 1.1.1-RC1 - Improved documentation for various classes. From ee35c4e21c15aa9c36d28ff96fe8438e3d20e494 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 16 Jan 2013 21:15:50 +0100 Subject: [PATCH 050/226] log4cplus-1.1.1-2.cygport: Rename from log4cplus-1.1.1-1.cygport. --- cygport/{log4cplus-1.1.1-1.cygport => log4cplus-1.1.1-2.cygport} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cygport/{log4cplus-1.1.1-1.cygport => log4cplus-1.1.1-2.cygport} (100%) diff --git a/cygport/log4cplus-1.1.1-1.cygport b/cygport/log4cplus-1.1.1-2.cygport similarity index 100% rename from cygport/log4cplus-1.1.1-1.cygport rename to cygport/log4cplus-1.1.1-2.cygport From cbe30b87d4029a769a34d0b84965e4f9392595f9 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 18 Jan 2013 11:21:17 +0100 Subject: [PATCH 051/226] win32.h: Fix compilation issues with MinGW32-TDM compiler and run time library. --- include/log4cplus/config/win32.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index cbd833db5..51b840701 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -74,6 +74,8 @@ #define LOG4CPLUS_HAVE__VSNPRINTF #define LOG4CPLUS_HAVE__VSNWPRINTF +#if defined (_MSC_VER) \ + || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3) // MS secure versions of vprintf(). # define LOG4CPLUS_HAVE_VSPRINTF_S # define LOG4CPLUS_HAVE_VSWPRINTF_S @@ -151,6 +153,9 @@ # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS # define LOG4CPLUS_ATTRIBUTE_NORETURN __declspec(noreturn) # endif +# if _MSC_VER >= 1700 +# define LOG4CPLUS_HAVE_CXX11_ATOMICS +# endif #endif #if defined (__GNUC__) @@ -166,8 +171,10 @@ # endif # endif # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) -# define LOG4CPLUS_HAVE___ATOMIC_ADD_FETCH -# define LOG4CPLUS_HAVE___ATOMIC_SUB_FETCH +# if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) +# define LOG4CPLUS_HAVE___ATOMIC_ADD_FETCH +# define LOG4CPLUS_HAVE___ATOMIC_SUB_FETCH +# endif # define LOG4CPLUS_INLINES_ARE_EXPORTED # endif # define LOG4CPLUS_HAVE_FUNCTION_MACRO From 5593fa78e2f89d6105b33189b83624c31fbf92d2 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 18 Jan 2013 12:06:07 +0100 Subject: [PATCH 052/226] src/CMakeLists.txt: Define MINGW_HAS_SECURE_API=1 to get *_s() functions declarations. lockfile.cxx: Check for defined _tsopen_s and _tsopen before using them. --- src/CMakeLists.txt | 3 +++ src/lockfile.cxx | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f70a05a6..9f4f5bc06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -68,6 +68,9 @@ endif () if (UNICODE) add_definitions (-DUNICODE -D_UNICODE -UMBCS -U_MBCS) endif (UNICODE) +if (WIN32) + add_definitions (-DMINGW_HAS_SECURE_API=1) +endif (WIN32) add_library (${log4cplus} ${log4cplus_sources}) diff --git a/src/lockfile.cxx b/src/lockfile.cxx index 2db103dac..0235ef41b 100644 --- a/src/lockfile.cxx +++ b/src/lockfile.cxx @@ -172,11 +172,11 @@ LockFile::open (int open_flags) const LogLog & loglog = getLogLog (); #if defined (_WIN32) -# if defined (LOG4CPLUS_HAVE__TSOPEN_S) +# if defined (LOG4CPLUS_HAVE__TSOPEN_S) && defined (_tsopen_s) errno_t eno = _tsopen_s (&data->fd, lock_file_name.c_str (), open_flags, OPEN_SHFLAGS, OPEN_MODE); if (eno != 0) -# elif defined (LOG4CPLUS_HAVE__TSOPEN) +# elif defined (LOG4CPLUS_HAVE__TSOPEN) && defined (_tsopen) data->fd = _tsopen (lock_file_name.c_str (), open_flags, OPEN_SHFLAGS, OPEN_MODE); if (data->fd == -1) From 211ccfb535918017393732a8b73063763d905bfd Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 23 Jan 2013 18:45:49 +0100 Subject: [PATCH 053/226] Update for 1.1.1-RC3. --- ChangeLog | 7 +++++++ ...log4cplus-1.1.1-2.cygport => log4cplus-1.1.1-3.cygport} | 0 2 files changed, 7 insertions(+) rename cygport/{log4cplus-1.1.1-2.cygport => log4cplus-1.1.1-3.cygport} (100%) diff --git a/ChangeLog b/ChangeLog index 8b29fe3af..12ed03952 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +log4cplus 1.1.1-RC3 + +- Fixed another MinGW related build failure. + +- Fixed mismatched #if/#endif in Windows builds. + + log4cplus 1.1.1-RC2 - Allow to disable TLS usage in macros through diff --git a/cygport/log4cplus-1.1.1-2.cygport b/cygport/log4cplus-1.1.1-3.cygport similarity index 100% rename from cygport/log4cplus-1.1.1-2.cygport rename to cygport/log4cplus-1.1.1-3.cygport From 003129575ce065c7a3a8740b6745be4c0dc21e67 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 25 Jan 2013 23:48:09 +0100 Subject: [PATCH 054/226] Fix bug #156 - truncated messages when using printf style interface. --- include/log4cplus/helpers/snprintf.h | 5 +- src/clogger.cxx | 34 +++++++---- src/snprintf.cxx | 86 ++++++++++++++-------------- 3 files changed, 69 insertions(+), 56 deletions(-) diff --git a/include/log4cplus/helpers/snprintf.h b/include/log4cplus/helpers/snprintf.h index be8bd8159..cce62a8a2 100644 --- a/include/log4cplus/helpers/snprintf.h +++ b/include/log4cplus/helpers/snprintf.h @@ -46,8 +46,9 @@ class LOG4CPLUS_EXPORT snprintf_buf tchar const * print (tchar const * fmt, ...) LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 3); - tchar const * print_va_list (tchar const * fmt, std::va_list) - LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 0); + + int print_va_list (tchar const * & str, tchar const * fmt, std::va_list) + LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 0); private: std::vector buf; diff --git a/src/clogger.cxx b/src/clogger.cxx index f8578ffad..bd6ee73d7 100644 --- a/src/clogger.cxx +++ b/src/clogger.cxx @@ -145,11 +145,18 @@ log4cplus_logger_log(const log4cplus_char_t *name, loglevel_t ll, if( logger.isEnabledFor(ll) ) { - std::va_list ap; - va_start(ap, msgfmt); + const tchar * msg = 0; snprintf_buf buf; - const tchar * msg = buf.print_va_list(msgfmt, ap); - va_end(ap); + std::va_list ap; + + do + { + va_start(ap, msgfmt); + retval = buf.print_va_list(msg, msgfmt, ap); + va_end(ap); + } + while (retval == -1); + logger.forcedLog(ll, msg); } @@ -164,19 +171,26 @@ log4cplus_logger_log(const log4cplus_char_t *name, loglevel_t ll, } LOG4CPLUS_EXPORT int -log4cplus_logger_force_log(const log4cplus_char_t *name, loglevel_t ll, const log4cplus_char_t *msgfmt, ...) +log4cplus_logger_force_log(const log4cplus_char_t *name, loglevel_t ll, + const log4cplus_char_t *msgfmt, ...) { int retval = -1; try { Logger logger = name ? Logger::getInstance(name) : Logger::getRoot(); - - std::va_list ap; - va_start(ap, msgfmt); + const tchar * msg = 0; snprintf_buf buf; - const tchar * msg = buf.print_va_list(msgfmt, ap); - va_end(ap); + std::va_list ap; + + do + { + va_start(ap, msgfmt); + retval = buf.print_va_list(msg, msgfmt, ap); + va_end(ap); + } + while (retval == -1); + logger.forcedLog(ll, msg); retval = 0; diff --git a/src/snprintf.cxx b/src/snprintf.cxx index 96b2d988a..6aa9e4067 100644 --- a/src/snprintf.cxx +++ b/src/snprintf.cxx @@ -1,15 +1,15 @@ // Copyright (C) 2010, Vaclav Haisman. All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. -// +// // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -107,7 +107,7 @@ vstprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, if (ret >= 0) assert (static_cast(ret) <= dest_size); - + return ret; } @@ -152,7 +152,7 @@ vsntprintf (tchar * dest, std::size_t dest_size, tchar const * fmt, # error "None of vsnprintf_s, _vsnprintf_s, vsnprintf or _vsnprintf is available." # endif #endif - + return ret; } #endif @@ -171,16 +171,25 @@ snprintf_buf::print (tchar const * fmt, ...) { assert (fmt); + tchar const * str = 0; + int ret = 0; std::va_list args; - va_start (args, fmt); - tchar const * ret = print_va_list (fmt, args); - va_end (args); - return ret; + + do + { + va_start (args, fmt); + ret = print_va_list (str, fmt, args); + va_end (args); + } + while (ret == -1); + + return str; } -tchar const * -snprintf_buf::print_va_list(tchar const * fmt, std::va_list args) +int +snprintf_buf::print_va_list (tchar const * & str, tchar const * fmt, + std::va_list args) { int printed; std::size_t const fmt_len = std::char_traits::length (fmt); @@ -195,56 +204,45 @@ snprintf_buf::print_va_list(tchar const * fmt, std::va_list args) { fnull = std::fopen (NULL_FILE, "wb"); if (! fnull) - { LogLog::getLogLog ()->error ( - LOG4CPLUS_TEXT ("Could not open NULL_FILE.")); - buf.clear (); - buf.push_back (0); - return &buf[0]; - } + LOG4CPLUS_TEXT ("Could not open NULL_FILE."), true); } - + printed = vftprintf (fnull, fmt, args); if (printed == -1) - { LogLog::getLogLog ()->error ( - LOG4CPLUS_TEXT ("Error printing into NULL_FILE.")); - buf.clear (); - buf.push_back (0); - return &buf[0]; - } + LOG4CPLUS_TEXT ("Error printing into NULL_FILE."), true); buf.resize (printed + 1); int sprinted = vstprintf (&buf[0], buf.size (), fmt, args); - if (sprinted == -1) - { + if (sprinted == -1 || sprinted >= buf.size ()) LogLog::getLogLog ()->error ( - LOG4CPLUS_TEXT ("Error printing into string.")); - buf.clear (); - buf.push_back (0); - return &buf[0]; - } + LOG4CPLUS_TEXT ("Error printing into string."), true); + assert (printed == sprinted); - + buf[sprinted] = 0; #else - do + printed = vsntprintf (&buf[0], buf_size - 1, fmt, args); + if (printed == -1) + { + buf_size *= 2; + buf.resize (buf_size); + } + else if (printed >= static_cast(buf_size)) { - printed = vsntprintf (&buf[0], buf_size - 1, fmt, args); - if (printed == -1) - { - buf_size *= 2; - buf.resize (buf_size); - } - else - buf[printed] = 0; + buf_size = printed + 1; + buf.resize (buf_size); + printed = -1; } - while (printed == -1); + else + buf[printed] = 0; #endif - return &buf[0]; + str = &buf[0]; + return printed; } From 507f52adba9c6bbbbd03bce76c33a13f132f6b1f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 26 Jan 2013 20:50:29 +0100 Subject: [PATCH 055/226] snprintf.cxx: Fix another truncated messages issue. Bug #156. --- src/snprintf.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/snprintf.cxx b/src/snprintf.cxx index 6aa9e4067..e9e454b63 100644 --- a/src/snprintf.cxx +++ b/src/snprintf.cxx @@ -196,7 +196,7 @@ snprintf_buf::print_va_list (tchar const * & str, tchar const * fmt, std::size_t buf_size = buf.size (); std::size_t const output_estimate = fmt_len + fmt_len / 2 + 1; if (output_estimate > buf_size) - buf.resize (output_estimate); + buf.resize (buf_size = output_estimate); #if defined (LOG4CPLUS_USE_POOR_MANS_SNPRINTF) std::FILE * & fnull = internal::get_ptd ()->fnull; @@ -230,9 +230,9 @@ snprintf_buf::print_va_list (tchar const * & str, tchar const * fmt, buf_size *= 2; buf.resize (buf_size); } - else if (printed >= static_cast(buf_size)) + else if (printed >= static_cast(buf_size - 1)) { - buf_size = printed + 1; + buf_size = printed + 2; buf.resize (buf_size); printed = -1; } From 48385fd7f7565210111b5d54443a2e91503623b8 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 27 Jan 2013 23:47:59 +0100 Subject: [PATCH 056/226] Fix single-threaded builds. --- include/log4cplus/socketappender.h | 2 ++ src/socketappender.cxx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/log4cplus/socketappender.h b/include/log4cplus/socketappender.h index aa75c84dd..5297cd79c 100644 --- a/include/log4cplus/socketappender.h +++ b/include/log4cplus/socketappender.h @@ -99,6 +99,8 @@ namespace log4cplus * */ class LOG4CPLUS_EXPORT SocketAppender : public Appender { +#if ! defined (LOG4CPLUS_SINGLE_THREADED) +#endif public: // Ctors SocketAppender(const log4cplus::tstring& host, unsigned short port, diff --git a/src/socketappender.cxx b/src/socketappender.cxx index cd06440cb..f8486bf0b 100644 --- a/src/socketappender.cxx +++ b/src/socketappender.cxx @@ -248,6 +248,8 @@ SocketAppender::append(const spi::InternalLoggingEvent& event) } +#if ! defined (LOG4CPLUS_SINGLE_THREADED) +#endif ///////////////////////////////////////////////////////////////////////////// // namespace helpers methods ///////////////////////////////////////////////////////////////////////////// From 62e8e65b57284fac084609d2d725259f2f363174 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 28 Jan 2013 00:07:32 +0100 Subject: [PATCH 057/226] socketbuffer.cxx: Include sys/types.h. --- src/socketbuffer.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/socketbuffer.cxx b/src/socketbuffer.cxx index fe8f61ec2..5a04d4c01 100644 --- a/src/socketbuffer.cxx +++ b/src/socketbuffer.cxx @@ -23,6 +23,10 @@ #include #include +#if defined (LOG4CPLUS_HAVE_SYS_TYPES_H) +#include +#endif + #if !defined(_WIN32) # include #else From d31a2ed1629dcd7b1ffd6593302615225cac0061 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Feb 2013 21:22:54 +0100 Subject: [PATCH 058/226] main.cxx: Fix ndc_text to actually test NDC. --- tests/ndc_test/main.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/ndc_test/main.cxx b/tests/ndc_test/main.cxx index 4608917ef..01d80027d 100644 --- a/tests/ndc_test/main.cxx +++ b/tests/ndc_test/main.cxx @@ -19,7 +19,10 @@ main() try { SharedObjectPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); - append_1->setLayout( std::auto_ptr(new log4cplus::TTCCLayout()) ); + append_1->setLayout( + std::auto_ptr( + new log4cplus::PatternLayout( + LOG4CPLUS_TEXT ("%-5p %c <%x> - %m%n")))); Logger::getRoot().addAppender(append_1); Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("test")); From 941e6bd8042c6053cea4f40ab5fa21eeee261b05 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Feb 2013 21:27:06 +0100 Subject: [PATCH 059/226] Update copyright headers with year 2013. --- include/log4cplus/appender.h | 2 +- include/log4cplus/asyncappender.h | 2 +- include/log4cplus/boost/deviceappender.hxx | 2 +- include/log4cplus/clfsappender.h | 2 +- include/log4cplus/clogger.h | 2 +- include/log4cplus/config.hxx | 2 +- include/log4cplus/config/macosx.h | 2 +- include/log4cplus/config/win32.h | 2 +- include/log4cplus/config/windowsh-inc.h | 2 +- include/log4cplus/configurator.h | 2 +- include/log4cplus/consoleappender.h | 2 +- include/log4cplus/fileappender.h | 2 +- include/log4cplus/fstreams.h | 2 +- include/log4cplus/helpers/appenderattachableimpl.h | 2 +- include/log4cplus/helpers/fileinfo.h | 2 +- include/log4cplus/helpers/lockfile.h | 2 +- include/log4cplus/helpers/loglog.h | 2 +- include/log4cplus/helpers/logloguser.h | 2 +- include/log4cplus/helpers/pointer.h | 2 +- include/log4cplus/helpers/property.h | 2 +- include/log4cplus/helpers/queue.h | 2 +- include/log4cplus/helpers/sleep.h | 2 +- include/log4cplus/helpers/snprintf.h | 2 +- include/log4cplus/helpers/socket.h | 2 +- include/log4cplus/helpers/socketbuffer.h | 2 +- include/log4cplus/helpers/stringhelper.h | 2 +- include/log4cplus/helpers/thread-config.h | 2 +- include/log4cplus/helpers/timehelper.h | 2 +- include/log4cplus/hierarchy.h | 2 +- include/log4cplus/hierarchylocker.h | 2 +- include/log4cplus/internal/cygwin-win32.h | 2 +- include/log4cplus/internal/env.h | 2 +- include/log4cplus/internal/internal.h | 2 +- include/log4cplus/internal/socket.h | 2 +- include/log4cplus/layout.h | 2 +- include/log4cplus/log4judpappender.h | 2 +- include/log4cplus/logger.h | 2 +- include/log4cplus/loggingmacros.h | 2 +- include/log4cplus/loglevel.h | 2 +- include/log4cplus/mdc.h | 2 +- include/log4cplus/ndc.h | 2 +- include/log4cplus/nteventlogappender.h | 2 +- include/log4cplus/nullappender.h | 2 +- include/log4cplus/qt4debugappender.h | 2 +- include/log4cplus/socketappender.h | 2 +- include/log4cplus/spi/appenderattachable.h | 2 +- include/log4cplus/spi/factory.h | 2 +- include/log4cplus/spi/filter.h | 2 +- include/log4cplus/spi/loggerfactory.h | 2 +- include/log4cplus/spi/loggerimpl.h | 2 +- include/log4cplus/spi/loggingevent.h | 2 +- include/log4cplus/spi/objectregistry.h | 2 +- include/log4cplus/spi/rootlogger.h | 2 +- include/log4cplus/streams.h | 2 +- include/log4cplus/syslogappender.h | 2 +- include/log4cplus/tchar.h | 2 +- include/log4cplus/thread/impl/syncprims-impl.h | 2 +- include/log4cplus/thread/impl/syncprims-pmsm.h | 2 +- include/log4cplus/thread/impl/syncprims-pthreads.h | 2 +- include/log4cplus/thread/impl/syncprims-win32.h | 2 +- include/log4cplus/thread/impl/threads-impl.h | 2 +- include/log4cplus/thread/impl/tls.h | 2 +- include/log4cplus/thread/syncprims-pub-impl.h | 2 +- include/log4cplus/thread/syncprims.h | 2 +- include/log4cplus/thread/threads.h | 2 +- include/log4cplus/tracelogger.h | 2 +- include/log4cplus/tstring.h | 2 +- include/log4cplus/version.h | 2 +- include/log4cplus/win32consoleappender.h | 2 +- include/log4cplus/win32debugappender.h | 2 +- loggingserver/loggingserver.cxx | 2 +- qt4debugappender/qt4debugappender.cxx | 2 +- src/appender.cxx | 2 +- src/appenderattachableimpl.cxx | 2 +- src/asyncappender.cxx | 2 +- src/clfsappender.cxx | 2 +- src/clogger.cxx | 2 +- src/configurator.cxx | 2 +- src/consoleappender.cxx | 2 +- src/cygwin-win32.cxx | 2 +- src/env.cxx | 2 +- src/factory.cxx | 2 +- src/fileappender.cxx | 2 +- src/fileinfo.cxx | 2 +- src/filter.cxx | 2 +- src/global-init.cxx | 2 +- src/hierarchy.cxx | 2 +- src/hierarchylocker.cxx | 2 +- src/layout.cxx | 2 +- src/lockfile.cxx | 2 +- src/log4judpappender.cxx | 2 +- src/logger.cxx | 2 +- src/loggerimpl.cxx | 2 +- src/loggingevent.cxx | 2 +- src/loggingmacros.cxx | 2 +- src/loglevel.cxx | 2 +- src/loglog.cxx | 2 +- src/logloguser.cxx | 2 +- src/mdc.cxx | 2 +- src/ndc.cxx | 2 +- src/nteventlogappender.cxx | 2 +- src/nullappender.cxx | 2 +- src/objectregistry.cxx | 2 +- src/patternlayout.cxx | 2 +- src/pointer.cxx | 2 +- src/property.cxx | 2 +- src/queue.cxx | 2 +- src/rootlogger.cxx | 2 +- src/sleep.cxx | 2 +- src/snprintf.cxx | 2 +- src/socket-unix.cxx | 2 +- src/socket-win32.cxx | 2 +- src/socket.cxx | 2 +- src/socketappender.cxx | 2 +- src/socketbuffer.cxx | 2 +- src/stringhelper-clocale.cxx | 2 +- src/stringhelper-cxxlocale.cxx | 2 +- src/stringhelper-iconv.cxx | 2 +- src/stringhelper.cxx | 2 +- src/syncprims.cxx | 2 +- src/syslogappender.cxx | 2 +- src/threads.cxx | 2 +- src/timehelper.cxx | 2 +- src/tls.cxx | 2 +- src/version.cxx | 2 +- src/win32consoleappender.cxx | 2 +- src/win32debugappender.cxx | 2 +- 127 files changed, 127 insertions(+), 127 deletions(-) diff --git a/include/log4cplus/appender.h b/include/log4cplus/appender.h index e09de5c4b..051dcecce 100644 --- a/include/log4cplus/appender.h +++ b/include/log4cplus/appender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/asyncappender.h b/include/log4cplus/asyncappender.h index 641f98843..af9d5e536 100644 --- a/include/log4cplus/asyncappender.h +++ b/include/log4cplus/asyncappender.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/boost/deviceappender.hxx b/include/log4cplus/boost/deviceappender.hxx index b1caba742..e31fc7902 100644 --- a/include/log4cplus/boost/deviceappender.hxx +++ b/include/log4cplus/boost/deviceappender.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/clfsappender.h b/include/log4cplus/clfsappender.h index 29c1d8fa5..ca46b69c2 100644 --- a/include/log4cplus/clfsappender.h +++ b/include/log4cplus/clfsappender.h @@ -5,7 +5,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/clogger.h b/include/log4cplus/clogger.h index aa2eb88d1..a340d1bec 100644 --- a/include/log4cplus/clogger.h +++ b/include/log4cplus/clogger.h @@ -6,7 +6,7 @@ * Author: Jens Rehsack * * - * Copyright 2011 Jens Rehsack & Tad E. Smith + * Copyright 2011-2013 Jens Rehsack & Tad E. Smith * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index 4c508effe..f80be9a88 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/config/macosx.h b/include/log4cplus/config/macosx.h index 2e3065cdc..448090c71 100644 --- a/include/log4cplus/config/macosx.h +++ b/include/log4cplus/config/macosx.h @@ -5,7 +5,7 @@ // Author: Christopher R. Bailey // // -// Copyright 2003-2010 Christopher R. Bailey +// Copyright 2003-2013 Christopher R. Bailey // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index 51b840701..c0d2f512a 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/config/windowsh-inc.h b/include/log4cplus/config/windowsh-inc.h index 86dc8647d..b71a8e105 100644 --- a/include/log4cplus/config/windowsh-inc.h +++ b/include/log4cplus/config/windowsh-inc.h @@ -5,7 +5,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2010-2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/configurator.h b/include/log4cplus/configurator.h index b8b222b9f..5cbb96f11 100644 --- a/include/log4cplus/configurator.h +++ b/include/log4cplus/configurator.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/consoleappender.h b/include/log4cplus/consoleappender.h index 404512b43..e31bdad5b 100644 --- a/include/log4cplus/consoleappender.h +++ b/include/log4cplus/consoleappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2009 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/fileappender.h b/include/log4cplus/fileappender.h index b1a7e209b..787b92ea8 100644 --- a/include/log4cplus/fileappender.h +++ b/include/log4cplus/fileappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/fstreams.h b/include/log4cplus/fstreams.h index 99e3a6602..d0c0831d5 100644 --- a/include/log4cplus/fstreams.h +++ b/include/log4cplus/fstreams.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2011 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/appenderattachableimpl.h b/include/log4cplus/helpers/appenderattachableimpl.h index 1f13ea831..4cfaf3f21 100644 --- a/include/log4cplus/helpers/appenderattachableimpl.h +++ b/include/log4cplus/helpers/appenderattachableimpl.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/fileinfo.h b/include/log4cplus/helpers/fileinfo.h index 7daa25d55..725c940d8 100644 --- a/include/log4cplus/helpers/fileinfo.h +++ b/include/log4cplus/helpers/fileinfo.h @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/helpers/lockfile.h b/include/log4cplus/helpers/lockfile.h index c2775e909..f451ff82b 100644 --- a/include/log4cplus/helpers/lockfile.h +++ b/include/log4cplus/helpers/lockfile.h @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/helpers/loglog.h b/include/log4cplus/helpers/loglog.h index 3c7a7bc75..336f18fda 100644 --- a/include/log4cplus/helpers/loglog.h +++ b/include/log4cplus/helpers/loglog.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/logloguser.h b/include/log4cplus/helpers/logloguser.h index e8a3ddbf8..11b3f5ed0 100644 --- a/include/log4cplus/helpers/logloguser.h +++ b/include/log4cplus/helpers/logloguser.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/pointer.h b/include/log4cplus/helpers/pointer.h index 20d44d424..0b1b6febb 100644 --- a/include/log4cplus/helpers/pointer.h +++ b/include/log4cplus/helpers/pointer.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/property.h b/include/log4cplus/helpers/property.h index 909a9cd7a..e97c6d4c5 100644 --- a/include/log4cplus/helpers/property.h +++ b/include/log4cplus/helpers/property.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2002-2010 Tad E. Smith +// Copyright 2002-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/queue.h b/include/log4cplus/helpers/queue.h index 2ebd13c3e..eefaf2f0e 100644 --- a/include/log4cplus/helpers/queue.h +++ b/include/log4cplus/helpers/queue.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/helpers/sleep.h b/include/log4cplus/helpers/sleep.h index 36d45592c..f3c56363e 100644 --- a/include/log4cplus/helpers/sleep.h +++ b/include/log4cplus/helpers/sleep.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/snprintf.h b/include/log4cplus/helpers/snprintf.h index cce62a8a2..f0dc9490c 100644 --- a/include/log4cplus/helpers/snprintf.h +++ b/include/log4cplus/helpers/snprintf.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010-2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/helpers/socket.h b/include/log4cplus/helpers/socket.h index e0bc9b4f4..ba148ef71 100644 --- a/include/log4cplus/helpers/socket.h +++ b/include/log4cplus/helpers/socket.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/socketbuffer.h b/include/log4cplus/helpers/socketbuffer.h index b1bd0f381..f8b961326 100644 --- a/include/log4cplus/helpers/socketbuffer.h +++ b/include/log4cplus/helpers/socketbuffer.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/stringhelper.h b/include/log4cplus/helpers/stringhelper.h index 0feea1024..30e6ae77f 100644 --- a/include/log4cplus/helpers/stringhelper.h +++ b/include/log4cplus/helpers/stringhelper.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/thread-config.h b/include/log4cplus/helpers/thread-config.h index e9917b98d..4f9e06367 100644 --- a/include/log4cplus/helpers/thread-config.h +++ b/include/log4cplus/helpers/thread-config.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/helpers/timehelper.h b/include/log4cplus/helpers/timehelper.h index cbac5786d..06b3281b7 100644 --- a/include/log4cplus/helpers/timehelper.h +++ b/include/log4cplus/helpers/timehelper.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/hierarchy.h b/include/log4cplus/hierarchy.h index 8f473c4d1..2c023a961 100644 --- a/include/log4cplus/hierarchy.h +++ b/include/log4cplus/hierarchy.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/hierarchylocker.h b/include/log4cplus/hierarchylocker.h index 1bad2d150..ed2766470 100644 --- a/include/log4cplus/hierarchylocker.h +++ b/include/log4cplus/hierarchylocker.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/internal/cygwin-win32.h b/include/log4cplus/internal/cygwin-win32.h index 4e9b57b1d..ab5a74404 100644 --- a/include/log4cplus/internal/cygwin-win32.h +++ b/include/log4cplus/internal/cygwin-win32.h @@ -4,7 +4,7 @@ // Created: 7/2011 // Author: Vaclav Zeman // -// Copyright (C) 2011, Vaclav Zeman. All rights reserved. +// Copyright (C) 2011-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/internal/env.h b/include/log4cplus/internal/env.h index 08b3e4a17..8c9a36445 100644 --- a/include/log4cplus/internal/env.h +++ b/include/log4cplus/internal/env.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/internal/internal.h b/include/log4cplus/internal/internal.h index 80de4817c..97a8aabe0 100644 --- a/include/log4cplus/internal/internal.h +++ b/include/log4cplus/internal/internal.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/internal/socket.h b/include/log4cplus/internal/socket.h index 6ac7dc6c4..e1402e3a2 100644 --- a/include/log4cplus/internal/socket.h +++ b/include/log4cplus/internal/socket.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/layout.h b/include/log4cplus/layout.h index beac3d8b4..7a2100038 100644 --- a/include/log4cplus/layout.h +++ b/include/log4cplus/layout.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/log4judpappender.h b/include/log4cplus/log4judpappender.h index 0783af6bc..51302c723 100644 --- a/include/log4cplus/log4judpappender.h +++ b/include/log4cplus/log4judpappender.h @@ -5,7 +5,7 @@ // Author: Siva Chandran P // // -// Copyright 2012 Siva Chandran P +// Copyright 2012-2013 Siva Chandran P // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/logger.h b/include/log4cplus/logger.h index 524912e71..d0397612b 100644 --- a/include/log4cplus/logger.h +++ b/include/log4cplus/logger.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/loggingmacros.h b/include/log4cplus/loggingmacros.h index 8fe55993c..4177388fe 100644 --- a/include/log4cplus/loggingmacros.h +++ b/include/log4cplus/loggingmacros.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/loglevel.h b/include/log4cplus/loglevel.h index 7d7d83b7a..d7e0db2cb 100644 --- a/include/log4cplus/loglevel.h +++ b/include/log4cplus/loglevel.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/mdc.h b/include/log4cplus/mdc.h index f4b009ea6..ff23774d5 100644 --- a/include/log4cplus/mdc.h +++ b/include/log4cplus/mdc.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/ndc.h b/include/log4cplus/ndc.h index 8acf49d09..26e1b5918 100644 --- a/include/log4cplus/ndc.h +++ b/include/log4cplus/ndc.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/nteventlogappender.h b/include/log4cplus/nteventlogappender.h index 99635ff4e..9ea3a8974 100644 --- a/include/log4cplus/nteventlogappender.h +++ b/include/log4cplus/nteventlogappender.h @@ -4,7 +4,7 @@ // Created: 4/2003 // Author: Michael CATANZARITI // -// Copyright 2003-2010 Michael CATANZARITI +// Copyright 2003-2013 Michael CATANZARITI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/nullappender.h b/include/log4cplus/nullappender.h index 84598527d..15456fc4b 100644 --- a/include/log4cplus/nullappender.h +++ b/include/log4cplus/nullappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/qt4debugappender.h b/include/log4cplus/qt4debugappender.h index ddb8d2b6c..8908a6ed9 100644 --- a/include/log4cplus/qt4debugappender.h +++ b/include/log4cplus/qt4debugappender.h @@ -5,7 +5,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/socketappender.h b/include/log4cplus/socketappender.h index 5297cd79c..79c7fa43c 100644 --- a/include/log4cplus/socketappender.h +++ b/include/log4cplus/socketappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/appenderattachable.h b/include/log4cplus/spi/appenderattachable.h index 0f527ed26..986bf9b4d 100644 --- a/include/log4cplus/spi/appenderattachable.h +++ b/include/log4cplus/spi/appenderattachable.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/factory.h b/include/log4cplus/spi/factory.h index c449ee9d7..709edf55e 100644 --- a/include/log4cplus/spi/factory.h +++ b/include/log4cplus/spi/factory.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2002-2010 Tad E. Smith +// Copyright 2002-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/filter.h b/include/log4cplus/spi/filter.h index 6e38a8090..1febd23fb 100644 --- a/include/log4cplus/spi/filter.h +++ b/include/log4cplus/spi/filter.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 1999-2010 Tad E. Smith +// Copyright 1999-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/loggerfactory.h b/include/log4cplus/spi/loggerfactory.h index a417db64f..ad735f1d6 100644 --- a/include/log4cplus/spi/loggerfactory.h +++ b/include/log4cplus/spi/loggerfactory.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/loggerimpl.h b/include/log4cplus/spi/loggerimpl.h index d1f287bf6..c7e46337b 100644 --- a/include/log4cplus/spi/loggerimpl.h +++ b/include/log4cplus/spi/loggerimpl.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/loggingevent.h b/include/log4cplus/spi/loggingevent.h index 44043103a..e57bd6e14 100644 --- a/include/log4cplus/spi/loggingevent.h +++ b/include/log4cplus/spi/loggingevent.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/objectregistry.h b/include/log4cplus/spi/objectregistry.h index 5adfa031f..d05947422 100644 --- a/include/log4cplus/spi/objectregistry.h +++ b/include/log4cplus/spi/objectregistry.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/spi/rootlogger.h b/include/log4cplus/spi/rootlogger.h index ac73326b1..6c466c261 100644 --- a/include/log4cplus/spi/rootlogger.h +++ b/include/log4cplus/spi/rootlogger.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/streams.h b/include/log4cplus/streams.h index cc5200805..df33c4d0d 100644 --- a/include/log4cplus/streams.h +++ b/include/log4cplus/streams.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/syslogappender.h b/include/log4cplus/syslogappender.h index f33bc7aec..60e06bd5c 100644 --- a/include/log4cplus/syslogappender.h +++ b/include/log4cplus/syslogappender.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/tchar.h b/include/log4cplus/tchar.h index f433b58f4..217fc76d8 100644 --- a/include/log4cplus/tchar.h +++ b/include/log4cplus/tchar.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/impl/syncprims-impl.h b/include/log4cplus/thread/impl/syncprims-impl.h index ba608e3dc..6a2df916b 100644 --- a/include/log4cplus/thread/impl/syncprims-impl.h +++ b/include/log4cplus/thread/impl/syncprims-impl.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/impl/syncprims-pmsm.h b/include/log4cplus/thread/impl/syncprims-pmsm.h index f5cd3ef71..34b315db5 100644 --- a/include/log4cplus/thread/impl/syncprims-pmsm.h +++ b/include/log4cplus/thread/impl/syncprims-pmsm.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/impl/syncprims-pthreads.h b/include/log4cplus/thread/impl/syncprims-pthreads.h index 851d7e0ed..0d3167c8b 100644 --- a/include/log4cplus/thread/impl/syncprims-pthreads.h +++ b/include/log4cplus/thread/impl/syncprims-pthreads.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/impl/syncprims-win32.h b/include/log4cplus/thread/impl/syncprims-win32.h index f16837bcc..35cc42303 100644 --- a/include/log4cplus/thread/impl/syncprims-win32.h +++ b/include/log4cplus/thread/impl/syncprims-win32.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/impl/threads-impl.h b/include/log4cplus/thread/impl/threads-impl.h index 3389e9414..88b40b24a 100644 --- a/include/log4cplus/thread/impl/threads-impl.h +++ b/include/log4cplus/thread/impl/threads-impl.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/thread/impl/tls.h b/include/log4cplus/thread/impl/tls.h index d471a56a2..5a390aeb7 100644 --- a/include/log4cplus/thread/impl/tls.h +++ b/include/log4cplus/thread/impl/tls.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/syncprims-pub-impl.h b/include/log4cplus/thread/syncprims-pub-impl.h index e82d64174..dd53bce0b 100644 --- a/include/log4cplus/thread/syncprims-pub-impl.h +++ b/include/log4cplus/thread/syncprims-pub-impl.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/syncprims.h b/include/log4cplus/thread/syncprims.h index 6e52dc206..d0438458b 100644 --- a/include/log4cplus/thread/syncprims.h +++ b/include/log4cplus/thread/syncprims.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/thread/threads.h b/include/log4cplus/thread/threads.h index 42fa48687..dbd152c5f 100644 --- a/include/log4cplus/thread/threads.h +++ b/include/log4cplus/thread/threads.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/tracelogger.h b/include/log4cplus/tracelogger.h index d0d5b4c1d..a056ccdc5 100644 --- a/include/log4cplus/tracelogger.h +++ b/include/log4cplus/tracelogger.h @@ -5,7 +5,7 @@ // Author: Vaclav Haisman // // -// Copyright 2009-2010 Tad E. Smith +// Copyright 2009-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/tstring.h b/include/log4cplus/tstring.h index dd2833878..587aaa15e 100644 --- a/include/log4cplus/tstring.h +++ b/include/log4cplus/tstring.h @@ -5,7 +5,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/include/log4cplus/version.h b/include/log4cplus/version.h index 242eb159a..a5485ddab 100644 --- a/include/log4cplus/version.h +++ b/include/log4cplus/version.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/win32consoleappender.h b/include/log4cplus/win32consoleappender.h index ebbfebe5b..c98eb5553 100644 --- a/include/log4cplus/win32consoleappender.h +++ b/include/log4cplus/win32consoleappender.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/include/log4cplus/win32debugappender.h b/include/log4cplus/win32debugappender.h index ba6667abf..50059d475 100644 --- a/include/log4cplus/win32debugappender.h +++ b/include/log4cplus/win32debugappender.h @@ -5,7 +5,7 @@ // Author: Eduardo Francos, Odalio SARL // // -// Copyright 2003-2010 Odalio SARL +// Copyright 2003-2013 Odalio SARL // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/loggingserver/loggingserver.cxx b/loggingserver/loggingserver.cxx index 8d8dc3c93..31c0d8aae 100644 --- a/loggingserver/loggingserver.cxx +++ b/loggingserver/loggingserver.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/qt4debugappender/qt4debugappender.cxx b/qt4debugappender/qt4debugappender.cxx index ac03f41e7..e9f6304af 100644 --- a/qt4debugappender/qt4debugappender.cxx +++ b/qt4debugappender/qt4debugappender.cxx @@ -4,7 +4,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/appender.cxx b/src/appender.cxx index 1c88f916c..625729d7c 100644 --- a/src/appender.cxx +++ b/src/appender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/appenderattachableimpl.cxx b/src/appenderattachableimpl.cxx index 7eb6953a5..8ec908411 100644 --- a/src/appenderattachableimpl.cxx +++ b/src/appenderattachableimpl.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/asyncappender.cxx b/src/asyncappender.cxx index c30c5eb61..eddf0f0ec 100644 --- a/src/asyncappender.cxx +++ b/src/asyncappender.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/clfsappender.cxx b/src/clfsappender.cxx index 06a406263..a17c353c7 100644 --- a/src/clfsappender.cxx +++ b/src/clfsappender.cxx @@ -4,7 +4,7 @@ // Author: Vaclav Zeman // // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/clogger.cxx b/src/clogger.cxx index bd6ee73d7..6fe7e3838 100644 --- a/src/clogger.cxx +++ b/src/clogger.cxx @@ -4,7 +4,7 @@ // Author: Jens Rehsack // // -// Copyright 2011 Jens Rehsack & Tad E. Smith +// Copyright 2011-2013 Jens Rehsack & Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/configurator.cxx b/src/configurator.cxx index 5fbab28f3..b57501abc 100644 --- a/src/configurator.cxx +++ b/src/configurator.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/consoleappender.cxx b/src/consoleappender.cxx index 021d3d984..ff8b01c3e 100644 --- a/src/consoleappender.cxx +++ b/src/consoleappender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/cygwin-win32.cxx b/src/cygwin-win32.cxx index 766dc520b..c961afe7c 100644 --- a/src/cygwin-win32.cxx +++ b/src/cygwin-win32.cxx @@ -3,7 +3,7 @@ // Created: 7/2011 // Author: Vaclav Zeman // -// Copyright (C) 2011, Vaclav Zeman. All rights reserved. +// Copyright (C) 2011-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/env.cxx b/src/env.cxx index 43186449c..89cda1822 100644 --- a/src/env.cxx +++ b/src/env.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/factory.cxx b/src/factory.cxx index dae83219a..b11b4670b 100644 --- a/src/factory.cxx +++ b/src/factory.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2002-2010 Tad E. Smith +// Copyright 2002-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/fileappender.cxx b/src/fileappender.cxx index 04928d67c..0d8b4c680 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/fileinfo.cxx b/src/fileinfo.cxx index 5b0405ba8..36f57e23f 100644 --- a/src/fileinfo.cxx +++ b/src/fileinfo.cxx @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/filter.cxx b/src/filter.cxx index a2c23878f..55de56c3a 100644 --- a/src/filter.cxx +++ b/src/filter.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/global-init.cxx b/src/global-init.cxx index 90fe75d63..0108815e1 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/hierarchy.cxx b/src/hierarchy.cxx index 07020ef73..538705ee3 100644 --- a/src/hierarchy.cxx +++ b/src/hierarchy.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/hierarchylocker.cxx b/src/hierarchylocker.cxx index df31794ce..b7e77a79a 100644 --- a/src/hierarchylocker.cxx +++ b/src/hierarchylocker.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/layout.cxx b/src/layout.cxx index 61331e1b2..de801bd1b 100644 --- a/src/layout.cxx +++ b/src/layout.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/lockfile.cxx b/src/lockfile.cxx index 0235ef41b..f39ab01dc 100644 --- a/src/lockfile.cxx +++ b/src/lockfile.cxx @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2012, Vaclav Zeman. All rights reserved. +// Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/log4judpappender.cxx b/src/log4judpappender.cxx index f33a04b34..30b09cd17 100644 --- a/src/log4judpappender.cxx +++ b/src/log4judpappender.cxx @@ -4,7 +4,7 @@ // Author: Siva Chandran P // // -// Copyright 2012 Siva Chandran P +// Copyright 2012-2013 Siva Chandran P // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/logger.cxx b/src/logger.cxx index 2d490437c..a0502327f 100644 --- a/src/logger.cxx +++ b/src/logger.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/loggerimpl.cxx b/src/loggerimpl.cxx index 08ba0aaca..ea6455b6f 100644 --- a/src/loggerimpl.cxx +++ b/src/loggerimpl.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/loggingevent.cxx b/src/loggingevent.cxx index f0c951bde..5279a1e87 100644 --- a/src/loggingevent.cxx +++ b/src/loggingevent.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/loggingmacros.cxx b/src/loggingmacros.cxx index 3005ed8d3..8025e516c 100644 --- a/src/loggingmacros.cxx +++ b/src/loggingmacros.cxx @@ -4,7 +4,7 @@ // Author: Vaclav Haisman // // -// Copyright 2010 Vaclav Haisman +// Copyright 2010-2013 Vaclav Haisman // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/loglevel.cxx b/src/loglevel.cxx index 4481f792a..6b2e0dcaf 100644 --- a/src/loglevel.cxx +++ b/src/loglevel.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/loglog.cxx b/src/loglog.cxx index 0e174e10c..7fb7b9f51 100644 --- a/src/loglog.cxx +++ b/src/loglog.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/logloguser.cxx b/src/logloguser.cxx index 2804c22b7..e97052fef 100644 --- a/src/logloguser.cxx +++ b/src/logloguser.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/mdc.cxx b/src/mdc.cxx index 6d83ed649..faec501ff 100644 --- a/src/mdc.cxx +++ b/src/mdc.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/ndc.cxx b/src/ndc.cxx index e17285593..a8fdfe88d 100644 --- a/src/ndc.cxx +++ b/src/ndc.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/nteventlogappender.cxx b/src/nteventlogappender.cxx index cc2d19a5e..eb71270e8 100644 --- a/src/nteventlogappender.cxx +++ b/src/nteventlogappender.cxx @@ -3,7 +3,7 @@ // Created: 4/2003 // Author: Michael CATANZARITI // -// Copyright 2003-2010 Michael CATANZARITI +// Copyright 2003-2013 Michael CATANZARITI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/nullappender.cxx b/src/nullappender.cxx index 67111934c..5a6fd05ca 100644 --- a/src/nullappender.cxx +++ b/src/nullappender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/objectregistry.cxx b/src/objectregistry.cxx index edc6c9889..d81c82b51 100644 --- a/src/objectregistry.cxx +++ b/src/objectregistry.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/patternlayout.cxx b/src/patternlayout.cxx index d0d03d7e3..c24d81b04 100644 --- a/src/patternlayout.cxx +++ b/src/patternlayout.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/pointer.cxx b/src/pointer.cxx index a800a8591..da1db3c95 100644 --- a/src/pointer.cxx +++ b/src/pointer.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/property.cxx b/src/property.cxx index 1b0d92eb8..bc594cbd8 100644 --- a/src/property.cxx +++ b/src/property.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2002-2010 Tad E. Smith +// Copyright 2002-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/queue.cxx b/src/queue.cxx index 5630fad5b..a45d365e2 100644 --- a/src/queue.cxx +++ b/src/queue.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/rootlogger.cxx b/src/rootlogger.cxx index ff0122059..799f70c5b 100644 --- a/src/rootlogger.cxx +++ b/src/rootlogger.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/sleep.cxx b/src/sleep.cxx index 901dddcde..50bfc9c96 100644 --- a/src/sleep.cxx +++ b/src/sleep.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/snprintf.cxx b/src/snprintf.cxx index e9e454b63..5c2c477d1 100644 --- a/src/snprintf.cxx +++ b/src/snprintf.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/socket-unix.cxx b/src/socket-unix.cxx index c76c5bbff..4a5d2cdf1 100644 --- a/src/socket-unix.cxx +++ b/src/socket-unix.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index f05eb4001..dc4af1323 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/socket.cxx b/src/socket.cxx index c5e5de783..8b7867935 100644 --- a/src/socket.cxx +++ b/src/socket.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/socketappender.cxx b/src/socketappender.cxx index f8486bf0b..38381faf2 100644 --- a/src/socketappender.cxx +++ b/src/socketappender.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/socketbuffer.cxx b/src/socketbuffer.cxx index 5a04d4c01..297c78d18 100644 --- a/src/socketbuffer.cxx +++ b/src/socketbuffer.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/stringhelper-clocale.cxx b/src/stringhelper-clocale.cxx index 24b58ac3c..f04d195f4 100644 --- a/src/stringhelper-clocale.cxx +++ b/src/stringhelper-clocale.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/stringhelper-cxxlocale.cxx b/src/stringhelper-cxxlocale.cxx index 579a1c54b..c57bff5fc 100644 --- a/src/stringhelper-cxxlocale.cxx +++ b/src/stringhelper-cxxlocale.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/stringhelper-iconv.cxx b/src/stringhelper-iconv.cxx index ddc08ca1d..987c30d26 100644 --- a/src/stringhelper-iconv.cxx +++ b/src/stringhelper-iconv.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/stringhelper.cxx b/src/stringhelper.cxx index 219e957da..a2cf849ed 100644 --- a/src/stringhelper.cxx +++ b/src/stringhelper.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/syncprims.cxx b/src/syncprims.cxx index b81af85da..bd6da2322 100644 --- a/src/syncprims.cxx +++ b/src/syncprims.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/syslogappender.cxx b/src/syslogappender.cxx index 6343df53c..6b8cdc67e 100644 --- a/src/syslogappender.cxx +++ b/src/syslogappender.cxx @@ -3,7 +3,7 @@ // Created: 6/2001 // Author: Tad E. Smith // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/threads.cxx b/src/threads.cxx index 3e77ea069..b9da69869 100644 --- a/src/threads.cxx +++ b/src/threads.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2001-2010 Tad E. Smith +// Copyright 2001-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/timehelper.cxx b/src/timehelper.cxx index afc7cddd5..70af7d371 100644 --- a/src/timehelper.cxx +++ b/src/timehelper.cxx @@ -4,7 +4,7 @@ // Author: Tad E. Smith // // -// Copyright 2003-2010 Tad E. Smith +// Copyright 2003-2013 Tad E. Smith // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/tls.cxx b/src/tls.cxx index 2f8bc017d..66d787772 100644 --- a/src/tls.cxx +++ b/src/tls.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/version.cxx b/src/version.cxx index e96839586..cd00b9e2e 100644 --- a/src/version.cxx +++ b/src/version.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/win32consoleappender.cxx b/src/win32consoleappender.cxx index 4f9688272..0fb1a3acd 100644 --- a/src/win32consoleappender.cxx +++ b/src/win32consoleappender.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: diff --git a/src/win32debugappender.cxx b/src/win32debugappender.cxx index b83e0f6be..d7e56a082 100644 --- a/src/win32debugappender.cxx +++ b/src/win32debugappender.cxx @@ -4,7 +4,7 @@ // Author: Eduardo Francos, Odalio SARL // // -// Copyright 2003-2010 Odalio SARL +// Copyright 2003-2013 Odalio SARL // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From 56c7c8535c351056977859dc84cb315356c8a8d9 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Feb 2013 21:27:46 +0100 Subject: [PATCH 060/226] update_copyrights.sh: Simple script to update copyright years. --- scripts/update_copyrights.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/update_copyrights.sh diff --git a/scripts/update_copyrights.sh b/scripts/update_copyrights.sh new file mode 100755 index 000000000..aa0ac8145 --- /dev/null +++ b/scripts/update_copyrights.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +FILES=`find . \( \( -not -path './objdir*' \) -and \( -name '*.h' -o -name '*.hxx' -o -name '*.cxx' \) \)` +perl -wn -i.bak -e ' +use strict; + +my $YEAR = 2013; + +my $sep = qr/[\s,;]/; +if (/copyright/i) +{ + print STDERR; +} +if (/(copyright $sep+ (?:\(c\) $sep+)? (?:\d{4})) (\s* - \s*) (\d{4})/ixgp) +{ + #print STDERR "($1) ($2) ($3)\n"; + #print STDERR "${^PREMATCH}$1$2$YEAR${^POSTMATCH}"; + print "${^PREMATCH}$1$2$YEAR${^POSTMATCH}"; +} +elsif (/(copyright $sep+ (?:\(c\) $sep+)? (\d{4}))/ixgp) +{ + #print STDERR "($1)\n"; + #print STDERR "${^PREMATCH}$1-$YEAR${^POSTMATCH}"; + print "${^PREMATCH}$1-$YEAR${^POSTMATCH}"; +} +else +{ + print; +} +' $FILES From 3f7602a57addf84286412438eac7d5f9532ca58a Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Feb 2013 21:28:34 +0100 Subject: [PATCH 061/226] log4cplus.spec: Fix bug #157. Update to fix Fedora package builds. Patch provided by: Clement Lan --- log4cplus.spec | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/log4cplus.spec b/log4cplus.spec index 0267a2a81..58be1d0b1 100644 --- a/log4cplus.spec +++ b/log4cplus.spec @@ -47,6 +47,13 @@ cp -rp include/log4cplus $RPM_BUILD_ROOT%{prefix}/include/ rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/stamp-* rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/*.in rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/stamp-* +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/macosx.h +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/win32.h +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/config/windowsh-inc.h +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/internal/cygwin-win32.h +rm -f $RPM_BUILD_ROOT%{prefix}/include/log4cplus/thread/impl/syncprims-win32.h +find %{buildroot} -name .svn -type d -exec find '{}' -delete \; +find %{buildroot} -name "*.in" -delete %clean @@ -62,4 +69,12 @@ rm -rf $RPM_BUILD_ROOT %prefix/include/log4cplus/*.h %prefix/include/log4cplus/helpers/*.h %prefix/include/log4cplus/spi/*.h -%attr(644,root,root) %prefix/lib/*.a +%prefix/include/log4cplus/boost/*.hxx +%prefix/include/log4cplus/config.hxx +%prefix/include/log4cplus/config/defines.hxx +%prefix/include/log4cplus/internal/*.h +%prefix/include/log4cplus/thread/impl/*.h +%prefix/include/log4cplus/thread/*.h +%attr(644,root,root) +%prefix/lib/*.a +%prefix/lib/pkgconfig/log4cplus.pc From 3eb969e3b1f9800ca70901cb1803b2c05f3ed52f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Feb 2013 21:36:24 +0100 Subject: [PATCH 062/226] Improve initialization where possible. Produce messages during compilation to warn to initialize log4cplus. --- include/log4cplus/config.hxx | 3 + include/log4cplus/config/win32.h | 7 ++ src/global-init.cxx | 159 +++++++++++++++++++---------- tests/appender_test/main.cxx | 1 + tests/configandwatch_test/main.cxx | 1 + tests/customloglevel_test/main.cxx | 64 ++++++------ tests/fileappender_test/main.cxx | 1 + tests/filter_test/main.cxx | 1 + tests/hierarchy_test/main.cxx | 1 + tests/loglog_test/main.cxx | 1 + tests/ndc_test/main.cxx | 1 + tests/ostream_test/main.cxx | 1 + tests/patternlayout_test/main.cxx | 1 + tests/performance_test/main.cxx | 1 + tests/priority_test/main.cxx | 1 + tests/propertyconfig_test/main.cxx | 1 + tests/socket_test/main.cxx | 1 + tests/thread_test/main.cxx | 1 + tests/timeformat_test/main.cxx | 1 + 19 files changed, 164 insertions(+), 84 deletions(-) diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index f80be9a88..9e3c69362 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -156,6 +156,9 @@ namespace log4cplus //! automatically by other means. LOG4CPLUS_EXPORT void threadCleanup (); +//! Initializes log4cplus. +LOG4CPLUS_EXPORT void initialize (); + } // namespace log4cplus #endif diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index c0d2f512a..765cea0fe 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -190,6 +190,13 @@ # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS #endif // __BORLANDC__ +#if ! defined (LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING) +# if defined (LOG4CPLUS_STATIC) && defined (_MSC_VER) && ! defined (_DLL) +# pragma message("You are not using DLL C run time library. " \ + "You must call log4cplus::initialize() once before " \ + "you use any other log4cplus API.") +# endif +#endif #endif // _WIN32 #endif // LOG4CPLUS_CONFIG_WIN32_HEADER_ diff --git a/src/global-init.cxx b/src/global-init.cxx index 0108815e1..178d9535e 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -357,7 +357,8 @@ threadSetup () } -void initializeLog4cplus() +void +initializeLog4cplus() { static bool initialized = false; if (initialized) @@ -375,6 +376,13 @@ void initializeLog4cplus() } +void +initialize () +{ + initializeLog4cplus (); +} + + void threadCleanup () { @@ -386,28 +394,47 @@ threadCleanup () #if defined (_WIN32) +static +VOID CALLBACK +initializeLog4cplusApcProc (ULONG_PTR /*dwParam*/) +{ + initializeLog4cplus (); + threadSetup (); +} + + +static +void +queueLog4cplusInitializationThroughAPC () +{ + if (! QueueUserAPC (initializeLog4cplusApcProc, GetCurrentThread (), + 0)) + throw std::runtime_error ("QueueUserAPC() has failed"); +} + + static void NTAPI thread_callback (LPVOID /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpReserved*/) { // Perform actions based on the reason for calling. - switch( fdwReason ) + switch (fdwReason) { case DLL_PROCESS_ATTACH: { - log4cplus::initializeLog4cplus(); - - // Do thread-specific initialization for the main thread. - log4cplus::threadSetup (); - + // We cannot initialize log4cplus directly here. This is because + // DllMain() is called under loader lock. When we are using C++11 + // threads and synchronization primitives then there is a deadlock + // somewhere in internals of std::mutex::lock(). + queueLog4cplusInitializationThroughAPC (); break; } case DLL_THREAD_ATTACH: { - // Do thread-specific initialization. - log4cplus::threadSetup (); - + // We could call threadSetup() here but that imposes overhead + // on threads that do not use log4cplus. Thread local data will + // be initialized lazily instead. break; } @@ -441,8 +468,7 @@ thread_callback (LPVOID /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpReserved*/) } // namespace log4cplus -#if defined (_WIN32) && defined (LOG4CPLUS_BUILD_DLL) - +#if defined (_WIN32) && defined (LOG4CPLUS_BUILD_DLL) && defined (_DLL) extern "C" BOOL WINAPI @@ -453,56 +479,81 @@ DllMain (LOG4CPLUS_DLLMAIN_HINSTANCE hinstDLL, DWORD fdwReason, return TRUE; // Successful DLL_PROCESS_ATTACH. } - -#else -#if defined (_MSC_VER) && _MSC_VER >= 1400 - -extern "C" -{ - -// This magic has been pieced together from several sources: -// - -// - - -#pragma data_seg (push, old_seg) -#ifdef _WIN64 -#pragma const_seg (".CRT$XLX") -extern const -#else -#pragma data_seg (".CRT$XLX") -#endif -PIMAGE_TLS_CALLBACK p_thread_callback = log4cplus::thread_callback; -#pragma data_seg (pop, old_seg) -#ifdef _WIN64 -#pragma comment (linker, "/INCLUDE:_tls_used") -#pragma comment (linker, "/INCLUDE:p_thread_callback") -#else -#pragma comment (linker, "/INCLUDE:__tls_used") -#pragma comment (linker, "/INCLUDE:_p_thread_callback") -#endif - -} // extern "C" +#elif defined (_WIN32) \ + && defined (_MSC_VER) && _MSC_VER >= 1400 && defined (_DLL) +extern "C" +{ + +// This magic has been pieced together from several sources: +// - +// - +#pragma data_seg (push, old_seg) +#ifdef _WIN64 +#pragma const_seg (".CRT$XLX") +extern const #else +#pragma data_seg (".CRT$XLX") +#endif +PIMAGE_TLS_CALLBACK log4cplus_p_thread_callback = log4cplus::thread_callback; +#pragma data_seg (pop, old_seg) +#ifdef _WIN64 +#pragma comment (linker, "/INCLUDE:_tls_used") +#pragma comment (linker, "/INCLUDE:log4cplus_p_thread_callback") +#else +#pragma comment (linker, "/INCLUDE:__tls_used") +#pragma comment (linker, "/INCLUDE:_log4cplus_p_thread_callback") +#endif + +} // extern "C" +#elif defined (_WIN32) namespace { - struct _static_log4cplus_initializer +struct _static_log4cplus_initializer +{ + _static_log4cplus_initializer () { - _static_log4cplus_initializer () - { - log4cplus::initializeLog4cplus(); - } - - ~_static_log4cplus_initializer () - { - // Last thread cleanup. - log4cplus::threadCleanup (); - } - } static initializer; -} + // It is not possible to reliably call initializeLog4cplus() here + // when we are using Visual Studio and C++11 threads + // and synchronization primitives. It would result into a deadlock + // on loader lock. +#if ! (defined (LOG4CPLUS_WITH_CXX11_THREADS) && defined (_MSC_VER)) + log4cplus::initializeLog4cplus (); +#endif + } + ~_static_log4cplus_initializer () + { + // Last thread cleanup. + log4cplus::threadCleanup (); +#if ! defined (LOG4CPLUS_THREAD_LOCAL_VAR) + log4cplus::thread::impl::tls_cleanup ( + log4cplus::internal::tls_storage_key); #endif + } +} static initializer; + +} // namespace + +#else +namespace { + +struct _static_log4cplus_initializer +{ + _static_log4cplus_initializer () + { + log4cplus::initializeLog4cplus(); + } + + ~_static_log4cplus_initializer () + { + // Last thread cleanup. + log4cplus::threadCleanup (); + } +} static initializer; + +} // namespace #endif diff --git a/tests/appender_test/main.cxx b/tests/appender_test/main.cxx index 5ecfee961..16310669a 100644 --- a/tests/appender_test/main.cxx +++ b/tests/appender_test/main.cxx @@ -29,6 +29,7 @@ printAppenderList(SharedAppenderPtrList list) int main() { + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); { AppenderAttachableImpl aai; diff --git a/tests/configandwatch_test/main.cxx b/tests/configandwatch_test/main.cxx index d237afe5d..e5a7d4efe 100644 --- a/tests/configandwatch_test/main.cxx +++ b/tests/configandwatch_test/main.cxx @@ -32,6 +32,7 @@ int main() { tcout << LOG4CPLUS_TEXT("Entering main()...") << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); Logger root = Logger::getRoot(); try diff --git a/tests/customloglevel_test/main.cxx b/tests/customloglevel_test/main.cxx index 766272e36..3c45b4cca 100644 --- a/tests/customloglevel_test/main.cxx +++ b/tests/customloglevel_test/main.cxx @@ -18,45 +18,49 @@ main() { cout << "Entering main()..." << endl; { - SharedAppenderPtr append_1(new ConsoleAppender()); - append_1->setName(LOG4CPLUS_TEXT("First")); // append_1->setLayout( std::auto_ptr(new TTCCLayout()) ); - cout << "Getting root logger...DONE" << endl; - Logger::getRoot().addAppender(append_1); + LOG4CPLUS_FATAL(root, "\nSetting test.subtest to WARN"); + LOG4CPLUS_FATAL(root, "\nSetting test to CRITICAL"); + LOG4CPLUS_FATAL(root, "\nSetting test.subtest to NOT_SET_LOG_LEVEL"); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel()) << '\n'); + log4cplus::initialize (); + SharedAppenderPtr append_1(new ConsoleAppender()); + append_1->setName(LOG4CPLUS_TEXT("First")); + // append_1->setLayout( std::auto_ptr(new TTCCLayout()) ); + cout << "Getting root logger...DONE" << endl; + Logger::getRoot().addAppender(append_1); - Logger root = Logger::getRoot(); - Logger test = Logger::getInstance(LOG4CPLUS_TEXT("test")); - Logger subTest = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest")); - LogLevelManager& llm = getLogLevelManager(); + Logger root = Logger::getRoot(); + Logger test = Logger::getInstance(LOG4CPLUS_TEXT("test")); + Logger subTest = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest")); + LogLevelManager& llm = getLogLevelManager(); - LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "\nSetting test.subtest to WARN"); - subTest.setLogLevel(WARN_LOG_LEVEL); - LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "Setting test.subtest to WARN"); + subTest.setLogLevel(WARN_LOG_LEVEL); + LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "\nSetting test to CRITICAL"); - test.setLogLevel(CRITICAL_LOG_LEVEL); - LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "Setting test to CRITICAL"); + test.setLogLevel(CRITICAL_LOG_LEVEL); + LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "\nSetting test.subtest to NOT_SET_LOG_LEVEL"); - subTest.setLogLevel(NOT_SET_LOG_LEVEL); - LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel()) << '\n'); + LOG4CPLUS_FATAL(root, "Setting test.subtest to NOT_SET_LOG_LEVEL"); + subTest.setLogLevel(NOT_SET_LOG_LEVEL); + LOG4CPLUS_FATAL(root, "root: " << llm.toString(root.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test: " << llm.toString(test.getChainedLogLevel())); + LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel())); - writeLogMessage(); - cout << "Returned from writeLogMessage()..." << endl; + writeLogMessage(); + cout << "Returned from writeLogMessage()..." << endl; } cout << "REALLY exiting main()..." << endl; return 0; } - - diff --git a/tests/fileappender_test/main.cxx b/tests/fileappender_test/main.cxx index 391fd047d..b31f1aa3d 100644 --- a/tests/fileappender_test/main.cxx +++ b/tests/fileappender_test/main.cxx @@ -14,6 +14,7 @@ const int LOOP_COUNT = 20000; int main() { + log4cplus::initialize (); helpers::LogLog::getLogLog()->setInternalDebugging(true); SharedAppenderPtr append_1( new RollingFileAppender(LOG4CPLUS_TEXT("Test.log"), 5*1024, 5)); diff --git a/tests/filter_test/main.cxx b/tests/filter_test/main.cxx index 31d223ddb..b3fb3e7fa 100644 --- a/tests/filter_test/main.cxx +++ b/tests/filter_test/main.cxx @@ -28,6 +28,7 @@ int main() { tcout << "Entering main()..." << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); Logger root = Logger::getRoot(); try { diff --git a/tests/hierarchy_test/main.cxx b/tests/hierarchy_test/main.cxx index 9e9a77215..3263f8e97 100644 --- a/tests/hierarchy_test/main.cxx +++ b/tests/hierarchy_test/main.cxx @@ -11,6 +11,7 @@ using namespace log4cplus::helpers; int main() { + log4cplus::initialize (); { Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("test")); diff --git a/tests/loglog_test/main.cxx b/tests/loglog_test/main.cxx index bed79115e..0bb8d0701 100644 --- a/tests/loglog_test/main.cxx +++ b/tests/loglog_test/main.cxx @@ -16,6 +16,7 @@ void printMsgs() { int main() { + log4cplus::initialize (); printMsgs(); cout << "Turning on debug..." << endl; diff --git a/tests/ndc_test/main.cxx b/tests/ndc_test/main.cxx index 01d80027d..3eccdd09c 100644 --- a/tests/ndc_test/main.cxx +++ b/tests/ndc_test/main.cxx @@ -15,6 +15,7 @@ int main() { cout << "Entering main()..." << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); try { SharedObjectPtr append_1(new ConsoleAppender()); diff --git a/tests/ostream_test/main.cxx b/tests/ostream_test/main.cxx index b7cefcebc..df4e1a315 100644 --- a/tests/ostream_test/main.cxx +++ b/tests/ostream_test/main.cxx @@ -11,6 +11,7 @@ using namespace log4cplus; int main() { + log4cplus::initialize (); SharedAppenderPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); Logger::getRoot().addAppender(append_1); diff --git a/tests/patternlayout_test/main.cxx b/tests/patternlayout_test/main.cxx index f57d4dcca..777182445 100644 --- a/tests/patternlayout_test/main.cxx +++ b/tests/patternlayout_test/main.cxx @@ -18,6 +18,7 @@ int main() { cout << "Entering main()..." << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); try { SharedObjectPtr append_1(new ConsoleAppender()); diff --git a/tests/performance_test/main.cxx b/tests/performance_test/main.cxx index 9536c28f9..f07afbfa8 100644 --- a/tests/performance_test/main.cxx +++ b/tests/performance_test/main.cxx @@ -26,6 +26,7 @@ int main() { tcout << LOG4CPLUS_TEXT("Entering main()...") << endl; + log4cplus::initialize (); PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties")); Logger root = Logger::getRoot(); try { diff --git a/tests/priority_test/main.cxx b/tests/priority_test/main.cxx index 62653e158..7d31cb522 100644 --- a/tests/priority_test/main.cxx +++ b/tests/priority_test/main.cxx @@ -18,6 +18,7 @@ int main() { cout << "Entering main()..." << endl; + log4cplus::initialize (); { SharedAppenderPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); diff --git a/tests/propertyconfig_test/main.cxx b/tests/propertyconfig_test/main.cxx index fd7487e5e..59ed1d94c 100644 --- a/tests/propertyconfig_test/main.cxx +++ b/tests/propertyconfig_test/main.cxx @@ -15,6 +15,7 @@ int main() { tcout << LOG4CPLUS_TEXT("Entering main()...") << endl; + log4cplus::initialize (); LogLog::getLogLog()->setInternalDebugging(true); Logger root = Logger::getRoot(); try { diff --git a/tests/socket_test/main.cxx b/tests/socket_test/main.cxx index d52b87b09..f2a267f01 100644 --- a/tests/socket_test/main.cxx +++ b/tests/socket_test/main.cxx @@ -14,6 +14,7 @@ using namespace log4cplus; int main(int argc, char **argv) { + log4cplus::initialize (); log4cplus::helpers::sleep(1); tstring serverName = (argc > 1 ? LOG4CPLUS_C_STR_TO_TSTRING(argv[1]) : tstring()); // tstring host = LOG4CPLUS_TEXT("192.168.2.10"); diff --git a/tests/thread_test/main.cxx b/tests/thread_test/main.cxx index c54100f20..dfeb0b75f 100644 --- a/tests/thread_test/main.cxx +++ b/tests/thread_test/main.cxx @@ -76,6 +76,7 @@ class TestThread : public AbstractThread { int main() { + log4cplus::initialize(); try { auto_ptr slowObject(new SlowObject()); diff --git a/tests/timeformat_test/main.cxx b/tests/timeformat_test/main.cxx index 3cdfd4f8c..2fc99fd48 100644 --- a/tests/timeformat_test/main.cxx +++ b/tests/timeformat_test/main.cxx @@ -14,6 +14,7 @@ int main() { std::cout << "Entering main()..." << std::endl; + log4cplus::initialize (); try { Time time; From 7ab0a63dd56a25873f0d5d30e21d2ae4882f8e41 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Feb 2013 21:38:54 +0100 Subject: [PATCH 063/226] Fix issues with Visual Studio 2005 CMake builds. CMakeLists.txt: Define _WIN32_WINNT to 0x0500. src/CMakeLists.txt: Use _WIN32_WINNT to define it during compilation. win32.h: Limit use intrin.h to Visual Studio 2009 and later. It turns out that older Windows SDKs (7.0A and 7.1 likely) and intrin.h have clashing declarations of some synchronization primitives. This is an indirect attempt at excluding the use of intrin.h when using compiler that is more likely to be used with older SDKs. We have resorted to indirect attempt like this because there is no way to actually detect Windows SDK version through macros. --- CMakeLists.txt | 2 ++ include/log4cplus/config/win32.h | 2 +- src/CMakeLists.txt | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7396d8065..728be8547 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,8 @@ option(UNICODE "Build with tchar = wchar_t" ${UNICODE_DEFAULT}) option(WITH_ICONV "Use iconv() for char->wchar_t conversion." OFF) + +set(_WIN32_WINNT 0x0500 CACHE STRING "Define Windows API version to use.") if (UNICODE) set (log4cplus_postfix "${log4cplus_postfix}U") diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index 765cea0fe..c5b0d3d31 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -34,7 +34,7 @@ #ifdef _WIN32 -#if (defined (_MSC_VER) && _MSC_VER >= 1400) \ +#if (defined (_MSC_VER) && _MSC_VER > 1400) \ || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3) # define LOG4CPLUS_HAVE_INTRIN_H #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f4f5bc06..852897972 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,6 +70,7 @@ if (UNICODE) endif (UNICODE) if (WIN32) add_definitions (-DMINGW_HAS_SECURE_API=1) + add_definitions (-D_WIN32_WINNT=${_WIN32_WINNT}) endif (WIN32) add_library (${log4cplus} ${log4cplus_sources}) From 8305788e7074403ab7a6ef2e041164184fb63265 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Feb 2013 21:50:57 +0100 Subject: [PATCH 064/226] customloglevel_test/main.cxx: Fix after recent merges. --- tests/customloglevel_test/main.cxx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/customloglevel_test/main.cxx b/tests/customloglevel_test/main.cxx index 3c45b4cca..459e7a751 100644 --- a/tests/customloglevel_test/main.cxx +++ b/tests/customloglevel_test/main.cxx @@ -18,11 +18,6 @@ main() { cout << "Entering main()..." << endl; { -// append_1->setLayout( std::auto_ptr(new TTCCLayout()) ); - LOG4CPLUS_FATAL(root, "\nSetting test.subtest to WARN"); - LOG4CPLUS_FATAL(root, "\nSetting test to CRITICAL"); - LOG4CPLUS_FATAL(root, "\nSetting test.subtest to NOT_SET_LOG_LEVEL"); - LOG4CPLUS_FATAL(root, "test.subtest: " << llm.toString(subTest.getChainedLogLevel()) << '\n'); log4cplus::initialize (); SharedAppenderPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); From 4f9eb2aeb8fea1ec89393527a9ac522017db9d51 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Feb 2013 21:58:02 +0100 Subject: [PATCH 065/226] Fix merge artifacts in SocketAppender. --- include/log4cplus/socketappender.h | 2 -- src/socketappender.cxx | 2 -- 2 files changed, 4 deletions(-) diff --git a/include/log4cplus/socketappender.h b/include/log4cplus/socketappender.h index 79c7fa43c..a288c512a 100644 --- a/include/log4cplus/socketappender.h +++ b/include/log4cplus/socketappender.h @@ -99,8 +99,6 @@ namespace log4cplus * */ class LOG4CPLUS_EXPORT SocketAppender : public Appender { -#if ! defined (LOG4CPLUS_SINGLE_THREADED) -#endif public: // Ctors SocketAppender(const log4cplus::tstring& host, unsigned short port, diff --git a/src/socketappender.cxx b/src/socketappender.cxx index 38381faf2..87db0bab1 100644 --- a/src/socketappender.cxx +++ b/src/socketappender.cxx @@ -248,8 +248,6 @@ SocketAppender::append(const spi::InternalLoggingEvent& event) } -#if ! defined (LOG4CPLUS_SINGLE_THREADED) -#endif ///////////////////////////////////////////////////////////////////////////// // namespace helpers methods ///////////////////////////////////////////////////////////////////////////// From b17466e57ad75a8b2b13df44cbeacd5e9d512892 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 25 Feb 2013 11:57:48 +0100 Subject: [PATCH 066/226] Added support for displaying the whole content of MDC map if no key is given in the patternlayout "%X" --- src/patternlayout.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/patternlayout.cxx b/src/patternlayout.cxx index c24d81b04..5f7a09598 100644 --- a/src/patternlayout.cxx +++ b/src/patternlayout.cxx @@ -580,7 +580,26 @@ void log4cplus::pattern::MDCPatternConverter::convert (tstring & result, const spi::InternalLoggingEvent& event) { - result = event.getMDC (key); + if(!key.empty()) + { + result = event.getMDC (key); + } + else + { + result = LOG4CPLUS_TEXT(""); + + MappedDiagnosticContextMap mdcMap = event.getMDCCopy(); + + for ( MappedDiagnosticContextMap::const_iterator it = mdcMap.begin(); it != mdcMap.end(); it ++) + { + tstring name(it->first); + + tstring value(it->second); + + result += LOG4CPLUS_TEXT("{") + name + LOG4CPLUS_TEXT(", ") + value + LOG4CPLUS_TEXT("}"); + + } + } } From b88b21cdffad6f5c8b26fbabd0a0da99cf9adfa3 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 25 Feb 2013 11:58:13 +0100 Subject: [PATCH 067/226] patternlayout.cxx: Fix formatting after previous merge. --- src/patternlayout.cxx | 44 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/patternlayout.cxx b/src/patternlayout.cxx index 5f7a09598..811c9fc38 100644 --- a/src/patternlayout.cxx +++ b/src/patternlayout.cxx @@ -580,26 +580,30 @@ void log4cplus::pattern::MDCPatternConverter::convert (tstring & result, const spi::InternalLoggingEvent& event) { - if(!key.empty()) - { - result = event.getMDC (key); - } - else - { - result = LOG4CPLUS_TEXT(""); - - MappedDiagnosticContextMap mdcMap = event.getMDCCopy(); - - for ( MappedDiagnosticContextMap::const_iterator it = mdcMap.begin(); it != mdcMap.end(); it ++) - { - tstring name(it->first); - - tstring value(it->second); - - result += LOG4CPLUS_TEXT("{") + name + LOG4CPLUS_TEXT(", ") + value + LOG4CPLUS_TEXT("}"); - - } - } + if (!key.empty()) + { + result = event.getMDC (key); + } + else + { + result.clear (); + + MappedDiagnosticContextMap const & mdcMap = event.getMDCCopy(); + + for (MappedDiagnosticContextMap::const_iterator it = mdcMap.begin(); + it != mdcMap.end(); ++it) + { + tstring const & name(it->first); + tstring const & value(it->second); + + result += LOG4CPLUS_TEXT("{"); + result += name; + result += LOG4CPLUS_TEXT(", "); + result += value; + result += LOG4CPLUS_TEXT("}"); + + } + } } From 18a4b4142dbc2533cb1a303fdc66e53e5a3aef07 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 25 Feb 2013 12:05:52 +0100 Subject: [PATCH 068/226] AUTHORS: Add Yaqian Shen. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 2913fd858..722d3a954 100644 --- a/AUTHORS +++ b/AUTHORS @@ -20,3 +20,4 @@ Chernyshev Vyacheslav Chris Steenwyk Jukka Lantto Konstantin Baumann +Yaqian Shen From 229877e15290d52117dc9cfb7f0698844522dda4 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 1 Mar 2013 12:51:39 +0100 Subject: [PATCH 069/226] Improve CMake builds. 1. Updated test target by utilizing CMAKE_RUNTIME_OUTPUT_DIRECTORY variable. 2. Updated cpack to pick up the LICENSE. 3. Added 'S' prefix for static libs. Patch provided by: Sergey Nikulov --- CMakeLists.txt | 7 +++++++ Log4CPlusCPack.cmake | 2 +- tests/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 728be8547..e46b3b16a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,11 @@ option(WITH_ICONV "Use iconv() for char->wchar_t conversion." set(_WIN32_WINNT 0x0500 CACHE STRING "Define Windows API version to use.") +if (NOT ${BUILD_SHARED_LIBS}) + # set S-prefix for static build + set (log4cplus_postfix "${log4cplus_postfix}S") +endif() + if (UNICODE) set (log4cplus_postfix "${log4cplus_postfix}U") endif (UNICODE) @@ -63,6 +68,8 @@ include_directories (${log4cplus_SOURCE_DIR}/include ${log4cplus_BINARY_DIR}/include ) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) + if (LOG4CPLUS_BUILD_TESTING) enable_testing() endif (LOG4CPLUS_BUILD_TESTING) diff --git a/Log4CPlusCPack.cmake b/Log4CPlusCPack.cmake index 495b7ef02..45882b5cb 100644 --- a/Log4CPlusCPack.cmake +++ b/Log4CPlusCPack.cmake @@ -1,6 +1,6 @@ set(CPACK_PACKAGE_NAME log4cplus) set(CPACK_PACKAGE_VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "log4cplus is a log4j-inspired logging library for C++") - +set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) include(CPack) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3a72f5972..3e5b37d8d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,7 +12,7 @@ function(log4cplus_add_test _name) # message (STATUS "${_name} sources: ${_srcs}") add_executable (${_name} ${_srcs}) target_link_libraries (${_name} ${log4cplus}) - add_test(${_name} ${_name}) + add_test(NAME ${_name} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${_name}) endfunction() From 51c3aed8709238fee9c553a48110ad06d0aa4578 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 1 Mar 2013 12:52:04 +0100 Subject: [PATCH 070/226] AUTHORS: Add Sergey Nikulov. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 722d3a954..f6e3cbaea 100644 --- a/AUTHORS +++ b/AUTHORS @@ -21,3 +21,4 @@ Chris Steenwyk Jukka Lantto Konstantin Baumann Yaqian Shen +Sergey Nikulov From 4d2052ab21823f8f206db288e3bcdbe627933cec Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Mar 2013 20:25:49 +0100 Subject: [PATCH 071/226] sleep.cxx: Avoid clock_nanosleep() when compiling with Bionic C library (Android) to work around missing clock_nanosleep() declaration in headers. --- src/sleep.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sleep.cxx b/src/sleep.cxx index 50bfc9c96..094be8896 100644 --- a/src/sleep.cxx +++ b/src/sleep.cxx @@ -48,7 +48,10 @@ static inline int unix_nanosleep (const struct timespec *req, struct timespec *rem) { -#if defined (LOG4CPLUS_HAVE_CLOCK_NANOSLEEP) +#if defined (LOG4CPLUS_HAVE_CLOCK_NANOSLEEP) \ + && ! defined (__BIONIC__) + // We do not allow Android with Bionic C library to use + // clock_nanosleep() as it is missing declaration in headers. return clock_nanosleep (CLOCK_REALTIME, 0, req, rem); #elif defined (LOG4CPLUS_HAVE_NANOSLEEP) From 4d762dc59f0cd625303677bd4597274fd4a4fb3d Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Mar 2013 20:28:53 +0100 Subject: [PATCH 072/226] android: Import CMake scripts for Android builds. Patch provided by: Nikita Manovich --- CMakeLists.txt | 8 + android/android.toolchain.cmake | 1567 ++++++++++++++++++++++ android/scripts/cmake_android.sh | 8 + android/scripts/cmake_android_armeabi.sh | 8 + android/scripts/cmake_android_mips.sh | 8 + android/scripts/cmake_android_neon.sh | 8 + android/scripts/cmake_android_x86.sh | 9 + 7 files changed, 1616 insertions(+) create mode 100644 android/android.toolchain.cmake create mode 100755 android/scripts/cmake_android.sh create mode 100755 android/scripts/cmake_android_armeabi.sh create mode 100755 android/scripts/cmake_android_mips.sh create mode 100755 android/scripts/cmake_android_neon.sh create mode 100755 android/scripts/cmake_android_x86.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index e46b3b16a..4cddc9851 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,11 @@ +# This block needs to stay before the project (log4cplus) line so that +# the output files placed into Android's libs directory. +if (CMAKE_TOOLCHAIN_FILE) + # Android: set output folder to ${CMAKE_BINARY_DIR} + set (LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH + "root for library output, set this to change where android libs are compiled to") +endif () + project (log4cplus) cmake_minimum_required (VERSION 2.8.0) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake new file mode 100644 index 000000000..f5daf307f --- /dev/null +++ b/android/android.toolchain.cmake @@ -0,0 +1,1567 @@ +# Copyright (c) 2010-2011, Ethan Rublee +# Copyright (c) 2011-2012, Andrey Kamaev +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. The name of the copyright holders may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# ------------------------------------------------------------------------------ +# Android CMake toolchain file, for use with the Android NDK r5-r8 +# Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended). +# See home page: https://github.com/taka-no-me/android-cmake +# +# The file is mantained by the OpenCV project. The latest version can be get at +# http://code.opencv.org/projects/opencv/repository/revisions/master/changes/android/android.toolchain.cmake +# +# Usage Linux: +# $ export ANDROID_NDK=/absolute/path/to/the/android-ndk +# $ mkdir build && cd build +# $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake .. +# $ make -j8 +# +# Usage Linux (using standalone toolchain): +# $ export ANDROID_STANDALONE_TOOLCHAIN=/absolute/path/to/android-toolchain +# $ mkdir build && cd build +# $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake .. +# $ make -j8 +# +# Usage Windows: +# You need native port of make to build your project. +# Android NDK r7 (or newer) already has make.exe on board. +# For older NDK you have to install it separately. +# For example, this one: http://gnuwin32.sourceforge.net/packages/make.htm +# +# $ SET ANDROID_NDK=C:\absolute\path\to\the\android-ndk +# $ mkdir build && cd build +# $ cmake.exe -G"MinGW Makefiles" +# -DCMAKE_TOOLCHAIN_FILE=path\to\the\android.toolchain.cmake +# -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows\bin\make.exe" .. +# $ cmake.exe --build . +# +# +# Options (can be set as cmake parameters: -D=): +# ANDROID_NDK=/opt/android-ndk - path to the NDK root. +# Can be set as environment variable. Can be set only at first cmake run. +# +# ANDROID_STANDALONE_TOOLCHAIN=/opt/android-toolchain - path to the +# standalone toolchain. This option is not used if full NDK is found +# (ignored if ANDROID_NDK is set). +# Can be set as environment variable. Can be set only at first cmake run. +# +# ANDROID_ABI=armeabi-v7a - specifies the target Application Binary +# Interface (ABI). This option nearly matches to the APP_ABI variable +# used by ndk-build tool from Android NDK. +# +# Possible targets are: +# "armeabi" - matches to the NDK ABI with the same name. +# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. +# "armeabi-v7a" - matches to the NDK ABI with the same name. +# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. +# "armeabi-v7a with NEON" - same as armeabi-v7a, but +# sets NEON as floating-point unit +# "armeabi-v7a with VFPV3" - same as armeabi-v7a, but +# sets VFPV3 as floating-point unit (has 32 registers instead of 16). +# "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP. +# "x86" - matches to the NDK ABI with the same name. +# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. +# "mips" - matches to the NDK ABI with the same name +# (It is not tested on real devices by the authos of this toolchain) +# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. +# +# ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for. +# Option is read-only when standalone toolchain is used. +# +# ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.6 - the name of compiler +# toolchain to be used. The list of possible values depends on the NDK +# version. For NDK r8c the possible values are: +# +# * arm-linux-androideabi-4.4.3 +# * arm-linux-androideabi-4.6 +# * arm-linux-androideabi-clang3.1 +# * mipsel-linux-android-4.4.3 +# * mipsel-linux-android-4.6 +# * mipsel-linux-android-clang3.1 +# * x86-4.4.3 +# * x86-4.6 +# * x86-clang3.1 +# +# ANDROID_FORCE_ARM_BUILD=OFF - set ON to generate 32-bit ARM instructions +# instead of Thumb. Is not available for "x86" (inapplicable) and +# "armeabi-v6 with VFP" (is forced to be ON) ABIs. +# +# ANDROID_NO_UNDEFINED=ON - set ON to show all undefined symbols as linker +# errors even if they are not used. +# +# ANDROID_SO_UNDEFINED=OFF - set ON to allow undefined symbols in shared +# libraries. Automatically turned for NDK r5x and r6x due to GLESv2 +# problems. +# +# LIBRARY_OUTPUT_PATH_ROOT=${CMAKE_SOURCE_DIR} - where to output binary +# files. See additional details below. +# +# ANDROID_SET_OBSOLETE_VARIABLES=ON - if set, then toolchain defines some +# obsolete variables which were used by previous versions of this file for +# backward compatibility. +# +# ANDROID_STL=gnustl_static - specify the runtime to use. +# +# Possible values are: +# none -> Do not configure the runtime. +# system -> Use the default minimal system C++ runtime library. +# Implies -fno-rtti -fno-exceptions. +# Is not available for standalone toolchain. +# system_re -> Use the default minimal system C++ runtime library. +# Implies -frtti -fexceptions. +# Is not available for standalone toolchain. +# gabi++_static -> Use the GAbi++ runtime as a static library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7 and newer. +# Is not available for standalone toolchain. +# gabi++_shared -> Use the GAbi++ runtime as a shared library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7 and newer. +# Is not available for standalone toolchain. +# stlport_static -> Use the STLport runtime as a static library. +# Implies -fno-rtti -fno-exceptions for NDK before r7. +# Implies -frtti -fno-exceptions for NDK r7 and newer. +# Is not available for standalone toolchain. +# stlport_shared -> Use the STLport runtime as a shared library. +# Implies -fno-rtti -fno-exceptions for NDK before r7. +# Implies -frtti -fno-exceptions for NDK r7 and newer. +# Is not available for standalone toolchain. +# gnustl_static -> Use the GNU STL as a static library. +# Implies -frtti -fexceptions. +# gnustl_shared -> Use the GNU STL as a shared library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7b and newer. +# Silently degrades to gnustl_static if not available. +# +# ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on +# chosen runtime. If disabled, then the user is responsible for settings +# these options. +# +# What?: +# android-cmake toolchain searches for NDK/toolchain in the following order: +# ANDROID_NDK - cmake parameter +# ANDROID_NDK - environment variable +# ANDROID_STANDALONE_TOOLCHAIN - cmake parameter +# ANDROID_STANDALONE_TOOLCHAIN - environment variable +# ANDROID_NDK - default locations +# ANDROID_STANDALONE_TOOLCHAIN - default locations +# +# Make sure to do the following in your scripts: +# SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" ) +# SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" ) +# The flags will be prepopulated with critical flags, so don't loose them. +# Also be aware that toolchain also sets configuration-specific compiler +# flags and linker flags. +# +# ANDROID and BUILD_ANDROID will be set to true, you may test any of these +# variables to make necessary Android-specific configuration changes. +# +# Also ARMEABI or ARMEABI_V7A or X86 or MIPS will be set true, mutually +# exclusive. NEON option will be set true if VFP is set to NEON. +# +# LIBRARY_OUTPUT_PATH_ROOT should be set in cache to determine where Android +# libraries will be installed. +# Default is ${CMAKE_SOURCE_DIR}, and the android libs will always be +# under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME} +# (depending on the target ABI). This is convenient for Android packaging. +# +# Change Log: +# - initial version December 2010 +# - April 2011 +# [+] added possibility to build with NDK (without standalone toolchain) +# [+] support cross-compilation on Windows (native, no cygwin support) +# [+] added compiler option to force "char" type to be signed +# [+] added toolchain option to compile to 32-bit ARM instructions +# [+] added toolchain option to disable SWIG search +# [+] added platform "armeabi-v7a with VFPV3" +# [~] ARM_TARGETS renamed to ARM_TARGET +# [+] EXECUTABLE_OUTPUT_PATH is set by toolchain (required on Windows) +# [~] Fixed bug with ANDROID_API_LEVEL variable +# [~] turn off SWIG search if it is not found first time +# - May 2011 +# [~] ANDROID_LEVEL is renamed to ANDROID_API_LEVEL +# [+] ANDROID_API_LEVEL is detected by toolchain if not specified +# [~] added guard to prevent changing of output directories on the first +# cmake pass +# [~] toolchain exits with error if ARM_TARGET is not recognized +# - June 2011 +# [~] default NDK path is updated for version r5c +# [+] variable CMAKE_SYSTEM_PROCESSOR is set based on ARM_TARGET +# [~] toolchain install directory is added to linker paths +# [-] removed SWIG-related stuff from toolchain +# [+] added macro find_host_package, find_host_program to search +# packages/programs on the host system +# [~] fixed path to STL library +# - July 2011 +# [~] fixed options caching +# [~] search for all supported NDK versions +# [~] allowed spaces in NDK path +# - September 2011 +# [~] updated for NDK r6b +# - November 2011 +# [*] rewritten for NDK r7 +# [+] x86 toolchain support (experimental) +# [+] added "armeabi-v6 with VFP" ABI for ARMv6 processors. +# [~] improved compiler and linker flags management +# [+] support different build flags for Release and Debug configurations +# [~] by default compiler flags the same as used by ndk-build (but only +# where reasonable) +# [~] ANDROID_NDK_TOOLCHAIN_ROOT is splitted to ANDROID_STANDALONE_TOOLCHAIN +# and ANDROID_TOOLCHAIN_ROOT +# [~] ARM_TARGET is renamed to ANDROID_ABI +# [~] ARMEABI_NDK_NAME is renamed to ANDROID_NDK_ABI_NAME +# [~] ANDROID_API_LEVEL is renamed to ANDROID_NATIVE_API_LEVEL +# - January 2012 +# [+] added stlport_static support (experimental) +# [+] added special check for cygwin +# [+] filtered out hidden files (starting with .) while globbing inside NDK +# [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6 +# [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags +# - February 2012 +# [+] updated for NDK r7b +# [~] fixed cmake try_compile() command +# [~] Fix for missing install_name_tool on OS X +# - March 2012 +# [~] fixed incorrect C compiler flags +# [~] fixed CMAKE_SYSTEM_PROCESSOR change on ANDROID_ABI change +# [+] improved toolchain loading speed +# [+] added assembler language support (.S) +# [+] allowed preset search paths and extra search suffixes +# - April 2012 +# [+] updated for NDK r7c +# [~] fixed most of problems with compiler/linker flags and caching +# [+] added option ANDROID_FUNCTION_LEVEL_LINKING +# - May 2012 +# [+] updated for NDK r8 +# [+] added mips architecture support +# - August 2012 +# [+] updated for NDK r8b +# [~] all intermediate files generated by toolchain are moved to CMakeFiles +# [~] libstdc++ and libsupc are removed from explicit link libraries +# [+] added CCache support (via NDK_CCACHE environment or cmake variable) +# [+] added gold linker support for NDK r8b +# [~] fixed mips linker flags for NDK r8b +# - September 2012 +# [+] added NDK release name detection (see ANDROID_NDK_RELEASE) +# [+] added support for all C++ runtimes from NDK +# (system, gabi++, stlport, gnustl) +# [+] improved warnings on known issues of NDKs +# [~] use gold linker as default if available (NDK r8b) +# [~] globally turned off rpath +# [~] compiler options are aligned with NDK r8b +# - October 2012 +# [~] fixed C++ linking: explicitly link with math library (OpenCV #2426) +# - November 2012 +# [+] updated for NDK r8c +# [+] added support for clang compiler +# - December 2012 +# [~] fixed ccache full path search +# [+] updated for NDK r8d +# ------------------------------------------------------------------------------ + +cmake_minimum_required( VERSION 2.6.3 ) + +if( DEFINED CMAKE_CROSSCOMPILING ) + # subsequent toolchain loading is not really needed + return() +endif() + +get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE ) +if( _CMAKE_IN_TRY_COMPILE ) + include( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL ) +endif() + +# this one is important +set( CMAKE_SYSTEM_NAME Linux ) +# this one not so much +set( CMAKE_SYSTEM_VERSION 1 ) + +# rpath makes low sence for Android +set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) + +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS) + if( CMAKE_HOST_WIN32 ) + file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) + set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}/android-ndk" "$ENV{SystemDrive}/NVPACK/android-ndk" ) + else() + file( TO_CMAKE_PATH "$ENV{HOME}" ANDROID_NDK_SEARCH_PATHS ) + set( ANDROID_NDK_SEARCH_PATHS /opt/android-ndk "${ANDROID_NDK_SEARCH_PATHS}/NVPACK/android-ndk" ) + endif() +endif() +if(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH) + set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain ) +endif() + +set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" ) +set( ANDROID_SUPPORTED_ABIS_x86 "x86" ) +set( ANDROID_SUPPORTED_ABIS_mipsel "mips" ) + +set( ANDROID_DEFAULT_NDK_API_LEVEL 8 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 ) + + +macro( __LIST_FILTER listvar regex ) + if( ${listvar} ) + foreach( __val ${${listvar}} ) + if( __val MATCHES "${regex}" ) + list( REMOVE_ITEM ${listvar} "${__val}" ) + endif() + endforeach() + endif() +endmacro() + +macro( __INIT_VARIABLE var_name ) + set( __test_path 0 ) + foreach( __var ${ARGN} ) + if( __var STREQUAL "PATH" ) + set( __test_path 1 ) + break() + endif() + endforeach() + if( __test_path AND NOT EXISTS "${${var_name}}" ) + unset( ${var_name} CACHE ) + endif() + if( "${${var_name}}" STREQUAL "" ) + set( __values 0 ) + foreach( __var ${ARGN} ) + if( __var STREQUAL "VALUES" ) + set( __values 1 ) + elseif( NOT __var STREQUAL "PATH" ) + set( __obsolete 0 ) + if( __var MATCHES "^OBSOLETE_.*$" ) + string( REPLACE "OBSOLETE_" "" __var "${__var}" ) + set( __obsolete 1 ) + endif() + if( __var MATCHES "^ENV_.*$" ) + string( REPLACE "ENV_" "" __var "${__var}" ) + set( __value "$ENV{${__var}}" ) + elseif( DEFINED ${__var} ) + set( __value "${${__var}}" ) + else() + if( __values ) + set( __value "${__var}" ) + else() + set( __value "" ) + endif() + endif() + if( NOT "${__value}" STREQUAL "" ) + if( __test_path ) + if( EXISTS "${__value}" ) + file( TO_CMAKE_PATH "${__value}" ${var_name} ) + if( __obsolete AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." ) + endif() + break() + endif() + else() + set( ${var_name} "${__value}" ) + if( __obsolete AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." ) + endif() + break() + endif() + endif() + endif() + endforeach() + unset( __value ) + unset( __values ) + unset( __obsolete ) + elseif( __test_path ) + file( TO_CMAKE_PATH "${${var_name}}" ${var_name} ) + endif() + unset( __test_path ) +endmacro() + +macro( __DETECT_NATIVE_API_LEVEL _var _path ) + SET( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*$" ) + FILE( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" ) + if( NOT __apiFileContent ) + message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." ) + endif() + string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" ) + unset( __apiFileContent ) + unset( __ndkApiLevelRegex ) +endmacro() + +macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root ) + if( EXISTS "${_root}" ) + file( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" ) + __LIST_FILTER( __gccExePath "^[.].*" ) + list( LENGTH __gccExePath __gccExePathsCount ) + if( NOT __gccExePathsCount EQUAL 1 AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "Could not determine machine name for compiler from ${_root}" ) + set( ${_var} "" ) + else() + get_filename_component( __gccExeName "${__gccExePath}" NAME_WE ) + string( REPLACE "-gcc" "" ${_var} "${__gccExeName}" ) + endif() + unset( __gccExePath ) + unset( __gccExePathsCount ) + unset( __gccExeName ) + else() + set( ${_var} "" ) + endif() +endmacro() + + +# fight against cygwin +set( ANDROID_FORBID_SYGWIN TRUE CACHE BOOL "Prevent cmake from working under cygwin and using cygwin tools") +mark_as_advanced( ANDROID_FORBID_SYGWIN ) +if( ANDROID_FORBID_SYGWIN ) + if( CYGWIN ) + message( FATAL_ERROR "Android NDK and android-cmake toolchain are not welcome Cygwin. It is unlikely that this cmake toolchain will work under cygwin. But if you want to try then you can set cmake variable ANDROID_FORBID_SYGWIN to FALSE and rerun cmake." ) + endif() + + if( CMAKE_HOST_WIN32 ) + # remove cygwin from PATH + set( __new_path "$ENV{PATH}") + __LIST_FILTER( __new_path "cygwin" ) + set(ENV{PATH} "${__new_path}") + unset(__new_path) + endif() +endif() + +# detect current host platform +set( TOOL_OS_SUFFIX "" ) +if( CMAKE_HOST_APPLE ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86" ) +elseif( CMAKE_HOST_WIN32 ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "windows" ) + set( TOOL_OS_SUFFIX ".exe" ) +elseif( CMAKE_HOST_UNIX ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86" ) +else() + message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" ) +endif() + +# see if we have path to Android NDK +__INIT_VARIABLE( ANDROID_NDK PATH ENV_ANDROID_NDK ) +if( NOT ANDROID_NDK ) + # see if we have path to Android standalone toolchain + __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN OBSOLETE_ANDROID_NDK_TOOLCHAIN_ROOT OBSOLETE_ENV_ANDROID_NDK_TOOLCHAIN_ROOT ) + + if( NOT ANDROID_STANDALONE_TOOLCHAIN ) + #try to find Android NDK in one of the the default locations + set( __ndkSearchPaths ) + foreach( __ndkSearchPath ${ANDROID_NDK_SEARCH_PATHS} ) + foreach( suffix ${ANDROID_SUPPORTED_NDK_VERSIONS} ) + list( APPEND __ndkSearchPaths "${__ndkSearchPath}${suffix}" ) + endforeach() + endforeach() + __INIT_VARIABLE( ANDROID_NDK PATH VALUES ${__ndkSearchPaths} ) + unset( __ndkSearchPaths ) + + if( ANDROID_NDK ) + message( STATUS "Using default path for Android NDK: ${ANDROID_NDK}" ) + message( STATUS " If you prefer to use a different location, please define a cmake or environment variable: ANDROID_NDK" ) + else() + #try to find Android standalone toolchain in one of the the default locations + __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH ) + + if( ANDROID_STANDALONE_TOOLCHAIN ) + message( STATUS "Using default path for standalone toolchain ${ANDROID_STANDALONE_TOOLCHAIN}" ) + message( STATUS " If you prefer to use a different location, please define the variable: ANDROID_STANDALONE_TOOLCHAIN" ) + endif( ANDROID_STANDALONE_TOOLCHAIN ) + endif( ANDROID_NDK ) + endif( NOT ANDROID_STANDALONE_TOOLCHAIN ) +endif( NOT ANDROID_NDK ) +# remember found paths +if( ANDROID_NDK ) + get_filename_component( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE ) + # try to detect change + if( CMAKE_AR ) + string( LENGTH "${ANDROID_NDK}" __length ) + string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath ) + if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK ) + message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first. + " ) + endif() + unset( __androidNdkPreviousPath ) + unset( __length ) + endif() + set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE ) + set( BUILD_WITH_ANDROID_NDK True ) + file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? ) +elseif( ANDROID_STANDALONE_TOOLCHAIN ) + get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE ) + # try to detect change + if( CMAKE_AR ) + string( LENGTH "${ANDROID_STANDALONE_TOOLCHAIN}" __length ) + string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidStandaloneToolchainPreviousPath ) + if( NOT __androidStandaloneToolchainPreviousPath STREQUAL ANDROID_STANDALONE_TOOLCHAIN ) + message( FATAL_ERROR "It is not possible to change path to the Android standalone toolchain on subsequent run." ) + endif() + unset( __androidStandaloneToolchainPreviousPath ) + unset( __length ) + endif() + set( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" CACHE INTERNAL "Path of the Android standalone toolchain" FORCE ) + set( BUILD_WITH_STANDALONE_TOOLCHAIN True ) +else() + list(GET ANDROID_NDK_SEARCH_PATHS 0 ANDROID_NDK_SEARCH_PATH) + message( FATAL_ERROR "Could not find neither Android NDK nor Android standalone toolchain. + You should either set an environment variable: + export ANDROID_NDK=~/my-android-ndk + or + export ANDROID_STANDALONE_TOOLCHAIN=~/my-android-toolchain + or put the toolchain or NDK in the default path: + sudo ln -s ~/my-android-ndk ${ANDROID_NDK_SEARCH_PATH} + sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" ) +endif() + +# get all the details about standalone toolchain +if( BUILD_WITH_STANDALONE_TOOLCHAIN ) + __DETECT_NATIVE_API_LEVEL( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" ) + set( ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + set( __availableToolchains "standalone" ) + __DETECT_TOOLCHAIN_MACHINE_NAME( __availableToolchainMachines "${ANDROID_STANDALONE_TOOLCHAIN}" ) + if( NOT __availableToolchainMachines ) + message( FATAL_ERROR "Could not determine machine name of your toolchain. Probably your Android standalone toolchain is broken." ) + endif() + if( __availableToolchainMachines MATCHES i686 ) + set( __availableToolchainArchs "x86" ) + elseif( __availableToolchainMachines MATCHES arm ) + set( __availableToolchainArchs "arm" ) + elseif( __availableToolchainMachines MATCHES mipsel ) + set( __availableToolchainArchs "mipsel" ) + endif() + execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" -dumpversion + OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" ) + if( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/bin/clang${TOOL_OS_SUFFIX}" ) + list( APPEND __availableToolchains "standalone-clang" ) + list( APPEND __availableToolchainMachines ${__availableToolchainMachines} ) + list( APPEND __availableToolchainArchs ${__availableToolchainArchs} ) + list( APPEND __availableToolchainCompilerVersions ${__availableToolchainCompilerVersions} ) + endif() +endif() + +macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar ) + foreach( __toolchain ${${__availableToolchainsVar}} ) + if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/" ) + string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) + else() + set( __gcc_toolchain "${__toolchain}" ) + endif() + __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__gcc_toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) + if( __machine ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?$" __version "${__gcc_toolchain}" ) + string( REGEX MATCH "^[^-]+" __arch "${__gcc_toolchain}" ) + list( APPEND __availableToolchainMachines "${__machine}" ) + list( APPEND __availableToolchainArchs "${__arch}" ) + list( APPEND __availableToolchainCompilerVersions "${__version}" ) + else() + list( REMOVE_ITEM ${__availableToolchainsVar} "${__toolchain}" ) + endif() + unset( __gcc_toolchain ) + endforeach() +endmacro() + +# get all the details about NDK +if( BUILD_WITH_ANDROID_NDK ) + file( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" ) + string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" ) + set( __availableToolchains "" ) + set( __availableToolchainMachines "" ) + set( __availableToolchainArchs "" ) + set( __availableToolchainCompilerVersions "" ) + if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/" ) + # do not go through all toolchains if we know the name + set( __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains ) + endif() + if( NOT __availableToolchains ) + file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" ) + if( __availableToolchains ) + list(SORT __availableToolchains) # we need clang to go after gcc + endif() + __LIST_FILTER( __availableToolchains "^[.]" ) + __LIST_FILTER( __availableToolchains "llvm" ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains ) + endif() + if( NOT __availableToolchains ) + message( FATAL_ERROR "Could not find any working toolchain in the NDK. Probably your Android NDK is broken." ) + endif() +endif() + +# build list of available ABIs +set( ANDROID_SUPPORTED_ABIS "" ) +set( __uniqToolchainArchNames ${__availableToolchainArchs} ) +list( REMOVE_DUPLICATES __uniqToolchainArchNames ) +list( SORT __uniqToolchainArchNames ) +foreach( __arch ${__uniqToolchainArchNames} ) +list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} ) +endforeach() +unset( __uniqToolchainArchNames ) +if( NOT ANDROID_SUPPORTED_ABIS ) +message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." ) +endif() + +# choose target ABI +__INIT_VARIABLE( ANDROID_ABI OBSOLETE_ARM_TARGET OBSOLETE_ARM_TARGETS VALUES ${ANDROID_SUPPORTED_ABIS} ) +# verify that target ABI is supported +list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx ) +if( __androidAbiIdx EQUAL -1 ) + string( REPLACE ";" "\", \"", PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" ) + message( FATAL_ERROR "Specified ANDROID_ABI = \"${ANDROID_ABI}\" is not supported by this cmake toolchain or your NDK/toolchain. + Supported values are: \"${PRINTABLE_ANDROID_SUPPORTED_ABIS}\" + " ) +endif() +unset( __androidAbiIdx ) + +# set target ABI options +if( ANDROID_ABI STREQUAL "x86" ) + set( X86 true ) + set( ANDROID_NDK_ABI_NAME "x86" ) + set( ANDROID_ARCH_NAME "x86" ) + set( ANDROID_ARCH_FULLNAME "x86" ) + set( ANDROID_LLVM_TRIPLE "i686-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "i686" ) +elseif( ANDROID_ABI STREQUAL "mips" ) + set( MIPS true ) + set( ANDROID_NDK_ABI_NAME "mips" ) + set( ANDROID_ARCH_NAME "mips" ) + set( ANDROID_ARCH_FULLNAME "mipsel" ) + set( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "mips" ) +elseif( ANDROID_ABI STREQUAL "armeabi" ) + set( ARMEABI true ) + set( ANDROID_NDK_ABI_NAME "armeabi" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_ARCH_FULLNAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv5te" ) +elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" ) + set( ARMEABI_V6 true ) + set( ANDROID_NDK_ABI_NAME "armeabi" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_ARCH_FULLNAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv6" ) + # need always fallback to older platform + set( ARMEABI true ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a") + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_ARCH_FULLNAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" ) + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_ARCH_FULLNAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) + set( VFPV3 true ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" ) + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_ARCH_FULLNAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) + set( VFPV3 true ) + set( NEON true ) +else() + message( SEND_ERROR "Unknown ANDROID_ABI=\"${ANDROID_ABI}\" is specified." ) +endif() + +if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" ) + # really dirty hack + # it is not possible to change CMAKE_SYSTEM_PROCESSOR after the first run... + file( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n" ) +endif() + +if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 ) + __INIT_VARIABLE( ANDROID_FORCE_ARM_BUILD OBSOLETE_FORCE_ARM VALUES OFF ) + set( ANDROID_FORCE_ARM_BUILD ${ANDROID_FORCE_ARM_BUILD} CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1" FORCE ) + mark_as_advanced( ANDROID_FORCE_ARM_BUILD ) +else() + unset( ANDROID_FORCE_ARM_BUILD CACHE ) +endif() + +# choose toolchain +if( ANDROID_TOOLCHAIN_NAME ) + list( FIND __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" __toolchainIdx ) + if( __toolchainIdx EQUAL -1 ) + list( SORT __availableToolchains ) + string( REPLACE ";" "\n * " toolchains_list "${__availableToolchains}" ) + set( toolchains_list " * ${toolchains_list}") + message( FATAL_ERROR "Specified toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing in your NDK or broken. Please verify that your NDK is working or select another compiler toolchain. +To configure the toolchain set CMake variable ANDROID_TOOLCHAIN_NAME to one of the following values:\n${toolchains_list}\n" ) + endif() + list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch ) + if( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME ) + message( SEND_ERROR "Selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." ) + endif() +else() + set( __toolchainIdx -1 ) + set( __applicableToolchains "" ) + set( __toolchainMaxVersion "0.0.0" ) + list( LENGTH __availableToolchains __availableToolchainsCount ) + math( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" ) + foreach( __idx RANGE ${__availableToolchainsCount} ) + list( GET __availableToolchainArchs ${__idx} __toolchainArch ) + if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME ) + list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion ) + if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion ) + set( __toolchainMaxVersion "${__toolchainVersion}" ) + set( __toolchainIdx ${__idx} ) + endif() + endif() + endforeach() + unset( __availableToolchainsCount ) + unset( __toolchainMaxVersion ) + unset( __toolchainVersion ) +endif() +unset( __toolchainArch ) +if( __toolchainIdx EQUAL -1 ) + message( FATAL_ERROR "No one of available compiler toolchains is able to compile for ${ANDROID_ARCH_NAME} platform." ) +endif() +list( GET __availableToolchains ${__toolchainIdx} ANDROID_TOOLCHAIN_NAME ) +list( GET __availableToolchainMachines ${__toolchainIdx} ANDROID_TOOLCHAIN_MACHINE_NAME ) +list( GET __availableToolchainCompilerVersions ${__toolchainIdx} ANDROID_COMPILER_VERSION ) + +unset( __toolchainIdx ) +unset( __availableToolchains ) +unset( __availableToolchainMachines ) +unset( __availableToolchainArchs ) +unset( __availableToolchainCompilerVersions ) + +# choose native API level +__INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL ) +string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" ) +# TODO: filter out unsupported levels +# validate +list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx ) +if( __levelIdx EQUAL -1 ) + message( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." ) +else() + if( BUILD_WITH_ANDROID_NDK ) + __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" ) + if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL ) + message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." ) + endif() + unset( __realApiLevel ) + endif() + set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE ) + if( CMAKE_VERSION VERSION_GREATER "2.8" ) + list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS ) + set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + endif() +endif() +unset( __levelIdx ) + + +# remember target ABI +set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE ) +if( CMAKE_VERSION VERSION_GREATER "2.8" ) + list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} ) + set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} ) +endif() + + +# runtime choice (STL, rtti, exceptions) +if( NOT ANDROID_STL ) + # honor legacy ANDROID_USE_STLPORT + if( DEFINED ANDROID_USE_STLPORT ) + if( ANDROID_USE_STLPORT ) + set( ANDROID_STL stlport_static ) + endif() + message( WARNING "You are using an obsolete variable ANDROID_USE_STLPORT to select the STL variant. Use -DANDROID_STL=stlport_static instead." ) + endif() + if( NOT ANDROID_STL ) + set( ANDROID_STL gnustl_static ) + endif() +endif() +set( ANDROID_STL "${ANDROID_STL}" CACHE STRING "C++ runtime" ) +set( ANDROID_STL_FORCE_FEATURES ON CACHE BOOL "automatically configure rtti and exceptions support based on C++ runtime" ) +mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES ) + +if( BUILD_WITH_ANDROID_NDK ) + if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared)$") + message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". +The possible values are: + none -> Do not configure the runtime. + system -> Use the default minimal system C++ runtime library. + system_re -> Same as system but with rtti and exceptions. + gabi++_static -> Use the GAbi++ runtime as a static library. + gabi++_shared -> Use the GAbi++ runtime as a shared library. + stlport_static -> Use the STLport runtime as a static library. + stlport_shared -> Use the STLport runtime as a shared library. + gnustl_static -> (default) Use the GNU STL as a static library. + gnustl_shared -> Use the GNU STL as a shared library. +" ) + endif() +elseif( BUILD_WITH_STANDALONE_TOOLCHAIN ) + if( NOT "${ANDROID_STL}" MATCHES "^(none|gnustl_static|gnustl_shared)$") + message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". +The possible values are: + none -> Do not configure the runtime. + gnustl_static -> (default) Use the GNU STL as a static library. + gnustl_shared -> Use the GNU STL as a shared library. +" ) + endif() +endif() + +unset( ANDROID_RTTI ) +unset( ANDROID_EXCEPTIONS ) +unset( ANDROID_STL_INCLUDE_DIRS ) +unset( __libstl ) +unset( __libsupcxx ) + +if( NOT _CMAKE_IN_TRY_COMPILE AND ANDROID_NDK_RELEASE STREQUAL "r7b" AND ARMEABI_V7A AND NOT VFPV3 AND ANDROID_STL MATCHES "gnustl" ) + message( WARNING "The GNU STL armeabi-v7a binaries from NDK r7b can crash non-NEON devices. The files provided with NDK r7b were not configured properly, resulting in crashes on Tegra2-based devices and others when trying to use certain floating-point functions (e.g., cosf, sinf, expf). +You are strongly recommended to switch to another NDK release. +" ) +endif() + +if( NOT _CMAKE_IN_TRY_COMPILE AND X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" ) + message( WARNING "The x86 system header file from NDK r6 has incorrect definition for ptrdiff_t. You are recommended to upgrade to a newer NDK release or manually patch the header: +See https://android.googlesource.com/platform/development.git f907f4f9d4e56ccc8093df6fee54454b8bcab6c2 + diff --git a/ndk/platforms/android-9/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h + index 5e28c64..65892a1 100644 + --- a/ndk/platforms/android-9/arch-x86/include/machine/_types.h + +++ b/ndk/platforms/android-9/arch-x86/include/machine/_types.h + @@ -51,7 +51,11 @@ typedef long int ssize_t; + #endif + #ifndef _PTRDIFF_T + #define _PTRDIFF_T + -typedef long ptrdiff_t; + +# ifdef __ANDROID__ + + typedef int ptrdiff_t; + +# else + + typedef long ptrdiff_t; + +# endif + #endif +" ) +endif() + + +# setup paths and STL for standalone toolchain +if( BUILD_WITH_STANDALONE_TOOLCHAIN ) + set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" ) + set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" ) + set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" ) + + if( NOT ANDROID_STL STREQUAL "none" ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" ) + if( ARMEABI_V7A AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" ) + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" ) + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" ) + else() + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" ) + endif() + # always search static GNU STL to get the location of libsupc++.a + if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb" ) + elseif( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb" ) + elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" ) + endif() + if( __libstl ) + set( __libsupcxx "${__libstl}/libsupc++.a" ) + set( __libstl "${__libstl}/libstdc++.a" ) + endif() + if( NOT EXISTS "${__libsupcxx}" ) + message( FATAL_ERROR "The required libstdsupc++.a is missing in your standalone toolchain. + Usually it happens because of bug in make-standalone-toolchain.sh script from NDK r7, r7b and r7c. + You need to either upgrade to newer NDK or manually copy + $ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a + to + ${__libsupcxx} + " ) + endif() + if( ANDROID_STL STREQUAL "gnustl_shared" ) + if( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" ) + elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" ) + endif() + endif() + endif() +endif() + +# clang +if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" ) + set( ANDROID_COMPILER_IS_CLANG 1 ) + execute_process( COMMAND "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/clang${TOOL_OS_SUFFIX}" --version OUTPUT_VARIABLE ANDROID_CLANG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) + string( REGEX MATCH "[0-9]+[.][0-9]+" ANDROID_CLANG_VERSION "${ANDROID_CLANG_VERSION}") +elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" ) + string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}") + string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) + if( NOT EXISTS "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}/bin/clang${TOOL_OS_SUFFIX}" ) + message( FATAL_ERROR "Could not find the " ) + endif() + set( ANDROID_COMPILER_IS_CLANG 1 ) + set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) +else() + set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) + unset( ANDROID_COMPILER_IS_CLANG CACHE ) +endif() + +string( REPLACE "." "" _clang_name "clang${ANDROID_CLANG_VERSION}" ) +if( NOT EXISTS "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" ) + set( _clang_name "clang" ) +endif() + + +# setup paths and STL for NDK +if( BUILD_WITH_ANDROID_NDK ) + set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) + set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" ) + + if( ANDROID_STL STREQUAL "none" ) + # do nothing + elseif( ANDROID_STL STREQUAL "system" ) + set( ANDROID_RTTI OFF ) + set( ANDROID_EXCEPTIONS OFF ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" ) + elseif( ANDROID_STL STREQUAL "system_re" ) + set( ANDROID_RTTI ON ) + set( ANDROID_EXCEPTIONS ON ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" ) + elseif( ANDROID_STL MATCHES "gabi" ) + if( ANDROID_NDK_RELEASE STRLESS "r7" ) + message( FATAL_ERROR "gabi++ is not awailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.") + endif() + set( ANDROID_RTTI ON ) + set( ANDROID_EXCEPTIONS OFF ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/gabi++/include" ) + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${ANDROID_NDK_ABI_NAME}/libgabi++_static.a" ) + elseif( ANDROID_STL MATCHES "stlport" ) + if( NOT ANDROID_NDK_RELEASE STRLESS "r8d" ) + set( ANDROID_EXCEPTIONS ON ) + else() + set( ANDROID_EXCEPTIONS OFF ) + endif() + if( ANDROID_NDK_RELEASE STRLESS "r7" ) + set( ANDROID_RTTI OFF ) + else() + set( ANDROID_RTTI ON ) + endif() + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" ) + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/stlport/libs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" ) + elseif( ANDROID_STL MATCHES "gnustl" ) + set( ANDROID_EXCEPTIONS ON ) + set( ANDROID_RTTI ON ) + if( EXISTS "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) + if( ARMEABI_V7A AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.7" AND ANDROID_NDK_RELEASE STREQUAL "r8d" ) + # gnustl binary for 4.7 compiler is buggy :( + # TODO: look for right fix + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.6" ) + else() + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) + endif() + else() + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" ) + endif() + set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" ) + if( EXISTS "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" ) + set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" ) + else() + set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + endif() + else() + message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" ) + endif() + # find libsupc++.a - rtti & exceptions + if( ANDROID_STL STREQUAL "system_re" OR ANDROID_STL MATCHES "gnustl" ) + if( ANDROID_NDK_RELEASE STRGREATER "r8" ) # r8b + set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) + elseif( NOT ANDROID_NDK_RELEASE STRLESS "r7" AND ANDROID_NDK_RELEASE STRLESS "r8b") + set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) + else( ANDROID_NDK_RELEASE STRLESS "r7" ) + if( ARMEABI_V7A ) + if( ANDROID_FORCE_ARM_BUILD ) + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" ) + else() + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" ) + endif() + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD ) + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" ) + else() + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" ) + endif() + endif() + if( NOT EXISTS "${__libsupcxx}") + message( ERROR "Could not find libsupc++.a for a chosen platform. Either your NDK is not supported or is broken.") + endif() + endif() +endif() + + +# case of shared STL linkage +if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl ) + string( REPLACE "_static.a" "_shared.so" __libstl "${__libstl}" ) + if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" ) + get_filename_component( __libstlname "${__libstl}" NAME ) + execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess ) + if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}") + message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" ) + endif() + unset( __fileCopyProcess ) + unset( __libstlname ) + endif() +endif() + + +# ccache support +__INIT_VARIABLE( _ndk_ccache NDK_CCACHE ENV_NDK_CCACHE ) +if( _ndk_ccache ) + if( DEFINED NDK_CCACHE AND NOT EXISTS NDK_CCACHE ) + unset( NDK_CCACHE CACHE ) + endif() + find_program( NDK_CCACHE "${_ndk_ccache}" DOC "The path to ccache binary") +else() + unset( NDK_CCACHE CACHE ) +endif() +unset( _ndk_ccache ) + + +# setup the cross-compiler +if( NOT CMAKE_C_COMPILER ) + if( NDK_CCACHE ) + set( CMAKE_C_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C compiler" ) + set( CMAKE_CXX_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C++ compiler" ) + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + else() + set( CMAKE_C_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + endif() + else() + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + else() + set( CMAKE_C_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler" ) + set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler" ) + endif() + endif() + set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" ) + set( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" ) + set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) + set( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" ) + set( CMAKE_NM "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" ) + set( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" ) + set( CMAKE_OBJDUMP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" ) + set( CMAKE_RANLIB "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib" ) +endif() + +set( _CMAKE_TOOLCHAIN_PREFIX "${ANDROID_TOOLCHAIN_MACHINE_NAME}-" ) +if( CMAKE_VERSION VERSION_LESS 2.8.5 ) + set( CMAKE_ASM_COMPILER_ARG1 "-c" ) +endif() +if( APPLE ) + find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool ) + if( NOT CMAKE_INSTALL_NAME_TOOL ) + message( FATAL_ERROR "Could not find install_name_tool, please check your installation." ) + endif() + mark_as_advanced( CMAKE_INSTALL_NAME_TOOL ) +endif() + +# Force set compilers because standard identification works badly for us +include( CMakeForceCompiler ) +CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU ) +if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER_ID Clang) +endif() +set( CMAKE_C_PLATFORM_ID Linux ) +set( CMAKE_C_SIZEOF_DATA_PTR 4 ) +set( CMAKE_C_HAS_ISYSROOT 1 ) +set( CMAKE_C_COMPILER_ABI ELF ) +CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU ) +if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_CXX_COMPILER_ID Clang) +endif() +set( CMAKE_CXX_PLATFORM_ID Linux ) +set( CMAKE_CXX_SIZEOF_DATA_PTR 4 ) +set( CMAKE_CXX_HAS_ISYSROOT 1 ) +set( CMAKE_CXX_COMPILER_ABI ELF ) +set( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C ) +# force ASM compiler (required for CMake < 2.8.5) +set( CMAKE_ASM_COMPILER_ID_RUN TRUE ) +set( CMAKE_ASM_COMPILER_ID GNU ) +set( CMAKE_ASM_COMPILER_WORKS TRUE ) +set( CMAKE_ASM_COMPILER_FORCED TRUE ) +set( CMAKE_COMPILER_IS_GNUASM 1) +set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm ) + +# flags and definitions +remove_definitions( -DANDROID ) +add_definitions( -DANDROID ) + +if(ANDROID_SYSROOT MATCHES "[ ;\"]") + set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" ) + if( NOT _CMAKE_IN_TRY_COMPILE ) + # quotes will break try_compile and compiler identification + message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.") + endif() +else() + set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" ) +endif() + +# NDK flags +if( ARMEABI OR ARMEABI_V7A ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__" ) + if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 ) + # It is recommended to use the -mthumb compiler flag to force the generation + # of 16-bit Thumb-1 instructions (the default being 32-bit ARM ones). + set( ANDROID_CXX_FLAGS_RELEASE "-mthumb" ) + set( ANDROID_CXX_FLAGS_DEBUG "-marm -finline-limit=64" ) + else() + # always compile ARMEABI_V6 in arm mode; otherwise there is no difference from ARMEABI + # O3 instead of O2/Os in release mode - like cmake sets for desktop gcc + set( ANDROID_CXX_FLAGS_RELEASE "-marm" ) + set( ANDROID_CXX_FLAGS_DEBUG "-marm -finline-limit=300" ) + endif() +elseif( X86 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + set( ANDROID_CXX_FLAGS_RELEASE "" ) + set( ANDROID_CXX_FLAGS_DEBUG "-finline-limit=300" ) +elseif( MIPS ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -frename-registers" ) + set( ANDROID_CXX_FLAGS_RELEASE "-finline-limit=300 -fno-strict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-finline-functions -fgcse-after-reload -frerun-cse-after-loop" ) +elseif() + set( ANDROID_CXX_FLAGS_RELEASE "" ) + set( ANDROID_CXX_FLAGS_DEBUG "" ) +endif() + +if( NOT X86 ) + set( ANDROID_CXX_FLAGS "-Wno-psabi ${ANDROID_CXX_FLAGS}" ) +endif() + +set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) # good/necessary when porting desktop libraries +set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -fomit-frame-pointer" ) +set( ANDROID_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer" ) + +# ABI-specific flags +if( ARMEABI_V7A ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp" ) + if( NEON ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" ) + elseif( VFPV3 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" ) + endif() +elseif( ARMEABI_V6 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" ) # vfp == vfpv2 +elseif( ARMEABI ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" ) +endif() + +# STL +if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" ) + if( ANDROID_STL MATCHES "gnustl" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o " ) + set( CMAKE_CXX_CREATE_SHARED_MODULE " -o " ) + set( CMAKE_CXX_LINK_EXECUTABLE " -o " ) + else() + set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o " ) + set( CMAKE_CXX_CREATE_SHARED_MODULE " -o " ) + set( CMAKE_CXX_LINK_EXECUTABLE " -o " ) + endif() + if ( X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" ) + # workaround "undefined reference to `__dso_handle'" problem + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) + endif() + if( EXISTS "${__libstl}" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libstl}\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libstl}\"" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libstl}\"" ) + endif() + if( EXISTS "${__libsupcxx}" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libsupcxx}\"" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libsupcxx}\"" ) + # C objects: + set( CMAKE_C_CREATE_SHARED_LIBRARY " -o " ) + set( CMAKE_C_CREATE_SHARED_MODULE " -o " ) + set( CMAKE_C_LINK_EXECUTABLE " -o " ) + set( CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"" ) + set( CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE} \"${__libsupcxx}\"" ) + set( CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} \"${__libsupcxx}\"" ) + endif() + if( ANDROID_STL MATCHES "gnustl" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} -lm" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} -lm" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lm" ) + endif() +endif() + +# variables controlling optional build flags +if (ANDROID_NDK_RELEASE STRLESS "r7") + # libGLESv2.so in NDK's prior to r7 refers to missing external symbols. + # So this flag option is required for all projects using OpenGL from native. + __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON ) +else() + __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF ) +endif() +__INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON ) +__INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON ) +__INIT_VARIABLE( ANDROID_GOLD_LINKER VALUES ON ) +__INIT_VARIABLE( ANDROID_NOEXECSTACK VALUES ON ) +__INIT_VARIABLE( ANDROID_RELRO VALUES ON ) + +set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" ) +set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) +set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) +set( ANDROID_GOLD_LINKER ${ANDROID_GOLD_LINKER} CACHE BOOL "Enables gold linker (only avaialble for NDK r8b for ARM and x86 architectures on linux-86 and darwin-x86 hosts)" ) +set( ANDROID_NOEXECSTACK ${ANDROID_NOEXECSTACK} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) +set( ANDROID_RELRO ${ANDROID_RELRO} CACHE BOOL "Enables RELRO - a memory corruption mitigation technique" ) +mark_as_advanced( ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_FUNCTION_LEVEL_LINKING ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO ) + +# linker flags +set( ANDROID_LINKER_FLAGS "" ) + +if( ARMEABI_V7A ) + # this is *required* to use the following linker flags that routes around + # a CPU bug in some Cortex-A8 implementations: + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--fix-cortex-a8" ) +endif() + +if( ANDROID_NO_UNDEFINED ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" ) +endif() + +if( ANDROID_SO_UNDEFINED ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-allow-shlib-undefined" ) +endif() + +if( ANDROID_FUNCTION_LEVEL_LINKING ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" ) +endif() + +if( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" ) + if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE STRGREATER "r8b") AND (ARMEABI OR ARMEABI_V7A OR X86) ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" ) + elseif( ANDROID_NDK_RELEASE STRGREATER "r8b") + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" ) + elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342 + On Linux and OS X host platform you can workaround this problem using gold linker (default). + Rerun cmake with -DANDROID_GOLD_LINKER=ON option in case of problems. +" ) + endif() +endif() # version 4.6 + +if( ANDROID_NOEXECSTACK ) + if( ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Xclang -mnoexecstack" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" ) + endif() + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,noexecstack" ) +endif() + +if( ANDROID_RELRO ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,relro -Wl,-z,now" ) +endif() + +if( ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "-Qunused-arguments ${ANDROID_CXX_FLAGS}" ) + if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD ) + set( ANDROID_CXX_FLAGS_RELEASE "-target thumbv7-none-linux-androideabi ${ANDROID_CXX_FLAGS_RELEASE}" ) + set( ANDROID_CXX_FLAGS_DEBUG "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS_DEBUG}" ) + else() + set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS}" ) + endif() + if( BUILD_WITH_ANDROID_NDK ) + if(ANDROID_ARCH_NAME STREQUAL "arm" ) + set( ANDROID_CXX_FLAGS "-isystem ${ANDROID_CLANG_TOOLCHAIN_ROOT}/lib/clang/${ANDROID_CLANG_VERSION}/include ${ANDROID_CXX_FLAGS}" ) + endif() + set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" ) + endif() +endif() + +# cache flags +set( CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags" ) +set( CMAKE_C_FLAGS "" CACHE STRING "c flags" ) +set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c++ Release flags" ) +set( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c Release flags" ) +set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c++ Debug flags" ) +set( CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c Debug flags" ) +set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags" ) +set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags" ) +set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker flags" ) + +# finish flags +set( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" ) +set( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" ) +set( CMAKE_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}" ) +set( CMAKE_C_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELEASE}" ) +set( CMAKE_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}" ) +set( CMAKE_C_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_C_FLAGS_DEBUG}" ) +set( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" ) +set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" ) +set( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" ) + +if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" ) + set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" ) + set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" ) + set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" ) +endif() + +# configure rtti +if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES ) + if( ANDROID_RTTI ) + set( CMAKE_CXX_FLAGS "-frtti ${CMAKE_CXX_FLAGS}" ) + else() + set( CMAKE_CXX_FLAGS "-fno-rtti ${CMAKE_CXX_FLAGS}" ) + endif() +endif() + +# configure exceptios +if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES ) + if( ANDROID_EXCEPTIONS ) + set( CMAKE_CXX_FLAGS "-fexceptions ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fexceptions ${CMAKE_C_FLAGS}" ) + else() + set( CMAKE_CXX_FLAGS "-fno-exceptions ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fno-exceptions ${CMAKE_C_FLAGS}" ) + endif() +endif() + +# global includes and link directories +include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} ) +link_directories( "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ) + +# setup output directories +set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" ) +set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" ) + +if(NOT _CMAKE_IN_TRY_COMPILE) + if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" ) + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" ) + else() + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" ) + endif() + set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" ) +endif() + +# set these global flags for cmake client scripts to change behavior +set( ANDROID True ) +set( BUILD_ANDROID True ) + +# where is the target environment +set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_ROOT}/bin" "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" "${ANDROID_SYSROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" ) + +# only search for libraries and includes in the ndk toolchain +set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) + + +# macro to find packages on the host OS +macro( find_host_package ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) + if( CMAKE_HOST_WIN32 ) + SET( WIN32 1 ) + SET( UNIX ) + elseif( CMAKE_HOST_APPLE ) + SET( APPLE 1 ) + SET( UNIX ) + endif() + find_package( ${ARGN} ) + SET( WIN32 ) + SET( APPLE ) + SET( UNIX 1 ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +endmacro() + + +# macro to find programs on the host OS +macro( find_host_program ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) + if( CMAKE_HOST_WIN32 ) + SET( WIN32 1 ) + SET( UNIX ) + elseif( CMAKE_HOST_APPLE ) + SET( APPLE 1 ) + SET( UNIX ) + endif() + find_program( ${ARGN} ) + SET( WIN32 ) + SET( APPLE ) + SET( UNIX 1 ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +endmacro() + + +macro( ANDROID_GET_ABI_RAWNAME TOOLCHAIN_FLAG VAR ) + if( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI" ) + set( ${VAR} "armeabi" ) + elseif( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI_V7A" ) + set( ${VAR} "armeabi-v7a" ) + elseif( "${TOOLCHAIN_FLAG}" STREQUAL "X86" ) + set( ${VAR} "x86" ) + elseif( "${TOOLCHAIN_FLAG}" STREQUAL "MIPS" ) + set( ${VAR} "mips" ) + else() + set( ${VAR} "unknown" ) + endif() +endmacro() + + +# export toolchain settings for the try_compile() command +if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" ) + set( __toolchain_config "") + foreach( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN ANDROID_SET_OBSOLETE_VARIABLES + ANDROID_NDK + ANDROID_STANDALONE_TOOLCHAIN + ANDROID_TOOLCHAIN_NAME + ANDROID_ABI + ANDROID_NATIVE_API_LEVEL + ANDROID_STL + ANDROID_STL_FORCE_FEATURES + ANDROID_FORCE_ARM_BUILD + ANDROID_NO_UNDEFINED + ANDROID_SO_UNDEFINED + ANDROID_FUNCTION_LEVEL_LINKING + ANDROID_GOLD_LINKER + ANDROID_NOEXECSTACK + ANDROID_RELRO + ) + if( DEFINED ${__var} ) + if( "${__var}" MATCHES " ") + set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" CACHE INTERNAL \"\" )\n" ) + else() + set( __toolchain_config "${__toolchain_config}set( ${__var} ${${__var}} CACHE INTERNAL \"\" )\n" ) + endif() + endif() + endforeach() + file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/android.toolchain.config.cmake" "${__toolchain_config}" ) + unset( __toolchain_config ) +endif() + + +# set some obsolete variables for backward compatibility +set( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" ) +mark_as_advanced( ANDROID_SET_OBSOLETE_VARIABLES ) +if( ANDROID_SET_OBSOLETE_VARIABLES ) + set( ANDROID_API_LEVEL ${ANDROID_NATIVE_API_LEVEL} ) + set( ARM_TARGET "${ANDROID_ABI}" ) + set( ARMEABI_NDK_NAME "${ANDROID_NDK_ABI_NAME}" ) +endif() + + +# Variables controlling behavior or set by cmake toolchain: +# ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips" +# ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version) +# ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none +# ANDROID_FORBID_SYGWIN : ON/OFF +# ANDROID_NO_UNDEFINED : ON/OFF +# ANDROID_SO_UNDEFINED : OFF/ON (default depends on NDK version) +# ANDROID_FUNCTION_LEVEL_LINKING : ON/OFF +# ANDROID_GOLD_LINKER : ON/OFF +# ANDROID_NOEXECSTACK : ON/OFF +# ANDROID_RELRO : ON/OFF +# ANDROID_FORCE_ARM_BUILD : ON/OFF +# ANDROID_STL_FORCE_FEATURES : ON/OFF +# ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF +# Can be set only at the first run: +# ANDROID_NDK +# ANDROID_STANDALONE_TOOLCHAIN +# ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain +# LIBRARY_OUTPUT_PATH_ROOT : +# NDK_CCACHE : +# Obsolete: +# ANDROID_API_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL +# ARM_TARGET : superseded by ANDROID_ABI +# ARM_TARGETS : superseded by ANDROID_ABI (can be set only) +# ANDROID_NDK_TOOLCHAIN_ROOT : superseded by ANDROID_STANDALONE_TOOLCHAIN (can be set only) +# ANDROID_USE_STLPORT : superseded by ANDROID_STL=stlport_static +# ANDROID_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL (completely removed) +# +# Primary read-only variables: +# ANDROID : always TRUE +# ARMEABI : TRUE for arm v6 and older devices +# ARMEABI_V6 : TRUE for arm v6 +# ARMEABI_V7A : TRUE for arm v7a +# NEON : TRUE if NEON unit is enabled +# VFPV3 : TRUE if VFP version 3 is enabled +# X86 : TRUE if configured for x86 +# MIPS : TRUE if configured for mips +# BUILD_ANDROID : always TRUE +# BUILD_WITH_ANDROID_NDK : TRUE if NDK is used +# BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used +# ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform +# ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86" or "mips" depending on ANDROID_ABI +# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d; set only for NDK +# ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI +# ANDROID_SYSROOT : path to the compiler sysroot +# TOOL_OS_SUFFIX : "" or ".exe" depending on host platform +# ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used +# Obsolete: +# ARMEABI_NDK_NAME : superseded by ANDROID_NDK_ABI_NAME +# +# Secondary (less stable) read-only variables: +# ANDROID_COMPILER_VERSION : GCC version used +# ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform +# ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI +# ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux" +# ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK) +# ANDROID_CLANG_TOOLCHAIN_ROOT : path to clang tools +# ANDROID_SUPPORTED_NATIVE_API_LEVELS : list of native API levels found inside NDK +# ANDROID_STL_INCLUDE_DIRS : stl include paths +# ANDROID_RTTI : if rtti is enabled by the runtime +# ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime +# ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used +# ANDROID_CLANG_VERSION : version of clang compiler if clang is used +# +# Defaults: +# ANDROID_DEFAULT_NDK_API_LEVEL +# ANDROID_DEFAULT_NDK_API_LEVEL_${ARCH} +# ANDROID_NDK_SEARCH_PATHS +# ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH +# ANDROID_SUPPORTED_ABIS_${ARCH} +# ANDROID_SUPPORTED_NDK_VERSIONS diff --git a/android/scripts/cmake_android.sh b/android/scripts/cmake_android.sh new file mode 100755 index 000000000..539e4f18b --- /dev/null +++ b/android/scripts/cmake_android.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd `dirname $0`/.. + +mkdir -p build +cd build + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/android/scripts/cmake_android_armeabi.sh b/android/scripts/cmake_android_armeabi.sh new file mode 100755 index 000000000..c740010f1 --- /dev/null +++ b/android/scripts/cmake_android_armeabi.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd `dirname $0`/.. + +mkdir -p build_armeabi +cd build_armeabi + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DANDROID_ABI=armeabi -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/android/scripts/cmake_android_mips.sh b/android/scripts/cmake_android_mips.sh new file mode 100755 index 000000000..0e85eef8a --- /dev/null +++ b/android/scripts/cmake_android_mips.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd `dirname $0`/.. + +mkdir -p build_mips +cd build_mips + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DANDROID_ABI=mips -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/android/scripts/cmake_android_neon.sh b/android/scripts/cmake_android_neon.sh new file mode 100755 index 000000000..b4bcd76fb --- /dev/null +++ b/android/scripts/cmake_android_neon.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd `dirname $0`/.. + +mkdir -p build_neon +cd build_neon + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + diff --git a/android/scripts/cmake_android_x86.sh b/android/scripts/cmake_android_x86.sh new file mode 100755 index 000000000..2260fd886 --- /dev/null +++ b/android/scripts/cmake_android_x86.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +cd `dirname $0`/.. + +mkdir -p build_x86 +cd build_x86 + +cmake -DANDROID_NATIVE_API_LEVEL=android-9 -DANDROID_ABI=x86 -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. + From 0ecbcda5d25c5c9784e012828a0686894064f3d2 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Mar 2013 20:30:24 +0100 Subject: [PATCH 073/226] CMakeLists.txt: Generate defines.hxx.cmake from defines.hxx.in by doing a bit of string manipulation. defines.hxx.cmake.in: Remove. --- CMakeLists.txt | 15 +- include/log4cplus/config/defines.hxx.cmake.in | 242 ------------------ 2 files changed, 11 insertions(+), 246 deletions(-) delete mode 100644 include/log4cplus/config/defines.hxx.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cddc9851..8a1f17ad9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,10 +67,17 @@ set (log4cplus "log4cplus${log4cplus_postfix}") include(ConfigureChecks.cmake) -configure_file(include/log4cplus/config.h.cmake.in - ${log4cplus_BINARY_DIR}/include/log4cplus/config.h @ONLY) -configure_file(include/log4cplus/config/defines.hxx.cmake.in - ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx @ONLY) +# Prepare defines.hxx.cmake from defines.hxx.in by doing a bit of +# string manipulation. +file(READ include/log4cplus/config/defines.hxx.in FILE_BUFFER) +string(REGEX REPLACE "#undef[^a-zA-Z0-9_]+([a-zA-Z0-9_]+)" + "#cmakedefine \\1 @\\1@" FILE_BUFFER "${FILE_BUFFER}") +set(DEFINES_HXX_CMAKE + ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx.cmake) +set(DEFINES_HXX ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx) +file(WRITE ${DEFINES_HXX_CMAKE} ${FILE_BUFFER}) + +configure_file(${DEFINES_HXX_CMAKE} ${DEFINES_HXX} @ONLY) include_directories (${log4cplus_SOURCE_DIR}/include ${log4cplus_BINARY_DIR}/include diff --git a/include/log4cplus/config/defines.hxx.cmake.in b/include/log4cplus/config/defines.hxx.cmake.in deleted file mode 100644 index 87678ca72..000000000 --- a/include/log4cplus/config/defines.hxx.cmake.in +++ /dev/null @@ -1,242 +0,0 @@ -#ifndef LOG4CPLUS_CONFIG_DEFINES_HXX -#define LOG4CPLUS_CONFIG_DEFINES_HXX - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYSLOG_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_ARPA_INET_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NETINET_IN_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NETINET_TCP_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_TIMEB_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_TIME_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_TYPES_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_STAT_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_SYSCALL_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_FILE_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_TIME_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_SYS_SOCKET_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NETDB_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_UNISTD_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_FCNTL_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_STDARG_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_STDIO_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_STDLIB_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_ERRNO_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_WCHAR_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_ICONV_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_LIMITS_H 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_FTIME 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GETADDRINFO 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GETHOSTBYNAME_R 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GETPID 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the `clock_gettime' function. */ -#cmakedefine LOG4CPLUS_HAVE_CLOCK_GETTIME 1 - -/* Define to 1 if you have the `nanosleep' function. */ -#cmakedefine LOG4CPLUS_HAVE_NANOSLEEP 1 - -/* Define to 1 if you have the `clock_nanosleep' function. */ -#cmakedefine LOG4CPLUS_HAVE_CLOCK_NANOSLEEP 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GMTIME_R 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_HTONL 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_HTONS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_LOCALTIME_R 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_LSTAT 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_FCNTL 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_LOCKF 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_FLOCK 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NTOHL 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_NTOHS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_STAT 1 - -/* Define if this is a single-threaded library. */ -#undef LOG4CPLUS_SINGLE_THREADED - -/* */ -#undef LOG4CPLUS_USE_PTHREADS - -/* Define for compilers/standard libraries that support more than just the "C" - locale. */ -#cmakedefine LOG4CPLUS_WORKING_LOCALE 1 - -/* Define for C99 compilers/standard libraries that support more than just the - "C" locale. */ -#cmakedefine LOG4CPLUS_WORKING_C_LOCALE 1 - -/* Define to int if undefined. */ -#cmakedefine socklen_t int - -/* Defined for --enable-debugging builds. */ -/* this is not used anywhere #undef LOG4CPLUS_DEBUGGING */ - -/* Defined if the compiler understands __declspec(export) or __attribute__((export)) construct. */ -#cmakedefine LOG4CPLUS_DECLSPEC_EXPORT @LOG4CPLUS_DECLSPEC_EXPORT@ - -/* Defined if the compiler understands __declspec(import) or __attribute__((import)) construct. */ -#cmakedefine LOG4CPLUS_DECLSPEC_IMPORT @LOG4CPLUS_DECLSPEC_IMPORT@ /**/ - -/* Defined if the compiler understands - __attribute__((visibility("hidden"))) construct. */ -#cmakedefine LOG4CPLUS_DECLSPEC_PRIVATE @LOG4CPLUS_DECLSPEC_PRIVATE@ - -/* */ -#cmakedefine LOG4CPLUS_HAVE_TLS_SUPPORT 1 - -/* */ -#cmakedefine LOG4CPLUS_THREAD_LOCAL_VAR @LOG4CPLUS_THREAD_LOCAL_VAR@ - -/* Defined if the host OS provides ENAMETOOLONG errno value. */ -#cmakedefine LOG4CPLUS_HAVE_ENAMETOOLONG 1 - -/* Defined if the compiler provides __sync_add_and_fetch(). */ -#cmakedefine LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH 1 - -/* Defined if the compiler provides __sync_sub_and_fetch(). */ -#cmakedefine LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH 1 - -/* Defined if the compiler provides C++11 header and increment, - decrement operations. */ -#cmakedefine LOG4CPLUS_HAVE_CXX11_ATOMICS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_C99_VARIADIC_MACROS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE_VSNPRINTF 1 - -/* Define to 1 if you have the `vsnwprintf' function. */ -#cmakedefine LOG4CPLUS_HAVE_VSNWPRINTF 1 - -/* Define to 1 if you have the `_vsnwprintf' function. */ -#cmakedefine LOG4CPLUS_HAVE__VSNWPRINTF 1 - -/* */ -#cmakedefine LOG4CPLUS_HAVE__VSNPRINTF 1 - -/* Define to 1 if you have the `vfprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE_VFPRINTF_S 1 - -/* Define to 1 if you have the `vfwprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE_VFWPRINTF_S 1 - -/* Define to 1 if you have the `vsprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE_VSPRINTF_S 1 - -/* Define to 1 if you have the `vswprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE_VSWPRINTF_S 1 - -/* Define to 1 if you have the `_vsnprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE__VSNPRINTF_S 1 - -/* Define to 1 if you have the `_vsnwprintf_s' function. */ -#cmakedefine LOG4CPLUS_HAVE__VSNWPRINTF_S 1 - -/* Defined if the compiler supports __FUNCTION__ macro. */ -#cmakedefine LOG4CPLUS_HAVE_FUNCTION_MACRO 1 - -/* Defined if the compiler supports __PRETTY_FUNCTION__ macro. */ -#cmakedefine LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO 1 - -/* Defined if the compiler supports __func__ symbol. */ -#cmakedefine LOG4CPLUS_HAVE_FUNC_SYMBOL 1 - -/* Define to 1 if you have the `mbstowcs' function. */ -#cmakedefine LOG4CPLUS_HAVE_MBSTOWCS 1 - -/* Define to 1 if you have the `wcstombs' function. */ -#cmakedefine LOG4CPLUS_HAVE_WCSTOMBS 1 - -/* Define to 1 if you have Linux style syscall(SYS_gettid). */ -#cmakedefine LOG4CPLUS_HAVE_GETTID 1 - -/* Define when iconv() is available. */ -#cmakedefine LOG4CPLUS_WITH_ICONV 1 - -/* Define to 1 if you have the `iconv' function. */ -#cmakedefine LOG4CPLUS_HAVE_ICONV 1 - -/* Define to 1 if you have the `iconv_close' function. */ -#cmakedefine LOG4CPLUS_HAVE_ICONV_CLOSE 1 - -/* Define to 1 if you have the `iconv_open' function. */ -#cmakedefine LOG4CPLUS_HAVE_ICONV_OPEN 1 - -#endif // LOG4CPLUS_CONFIG_DEFINES_HXX From 368ff5f6e7440b490745f7447c206433b0cac2e5 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Mar 2013 20:31:28 +0100 Subject: [PATCH 074/226] stringhelper-iconv.cxx: Do not let exception escape ~iconv_handle(). --- src/stringhelper-iconv.cxx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/stringhelper-iconv.cxx b/src/stringhelper-iconv.cxx index 987c30d26..2e4d6c67e 100644 --- a/src/stringhelper-iconv.cxx +++ b/src/stringhelper-iconv.cxx @@ -76,7 +76,7 @@ struct iconv_handle if (handle == iconv_error_handle) { std::ostringstream oss; - oss << "iconv_open failed: " << errno; + oss << "iconv_open(" << to << ", " << from << ") failed: " << errno; std::cerr << oss.str () << std::endl; throw std::runtime_error (oss.str ().c_str ()); } @@ -84,17 +84,22 @@ struct iconv_handle ~iconv_handle () { - if (handle != iconv_error_handle) + try { - int ret = iconv_close (handle); - if (ret == -1) + if (handle != iconv_error_handle) { - std::ostringstream oss; - oss << "iconv_close failed: " << errno; - std::cerr << oss.str () << std::endl; - throw std::runtime_error (oss.str ().c_str ()); + int ret = iconv_close (handle); + if (ret == -1) + { + std::ostringstream oss; + oss << "iconv_close failed: " << errno; + std::cerr << oss.str () << std::endl; + throw std::runtime_error (oss.str ().c_str ()); + } } } + catch (std::runtime_error const &) + { } } size_t From 63771b0e805fe37faa2e224b5f344f52871765b8 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Mar 2013 20:33:43 +0100 Subject: [PATCH 075/226] CMakeLists.txt: Synchronize version and SO version with configure.ac. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a1f17ad9..771a4e404 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,8 @@ cmake_minimum_required (VERSION 2.8.0) set (log4cplus_version_major 1) set (log4cplus_version_minor 1) -set (log4cplus_version_patch 0) -set (log4cplus_soversion 0) +set (log4cplus_version_patch 1) +set (log4cplus_soversion 6) set (log4cplus_postfix "") option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) From 948db9e0197486f39b461a88c05b249ca872daf8 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 14 Mar 2013 14:52:17 +0100 Subject: [PATCH 076/226] CMakeLists.txt: Parse log4cplus version out of version.h. Log4CPlusUtils.cmake: Helper macros. Patch provided by: Sergey Nikulov --- CMakeLists.txt | 7 ++++--- Log4CPlusUtils.cmake | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 Log4CPlusUtils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 771a4e404..5500202bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,10 @@ endif () project (log4cplus) cmake_minimum_required (VERSION 2.8.0) -set (log4cplus_version_major 1) -set (log4cplus_version_minor 1) -set (log4cplus_version_patch 1) +include (Log4CPlusUtils.cmake) +log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include" + log4cplus_version_major log4cplus_version_minor log4cplus_version_patch) +message("-- Generating build for Log4cplus version ${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") set (log4cplus_soversion 6) set (log4cplus_postfix "") diff --git a/Log4CPlusUtils.cmake b/Log4CPlusUtils.cmake new file mode 100644 index 000000000..f63ea9d9b --- /dev/null +++ b/Log4CPlusUtils.cmake @@ -0,0 +1,17 @@ +# +# Utility macros for Log4Cplus project +# + +# Get Log4cplus version macro +# first param - path to include folder, we will rip version from version.h +macro(log4cplus_get_version _include_PATH vmajor vminor vpatch) + file(STRINGS "${_include_PATH}/log4cplus/version.h" _log4cplus_VER_STRING_AUX REGEX ".*#define[ ]+LOG4CPLUS_VERSION[ ]+") + string(REGEX MATCHALL "[0-9]+" _log4clpus_VER_LIST "${_log4cplus_VER_STRING_AUX}") + list(LENGTH _log4clpus_VER_LIST _log4cplus_VER_LIST_LEN) +# we also count '4' from the name... + if(_log4cplus_VER_LIST_LEN EQUAL 5) + list(GET _log4clpus_VER_LIST 2 ${vmajor}) + list(GET _log4clpus_VER_LIST 3 ${vminor}) + list(GET _log4clpus_VER_LIST 4 ${vpatch}) + endif() +endmacro() From 07bd5cb078a979d5e1bbd07bcc098ab2c8a2c81b Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 28 Mar 2013 23:01:41 +0100 Subject: [PATCH 077/226] stringhelper.h: Fix two -Wconversion warnings. --- include/log4cplus/helpers/stringhelper.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/helpers/stringhelper.h b/include/log4cplus/helpers/stringhelper.h index 30e6ae77f..0b110d641 100644 --- a/include/log4cplus/helpers/stringhelper.h +++ b/include/log4cplus/helpers/stringhelper.h @@ -116,7 +116,7 @@ namespace log4cplus { intType const mod = -(a + value); value = -r; - *(it - 1) = LOG4CPLUS_TEXT('0') + static_cast(mod); + *(it - 1) = static_cast(LOG4CPLUS_TEXT('0') + mod); --it; } else @@ -180,7 +180,7 @@ namespace log4cplus { { intType mod = value % 10; value = value / 10; - *(it - 1) = LOG4CPLUS_TEXT('0') + static_cast(mod); + *(it - 1) = static_cast(LOG4CPLUS_TEXT('0') + mod); } if (negative) From a87c0056e89122aef0d5b8b19ee85511f474113d Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 28 Mar 2013 23:04:01 +0100 Subject: [PATCH 078/226] ConfigureChecks.cmake: Fix detection of some sys/* headers on OpenBSD. Add sys/types.h into the check. --- ConfigureChecks.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index d62cd4c02..83381e2bd 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -12,16 +12,16 @@ check_include_files(errno.h LOG4CPLUS_HAVE_ERRNO_H ) check_include_files(iconv.h LOG4CPLUS_HAVE_ICONV_H ) check_include_files(limits.h LOG4CPLUS_HAVE_LIMITS_H ) check_include_files(sys/types.h LOG4CPLUS_HAVE_SYS_TYPES_H ) -check_include_files(sys/socket.h LOG4CPLUS_HAVE_SYS_SOCKET_H ) +check_include_files("sys/types.h;sys/socket.h" LOG4CPLUS_HAVE_SYS_SOCKET_H ) check_include_files(sys/syscall.h LOG4CPLUS_HAVE_SYS_SYSCALL_H ) -check_include_files(sys/time.h LOG4CPLUS_HAVE_SYS_TIME_H ) -check_include_files(sys/timeb.h LOG4CPLUS_HAVE_SYS_TIMEB_H ) -check_include_files(sys/stat.h LOG4CPLUS_HAVE_SYS_STAT_H ) +check_include_files("sys/types.h;sys/time.h" LOG4CPLUS_HAVE_SYS_TIME_H ) +check_include_files("sys/types.h;sys/timeb.h" LOG4CPLUS_HAVE_SYS_TIMEB_H ) +check_include_files("sys/types.h;sys/stat.h" LOG4CPLUS_HAVE_SYS_STAT_H ) check_include_files(sys/file.h LOG4CPLUS_HAVE_SYS_FILE_H ) check_include_files(syslog.h LOG4CPLUS_HAVE_SYSLOG_H ) check_include_files(arpa/inet.h LOG4CPLUS_HAVE_ARPA_INET_H ) check_include_files(netinet/in.h LOG4CPLUS_HAVE_NETINET_IN_H ) -check_include_files(netinet/tcp.h LOG4CPLUS_HAVE_NETINET_TCP_H ) +check_include_files("sys/types.h;netinet/tcp.h" LOG4CPLUS_HAVE_NETINET_TCP_H ) check_include_files(netdb.h LOG4CPLUS_HAVE_NETDB_H ) check_include_files(unistd.h LOG4CPLUS_HAVE_UNISTD_H ) check_include_files(fcntl.h LOG4CPLUS_HAVE_FCNTL_H ) From 2667ccd20f96cd518842611c4bda1ded2dbd4b75 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 28 Mar 2013 23:11:32 +0100 Subject: [PATCH 079/226] Implement cooperative ServerSocket::accept() interruption for Windows. --- include/log4cplus/helpers/socket.h | 7 +- src/socket-win32.cxx | 256 ++++++++++++++++++++++------- src/socket.cxx | 36 ---- 3 files changed, 202 insertions(+), 97 deletions(-) diff --git a/include/log4cplus/helpers/socket.h b/include/log4cplus/helpers/socket.h index ba148ef71..b2f7031eb 100644 --- a/include/log4cplus/helpers/socket.h +++ b/include/log4cplus/helpers/socket.h @@ -43,7 +43,8 @@ namespace log4cplus { connection_failed, broken_pipe, invalid_access_mode, - message_truncated + message_truncated, + accept_interrupted }; typedef std::ptrdiff_t SOCKET_TYPE; @@ -110,6 +111,10 @@ namespace log4cplus { virtual ~ServerSocket(); Socket accept(); + void interruptAccept (); + + protected: + std::ptrdiff_t interruptHandles[2]; }; diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index dc4af1323..1504f96cf 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -262,68 +262,14 @@ acceptSocket(SOCKET_TYPE sock, SocketState & state) { init_winsock (); - SOCKET osSocket = to_os_socket (sock); + SOCKET connected_socket = ::accept (to_os_socket (sock), NULL, NULL); - // Check that the socket is ok. - - int val = 0; - int optlen = sizeof (val); - int ret = getsockopt (osSocket, SOL_SOCKET, SO_TYPE, - reinterpret_cast(&val), &optlen); - if (ret == SOCKET_ERROR) - goto error; - - // Now that we know the socket is working ok we can wait for - // either a new connection or for a transition to bad state. - - while (1) - { - fd_set readSet; - timeval timeout; - - FD_ZERO (&readSet); - FD_SET (osSocket, &readSet); - timeout.tv_sec = 0; - timeout.tv_usec = 200 * 1000; - - int selectResponse = ::select (1, &readSet, NULL, NULL, &timeout); - if (selectResponse < 0) - { - DWORD const eno = WSAGetLastError (); - if (eno == WSAENOTSOCK || eno == WSAEINVAL) - WSASetLastError (ERROR_NO_DATA); - - goto error; - } - else if (selectResponse == 0) - // Timeout. - continue; - else if (selectResponse == 1) - { - SOCKET connected_socket = ::accept (osSocket, NULL, NULL); - - if (connected_socket != INVALID_OS_SOCKET_VALUE) - state = ok; - else - goto error; - - return to_log4cplus_socket (connected_socket); - } - else - { - helpers::getLogLog ().error ( - LOG4CPLUS_TEXT ("unexpected select() return value: ") - + helpers::convertIntegerToString (selectResponse)); - WSASetLastError (ERROR_UNSUPPORTED_TYPE); - goto error; - } - } - -error: - DWORD eno = WSAGetLastError (); - set_last_socket_error (eno); + if (connected_socket != INVALID_OS_SOCKET_VALUE) + state = ok; + else + set_last_socket_error (WSAGetLastError ()); - return to_log4cplus_socket (INVALID_SOCKET); + return to_log4cplus_socket (connected_socket); } @@ -441,6 +387,196 @@ setTCPNoDelay (SOCKET_TYPE sock, bool val) } +// +// ServerSocket OS dependent stuff +// + +namespace +{ + +static +bool +setSocketBlocking (SOCKET_TYPE s) +{ + u_long val = 0; + int ret = ioctlsocket (to_os_socket (s), FIONBIO, &val); + if (ret == SOCKET_ERROR) + { + set_last_socket_error (WSAGetLastError ()); + return false; + } + else + return true; +} + +static +bool +removeSocketEvents (SOCKET_TYPE s, HANDLE ev) +{ + // Clean up socket events handling. + + int ret = WSAEventSelect (to_os_socket (s), ev, 0); + if (ret == SOCKET_ERROR) + { + set_last_socket_error (WSAGetLastError ()); + return false; + } + else + return true; +} + + +static +bool +socketEventHandlingCleanup (SOCKET_TYPE s, HANDLE ev) +{ + bool ret = removeSocketEvents (s, ev); + ret = setSocketBlocking (s) && ret; + ret = WSACloseEvent (ev) && ret; + return ret; +} + + +} // namespace + + +ServerSocket::ServerSocket(unsigned short port) +{ + sock = openSocket (port, state); + if (sock == INVALID_SOCKET_VALUE) + { + err = get_last_socket_error (); + return; + } + + HANDLE ev = WSACreateEvent (); + if (ev == WSA_INVALID_EVENT) + { + err = WSAGetLastError (); + closeSocket (sock); + sock = INVALID_SOCKET_VALUE; + } + else + { + assert (sizeof (std::ptrdiff_t) >= sizeof (HANDLE)); + interruptHandles[0] = reinterpret_cast(ev); + } +} + +Socket +ServerSocket::accept () +{ + int const N_EVENTS = 2; + HANDLE events[N_EVENTS] = { + reinterpret_cast(interruptHandles[0]) }; + HANDLE & accept_ev = events[1]; + int ret; + + // Create event and prime socket to set the event on FD_ACCEPT. + + accept_ev = WSACreateEvent (); + if (accept_ev == WSA_INVALID_EVENT) + { + set_last_socket_error (WSAGetLastError ()); + goto error; + } + + ret = WSAEventSelect (to_os_socket (sock), accept_ev, FD_ACCEPT); + if (ret == SOCKET_ERROR) + { + set_last_socket_error (WSAGetLastError ()); + goto error; + } + + do + { + // Wait either for interrupt event or actual connection coming in. + + DWORD wsawfme = WSAWaitForMultipleEvents (N_EVENTS, events, FALSE, + WSA_INFINITE, TRUE); + switch (wsawfme) + { + case WSA_WAIT_TIMEOUT: + case WSA_WAIT_IO_COMPLETION: + // Retry after timeout or APC. + continue; + + // This is interrupt signal/event. + case WSA_WAIT_EVENT_0: + { + // Reset the interrupt event back to non-signalled state. + + ret = WSAResetEvent (reinterpret_cast(interruptHandles[0])); + + // Clean up socket events handling. + + ret = socketEventHandlingCleanup (sock, accept_ev); + + // Return Socket with state set to accept_interrupted. + + return Socket (INVALID_SOCKET_VALUE, accept_interrupted, 0); + } + + // This is accept_ev. + case WSA_WAIT_EVENT_0 + 1: + { + // Clean up socket events handling. + + ret = socketEventHandlingCleanup (sock, accept_ev); + + // Finally, call accept(). + + SocketState st = not_opened; + SOCKET_TYPE clientSock = acceptSocket (sock, st); + int eno = 0; + if (clientSock == INVALID_SOCKET_VALUE) + eno = get_last_socket_error (); + + return Socket (clientSock, st, eno); + } + + case WSA_WAIT_FAILED: + default: + set_last_socket_error (WSAGetLastError ()); + goto error; + } + } + while (true); + + +error:; + DWORD eno = get_last_socket_error (); + + // Clean up socket events handling. + + if (sock != INVALID_SOCKET_VALUE) + { + (void) removeSocketEvents (sock, accept_ev); + (void) setSocketBlocking (sock); + } + + if (accept_ev != WSA_INVALID_EVENT) + WSACloseEvent (accept_ev); + + set_last_socket_error (eno); + return Socket (INVALID_SOCKET_VALUE, not_opened, eno); +} + + +void +ServerSocket::interruptAccept () +{ + (void) WSASetEvent (reinterpret_cast(interruptHandles[0])); +} + + +ServerSocket::~ServerSocket() +{ + (void) WSACloseEvent (reinterpret_cast(interruptHandles[0])); +} + + + } } // namespace log4cplus { namespace helpers { #endif // LOG4CPLUS_USE_WINSOCK diff --git a/src/socket.cxx b/src/socket.cxx index 8b7867935..bcf377b58 100644 --- a/src/socket.cxx +++ b/src/socket.cxx @@ -199,40 +199,4 @@ Socket::write(const std::string & buffer) } - - - -////////////////////////////////////////////////////////////////////////////// -// ServerSocket ctor and dtor -////////////////////////////////////////////////////////////////////////////// - -ServerSocket::ServerSocket(unsigned short port) -{ - sock = openSocket(port, state); - if(sock == INVALID_SOCKET_VALUE) { - err = get_last_socket_error (); - } -} - - - -ServerSocket::~ServerSocket() -{ -} - - - -////////////////////////////////////////////////////////////////////////////// -// ServerSocket methods -////////////////////////////////////////////////////////////////////////////// - -Socket -ServerSocket::accept() -{ - SocketState st = not_opened; - SOCKET_TYPE clientSock = acceptSocket(sock, st); - return Socket(clientSock, st, 0); -} - - } } // namespace log4cplus { namespace helpers { From d0be1a793b370129b674813cf5cecf1ecedab7a9 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 28 Mar 2013 23:18:36 +0100 Subject: [PATCH 080/226] Implement cooperative ServerSocket::accept() interruption for *NIX. --- ConfigureChecks.cmake | 4 + configure | 47 +++++++ configure.ac | 4 + include/log4cplus/config.h.in | 21 +++ include/log4cplus/config/defines.hxx.in | 12 ++ src/lockfile.cxx | 53 ++++++- src/socket-unix.cxx | 179 +++++++++++++++++++++++- 7 files changed, 315 insertions(+), 5 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 83381e2bd..947803214 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -30,6 +30,7 @@ check_include_files(stdarg.h LOG4CPLUS_HAVE_STDARG_H ) check_include_files(stdlib.h LOG4CPLUS_HAVE_STDLIB_H ) check_include_files(time.h LOG4CPLUS_HAVE_TIME_H ) check_include_files(wchar.h LOG4CPLUS_HAVE_WCHAR_H ) +check_include_files(poll.h LOG4CPLUS_HAVE_POLL_H ) check_include_files(inttypes.h HAVE_INTTYPES_H ) @@ -55,6 +56,9 @@ check_function_exists(gmtime_r LOG4CPLUS_HAVE_GMTIME_R ) check_function_exists(localtime_r LOG4CPLUS_HAVE_LOCALTIME_R ) check_function_exists(gettimeofday LOG4CPLUS_HAVE_GETTIMEOFDAY ) check_function_exists(getpid LOG4CPLUS_HAVE_GETPID ) +check_function_exists(poll LOG4CPLUS_HAVE_POLL ) +check_function_exists(pipe LOG4CPLUS_HAVE_PIPE ) +check_function_exists(pipe2 LOG4CPLUS_HAVE_PIPE2 ) check_function_exists(ftime LOG4CPLUS_HAVE_FTIME ) check_function_exists(stat LOG4CPLUS_HAVE_STAT ) check_function_exists(lstat LOG4CPLUS_HAVE_LSTAT ) diff --git a/configure b/configure index 5b067ffa6..9aed82c51 100755 --- a/configure +++ b/configure @@ -8682,6 +8682,14 @@ if test "x$ac_cv_header_limits_h" = xyes; then : fi + + ac_fn_cxx_check_header_mongrel "$LINENO" "poll.h" "ac_cv_header_poll_h" "$ac_includes_default" +if test "x$ac_cv_header_poll_h" = xyes; then : + $as_echo "#define LOG4CPLUS_HAVE_POLL_H 1" >>confdefs.h + +fi + + if test "x$with_iconv" = "xyes"; then : ac_fn_cxx_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default" @@ -9757,6 +9765,45 @@ fi done + for ac_func in poll +do : + ac_fn_cxx_check_func "$LINENO" "poll" "ac_cv_func_poll" +if test "x$ac_cv_func_poll" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_POLL 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_POLL 1" >>confdefs.h + +fi +done + + + for ac_func in pipe +do : + ac_fn_cxx_check_func "$LINENO" "pipe" "ac_cv_func_pipe" +if test "x$ac_cv_func_pipe" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PIPE 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_PIPE 1" >>confdefs.h + +fi +done + + + for ac_func in pipe2 +do : + ac_fn_cxx_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" +if test "x$ac_cv_func_pipe2" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PIPE2 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_PIPE2 1" >>confdefs.h + +fi +done + + for ac_func in ftime do : ac_fn_cxx_check_func "$LINENO" "ftime" "ac_cv_func_ftime" diff --git a/configure.ac b/configure.ac index 2d1b09b63..26cd5ec3d 100644 --- a/configure.ac +++ b/configure.ac @@ -339,6 +339,7 @@ LOG4CPLUS_CHECK_HEADER([wchar.h], [LOG4CPLUS_HAVE_WCHAR_H]) LOG4CPLUS_CHECK_HEADER([time.h], [LOG4CPLUS_HAVE_TIME_H]) LOG4CPLUS_CHECK_HEADER([errno.h], [LOG4CPLUS_HAVE_ERRNO_H]) LOG4CPLUS_CHECK_HEADER([limits.h], [LOG4CPLUS_HAVE_LIMITS_H]) +LOG4CPLUS_CHECK_HEADER([poll.h], [LOG4CPLUS_HAVE_POLL_H]) AS_IF([test "x$with_iconv" = "xyes"], [LOG4CPLUS_CHECK_HEADER([iconv.h], [LOG4CPLUS_HAVE_ICONV_H])]) @@ -427,6 +428,9 @@ LOG4CPLUS_CHECK_FUNCS([nanosleep], [LOG4CPLUS_HAVE_NANOSLEEP]) LOG4CPLUS_CHECK_FUNCS([clock_nanosleep], [LOG4CPLUS_HAVE_CLOCK_NANOSLEEP]) LOG4CPLUS_CHECK_FUNCS([clock_gettime], [LOG4CPLUS_HAVE_CLOCK_GETTIME]) LOG4CPLUS_CHECK_FUNCS([getpid], [LOG4CPLUS_HAVE_GETPID]) +LOG4CPLUS_CHECK_FUNCS([poll], [LOG4CPLUS_HAVE_POLL]) +LOG4CPLUS_CHECK_FUNCS([pipe], [LOG4CPLUS_HAVE_PIPE]) +LOG4CPLUS_CHECK_FUNCS([pipe2], [LOG4CPLUS_HAVE_PIPE2]) LOG4CPLUS_CHECK_FUNCS([ftime], [LOG4CPLUS_HAVE_FTIME]) LOG4CPLUS_CHECK_FUNCS([stat], [LOG4CPLUS_HAVE_STAT]) LOG4CPLUS_CHECK_FUNCS([lstat], [LOG4CPLUS_HAVE_LSTAT]) diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index e8af46748..c6e6eb44a 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -108,6 +108,15 @@ /* Define to 1 if you have the `ntohs' function. */ #undef HAVE_NTOHS +/* Define to 1 if you have the `pipe' function. */ +#undef HAVE_PIPE + +/* Define to 1 if you have the `pipe2' function. */ +#undef HAVE_PIPE2 + +/* Define to 1 if you have the `poll' function. */ +#undef HAVE_POLL + /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD @@ -313,6 +322,18 @@ /* */ #undef LOG4CPLUS_HAVE_NTOHS +/* */ +#undef LOG4CPLUS_HAVE_PIPE + +/* */ +#undef LOG4CPLUS_HAVE_PIPE2 + +/* */ +#undef LOG4CPLUS_HAVE_POLL + +/* */ +#undef LOG4CPLUS_HAVE_POLL_H + /* */ #undef LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO diff --git a/include/log4cplus/config/defines.hxx.in b/include/log4cplus/config/defines.hxx.in index 05a5f874b..286f9836b 100644 --- a/include/log4cplus/config/defines.hxx.in +++ b/include/log4cplus/config/defines.hxx.in @@ -121,6 +121,18 @@ /* */ #undef LOG4CPLUS_HAVE_NTOHS +/* */ +#undef LOG4CPLUS_HAVE_PIPE + +/* */ +#undef LOG4CPLUS_HAVE_PIPE2 + +/* */ +#undef LOG4CPLUS_HAVE_POLL + +/* */ +#undef LOG4CPLUS_HAVE_POLL_H + /* */ #undef LOG4CPLUS_HAVE_STAT diff --git a/src/lockfile.cxx b/src/lockfile.cxx index f39ab01dc..d7e63a934 100644 --- a/src/lockfile.cxx +++ b/src/lockfile.cxx @@ -106,7 +106,7 @@ namespace static HANDLE -get_os_HANDLE (int fd, helpers::LogLog & loglog) +get_os_HANDLE (int fd, helpers::LogLog & loglog = helpers::getLogLog ()) { HANDLE fh = reinterpret_cast(_get_osfhandle (fd)); if (fh == INVALID_HANDLE_VALUE) @@ -131,6 +131,52 @@ mode_t const OPEN_MODE = (S_IRWXU ^ S_IXUSR) #endif + +//! Helper function that sets FD_CLOEXEC on descriptor on platforms +//! that support it. +LOG4CPLUS_PRIVATE +bool +trySetCloseOnExec (int fd, helpers::LogLog & loglog = helpers::getLogLog ()) +{ +#if defined (WIN32) + int ret = SetHandleInformation (get_os_HANDLE (fd), HANDLE_FLAG_INHERIT, 0); + if (! ret) + { + DWORD eno = GetLastError (); + loglog.warn ( + tstring ( + LOG4CPLUS_TEXT ("could not unset HANDLE_FLAG_INHERIT on fd: ")) + + convertIntegerToString (fd) + + LOG4CPLUS_TEXT (", errno: ") + + convertIntegerToString (eno)); + return false; + } + +#elif defined (FD_CLOEXEC) + int ret = fcntl (fd, F_SETFD, FD_CLOEXEC); + if (ret == -1) + { + int eno = errno; + loglog.warn ( + tstring (LOG4CPLUS_TEXT ("could not set FD_CLOEXEC on fd: ")) + + convertIntegerToString (fd) + + LOG4CPLUS_TEXT (", errno: ") + + convertIntegerToString (eno)); + return false; + } +#else + return false; + +#endif + + return true; +} + + +// +// +// + struct LockFile::Impl { #if defined (LOG4CPLUS_USE_POSIX_LOCKING) \ @@ -194,9 +240,8 @@ LockFile::open (int open_flags) const tstring (LOG4CPLUS_TEXT ("could not open or create file ")) + lock_file_name, true); -#if ! defined (O_CLOEXEC) && defined (FD_CLOEXEC) - int ret = fcntl (data->fd, F_SETFD, FD_CLOEXEC); - if (ret == -1) +#if ! defined (O_CLOEXEC) + if (! trySetCloseOnExec (data->fd, loglog)) loglog.warn ( tstring (LOG4CPLUS_TEXT("could not set FD_CLOEXEC on file ")) + lock_file_name); diff --git a/src/socket-unix.cxx b/src/socket-unix.cxx index 4a5d2cdf1..038be0d30 100644 --- a/src/socket-unix.cxx +++ b/src/socket-unix.cxx @@ -60,13 +60,25 @@ #include #endif +#ifdef LOG4CPLUS_HAVE_FCNTL_H +#include +#endif + #ifdef LOG4CPLUS_HAVE_UNISTD_H #include #endif +#ifdef LOG4CPLUS_HAVE_POLL_H +#include +#endif + namespace log4cplus { namespace helpers { +// from lockfile.cxx +LOG4CPLUS_PRIVATE bool trySetCloseOnExec (int fd, + helpers::LogLog & loglog = helpers::getLogLog ()); + namespace { @@ -165,8 +177,9 @@ openSocket(unsigned short port, SocketState& state) int ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, &optval, optlen ); if (ret != 0) { + int const eno = errno; helpers::getLogLog ().warn (LOG4CPLUS_TEXT ("setsockopt() failed: ") - + helpers::convertIntegerToString (errno)); + + helpers::convertIntegerToString (eno)); } int retval = bind(sock, reinterpret_cast(&server), @@ -409,6 +422,170 @@ setTCPNoDelay (SOCKET_TYPE sock, bool val) } +// +// ServerSocket OS dependent stuff +// + +ServerSocket::ServerSocket(unsigned short port) +{ + int fds[2] = {-1, -1}; + int ret; + + sock = openSocket (port, state); + if (sock == INVALID_SOCKET_VALUE) + goto error; + +#if defined (LOG4CPLUS_HAVE_PIPE2) && defined (O_CLOEXEC) + ret = pipe2 (fds, O_CLOEXEC); + if (ret != 0) + goto error; + +#elif defined (LOG4CPLUS_HAVE_PIPE) + ret = pipe (fds); + if (ret != 0) + goto error; + + trySetCloseOnExec (fds[0]); + trySetCloseOnExec (fds[1]); + +#else +# error You are missing both pipe() or pipe2(). +#endif + + interruptHandles[0] = fds[0]; + interruptHandles[1] = fds[1]; + return; + +error:; + err = get_last_socket_error (); + state = not_opened; + + if (sock != INVALID_SOCKET_VALUE) + closeSocket (sock); + + if (fds[0] != -1) + ::close (fds[0]); + + if (fds[1] != -1) + ::close (fds[1]); +} + +Socket +ServerSocket::accept () +{ + struct pollfd pollfds[2]; + + struct pollfd & interrupt_pipe = pollfds[0]; + interrupt_pipe.fd = interruptHandles[0]; + interrupt_pipe.events = POLLIN; + interrupt_pipe.revents = 0; + + struct pollfd & accept_fd = pollfds[1]; + accept_fd.fd = to_os_socket (sock); + accept_fd.events = POLLIN; + accept_fd.revents = 0; + + do + { + interrupt_pipe.revents = 0; + accept_fd.revents = 0; + + int ret = poll (pollfds, 2, -1); + switch (ret) + { + // Error. + case -1: + if (errno == EINTR) + // Signal has interrupted the call. Just re-run it. + continue; + + set_last_socket_error (errno); + return Socket (INVALID_SOCKET_VALUE, not_opened, errno); + + // Timeout. This should not happen though. + case 0: + continue; + + default: + // Some descriptor is ready. + + if ((interrupt_pipe.revents & POLLIN) == POLLIN) + { + // Read byte from interruption pipe. + + helpers::getLogLog ().debug ( + LOG4CPLUS_TEXT ("ServerSocket::accept- ") + LOG4CPLUS_TEXT ("accept() interrupted by other thread")); + + char ch; + ret = ::read (interrupt_pipe.fd, &ch, 1); + if (ret == -1) + { + int const eno = errno; + helpers::getLogLog ().warn ( + LOG4CPLUS_TEXT ("ServerSocket::accept- read() failed: ") + + helpers::convertIntegerToString (eno)); + set_last_socket_error (eno); + return Socket (INVALID_SOCKET_VALUE, not_opened, eno); + } + + // Return Socket with state set to accept_interrupted. + + return Socket (INVALID_SOCKET_VALUE, accept_interrupted, 0); + } + else if ((accept_fd.revents & POLLIN) == POLLIN) + { + helpers::getLogLog ().debug ( + LOG4CPLUS_TEXT ("ServerSocket::accept- ") + LOG4CPLUS_TEXT ("accepting connection")); + + SocketState st = not_opened; + SOCKET_TYPE clientSock = acceptSocket (sock, st); + int eno = 0; + if (clientSock == INVALID_SOCKET_VALUE) + eno = get_last_socket_error (); + + return Socket (clientSock, st, eno); + } + else + return Socket (INVALID_SOCKET_VALUE, not_opened, 0); + } + } + while (true); +} + + +void +ServerSocket::interruptAccept () +{ + char ch = 'I'; + int ret; + + do + { + ret = ::write (interruptHandles[1], &ch, 1); + } + while (ret == -1 && errno == EINTR); + + if (ret == -1) + { + int const eno = errno; + helpers::getLogLog ().warn ( + LOG4CPLUS_TEXT ("ServerSocket::interruptAccept- write() failed: ") + + helpers::convertIntegerToString (eno)); + } +} + + +ServerSocket::~ServerSocket() +{ + if (interruptHandles[0] != -1) + ::close (interruptHandles[0]); + + if (interruptHandles[1] != -1) + ::close (interruptHandles[1]); +} + } } // namespace log4cplus #endif // LOG4CPLUS_USE_BSD_SOCKETS From 2c5d71a03886bbeb191acde4e999a7883d0ae8c8 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 30 Mar 2013 20:22:43 +0100 Subject: [PATCH 081/226] Bump SO version to 7 because of recent sockets code changes. --- CMakeLists.txt | 2 +- configure | 2 +- configure.ac | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5500202bb..23cebf92b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ include (Log4CPlusUtils.cmake) log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include" log4cplus_version_major log4cplus_version_minor log4cplus_version_patch) message("-- Generating build for Log4cplus version ${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") -set (log4cplus_soversion 6) +set (log4cplus_soversion 7) set (log4cplus_postfix "") option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) diff --git a/configure b/configure index 9aed82c51..383e32c26 100755 --- a/configure +++ b/configure @@ -4210,7 +4210,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=6:1:0 +LT_VERSION=7:0:0 LT_RELEASE=1.1 diff --git a/configure.ac b/configure.ac index 26cd5ec3d..987c28a36 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=6:1:0 +LT_VERSION=7:0:0 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) From 69c9f32dcdabb1fdbe97590334607221a7c4a7da Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 30 Mar 2013 20:25:46 +0100 Subject: [PATCH 082/226] ChangeLog: Update for 1.1.1-RC4. --- ChangeLog | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/ChangeLog b/ChangeLog index 12ed03952..50c499964 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,47 @@ +log4cplus 1.1.1-RC4 + +- Fixed bug #156 - Messages are truncated when produced using the + LOG4CPLUS_*_FMT() macros. + +- Fixed bug #157 - Fedora package build failure. + +- Improved log4cplus initialization: + + - Use APC to initialize log4cplus outside loader lock. + + - Use Microsoft C runtime library TLS callbacks to initialize + log4cplus as static library. + + - Warn during compilation that automatic initialization is not + possible when log4cplus is being compiled with static Microsoft C + runtime library. + + - Provide log4cplus::initialize() function to allow users to + initialize log4cplus in situations where automatic initialization + is not possible. + +- Several improvements to CMake build: + + - Fixed OpenBSD + CMake builds. + + - Fixed issues with Visual Studio 2005 CMake builds. + + - Added support for CMake builds on Android with NDK. (Sergey + Nikulov) + + - The defines.hxx.cmake file is now generated out of defines.hxx.in. + + - Library version is parsed out of version.h. (Sergey Nikulov) + +- MDC formatter for PatternLayout ("%X") now expands into list of key + value pairs if no specific key is given. (Yaqian Shen) + +- Avoid clock_nanosleep() on Android. + +- ServerSocket::accept() can now be interrupted from another thread + using new function ServerSocket::interruptAccept(). + + log4cplus 1.1.1-RC3 - Fixed another MinGW related build failure. From df2ec1aa61723ad2481a34d4d774c5df3651d5b0 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 1 May 2013 21:50:58 +0200 Subject: [PATCH 083/226] fileappender.cxx: Accept also std::ios_base::ate as "append to a log file" specification. --- src/fileappender.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fileappender.cxx b/src/fileappender.cxx index 0d8b4c680..e93abb600 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -235,7 +235,7 @@ FileAppender::FileAppender(const Properties& props, , bufferSize (0) , buffer (0) { - bool app = (mode_ == std::ios::app); + bool app = (mode_ & (std::ios_base::app | std::ios_base::ate)) != 0; tstring const & fn = props.getProperty( LOG4CPLUS_TEXT("File") ); if (fn.empty()) { From d982857f96edefcbe7d08384a8fdf88ca5cba109 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 1 May 2013 21:55:55 +0200 Subject: [PATCH 084/226] configure.ac: Do not check for -fkeep-inline-functions. --- configure | 66 +--------------------------------------------------- configure.ac | 2 +- 2 files changed, 2 insertions(+), 66 deletions(-) diff --git a/configure b/configure index 383e32c26..18de49e0d 100755 --- a/configure +++ b/configure @@ -6205,71 +6205,7 @@ case ".$var" in ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fkeep-inline-functions" >&5 -$as_echo_n "checking CXXFLAGS for gcc -fkeep-inline-functions... " >&6; } -if ${ax_cv_cxxflags_gcc_option__fkeep_inline_functions+:} false; then : - $as_echo_n "(cached) " >&6 -else - ax_cv_cxxflags_gcc_option__fkeep_inline_functions="no, unknown" - - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - ac_save_CXXFLAGS="$CXXFLAGS" -for ac_arg in "-pedantic -Werror % -fkeep-inline-functions" "-pedantic % -fkeep-inline-functions %% no, obsolete" # -do CXXFLAGS="$ac_save_CXXFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxxflags_gcc_option__fkeep_inline_functions=`echo $ac_arg | sed -e 's,.*% *,,'`; break -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done - CXXFLAGS="$ac_save_CXXFLAGS" - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxxflags_gcc_option__fkeep_inline_functions" >&5 -$as_echo "$ax_cv_cxxflags_gcc_option__fkeep_inline_functions" >&6; } -var=$ax_cv_cxxflags_gcc_option__fkeep_inline_functions -case ".$var" in - .ok|.ok,*) ;; - .|.no|.no,*) ;; - *) - if echo " $CXXFLAGS " | grep " $var " 2>&1 >/dev/null - then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS does contain \$var"; } >&5 - (: CXXFLAGS does contain $var) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CXXFLAGS=\"\$CXXFLAGS \$var\""; } >&5 - (: CXXFLAGS="$CXXFLAGS $var") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CXXFLAGS="$CXXFLAGS $var" - fi - ;; -esac - - case "$target_os" in #( + case "$target_os" in #( mingw32) : ;; #( *) : diff --git a/configure.ac b/configure.ac index 987c28a36..4b659da79 100644 --- a/configure.ac +++ b/configure.ac @@ -179,7 +179,7 @@ AS_CASE([$ax_cv_cxx_compiler_vendor], AS_IF([test "x$enable_debugging" = "xyes"], [AX_CXXFLAGS_GCC_OPTION([-g3]) - AX_CXXFLAGS_GCC_OPTION([-fkeep-inline-functions]) + dnl AX_CXXFLAGS_GCC_OPTION([-fkeep-inline-functions]) AS_CASE(["$target_os"], dnl Disable these for MinGW32 as it seems to generate DLLs that dnl segfault in DllMain(). From ce69c33b05dd7abc11616e657089c1b0694330ef Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 1 May 2013 21:58:56 +0200 Subject: [PATCH 085/226] release.txt: Mention G+. --- docs/release.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/release.txt b/docs/release.txt index f186ba93a..c55dd4001 100644 --- a/docs/release.txt +++ b/docs/release.txt @@ -14,4 +14,6 @@ This describes the release procedure: 6. Add news entry to log4cplus.sf.net web page. - 7. Add release entry to freecode.net. + 7. Post release information to G+ log4cplus group. + + 8. Add release entry to freecode.net. From be60a22db63a700ff6919b89ea474b55f648428b Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 1 May 2013 22:11:18 +0200 Subject: [PATCH 086/226] ChangeLog: Update for 1.1.1. --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 50c499964..2e3083f51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +log4cplus 1.1.1 + +- FileAppender - Accept also std::ios_base::ate as "append to a log + file" specification. + + log4cplus 1.1.1-RC4 - Fixed bug #156 - Messages are truncated when produced using the From 19fa21104341a5864a98caa662409b32aeb8e7f9 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 1 May 2013 22:48:03 +0200 Subject: [PATCH 087/226] webpage_doxygen.config: Update version number to 1.1.1. --- docs/webpage_doxygen.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/webpage_doxygen.config b/docs/webpage_doxygen.config index 934784e8c..3c5bc5a32 100644 --- a/docs/webpage_doxygen.config +++ b/docs/webpage_doxygen.config @@ -32,7 +32,7 @@ PROJECT_NAME = log4cplus # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.1.0 +PROJECT_NUMBER = 1.1.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = webpage_docs-1.1.0 +OUTPUT_DIRECTORY = webpage_docs-1.1.1 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output From 768c721156c3a135ce1b589190c2c50847f3d0ad Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 1 May 2013 22:49:22 +0200 Subject: [PATCH 088/226] webpage_doxygen.config: Update with Doxygen 1.8.3.1. --- docs/webpage_doxygen.config | 224 +++++++++++++++++++++++++----------- 1 file changed, 156 insertions(+), 68 deletions(-) diff --git a/docs/webpage_doxygen.config b/docs/webpage_doxygen.config index 3c5bc5a32..b844be4c0 100644 --- a/docs/webpage_doxygen.config +++ b/docs/webpage_doxygen.config @@ -1,4 +1,4 @@ -# Doxyfile 1.7.6.1 +# Doxyfile 1.8.3.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -126,7 +126,9 @@ FULL_PATH_NAMES = NO # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the -# path to strip. +# path to strip. Note that you specify absolute paths here, but also +# relative paths, which will be relative from the directory where doxygen is +# started. STRIP_FROM_PATH = @@ -229,17 +231,34 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, +# and language is one of the parsers supported by doxygen: IDL, Java, +# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, +# C++. For instance to make doxygen treat .inc files as Fortran files (default +# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note +# that for custom extensions you also need to set FILE_PATTERNS otherwise the +# files are not read by doxygen. EXTENSION_MAPPING = +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented classes, +# or namespaces to their corresponding documentation. Such a link can be +# prevented in individual cases by by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. + +AUTOLINK_SUPPORT = YES + # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and @@ -260,10 +279,10 @@ CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES (the +# default) will make doxygen replace the get and set methods by a property in +# the documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. @@ -353,6 +372,11 @@ EXTRACT_ALL = YES EXTRACT_PRIVATE = NO +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. @@ -520,7 +544,8 @@ GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. +# documentation sections, marked by \if section-label ... \endif +# and \cond section-label ... \endcond blocks. ENABLED_SECTIONS = @@ -540,12 +565,6 @@ MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. @@ -571,7 +590,7 @@ FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file +# output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. @@ -584,7 +603,8 @@ LAYOUT_FILE = # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. +# feature you need bibtex and perl available in the search path. Do not use +# file names with spaces, bibtex cannot handle them. CITE_BIB_FILES = @@ -766,6 +786,13 @@ FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = +# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page (index.html). +# This can be useful if you have a project on for instance GitHub and want reuse +# the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- @@ -784,7 +811,7 @@ INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. +# fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES @@ -887,13 +914,23 @@ HTML_FOOTER = webpage_footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# style sheet in the HTML output directory as well, or it will be erased! +# fine-tune the look of the HTML output. If left blank doxygen will +# generate a default style sheet. Note that it is recommended to use +# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this +# tag will in the future become obsolete. HTML_STYLESHEET = doxygen.css +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional +# user-defined cascading style sheet that is included after the standard +# style sheets created by doxygen. Using this option one can overrule +# certain style aspects. This is preferred over using HTML_STYLESHEET +# since it does not replace the standard style sheet and is therefor more +# robust against future updates. Doxygen will copy the style sheet file to +# the output directory. + +HTML_EXTRA_STYLESHEET = + # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the @@ -934,20 +971,23 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). +# page has loaded. HTML_DYNAMIC_SECTIONS = NO +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). @@ -975,9 +1015,9 @@ DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely +# identify the documentation publisher. This should be a reverse domain-name +# style string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher @@ -1126,11 +1166,6 @@ GENERATE_TREEVIEW = NO ENUM_VALUES_PER_LINE = 4 -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. @@ -1162,19 +1197,27 @@ FORMULA_TRANSPARENT = YES # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and +# output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO +# When MathJax is enabled you can set the default output format to be used for +# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and +# SVG. The default value is HTML-CSS, which is slower, but has the best +# compatibility. + +MATHJAX_FORMAT = HTML-CSS + # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the -# mathjax.org site, so you can quickly see the result without installing -# MathJax, but it is strongly recommended to install a local copy of MathJax -# before deployment. +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://www.mathjax.org/mathjax @@ -1194,15 +1237,55 @@ MATHJAX_EXTENSIONS = SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. +# implemented using a web server instead of a web client using Javascript. +# There are two flavours of web server based search depending on the +# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for +# searching and an index file used by the script. When EXTERNAL_SEARCH is +# enabled the indexing and searching needs to be provided by external tools. +# See the manual for details. SERVER_BASED_SEARCH = NO +# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP +# script for searching. Instead the search results are written to an XML file +# which needs to be processed by an external indexer. Doxygen will invoke an +# external search engine pointed to by the SEARCHENGINE_URL option to obtain +# the search results. Doxygen ships with an example indexer (doxyindexer) and +# search engine (doxysearch.cgi) which are based on the open source search engine +# library Xapian. See the manual for configuration details. + +EXTERNAL_SEARCH = NO + +# The SEARCHENGINE_URL should point to a search engine hosted by a web server +# which will returned the search results when EXTERNAL_SEARCH is enabled. +# Doxygen ships with an example search engine (doxysearch) which is based on +# the open source search engine library Xapian. See the manual for configuration +# details. + +SEARCHENGINE_URL = + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed +# search data is written to a file for indexing by an external tool. With the +# SEARCHDATA_FILE tag the name of this file can be specified. + +SEARCHDATA_FILE = searchdata.xml + +# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the +# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is +# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple +# projects and redirect the results back to the right project. + +EXTERNAL_SEARCH_ID = + +# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen +# projects other than the one defined by this configuration file, but that are +# all added to the same external search index. Each project needs to have a +# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id +# of to a relative location where the documentation can be found. +# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... + +EXTRA_SEARCH_MAPPINGS = + #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- @@ -1524,22 +1607,18 @@ SKIP_FUNCTION_MACROS = YES # Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. TAGFILES = @@ -1652,6 +1731,15 @@ GROUP_GRAPHS = YES UML_LOOK = NO +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. @@ -1692,7 +1780,7 @@ CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. From 0082e5b3822c47384dbef6c0e73edfc10f0bf074 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 23 May 2013 23:56:27 +0200 Subject: [PATCH 089/226] configure.ac: Add --disable-so-version and --disable-release-version options. */Makefile.am: Do not use -version-info and -release libtool options when they are disabled by --disable-so-version and --disable-release-version. --- configure | 65 ++++++++++++++++++++++++++++++++++++ configure.ac | 18 ++++++++++ qt4debugappender/Makefile.am | 16 ++++++++- qt4debugappender/Makefile.in | 7 +++- src/Makefile.am | 16 ++++++++- src/Makefile.in | 7 +++- 6 files changed, 125 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 18de49e0d..c99dead30 100755 --- a/configure +++ b/configure @@ -674,6 +674,10 @@ CXXDEPMODE ac_ct_CXX CXXFLAGS CXX +ENABLE_RELEASE_OPTION_FALSE +ENABLE_RELEASE_OPTION_TRUE +ENABLE_VERSION_INFO_OPTION_FALSE +ENABLE_VERSION_INFO_OPTION_TRUE LOG4CPLUS_NDEBUG LT_RELEASE LT_VERSION @@ -778,6 +782,8 @@ with_working_c_locale with_iconv enable_debugging enable_warnings +enable_so_version +enable_release_version enable_profiling enable_threads with_qt @@ -1433,6 +1439,9 @@ Optional Features: generate debugging information. --enable-warnings Use compiler warnings option, e.g. -Wall. Enabled by default. + --enable-so-version Use libtool -version-info option. + --enable-release-version + Use libtool -release option. --enable-profiling Compile with profiling compiler options. --enable-threads=yes/no Use this option to create a singled-threaded version of this library @@ -4338,6 +4347,54 @@ fi +# Check whether --enable-so-version was given. +if test "${enable_so_version+set}" = set; then : + enableval=$enable_so_version; case "${enableval}" in #( + yes) : + ;; #( + no) : + ;; #( + *) : + as_fn_error $? "bad value ${enableval} for --enable-so-version" "$LINENO" 5 ;; +esac +else + enable_so_version=yes +fi + + if test "x$enable_so_version" = "xyes"; then + ENABLE_VERSION_INFO_OPTION_TRUE= + ENABLE_VERSION_INFO_OPTION_FALSE='#' +else + ENABLE_VERSION_INFO_OPTION_TRUE='#' + ENABLE_VERSION_INFO_OPTION_FALSE= +fi + + + +# Check whether --enable-release-version was given. +if test "${enable_release_version+set}" = set; then : + enableval=$enable_release_version; case "${enableval}" in #( + yes) : + ;; #( + no) : + ;; #( + *) : + as_fn_error $? "bad value ${enableval} for --enable-release-version" "$LINENO" 5 ;; +esac +else + enable_release_version=yes +fi + + if test "x$enable_release_version" = "xyes"; then + ENABLE_RELEASE_OPTION_TRUE= + ENABLE_RELEASE_OPTION_FALSE='#' +else + ENABLE_RELEASE_OPTION_TRUE='#' + ENABLE_RELEASE_OPTION_FALSE= +fi + + + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -21265,6 +21322,14 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${ENABLE_VERSION_INFO_OPTION_TRUE}" && test -z "${ENABLE_VERSION_INFO_OPTION_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_VERSION_INFO_OPTION\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ENABLE_RELEASE_OPTION_TRUE}" && test -z "${ENABLE_RELEASE_OPTION_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_RELEASE_OPTION\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 4b659da79..cc2506c2f 100644 --- a/configure.ac +++ b/configure.ac @@ -103,6 +103,24 @@ AC_ARG_ENABLE([warnings], [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-warnings])], [enable_warnings=yes]) +dnl Enable SO version. + +AC_ARG_ENABLE([so-version], + [AC_HELP_STRING([--enable-so-version], [Use libtool -version-info option.])], + [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-so-version])], + [enable_so_version=yes]) +AM_CONDITIONAL([ENABLE_VERSION_INFO_OPTION], + [test "x$enable_so_version" = "xyes"]) + +dnl Enable release version. + +AC_ARG_ENABLE([release-version], + [AC_HELP_STRING([--enable-release-version], [Use libtool -release option.])], + [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-release-version])], + [enable_release_version=yes]) +AM_CONDITIONAL([ENABLE_RELEASE_OPTION], + [test "x$enable_release_version" = "xyes"]) + dnl Check for c/c++ compilers. AC_PROG_CXX diff --git a/qt4debugappender/Makefile.am b/qt4debugappender/Makefile.am index 60fd62b2b..c2cae6d6a 100644 --- a/qt4debugappender/Makefile.am +++ b/qt4debugappender/Makefile.am @@ -16,10 +16,24 @@ INCLUDES_SRC = \ LIB_SRC = $(INCLUDES_SRC) \ qt4debugappender.cxx +if ENABLE_VERSION_INFO_OPTION +VERSION_INFO_OPTION=-version-info @LT_VERSION@ +else +VERSION_INFO_OPTION=-avoid-version +endif + +if ENABLE_RELEASE_OPTION +RELEASE_OPTION=-release @LT_RELEASE@ +else +RELEASE_OPTION= +endif + +LOG4CPLUS_VERSION_LT_FLAGS=$(VERSION_INFO_OPTION) $(RELEASE_OPTION) + liblog4cplusqt4debugappender_la_SOURCES = $(LIB_SRC) liblog4cplusqt4debugappender_la_LIBADD = $(top_builddir)/src/liblog4cplus.la liblog4cplusqt4debugappender_la_LDFLAGS = -no-undefined \ - -version-info @LT_VERSION@ -release @LT_RELEASE@ \ + $(LOG4CPLUS_VERSION_LT_FLAGS) \ @QT_LIBS@ diff --git a/qt4debugappender/Makefile.in b/qt4debugappender/Makefile.in index 175dac5ec..1f9b1cfdf 100644 --- a/qt4debugappender/Makefile.in +++ b/qt4debugappender/Makefile.in @@ -303,10 +303,15 @@ INCLUDES_SRC = \ LIB_SRC = $(INCLUDES_SRC) \ qt4debugappender.cxx +@ENABLE_VERSION_INFO_OPTION_FALSE@VERSION_INFO_OPTION = -avoid-version +@ENABLE_VERSION_INFO_OPTION_TRUE@VERSION_INFO_OPTION = -version-info @LT_VERSION@ +@ENABLE_RELEASE_OPTION_FALSE@RELEASE_OPTION = +@ENABLE_RELEASE_OPTION_TRUE@RELEASE_OPTION = -release @LT_RELEASE@ +LOG4CPLUS_VERSION_LT_FLAGS = $(VERSION_INFO_OPTION) $(RELEASE_OPTION) liblog4cplusqt4debugappender_la_SOURCES = $(LIB_SRC) liblog4cplusqt4debugappender_la_LIBADD = $(top_builddir)/src/liblog4cplus.la liblog4cplusqt4debugappender_la_LDFLAGS = -no-undefined \ - -version-info @LT_VERSION@ -release @LT_RELEASE@ \ + $(LOG4CPLUS_VERSION_LT_FLAGS) \ @QT_LIBS@ all: all-am diff --git a/src/Makefile.am b/src/Makefile.am index 9d8214263..c0c35bb14 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -142,5 +142,19 @@ LIB_SRC = $(SINGLE_THREADED_SRC) liblog4cplus_la_SOURCES = $(LIB_SRC) +if ENABLE_VERSION_INFO_OPTION +VERSION_INFO_OPTION=-version-info @LT_VERSION@ +else +VERSION_INFO_OPTION=-avoid-version +endif + +if ENABLE_RELEASE_OPTION +RELEASE_OPTION=-release @LT_RELEASE@ +else +RELEASE_OPTION= +endif + +LOG4CPLUS_VERSION_LT_FLAGS=$(VERSION_INFO_OPTION) $(RELEASE_OPTION) + #liblog4cplus_a_LIBADD = @LIBOBJS@ @ALLOCA@ -liblog4cplus_la_LDFLAGS = -no-undefined -version-info @LT_VERSION@ -release @LT_RELEASE@ +liblog4cplus_la_LDFLAGS = -no-undefined $(LOG4CPLUS_VERSION_LT_FLAGS) diff --git a/src/Makefile.in b/src/Makefile.in index 404a50d03..bf434a68c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -439,9 +439,14 @@ SINGLE_THREADED_SRC = \ LIB_SRC = $(SINGLE_THREADED_SRC) liblog4cplus_la_SOURCES = $(LIB_SRC) +@ENABLE_VERSION_INFO_OPTION_FALSE@VERSION_INFO_OPTION = -avoid-version +@ENABLE_VERSION_INFO_OPTION_TRUE@VERSION_INFO_OPTION = -version-info @LT_VERSION@ +@ENABLE_RELEASE_OPTION_FALSE@RELEASE_OPTION = +@ENABLE_RELEASE_OPTION_TRUE@RELEASE_OPTION = -release @LT_RELEASE@ +LOG4CPLUS_VERSION_LT_FLAGS = $(VERSION_INFO_OPTION) $(RELEASE_OPTION) #liblog4cplus_a_LIBADD = @LIBOBJS@ @ALLOCA@ -liblog4cplus_la_LDFLAGS = -no-undefined -version-info @LT_VERSION@ -release @LT_RELEASE@ +liblog4cplus_la_LDFLAGS = -no-undefined $(LOG4CPLUS_VERSION_LT_FLAGS) all: all-am .SUFFIXES: From 916ec7ecc305080137bcb342abab3a6dcfc858ea Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 24 May 2013 20:12:14 +0200 Subject: [PATCH 090/226] configurator.cxx: Fix bug #163. Spotted by: sldr at users dot sourceforge dot net --- src/configurator.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/configurator.cxx b/src/configurator.cxx index b57501abc..dcaf74ad6 100644 --- a/src/configurator.cxx +++ b/src/configurator.cxx @@ -289,8 +289,7 @@ PropertyConfigurator::configure() helpers::getLogLog ().setQuietMode (quiet_mode); bool disable_override = false; - if (properties.getBool (disable_override, - LOG4CPLUS_TEXT ("disableOverride"))) + properties.getBool (disable_override, LOG4CPLUS_TEXT ("disableOverride")); initializeLog4cplus(); configureAppenders(); From 55f8eb195348c4fa7ecec7999b656ad4c701a0a1 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 29 May 2013 14:42:58 +0200 Subject: [PATCH 091/226] propagate-version.pl: New script to propagate version number into several files. --- scripts/propagate-version.pl | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 scripts/propagate-version.pl diff --git a/scripts/propagate-version.pl b/scripts/propagate-version.pl new file mode 100755 index 000000000..188c1b717 --- /dev/null +++ b/scripts/propagate-version.pl @@ -0,0 +1,77 @@ +#!perl + +# Enable in-place editing +BEGIN +{ + $^I = '.bak'; +} + +use strict; +use feature 'unicode_strings'; + +# parse line from include/log4cplus/version.h + +open (my $fh, "<", "include/log4cplus/version.h") + or die $!; + +my ($major, $minor, $point, $version); +while (my $line = <$fh>) +{ + if ($line =~ m/\s* # \s* define \s+ LOG4CPLUS_VERSION \s+ + LOG4CPLUS_MAKE_VERSION \s* \( + \s* (\d+) \s* , \s* (\d+) \s* , \s* (\d+) \s* \)/x) + { + ($major, $minor, $point) = ($1, $2, $3); + $version = "$major.$minor.$point"; + print "version: ", $version, "\n"; + last; + } +} + +# edit configure.ac + +{ + local $^I = ".bak"; + local @ARGV = ("configure.ac"); + while (my $line = <>) + { + $line =~ s/(.*AC_INIT\(.*\[)(\d+(?:\.\d+(?:\.\d+)?)?)(\].*)/$1$version$3/x; + $line =~ s/(.*LT_RELEASE=)(.*)/$1$major.$minor/x; + print $line; + } + + local @ARGV = ("docs/doxygen.config"); + while (my $line = <>) + { + $line =~ s/(\s* PROJECT_NUMBER \s* = \s*)(.*)/$1$version/x; + $line =~ s/(\s* OUTPUT_DIRECTORY \s* = \s*)(.*)/$1log4cplus-$version\/docs/x; + print $line; + } + + local @ARGV = ("docs/webpage_doxygen.config"); + while (my $line = <>) + { + $line =~ s/(\s* PROJECT_NUMBER \s* = \s*)(.*)/$1$version/x; + $line =~ s/(\s* OUTPUT_DIRECTORY \s* = \s*)(.*)/$1webpage_docs-$version/x; + print $line; + } + + local @ARGV = ("log4cplus.spec"); + while (my $line = <>) + { + $line =~ s/(Version: \s*)(.*)/$1$version/x; + $line =~ s/(Release: \s*)(.*)/${1}1/x; + print $line; + } +} + +my @cygport = ; +die "cannot cope with multiple Cygport files" if (@cygport > 1); +my $cygport = @cygport[0]; +my $new_cygport = "cygport/log4cplus-$version-1.cygport"; +if ($cygport ne $new_cygport) +{ + system("bzr mv \"$cygport\" \"$new_cygport\"") == 0 + or die "bzr mv on $cygport has failed: $?"; +} + From 9b7f107c0c43096b3cf157f2bb2d01563d364ec4 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 29 May 2013 14:45:17 +0200 Subject: [PATCH 092/226] Bump release version to 1.1.2. --- configure | 20 +++++++++---------- configure.ac | 2 +- ....1-3.cygport => log4cplus-1.1.2-1.cygport} | 0 docs/doxygen.config | 4 ++-- docs/webpage_doxygen.config | 4 ++-- include/log4cplus/version.h | 4 ++-- log4cplus.spec | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) rename cygport/{log4cplus-1.1.1-3.cygport => log4cplus-1.1.2-1.cygport} (100%) diff --git a/configure b/configure index c99dead30..10201d498 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for log4cplus 1.1.1. +# Generated by GNU Autoconf 2.69 for log4cplus 1.1.2. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='log4cplus' PACKAGE_TARNAME='log4cplus' -PACKAGE_VERSION='1.1.1' -PACKAGE_STRING='log4cplus 1.1.1' +PACKAGE_VERSION='1.1.2' +PACKAGE_STRING='log4cplus 1.1.2' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1352,7 +1352,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures log4cplus 1.1.1 to adapt to many kinds of systems. +\`configure' configures log4cplus 1.1.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1423,7 +1423,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of log4cplus 1.1.1:";; + short | recursive ) echo "Configuration of log4cplus 1.1.2:";; esac cat <<\_ACEOF @@ -1550,7 +1550,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -log4cplus configure 1.1.1 +log4cplus configure 1.1.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2097,7 +2097,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by log4cplus $as_me 1.1.1, which was +It was created by log4cplus $as_me 1.1.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3033,7 +3033,7 @@ fi # Define the identity of the package. PACKAGE='log4cplus' - VERSION='1.1.1' + VERSION='1.1.2' # Some tools Automake needs. @@ -21739,7 +21739,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by log4cplus $as_me 1.1.1, which was +This file was extended by log4cplus $as_me 1.1.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21805,7 +21805,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -log4cplus config.status 1.1.1 +log4cplus config.status 1.1.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index cc2506c2f..a5a98c5ad 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl autoconf-2.69 dnl automake-1.12.6 dnl libtool-2.4.2 -AC_INIT([log4cplus],[1.1.1]) +AC_INIT([log4cplus],[1.1.2]) AC_CANONICAL_TARGET AC_CONFIG_SRCDIR([src/logger.cxx]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/cygport/log4cplus-1.1.1-3.cygport b/cygport/log4cplus-1.1.2-1.cygport similarity index 100% rename from cygport/log4cplus-1.1.1-3.cygport rename to cygport/log4cplus-1.1.2-1.cygport diff --git a/docs/doxygen.config b/docs/doxygen.config index 7fb3753a9..a42bbc308 100644 --- a/docs/doxygen.config +++ b/docs/doxygen.config @@ -32,7 +32,7 @@ PROJECT_NAME = log4cplus # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.1.0 +PROJECT_NUMBER = 1.1.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = log4cplus-1.1.0/docs +OUTPUT_DIRECTORY = log4cplus-1.1.2/docs # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output diff --git a/docs/webpage_doxygen.config b/docs/webpage_doxygen.config index b844be4c0..9dcd9e8ca 100644 --- a/docs/webpage_doxygen.config +++ b/docs/webpage_doxygen.config @@ -32,7 +32,7 @@ PROJECT_NAME = log4cplus # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.1.1 +PROJECT_NUMBER = 1.1.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = webpage_docs-1.1.1 +OUTPUT_DIRECTORY = webpage_docs-1.1.2 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output diff --git a/include/log4cplus/version.h b/include/log4cplus/version.h index a5485ddab..eb5d47cbc 100644 --- a/include/log4cplus/version.h +++ b/include/log4cplus/version.h @@ -38,8 +38,8 @@ #define LOG4CPLUS_MAKE_VERSION_STR(major, minor, point) \ #major "." #minor "." #point -#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 1) -#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 1) +#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 2) +#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 2) namespace log4cplus diff --git a/log4cplus.spec b/log4cplus.spec index 58be1d0b1..539596b73 100644 --- a/log4cplus.spec +++ b/log4cplus.spec @@ -1,5 +1,5 @@ Name: log4cplus -Version: 1.1.0 +Version: 1.1.2 Release: 1 Summary: log4cplus, C++ logging library From 10d9ead0ff2edc55ae735d76f42e3176b4275b16 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 29 May 2013 14:49:37 +0200 Subject: [PATCH 093/226] README: Document --enable-so-version and --enable-release-version configure script options. --- README | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README b/README index e6c5a16a0..3f0b7bbaa 100644 --- a/README +++ b/README @@ -52,6 +52,22 @@ This option is enabled by default. It adds platform / compiler dependent warning options to compiler command line. +`--enable-so-version` +--------------------- + +This option is enabled by default. It enables SO version decoration +on resulting library file, e.g., the `.2.0.0` in +`liblog4cplus-1.2.so.2.0.0`. + + +`--enable-release-version` +-------------------------- + +This option is enabled by default. It enables release version +decoration on the resulting library file, e.g., the `-1.2` in +`liblog4cplus-1.2.so.2.0.0`. + + --enable-profiling ------------------ From ebc1db67d561aaca6a4e3392eed5f7e85404416e Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 29 May 2013 23:00:53 +0200 Subject: [PATCH 094/226] ChangeLog: Update for 1.1.2-RC1. --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2e3083f51..d54ac27ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +log4cplus 1.1.2-RC1 + +- Fixed bug #163 - Initialization issue. + +- Added --enable-so-version and --enable-release-version configure + script options to allow production of undecorated binaries. + + log4cplus 1.1.1 - FileAppender - Accept also std::ios_base::ate as "append to a log From a29109132777bf6c0b6e1b22231d6f373d537223 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 3 Jun 2013 16:23:35 +0200 Subject: [PATCH 095/226] prepare_dist_from_bzr.sh: Create POSIX format tar files. --- scripts/prepare_dist_from_bzr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare_dist_from_bzr.sh b/scripts/prepare_dist_from_bzr.sh index 69f494ffe..efaf8b8a1 100755 --- a/scripts/prepare_dist_from_bzr.sh +++ b/scripts/prepare_dist_from_bzr.sh @@ -85,7 +85,7 @@ $SEVENZA a -t7z "$DEST_DIR/$SRC_DIR".7z "$SRC_DIR" >/dev/null \ & $SEVENZA a -tzip "$DEST_DIR/$SRC_DIR".zip "$SRC_DIR" >/dev/null TAR_FILE="$SRC_DIR".tar -$TAR -cf "$TAR_FILE" "$SRC_DIR" +$TAR -c --format=posix -f "$TAR_FILE" "$SRC_DIR" $XZ -e -c "$TAR_FILE" >"$DEST_DIR/$TAR_FILE".xz \ & $BZIP2 -9 -c "$TAR_FILE" >"$DEST_DIR/$TAR_FILE".bz2 \ From fb0a293a75afac682d181e0ee5e5c9a6dad6c73f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 3 Jun 2013 16:48:13 +0200 Subject: [PATCH 096/226] propagate-version.pl: Update from trunk. --- scripts/propagate-version.pl | 40 +++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/scripts/propagate-version.pl b/scripts/propagate-version.pl index 188c1b717..bbfe1554a 100755 --- a/scripts/propagate-version.pl +++ b/scripts/propagate-version.pl @@ -28,6 +28,28 @@ BEGIN } } +close $fh; + +# parse SO version from configure.ac + +open (my $fh2, "<", "configure.ac") + or die $!; + +my ($so_current, $so_revision, $so_age); +while (my $line = <$fh2>) +{ + if ($line =~ m/\s* LT_VERSION= \s* + (\d+) \s* : \s* (\d+) \s* : \s* (\d+) \s*/x) + { + ($so_current, $so_revision, $so_age) = ($1, $2, $3); + print +("SO version: ", $so_current, ".", $so_revision, ".", $so_age, + "\n"); + last; + } +} + +close $fh2; + # edit configure.ac { @@ -63,15 +85,13 @@ BEGIN $line =~ s/(Release: \s*)(.*)/${1}1/x; print $line; } -} -my @cygport = ; -die "cannot cope with multiple Cygport files" if (@cygport > 1); -my $cygport = @cygport[0]; -my $new_cygport = "cygport/log4cplus-$version-1.cygport"; -if ($cygport ne $new_cygport) -{ - system("bzr mv \"$cygport\" \"$new_cygport\"") == 0 - or die "bzr mv on $cygport has failed: $?"; + local @ARGV = ("cygport/log4cplus.cygport"); + while (my $line = <>) + { + $line =~ s/(\s* VERSION \s* = \s*)(\d+\.\d+\.\d+)(-.+)?/$1$version$3/x + || $line =~ s/\d+ ([._\-]) \d+ ([._\-]) \d+ + /$major$1$minor$2$so_current/gx; + print $line; + } } - From 3768d167cf0aa30194368f5f72546e3048ad675a Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 3 Jun 2013 16:49:08 +0200 Subject: [PATCH 097/226] Rename log4cplus-1.1.2-1.cygport to log4cplus.cygport. --- ...{log4cplus-1.1.2-1.cygport => log4cplus.cygport} | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) rename cygport/{log4cplus-1.1.2-1.cygport => log4cplus.cygport} (74%) diff --git a/cygport/log4cplus-1.1.2-1.cygport b/cygport/log4cplus.cygport similarity index 74% rename from cygport/log4cplus-1.1.2-1.cygport rename to cygport/log4cplus.cygport index 167baabce..19ef16e4e 100644 --- a/cygport/log4cplus-1.1.2-1.cygport +++ b/cygport/log4cplus.cygport @@ -1,3 +1,6 @@ +NAME=log4cplus +VERSION=1.1.2-rc1 +RELEASE=1 CATEGORY="Libs" SUMMARY="C++ logging library" DESCRIPTION="log4cplus is a simple to use C++ logging API providing thread-safe, @@ -9,12 +12,12 @@ SRC_URI="mirror://sourceforge/log4cplus/log4cplus-stable/${PV%-rc*}/${P}.tar.xz" PATCH_URI="configure.ac-relax-libtool-version.patch configure.ac-disable-__thread-keyword.patch" -PKG_NAMES="lib${PN}1.1_6 lib${PN}qt4debugappender1.1_6 +PKG_NAMES="lib${PN}1.1_7 lib${PN}qt4debugappender1.1_7 lib${PN}-devel lib${PN}qt4debugappender-devel" -liblog4cplus1_1_6_SUMMARY="${SUMMARY} (runtime)" -liblog4cplus1_1_6_CONTENTS="usr/bin/cyglog4cplus-1-1-6.dll" -liblog4cplusqt4debugappender1_1_6_SUMMARY="${SUMMARY} (Qt4 runtime)" -liblog4cplusqt4debugappender1_1_6_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-6.dll" +liblog4cplus1_1_7_SUMMARY="${SUMMARY} (runtime)" +liblog4cplus1_1_7_CONTENTS="usr/bin/cyglog4cplus-1-1-7.dll" +liblog4cplusqt4debugappender1_1_7_SUMMARY="${SUMMARY} (Qt4 runtime)" +liblog4cplusqt4debugappender1_1_7_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-7.dll" liblog4cplus_devel_SUMMARY="${SUMMARY} (development)" liblog4cplus_devel_CONTENTS="--exclude=*qt4* usr/include/ usr/lib/ usr/share/doc/" liblog4cplusqt4debugappender_devel_SUMMARY="${SUMMARY} (Qt4 development)" From 489a80891f1d8cfb91eaff306f67f82be8b14028 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 4 Jun 2013 14:42:06 +0200 Subject: [PATCH 098/226] internal.h (get_ptd): Remove `alloc = false` to fix SIGSEGV in new threads when log4cplus is compiled with _WIN32_WINNT>=0x0600. --- include/log4cplus/internal/internal.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/include/log4cplus/internal/internal.h b/include/log4cplus/internal/internal.h index 97a8aabe0..3b467ef73 100644 --- a/include/log4cplus/internal/internal.h +++ b/include/log4cplus/internal/internal.h @@ -150,17 +150,9 @@ set_ptd (per_thread_data * p) } -//! The default value of the \param alloc is false for Win32 DLL builds -//! since per thread data are already initialized by DllMain(). inline per_thread_data * -get_ptd (bool alloc -#if defined (_WIN32) && defined (LOG4CPLUS_BUILD_DLL) - = false -#else - = true -#endif - ) +get_ptd (bool alloc = true) { if (LOG4CPLUS_UNLIKELY (! ptd && alloc)) return alloc_ptd (); From 0f801dfe0585611cc9035e8ad7f2ea844afdf1cc Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 17 Jun 2013 23:57:15 +0200 Subject: [PATCH 099/226] fileappender.cxx (RollingFileAppender::append): Roll log file both before and after FileAppener::append(), if needed. Based on patch by the BIND 10 project. See also http://bind10.isc.org/ticket/1622. --- src/fileappender.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/fileappender.cxx b/src/fileappender.cxx index e93abb600..4ca8aeef8 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -488,11 +488,20 @@ RollingFileAppender::~RollingFileAppender() void RollingFileAppender::append(const spi::InternalLoggingEvent& event) { + // Seek to the end of log file so that tellp() below returns the + // right size. + if (useLockFile) + out.seekp (0, std::ios_base::end); + + // Rotate log file if needed before appending to it. + if (out.tellp() > maxFileSize) + rollover(true); + FileAppender::append(event); - if(out.tellp() > maxFileSize) { + // Rotate log file if needed after appending to it. + if (out.tellp() > maxFileSize) rollover(true); - } } From 44dbff4da7bd10b2656535c0111ba148799d8020 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 18 Jun 2013 00:24:27 +0200 Subject: [PATCH 100/226] appender.h (Appender::isClosed): New function. loggerimpl.cxx (LoggerImpl::closeNestedAppenders): Check isClosed() before calling close() to avoid closing appender more than once. This fixes bug #166. Reported by: Marius Shekow --- include/log4cplus/appender.h | 8 ++++++++ src/loggerimpl.cxx | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/appender.h b/include/log4cplus/appender.h index 051dcecce..07d64da6e 100644 --- a/include/log4cplus/appender.h +++ b/include/log4cplus/appender.h @@ -148,6 +148,14 @@ namespace log4cplus { */ virtual void close() = 0; + /** + * Check the `closed` member value. + */ + bool isClosed() const + { + return closed; + } + /** * This method performs threshold checks and invokes filters before * delegating actual logging to the subclasses specific {@link diff --git a/src/loggerimpl.cxx b/src/loggerimpl.cxx index ea6455b6f..459831c03 100644 --- a/src/loggerimpl.cxx +++ b/src/loggerimpl.cxx @@ -80,9 +80,12 @@ void LoggerImpl::closeNestedAppenders() { SharedAppenderPtrList appenders = getAllAppenders(); - for(SharedAppenderPtrList::iterator it=appenders.begin(); it!=appenders.end(); ++it) + for(SharedAppenderPtrList::iterator it=appenders.begin(); + it!=appenders.end(); ++it) { - (*it)->close(); + Appender & appender = **it; + if (! appender.isClosed()) + appender.close(); } } From f031d2a533e139e4e9ad5ca84e9fb3446ef12496 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 20 Jun 2013 23:59:18 +0200 Subject: [PATCH 101/226] Merge Appender and FileAppender improvements from trunk. r1231: fileappender.cxx: Do not call destructorImpl() from dtors of RollingFileAppender and DailyRollingFileAppender. Appender's dtor already does that. appender.cxx: Move debugging output after `closed` check. r1232: fileappender.cxx: Partially revert the previous change set. r1233: fileappender.cxx: Reformat overlong comments. r1234: appender.h (Appender::destructorImpl): Add documentation. (Appender::isClosed): Move out of line, into appender.cxx. appender.cxx (Appender::isClosed): Implement here. (Appender::~Appender): Restore "Destroying appender named [...]." diagnostics here. Also add warning about missing call to destructorImpl(). --- include/log4cplus/appender.h | 15 ++++++++++----- src/appender.cxx | 27 +++++++++++++++++++-------- src/fileappender.cxx | 10 ++++++---- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/include/log4cplus/appender.h b/include/log4cplus/appender.h index 07d64da6e..5eca94c77 100644 --- a/include/log4cplus/appender.h +++ b/include/log4cplus/appender.h @@ -137,6 +137,14 @@ namespace log4cplus { // Dtor virtual ~Appender(); + /** + * This function is for derived appenders to call from their + * destructors. All classes derived from `Appender` class + * _must_ call this function from their destructors. It + * ensures that appenders will get properly closed during + * shutdown by call to `close()` function before they are + * destroyed. + */ void destructorImpl(); // Methods @@ -149,12 +157,9 @@ namespace log4cplus { virtual void close() = 0; /** - * Check the `closed` member value. + * Check if this appender is in closed state. */ - bool isClosed() const - { - return closed; - } + bool isClosed() const; /** * This method performs threshold checks and invokes filters before diff --git a/src/appender.cxx b/src/appender.cxx index 625729d7c..56f6f9f02 100644 --- a/src/appender.cxx +++ b/src/appender.cxx @@ -207,7 +207,16 @@ Appender::Appender(const log4cplus::helpers::Properties & properties) Appender::~Appender() -{ } +{ + helpers::LogLog & loglog = helpers::getLogLog (); + + loglog.debug(LOG4CPLUS_TEXT("Destroying appender named [") + name + + LOG4CPLUS_TEXT("].")); + + if (! closed) + loglog.error ( + LOG4CPLUS_TEXT ("Derived Appender did not call destructorImpl().")); +} @@ -218,13 +227,10 @@ Appender::~Appender() void Appender::destructorImpl() { - helpers::getLogLog().debug( LOG4CPLUS_TEXT("Destroying appender named [") - + name - + LOG4CPLUS_TEXT("].")); - - // An appender might be closed then destroyed. There is no - // point in closing twice. - if(closed) + // An appender might be closed then destroyed. There is no point + // in closing twice. It can actually be a wrong thing to do, e.g., + // files get rolled more than once. + if (closed) return; close(); @@ -232,6 +238,11 @@ Appender::destructorImpl() } +bool Appender::isClosed() const +{ + return closed; +} + void Appender::doAppend(const log4cplus::spi::InternalLoggingEvent& event) diff --git a/src/fileappender.cxx b/src/fileappender.cxx index 4ca8aeef8..1d1a782e9 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -396,8 +396,9 @@ FileAppender::reopen() { // Close the current file out.close(); - out.clear(); // reset flags since the C++ standard specified that all the - // flags should remain unchanged on a close + // reset flags since the C++ standard specified that all + // the flags should remain unchanged on a close + out.clear(); // Re-open the file. open(std::ios_base::out | std::ios_base::ate); @@ -748,8 +749,9 @@ DailyRollingFileAppender::rollover(bool alreadyLocked) // Close the current file out.close(); - out.clear(); // reset flags since the C++ standard specified that all the - // flags should remain unchanged on a close + // reset flags since the C++ standard specified that all the flags + // should remain unchanged on a close + out.clear(); // If we've already rolled over this time period, we'll make sure that we // don't overwrite any of those previous files. From c30b7b3c138aab1c9c947341ba7b2fe6dc09227d Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 30 Jun 2013 12:51:34 +0200 Subject: [PATCH 102/226] configure.ac: Bump SO bersion to 8:1:1 for recent changes. configure: Regenerate. --- configure | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 10201d498..5826ffe42 100755 --- a/configure +++ b/configure @@ -4219,7 +4219,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=7:0:0 +LT_VERSION=8:1:1 LT_RELEASE=1.1 diff --git a/configure.ac b/configure.ac index a5a98c5ad..ded395eef 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=7:0:0 +LT_VERSION=8:1:1 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) From 8c5bd39ba0b3fdd105e19271881021e183735bbc Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 30 Jun 2013 12:52:45 +0200 Subject: [PATCH 103/226] propagate-version.pl: Adjust propagated SO version for Cygwin cygport file. --- scripts/propagate-version.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/propagate-version.pl b/scripts/propagate-version.pl index bbfe1554a..08b09cd42 100755 --- a/scripts/propagate-version.pl +++ b/scripts/propagate-version.pl @@ -35,7 +35,7 @@ BEGIN open (my $fh2, "<", "configure.ac") or die $!; -my ($so_current, $so_revision, $so_age); +my ($so_current, $so_revision, $so_age, $so_current_adjusted); while (my $line = <$fh2>) { if ($line =~ m/\s* LT_VERSION= \s* @@ -44,6 +44,9 @@ BEGIN ($so_current, $so_revision, $so_age) = ($1, $2, $3); print +("SO version: ", $so_current, ".", $so_revision, ".", $so_age, "\n"); + $so_current_adjusted = $so_current - $so_age; + print +("MingGW/Cygwin version: ", $major, "-", $minor, "-", + $so_current_adjusted, "\n"); last; } } @@ -91,7 +94,7 @@ BEGIN { $line =~ s/(\s* VERSION \s* = \s*)(\d+\.\d+\.\d+)(-.+)?/$1$version$3/x || $line =~ s/\d+ ([._\-]) \d+ ([._\-]) \d+ - /$major$1$minor$2$so_current/gx; + /$major$1$minor$2$so_current_adjusted/gx; print $line; } } From 84c6b20fc6b428a3aee6eef104a375cfe3e2021b Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 3 Jul 2013 22:35:28 +0200 Subject: [PATCH 104/226] ChaneLog: Update for 1.1.2-RC2. --- ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index d54ac27ba..f0acc44db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +log4cplus 1.1.2-RC2 + +- Fixed crash of DLL builds on Windows when _WIN32_WINNT>=0x0600. + +- Roll log file both before and after append to avoid logging into + stale file when the log file has already been rolled by another + logging process. + +- Known issue: Logging into a single log file from multiple processes + on Windows breaks the rolling of the log files because open files + cannot be renamed. + +- Fixed bug #166 - Close appender only once even when it is used by + multiple loggers. + + log4cplus 1.1.2-RC1 - Fixed bug #163 - Initialization issue. From cb5068ad53c99f2208249a9569d8e839ceb8dd6f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 16 Jul 2013 07:56:11 +0200 Subject: [PATCH 105/226] stringhelper.h: Appease HP aCC compiler. --- include/log4cplus/helpers/stringhelper.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/log4cplus/helpers/stringhelper.h b/include/log4cplus/helpers/stringhelper.h index 0b110d641..56d150c92 100644 --- a/include/log4cplus/helpers/stringhelper.h +++ b/include/log4cplus/helpers/stringhelper.h @@ -159,10 +159,12 @@ namespace log4cplus { typedef std::numeric_limits intTypeLimits; typedef ConvertIntegerToStringHelper HelperType; + + tchar buffer[intTypeLimits::digits10 + 2]; + // We define buffer_size from buffer using sizeof operator + // to appease HP aCC compiler. + const std::size_t buffer_size = sizeof (buffer) / sizeof (tchar); - const std::size_t buffer_size - = intTypeLimits::digits10 + 2; - tchar buffer[buffer_size]; tchar * it = &buffer[buffer_size]; tchar const * const buf_end = it; From e22cce064a371a0e1577d5dcbb0543a290f3e512 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 16 Jul 2013 07:59:43 +0200 Subject: [PATCH 106/226] m4/ax_tls_support.m4: Check that thread-local pointers to classes are usable. configure: Regenerate. --- configure | 18 ++++++++++++++++++ m4/ax_tls_support.m4 | 22 ++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 5826ffe42..2451f21c1 100755 --- a/configure +++ b/configure @@ -9486,6 +9486,11 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern thread_local S * p_s; + thread_local S * p_s = 0; + extern thread_local int x; thread_local int * ptr = 0; int foo () { ptr = &x; return x; } @@ -9496,6 +9501,7 @@ main () { x = 2; foo (); + p_s = new S; ; return 0; } @@ -9537,6 +9543,11 @@ else #endif #endif + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern __thread S * p_s; + __thread S * p_s = 0; + extern __thread int x; __thread int * ptr = 0; int foo () { ptr = &x; return x; } @@ -9547,6 +9558,7 @@ main () { x = 2; foo (); + p_s = new S; ; return 0; @@ -9589,6 +9601,11 @@ else # error Please fail. And extra please fail. #else + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern __declspec(thread) S * p_s; + __declspec(thread) S * p_s = 0; + extern __declspec(thread) int x; __declspec(thread) int * ptr = 0; int foo () { ptr = &x; return x; } @@ -9600,6 +9617,7 @@ main () { x = 2; foo (); + p_s = new S; ; return 0; } diff --git a/m4/ax_tls_support.m4 b/m4/ax_tls_support.m4 index 641068971..95cdc50bc 100644 --- a/m4/ax_tls_support.m4 +++ b/m4/ax_tls_support.m4 @@ -15,13 +15,19 @@ AC_CACHE_CHECK([for thread_local], [ac_cv_thread_local], AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern thread_local S * p_s; + thread_local S * p_s = 0; + extern thread_local int x; thread_local int * ptr = 0; int foo () { ptr = &x; return x; } thread_local int x = 1; ]], [[x = 2; - foo ();]])], + foo (); + p_s = new S;]])], [ac_cv_thread_local=yes ax_tls_support=yes], [ac_cv_thread_local=no], @@ -43,6 +49,11 @@ AC_CACHE_CHECK([for __thread], [ac_cv__thread_keyword], [ #endif #endif + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern __thread S * p_s; + __thread S * p_s = 0; + extern __thread int x; __thread int * ptr = 0; int foo () { ptr = &x; return x; } @@ -50,6 +61,7 @@ AC_CACHE_CHECK([for __thread], [ac_cv__thread_keyword], [ ]], [[x = 2; foo (); + p_s = new S; ]])], [ac_cv__thread_keyword=yes ax_tls_support=yes], @@ -71,6 +83,11 @@ AC_CACHE_CHECK([for __declspec(thread)], [ac_cv_declspec_thread], [ # error Please fail. And extra please fail. #else + // check that pointers to classes work as well + struct S { S () { } void foo () { } int member; }; + extern __declspec(thread) S * p_s; + __declspec(thread) S * p_s = 0; + extern __declspec(thread) int x; __declspec(thread) int * ptr = 0; int foo () { ptr = &x; return x; } @@ -78,7 +95,8 @@ And extra please fail. #endif ]], [[x = 2; - foo ();]])], + foo (); + p_s = new S;]])], [ac_cv_declspec_thread=yes ax_tls_support=yes], [ac_cv_declspec_thread=no], From 94a86d51053a649951e3cf050f5fc718dc834476 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 16 Jul 2013 08:03:02 +0200 Subject: [PATCH 107/226] README: Add note about HP-UX with aCC. --- README | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README b/README index 3f0b7bbaa..952242b88 100644 --- a/README +++ b/README @@ -256,6 +256,14 @@ CXX=/opt/solarisstudio12.3/bin/CC CFLAGS="$COMMON_FLAGS" \ CXXFLAGS="$COMMON_FLAGS" LDFLAGS="-lpthread" +HP-UX with aCC +-------------- + +It is necessary to turn on C++98 mode of aCC by providing the `-AA` flag: + + $ ../configure --enable-threds=yes CXXFLAGS="-AA" + + Qt / Win32 / MSVC ----------------- From d6cb175e89e798e3959e1e1de23fb267749383c7 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 27 Jul 2013 22:01:08 +0200 Subject: [PATCH 108/226] ax_declspec.m4: Make __declspec(dllexport) test fail for Haiku as its GCC does not support the attribute there. --- configure | 5 +++-- m4/ax_declspec.m4 | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 2451f21c1..34c578e61 100755 --- a/configure +++ b/configure @@ -7248,9 +7248,10 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if defined (__clang__) +#if defined (__clang__) || defined (__HAIKU__) // Here the problem is that Clang only warns that it does not support -// __declspec(dllexport) but still compiles the executable. +// __declspec(dllexport) but still compiles the executable. GCC on Haiku OS +// suffers from the same problem. # error Please fail. And extra please fail. #else diff --git a/m4/ax_declspec.m4 b/m4/ax_declspec.m4 index 19672d390..e0a395f2d 100644 --- a/m4/ax_declspec.m4 +++ b/m4/ax_declspec.m4 @@ -48,9 +48,10 @@ AC_CACHE_CHECK([for __declspec(dllexport) and __declspec(dllimport)], AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ -#if defined (__clang__) +#if defined (__clang__) || defined (__HAIKU__) // Here the problem is that Clang only warns that it does not support -// __declspec(dllexport) but still compiles the executable. +// __declspec(dllexport) but still compiles the executable. GCC on Haiku OS +// suffers from the same problem. # error Please fail. And extra please fail. #else From fd24b736ffba886ab54f27e2ff654a2ade7273fc Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 27 Jul 2013 22:03:23 +0200 Subject: [PATCH 109/226] configure.ac: Check for network related functions in libnetwork to support Haiku and in libnet to (possibly) support BeOS. configure: Regenerate. --- configure | 4 ++-- configure.ac | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 34c578e61..7f227ff0b 100755 --- a/configure +++ b/configure @@ -7971,7 +7971,7 @@ return gethostbyname (); return 0; } _ACEOF -for ac_lib in '' nsl; do +for ac_lib in '' nsl network net; do if test -z "$ac_lib"; then ac_res="none required" else @@ -8027,7 +8027,7 @@ return setsockopt (); return 0; } _ACEOF -for ac_lib in '' socket; do +for ac_lib in '' socket network net; do if test -z "$ac_lib"; then ac_res="none required" else diff --git a/configure.ac b/configure.ac index ded395eef..e4324b047 100644 --- a/configure.ac +++ b/configure.ac @@ -318,8 +318,8 @@ AC_SEARCH_LIBS([clock_gettime], [rt posix4]) dnl On some systems libcompat exists only as a static library which dnl breaks compilation of shared library log4cplus. dnl AC_SEARCH_LIBS([ftime], [compat]) -AC_SEARCH_LIBS([gethostbyname], [nsl]) -AC_SEARCH_LIBS([setsockopt], [socket]) +AC_SEARCH_LIBS([gethostbyname], [nsl network net]) +AC_SEARCH_LIBS([setsockopt], [socket network net]) AS_IF([test "x$with_iconv" = "xyes"], [AC_SEARCH_LIBS([iconv_open], [iconv], [], [AC_SEARCH_LIBS([libiconv_open], [iconv])])]) From 3ae54b06eb5076f21d23282cb8c2e503b9384e23 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 27 Jul 2013 22:15:08 +0200 Subject: [PATCH 110/226] README: Add a note about Haiku support. --- README | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README b/README index 952242b88..829a940de 100644 --- a/README +++ b/README @@ -31,6 +31,7 @@ Tested on the following platforms - NetBSD 5.0.2/AMD64 with GCC 4.1.3 20080704 prerelease (NetBSD nb2 20081120) - OpenBSD 5.0/AMD64 with GCC 4.2.1 20070719 +- Haiku R1 Alpha 4.1 with GCC 4.6.3 Configure script options @@ -264,6 +265,23 @@ It is necessary to turn on C++98 mode of aCC by providing the `-AA` flag: $ ../configure --enable-threds=yes CXXFLAGS="-AA" +Haiku +----- + +Haiku is supported with GCC 4+. The default GCC version in Haiku is +set to version 2 (based on GCC 2.95.x). To change the default GCC +version to version 4, please run `setgcc gcc4` command. This is to +avoid linking errors like this: + +~~~~ +main.cpp:(.text.startup+0x54a): undefined reference to `_Unwind_Resume' +~~~~ + +Running the command switches the _current_ GCC version to version 4. +This change is permanent and global. See also Haiku ticket +[#8368](http://dev.haiku-os.org/ticket/8368). + + Qt / Win32 / MSVC ----------------- From b7a1f7cef14edae8d44db54c107fbd4cbde3705f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 14 Aug 2013 13:18:31 +0200 Subject: [PATCH 111/226] android.toolchain.cmake: Update to revision 80f6ede2 in OpenCV repository. --- android/android.toolchain.cmake | 367 +++++++++++++++++++++++--------- 1 file changed, 272 insertions(+), 95 deletions(-) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index f5daf307f..d7f09c788 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -1,5 +1,5 @@ # Copyright (c) 2010-2011, Ethan Rublee -# Copyright (c) 2011-2012, Andrey Kamaev +# Copyright (c) 2011-2013, Andrey Kamaev # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -281,8 +281,17 @@ # [+] updated for NDK r8c # [+] added support for clang compiler # - December 2012 +# [+] suppress warning about unused CMAKE_TOOLCHAIN_FILE variable +# [+] adjust API level to closest compatible as NDK does # [~] fixed ccache full path search # [+] updated for NDK r8d +# [~] compiler options are aligned with NDK r8d +# - March 2013 +# [+] updated for NDK r8e (x86 version) +# [+] support x86_64 version of NDK +# - April 2013 +# [+] support non-release NDK layouts (from Linaro git and Android git) +# [~] automatically detect if explicit link to crtbegin_*.o is needed # ------------------------------------------------------------------------------ cmake_minimum_required( VERSION 2.6.3 ) @@ -292,6 +301,10 @@ if( DEFINED CMAKE_CROSSCOMPILING ) return() endif() +if( CMAKE_TOOLCHAIN_FILE ) + # touch toolchain variable only to suppress "unused variable" warning +endif() + get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE ) if( _CMAKE_IN_TRY_COMPILE ) include( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL ) @@ -305,7 +318,7 @@ set( CMAKE_SYSTEM_VERSION 1 ) # rpath makes low sence for Android set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) -set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS) if( CMAKE_HOST_WIN32 ) file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) @@ -449,19 +462,32 @@ if( ANDROID_FORBID_SYGWIN ) endif() endif() + # detect current host platform +if( NOT DEFINED ANDROID_NDK_HOST_X64 AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64") + set( ANDROID_NDK_HOST_X64 1 CACHE BOOL "Try to use 64-bit compiler toolchain" ) + mark_as_advanced( ANDROID_NDK_HOST_X64 ) +endif() + set( TOOL_OS_SUFFIX "" ) if( CMAKE_HOST_APPLE ) - set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "darwin-x86" ) elseif( CMAKE_HOST_WIN32 ) - set( ANDROID_NDK_HOST_SYSTEM_NAME "windows" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "windows-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "windows" ) set( TOOL_OS_SUFFIX ".exe" ) elseif( CMAKE_HOST_UNIX ) - set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "linux-x86" ) else() message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" ) endif() +if( NOT ANDROID_NDK_HOST_X64 ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) +endif() + # see if we have path to Android NDK __INIT_VARIABLE( ANDROID_NDK PATH ENV_ANDROID_NDK ) if( NOT ANDROID_NDK ) @@ -493,23 +519,19 @@ if( NOT ANDROID_NDK ) endif( ANDROID_NDK ) endif( NOT ANDROID_STANDALONE_TOOLCHAIN ) endif( NOT ANDROID_NDK ) + # remember found paths if( ANDROID_NDK ) get_filename_component( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE ) - # try to detect change - if( CMAKE_AR ) - string( LENGTH "${ANDROID_NDK}" __length ) - string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath ) - if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK ) - message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first. - " ) - endif() - unset( __androidNdkPreviousPath ) - unset( __length ) - endif() set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE ) set( BUILD_WITH_ANDROID_NDK True ) - file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? ) + if( EXISTS "${ANDROID_NDK}/RELEASE.TXT" ) + file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? ) + string( REGEX MATCH r[0-9]+[a-z]? ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" ) + else() + set( ANDROID_NDK_RELEASE "r1x" ) + set( ANDROID_NDK_RELEASE_FULL "unreleased" ) + endif() elseif( ANDROID_STANDALONE_TOOLCHAIN ) get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE ) # try to detect change @@ -536,6 +558,51 @@ else() sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" ) endif() +# android NDK layout +if( BUILD_WITH_ANDROID_NDK ) + if( NOT DEFINED ANDROID_NDK_LAYOUT ) + # try to automatically detect the layout + if( EXISTS "${ANDROID_NDK}/RELEASE.TXT") + set( ANDROID_NDK_LAYOUT "RELEASE" ) + elseif( EXISTS "${ANDROID_NDK}/../../linux-x86/toolchain/" ) + set( ANDROID_NDK_LAYOUT "LINARO" ) + elseif( EXISTS "${ANDROID_NDK}/../../gcc/" ) + set( ANDROID_NDK_LAYOUT "ANDROID" ) + endif() + endif() + set( ANDROID_NDK_LAYOUT "${ANDROID_NDK_LAYOUT}" CACHE STRING "The inner layout of NDK" ) + mark_as_advanced( ANDROID_NDK_LAYOUT ) + if( ANDROID_NDK_LAYOUT STREQUAL "LINARO" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../${ANDROID_NDK_HOST_SYSTEM_NAME}/toolchain" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" ) + elseif( ANDROID_NDK_LAYOUT STREQUAL "ANDROID" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../gcc/${ANDROID_NDK_HOST_SYSTEM_NAME}/arm" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" ) + else() # ANDROID_NDK_LAYOUT STREQUAL "RELEASE" + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/toolchains" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME2}" ) + endif() + get_filename_component( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK_TOOLCHAINS_PATH}" ABSOLUTE ) + + # try to detect change of NDK + if( CMAKE_AR ) + string( LENGTH "${ANDROID_NDK_TOOLCHAINS_PATH}" __length ) + string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath ) + if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK_TOOLCHAINS_PATH ) + message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first. + " ) + endif() + unset( __androidNdkPreviousPath ) + unset( __length ) + endif() +endif() + + # get all the details about standalone toolchain if( BUILD_WITH_STANDALONE_TOOLCHAIN ) __DETECT_NATIVE_API_LEVEL( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" ) @@ -563,22 +630,27 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN ) endif() endif() -macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar ) - foreach( __toolchain ${${__availableToolchainsVar}} ) - if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/" ) +macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath ) + foreach( __toolchain ${${__availableToolchainsLst}} ) + if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) else() set( __gcc_toolchain "${__toolchain}" ) endif() - __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__gcc_toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) + __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" ) if( __machine ) - string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?$" __version "${__gcc_toolchain}" ) - string( REGEX MATCH "^[^-]+" __arch "${__gcc_toolchain}" ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" ) + if( __machine MATCHES i686 ) + set( __arch "x86" ) + elseif( __machine MATCHES arm ) + set( __arch "arm" ) + elseif( __machine MATCHES mipsel ) + set( __arch "mipsel" ) + endif() list( APPEND __availableToolchainMachines "${__machine}" ) list( APPEND __availableToolchainArchs "${__arch}" ) list( APPEND __availableToolchainCompilerVersions "${__version}" ) - else() - list( REMOVE_ITEM ${__availableToolchainsVar} "${__toolchain}" ) + list( APPEND ${__availableToolchainsVar} "${__toolchain}" ) endif() unset( __gcc_toolchain ) endforeach() @@ -592,19 +664,31 @@ if( BUILD_WITH_ANDROID_NDK ) set( __availableToolchainMachines "" ) set( __availableToolchainArchs "" ) set( __availableToolchainCompilerVersions "" ) - if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/" ) + if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_TOOLCHAIN_NAME}/" ) # do not go through all toolchains if we know the name - set( __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" ) - __GLOB_NDK_TOOLCHAINS( __availableToolchains ) + set( __availableToolchainsLst "${ANDROID_TOOLCHAIN_NAME}" ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) + if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" ) + if( __availableToolchains ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} ) + endif() + endif() endif() if( NOT __availableToolchains ) - file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" ) + file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" ) if( __availableToolchains ) - list(SORT __availableToolchains) # we need clang to go after gcc + list(SORT __availableToolchainsLst) # we need clang to go after gcc + endif() + __LIST_FILTER( __availableToolchainsLst "^[.]" ) + __LIST_FILTER( __availableToolchainsLst "llvm" ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) + if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" ) + if( __availableToolchains ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} ) + endif() endif() - __LIST_FILTER( __availableToolchains "^[.]" ) - __LIST_FILTER( __availableToolchains "llvm" ) - __GLOB_NDK_TOOLCHAINS( __availableToolchains ) endif() if( NOT __availableToolchains ) message( FATAL_ERROR "Could not find any working toolchain in the NDK. Probably your Android NDK is broken." ) @@ -617,11 +701,11 @@ set( __uniqToolchainArchNames ${__availableToolchainArchs} ) list( REMOVE_DUPLICATES __uniqToolchainArchNames ) list( SORT __uniqToolchainArchNames ) foreach( __arch ${__uniqToolchainArchNames} ) -list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} ) + list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} ) endforeach() unset( __uniqToolchainArchNames ) if( NOT ANDROID_SUPPORTED_ABIS ) -message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." ) + message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." ) endif() # choose target ABI @@ -733,6 +817,7 @@ else() list( GET __availableToolchainArchs ${__idx} __toolchainArch ) if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME ) list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion ) + string( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}") if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion ) set( __toolchainMaxVersion "${__toolchainVersion}" ) set( __toolchainIdx ${__idx} ) @@ -760,11 +845,22 @@ unset( __availableToolchainCompilerVersions ) # choose native API level __INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL ) string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" ) -# TODO: filter out unsupported levels +# adjust API level +set( __real_api_level ${ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME}} ) +foreach( __level ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + if( NOT __level GREATER ANDROID_NATIVE_API_LEVEL AND NOT __level LESS __real_api_level ) + set( __real_api_level ${__level} ) + endif() +endforeach() +if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL EQUAL __real_api_level ) + message( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'") + set( ANDROID_NATIVE_API_LEVEL ${__real_api_level} ) +endif() +unset(__real_api_level) # validate list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx ) if( __levelIdx EQUAL -1 ) - message( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." ) + message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain." ) else() if( BUILD_WITH_ANDROID_NDK ) __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" ) @@ -925,11 +1021,11 @@ if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" ) elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" ) string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}") string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) - if( NOT EXISTS "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}/bin/clang${TOOL_OS_SUFFIX}" ) - message( FATAL_ERROR "Could not find the " ) + if( NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}/bin/clang${TOOL_OS_SUFFIX}" ) + message( FATAL_ERROR "Could not find the Clang compiler driver" ) endif() set( ANDROID_COMPILER_IS_CLANG 1 ) - set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) + set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) else() set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) unset( ANDROID_COMPILER_IS_CLANG CACHE ) @@ -943,7 +1039,7 @@ endif() # setup paths and STL for NDK if( BUILD_WITH_ANDROID_NDK ) - set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) + set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" ) if( ANDROID_STL STREQUAL "none" ) @@ -1002,11 +1098,11 @@ if( BUILD_WITH_ANDROID_NDK ) endif() # find libsupc++.a - rtti & exceptions if( ANDROID_STL STREQUAL "system_re" OR ANDROID_STL MATCHES "gnustl" ) - if( ANDROID_NDK_RELEASE STRGREATER "r8" ) # r8b - set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) - elseif( NOT ANDROID_NDK_RELEASE STRLESS "r7" AND ANDROID_NDK_RELEASE STRLESS "r8b") - set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) - else( ANDROID_NDK_RELEASE STRLESS "r7" ) + set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r8b or newer + if( NOT EXISTS "${__libsupcxx}" ) + set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r7-r8 + endif() + if( NOT EXISTS "${__libsupcxx}" ) # before r7 if( ARMEABI_V7A ) if( ANDROID_FORCE_ARM_BUILD ) set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" ) @@ -1056,7 +1152,7 @@ unset( _ndk_ccache ) # setup the cross-compiler if( NOT CMAKE_C_COMPILER ) - if( NDK_CCACHE ) + if( NDK_CCACHE AND NOT ANDROID_SYSROOT MATCHES "[ ;\"]" ) set( CMAKE_C_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C compiler" ) set( CMAKE_CXX_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C++ compiler" ) if( ANDROID_COMPILER_IS_CLANG ) @@ -1128,11 +1224,25 @@ set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm ) remove_definitions( -DANDROID ) add_definitions( -DANDROID ) -if(ANDROID_SYSROOT MATCHES "[ ;\"]") - set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" ) +if( ANDROID_SYSROOT MATCHES "[ ;\"]" ) + if( CMAKE_HOST_WIN32 ) + # try to convert path to 8.3 form + file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "@echo %~s1" ) + execute_process( COMMAND "$ENV{ComSpec}" /c "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "${ANDROID_SYSROOT}" + OUTPUT_VARIABLE __path OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE __result ERROR_QUIET ) + if( __result EQUAL 0 ) + file( TO_CMAKE_PATH "${__path}" ANDROID_SYSROOT ) + set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" ) + else() + set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" ) + endif() + else() + set( ANDROID_CXX_FLAGS "'--sysroot=${ANDROID_SYSROOT}'" ) + endif() if( NOT _CMAKE_IN_TRY_COMPILE ) - # quotes will break try_compile and compiler identification - message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.") + # quotes can break try_compile and compiler identification + message(WARNING "Path to your Android NDK (or toolchain) has non-alphanumeric symbols.\nThe build might be broken.\n") endif() else() set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" ) @@ -1140,38 +1250,52 @@ endif() # NDK flags if( ARMEABI OR ARMEABI_V7A ) - set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__" ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables" ) if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 ) - # It is recommended to use the -mthumb compiler flag to force the generation - # of 16-bit Thumb-1 instructions (the default being 32-bit ARM ones). - set( ANDROID_CXX_FLAGS_RELEASE "-mthumb" ) - set( ANDROID_CXX_FLAGS_DEBUG "-marm -finline-limit=64" ) + set( ANDROID_CXX_FLAGS_RELEASE "-mthumb -fomit-frame-pointer -fno-strict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -finline-limit=64" ) + endif() else() # always compile ARMEABI_V6 in arm mode; otherwise there is no difference from ARMEABI - # O3 instead of O2/Os in release mode - like cmake sets for desktop gcc - set( ANDROID_CXX_FLAGS_RELEASE "-marm" ) - set( ANDROID_CXX_FLAGS_DEBUG "-marm -finline-limit=300" ) + set( ANDROID_CXX_FLAGS_RELEASE "-marm -fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" ) + endif() endif() elseif( X86 ) - set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) - set( ANDROID_CXX_FLAGS_RELEASE "" ) - set( ANDROID_CXX_FLAGS_DEBUG "-finline-limit=300" ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fPIC" ) + endif() + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" ) elseif( MIPS ) - set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -frename-registers" ) - set( ANDROID_CXX_FLAGS_RELEASE "-finline-limit=300 -fno-strict-aliasing" ) - set( ANDROID_CXX_FLAGS_DEBUG "-finline-functions -fgcse-after-reload -frerun-cse-after-loop" ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0" ) + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" ) + set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" ) + endif() elseif() set( ANDROID_CXX_FLAGS_RELEASE "" ) set( ANDROID_CXX_FLAGS_DEBUG "" ) endif() -if( NOT X86 ) - set( ANDROID_CXX_FLAGS "-Wno-psabi ${ANDROID_CXX_FLAGS}" ) +set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) # good/necessary when porting desktop libraries + +if( NOT X86 AND NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "-Wno-psabi ${ANDROID_CXX_FLAGS}" ) endif() -set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) # good/necessary when porting desktop libraries -set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -fomit-frame-pointer" ) -set( ANDROID_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer" ) +if( NOT ANDROID_COMPILER_VERSION VERSION_LESS "4.6" ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -no-canonical-prefixes" ) # see https://android-review.googlesource.com/#/c/47564/ +endif() # ABI-specific flags if( ARMEABI_V7A ) @@ -1189,22 +1313,18 @@ elseif( ARMEABI ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" ) endif() +if( ANDROID_STL MATCHES "gnustl" AND (EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}") ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o " ) + set( CMAKE_CXX_CREATE_SHARED_MODULE " -o " ) + set( CMAKE_CXX_LINK_EXECUTABLE " -o " ) +else() + set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o " ) + set( CMAKE_CXX_CREATE_SHARED_MODULE " -o " ) + set( CMAKE_CXX_LINK_EXECUTABLE " -o " ) +endif() + # STL if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" ) - if( ANDROID_STL MATCHES "gnustl" ) - set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o " ) - set( CMAKE_CXX_CREATE_SHARED_MODULE " -o " ) - set( CMAKE_CXX_LINK_EXECUTABLE " -o " ) - else() - set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o " ) - set( CMAKE_CXX_CREATE_SHARED_MODULE " -o " ) - set( CMAKE_CXX_LINK_EXECUTABLE " -o " ) - endif() - if ( X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" ) - # workaround "undefined reference to `__dso_handle'" problem - set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) - set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) - endif() if( EXISTS "${__libstl}" ) set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libstl}\"" ) set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libstl}\"" ) @@ -1223,9 +1343,12 @@ if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" ) set( CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} \"${__libsupcxx}\"" ) endif() if( ANDROID_STL MATCHES "gnustl" ) - set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} -lm" ) - set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} -lm" ) - set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lm" ) + if( NOT EXISTS "${ANDROID_LIBM_PATH}" ) + set( ANDROID_LIBM_PATH -lm ) + endif() + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} ${ANDROID_LIBM_PATH}" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} ${ANDROID_LIBM_PATH}" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${ANDROID_LIBM_PATH}" ) endif() endif() @@ -1261,7 +1384,14 @@ if( ARMEABI_V7A ) endif() if( ANDROID_NO_UNDEFINED ) - set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" ) + if( MIPS ) + # there is some sysroot-related problem in mips linker... + if( NOT ANDROID_SYSROOT MATCHES "[ ;\"]" ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined -Wl,-rpath-link,${ANDROID_SYSROOT}/usr/lib" ) + endif() + else() + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" ) + endif() endif() if( ANDROID_SO_UNDEFINED ) @@ -1308,9 +1438,6 @@ if( ANDROID_COMPILER_IS_CLANG ) set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS}" ) endif() if( BUILD_WITH_ANDROID_NDK ) - if(ANDROID_ARCH_NAME STREQUAL "arm" ) - set( ANDROID_CXX_FLAGS "-isystem ${ANDROID_CLANG_TOOLCHAIN_ROOT}/lib/clang/${ANDROID_CLANG_VERSION}/include ${ANDROID_CXX_FLAGS}" ) - endif() set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" ) endif() endif() @@ -1326,6 +1453,12 @@ set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared li set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags" ) set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker flags" ) +# put flags to cache (for debug purpose only) +set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" CACHE INTERNAL "Android specific c/c++ flags" ) +set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE}" CACHE INTERNAL "Android specific c/c++ Release flags" ) +set( ANDROID_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG}" CACHE INTERNAL "Android specific c/c++ Debug flags" ) +set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Android specific c/c++ linker flags" ) + # finish flags set( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" ) set( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" ) @@ -1338,9 +1471,9 @@ set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FL set( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" ) if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" ) - set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" ) - set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" ) - set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" ) + set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" ) + set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" ) + set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" ) endif() # configure rtti @@ -1367,6 +1500,43 @@ endif() include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} ) link_directories( "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ) +# detect if need link crtbegin_so.o explicitly +if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK ) + set( __cmd "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" ) + string( REPLACE "" "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" __cmd "${__cmd}" ) + string( REPLACE "" "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}" __cmd "${__cmd}" ) + string( REPLACE "" "${CMAKE_CXX_FLAGS}" __cmd "${__cmd}" ) + string( REPLACE "" "" __cmd "${__cmd}" ) + string( REPLACE "" "${CMAKE_SHARED_LINKER_FLAGS}" __cmd "${__cmd}" ) + string( REPLACE "" "-shared" __cmd "${__cmd}" ) + string( REPLACE "" "" __cmd "${__cmd}" ) + string( REPLACE "" "" __cmd "${__cmd}" ) + string( REPLACE "" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain_crtlink_test.so" __cmd "${__cmd}" ) + string( REPLACE "" "\"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" __cmd "${__cmd}" ) + string( REPLACE "" "" __cmd "${__cmd}" ) + separate_arguments( __cmd ) + foreach( __var ANDROID_NDK ANDROID_NDK_TOOLCHAINS_PATH ANDROID_STANDALONE_TOOLCHAIN ) + if( ${__var} ) + set( __tmp "${${__var}}" ) + separate_arguments( __tmp ) + string( REPLACE "${__tmp}" "${${__var}}" __cmd "${__cmd}") + endif() + endforeach() + string( REPLACE "'" "" __cmd "${__cmd}" ) + string( REPLACE "\"" "" __cmd "${__cmd}" ) + execute_process( COMMAND ${__cmd} RESULT_VARIABLE __cmd_result OUTPUT_QUIET ERROR_QUIET ) + if( __cmd_result EQUAL 0 ) + set( ANDROID_EXPLICIT_CRT_LINK ON ) + else() + set( ANDROID_EXPLICIT_CRT_LINK OFF ) + endif() +endif() + +if( ANDROID_EXPLICIT_CRT_LINK ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) +endif() + # setup output directories set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" ) set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" ) @@ -1456,7 +1626,9 @@ endmacro() if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" ) set( __toolchain_config "") foreach( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN ANDROID_SET_OBSOLETE_VARIABLES + ANDROID_NDK_HOST_X64 ANDROID_NDK + ANDROID_NDK_LAYOUT ANDROID_STANDALONE_TOOLCHAIN ANDROID_TOOLCHAIN_NAME ANDROID_ABI @@ -1470,6 +1642,8 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" ) ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO + ANDROID_LIBM_PATH + ANDROID_EXPLICIT_CRT_LINK ) if( DEFINED ${__var} ) if( "${__var}" MATCHES " ") @@ -1512,6 +1686,8 @@ endif() # ANDROID_NDK # ANDROID_STANDALONE_TOOLCHAIN # ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain +# ANDROID_NDK_HOST_X64 : try to use x86_64 toolchain (default for x64 host systems) +# ANDROID_NDK_LAYOUT : the inner NDK structure (RELEASE, LINARO, ANDROID) # LIBRARY_OUTPUT_PATH_ROOT : # NDK_CCACHE : # Obsolete: @@ -1536,7 +1712,7 @@ endif() # BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used # ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform # ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86" or "mips" depending on ANDROID_ABI -# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d; set only for NDK +# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d, r8e; set only for NDK # ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI # ANDROID_SYSROOT : path to the compiler sysroot # TOOL_OS_SUFFIX : "" or ".exe" depending on host platform @@ -1557,6 +1733,7 @@ endif() # ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime # ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used # ANDROID_CLANG_VERSION : version of clang compiler if clang is used +# ANDROID_LIBM_PATH : path to libm.so (set to something like $(TOP)/out/target/product//obj/lib/libm.so) to workaround unresolved `sincos` # # Defaults: # ANDROID_DEFAULT_NDK_API_LEVEL From 44c57f8577205b0a87d89e7bbcc63cc091f38e63 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 15 Aug 2013 12:18:40 +0200 Subject: [PATCH 112/226] Merge spec file for MinGW cross-compilation under Fedora from trunk. --- mingw-log4cplus.spec | 120 +++++++++++++++++++++++++++++++++++ scripts/propagate-version.pl | 7 +- 2 files changed, 125 insertions(+), 2 deletions(-) create mode 100755 mingw-log4cplus.spec diff --git a/mingw-log4cplus.spec b/mingw-log4cplus.spec new file mode 100755 index 000000000..4bff9e188 --- /dev/null +++ b/mingw-log4cplus.spec @@ -0,0 +1,120 @@ +Name: log4cplus +Version: 1.1.2 +Release: 1%{?dist} +Summary: log4cplus, C++ logging library + +License: Apache +Group: Development/Libraries +URL: http://log4cplus.sourceforge.net/ +Source0: http://downloads.sourceforge.net/project/log4cplus/log4cplus-stable/1.1.2/log4cplus-1.1.2.tar.gz + +BuildArch: noarch + +BuildRequires: mingw32-filesystem >= 95 +BuildRequires: mingw32-gcc +BuildRequires: mingw32-binutils +BuildRequires: mingw32-gettext +BuildRequires: mingw32-win-iconv +BuildRequires: mingw32-zlib + +BuildRequires: mingw64-filesystem >= 95 +BuildRequires: mingw64-gcc +BuildRequires: mingw64-binutils +BuildRequires: mingw64-gettext +BuildRequires: mingw64-win-iconv +BuildRequires: mingw64-zlib + +%description +log4cplus is a simple to use C++ logging API providing thread-safe, +flexible, and arbitrarily granular control over log management and +configuration. It is modeled after the Java log4j API. + +# Win32 +%package -n mingw32-log4cplus +Summary: MinGW compiled log4cplus library for the Win32 target + +%description -n mingw32-log4cplus +MinGW compiled log4cplus library for the Win32 target + +%package -n mingw32-log4cplus-devel +Summary: Headers for the MinGW compiled log4cplus library for the Win32 target + +%description -n mingw32-log4cplus-devel +Headers for the MinGW compiled log4cplus library for the Win32 target + +# Win64 +%package -n mingw64-log4cplus +Summary: MinGW compiled log4cplus library for the Win64 target + +%description -n mingw64-log4cplus +MinGW compiled log4cplus library for the Win64 target + +%package -n mingw64-log4cplus-devel +Summary: Headers for the MinGW compiled log4cplus library for the Win64 target + +%description -n mingw64-log4cplus-devel +Headers for the MinGW compiled log4cplus library for the Win64 target + +%prep +%setup -q -n log4cplus-%{version} + +%build +%mingw_configure --enable-shared +%mingw_make %{?_smp_mflags} + +%install +rm -rf $RPM_BUILD_ROOT +%mingw_make_install DESTDIR=$RPM_BUILD_ROOT +find $RPM_BUILD_ROOT -name "*.la" -delete +find $RPM_BUILD_ROOT -name "stamp-*" -delete +find $RPM_BUILD_ROOT -name "*.in" -delete +find $RPM_BUILD_ROOT -name macosx.h -delete +find $RPM_BUILD_ROOT -name windowsh-inc.h -delete +find $RPM_BUILD_ROOT -name cygwin-win32.h -delete +find $RPM_BUILD_ROOT -name syncprims-win32.h -delete +find $RPM_BUILD_ROOT -name liblog4cplus.a -delete +find $RPM_BUILD_ROOT -name .svn -type d -exec find '{}' -delete \; + +# Win32 +%files -n mingw32-log4cplus +%{mingw32_bindir}/lib*.dll + +%files -n mingw32-log4cplus-devel +%defattr(-,root,root,755) +%{mingw32_includedir}/log4cplus/*.h +%{mingw32_includedir}/log4cplus/helpers/*.h +%{mingw32_includedir}/log4cplus/spi/*.h +%{mingw32_includedir}/log4cplus/boost/*.hxx +%{mingw32_includedir}/log4cplus/config.hxx +%{mingw32_includedir}/log4cplus/config/defines.hxx +%{mingw32_includedir}/log4cplus/config/win32.h +%{mingw32_includedir}/log4cplus/internal/*.h +%{mingw32_includedir}/log4cplus/thread/impl/*.h +%{mingw32_includedir}/log4cplus/thread/*.h +%attr(644,root,root) +%{mingw32_libdir}/*.dll.a +%{mingw32_libdir}/pkgconfig/log4cplus.pc + +# Win64 +%files -n mingw64-log4cplus +%{mingw64_bindir}/lib*.dll + +%files -n mingw64-log4cplus-devel +%defattr(-,root,root,755) +%{mingw64_includedir}/log4cplus/*.h +%{mingw64_includedir}/log4cplus/helpers/*.h +%{mingw64_includedir}/log4cplus/spi/*.h +%{mingw64_includedir}/log4cplus/boost/*.hxx +%{mingw64_includedir}/log4cplus/config.hxx +%{mingw64_includedir}/log4cplus/config/defines.hxx +%{mingw64_includedir}/log4cplus/config/win32.h +%{mingw64_includedir}/log4cplus/internal/*.h +%{mingw64_includedir}/log4cplus/thread/impl/*.h +%{mingw64_includedir}/log4cplus/thread/*.h +%attr(644,root,root) +%{mingw64_libdir}/*.dll.a +%{mingw64_libdir}/pkgconfig/log4cplus.pc + +%changelog +* Wed Aug 14 2013 John Smits - 1.1.1-1 +- Initial release diff --git a/scripts/propagate-version.pl b/scripts/propagate-version.pl index 08b09cd42..1a32f3ae6 100755 --- a/scripts/propagate-version.pl +++ b/scripts/propagate-version.pl @@ -81,11 +81,14 @@ BEGIN print $line; } - local @ARGV = ("log4cplus.spec"); + local @ARGV = ("log4cplus.spec", "mingw-log4cplus.spec"); while (my $line = <>) { $line =~ s/(Version: \s*)(.*)/$1$version/x; - $line =~ s/(Release: \s*)(.*)/${1}1/x; + if ($line =~ /Source\d*:/x) + { + $line =~ s/(\d+\.\d+\.\d+)/$version/gx; + } print $line; } From 149c0aea7ada13e994df171edfadd375b3d7c271 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 15 Aug 2013 13:18:56 +0200 Subject: [PATCH 113/226] mingw-log4cplus.spec: Change John Smits's email. --- mingw-log4cplus.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-log4cplus.spec b/mingw-log4cplus.spec index 4bff9e188..722689a3f 100755 --- a/mingw-log4cplus.spec +++ b/mingw-log4cplus.spec @@ -116,5 +116,5 @@ find $RPM_BUILD_ROOT -name .svn -type d -exec find '{}' -delete \; %{mingw64_libdir}/pkgconfig/log4cplus.pc %changelog -* Wed Aug 14 2013 John Smits - 1.1.1-1 +* Wed Aug 14 2013 John Smits - 1.1.1-1 - Initial release From 593ae7569bfbc4f6480dd11fef8dd0da5745f6f5 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 3 Sep 2013 21:03:29 +0200 Subject: [PATCH 114/226] configure.ac: For AIX/XLC, add -qroconst to CXXFLAGS and -qmkshrobj=-300 to liblog4cplus LDFLAGS. --- Makefile.in | 1 + configure | 6 ++++++ configure.ac | 5 +++++ include/Makefile.in | 1 + loggingserver/Makefile.in | 1 + qt4debugappender/Makefile.in | 1 + src/Makefile.am | 4 +++- src/Makefile.in | 6 +++++- tests/Makefile.in | 1 + tests/appender_test/Makefile.in | 1 + tests/configandwatch_test/Makefile.in | 1 + tests/customloglevel_test/Makefile.in | 1 + tests/fileappender_test/Makefile.in | 1 + tests/filter_test/Makefile.in | 1 + tests/hierarchy_test/Makefile.in | 1 + tests/loglog_test/Makefile.in | 1 + tests/ndc_test/Makefile.in | 1 + tests/ostream_test/Makefile.in | 1 + tests/patternlayout_test/Makefile.in | 1 + tests/performance_test/Makefile.in | 1 + tests/priority_test/Makefile.in | 1 + tests/propertyconfig_test/Makefile.in | 1 + tests/socket_test/Makefile.in | 1 + tests/thread_test/Makefile.in | 1 + tests/timeformat_test/Makefile.in | 1 + 25 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 541430433..4805f8000 100644 --- a/Makefile.in +++ b/Makefile.in @@ -225,6 +225,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/configure b/configure index 7f227ff0b..63488fc6e 100755 --- a/configure +++ b/configure @@ -665,6 +665,7 @@ PTHREAD_CXXFLAGS PTHREAD_LIBS ax_pthread_config EGREP +LOG4CPLUS_AIX_XLC_LDFLAGS GREP SED CXXCPP @@ -5164,6 +5165,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu esac fi +LOG4CPLUS_AIX_XLC_LDFLAGS= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : @@ -5228,6 +5230,9 @@ $as_echo "$ac_cv_path_GREP" >&6; } case $ax_cv_cxx_compiler_vendor in #( + ibm) : + as_fn_append CXXFLAGS " -qroconst" + as_fn_append LOG4CPLUS_AIX_XLC_LDFLAGS " -qmkshrobj=-300" ;; #( gnu|clang) : { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fdiagnostics-show-caret" >&5 $as_echo_n "checking CXXFLAGS for gcc -fdiagnostics-show-caret... " >&6; } @@ -7189,6 +7194,7 @@ esac + continue_checks=1 diff --git a/configure.ac b/configure.ac index e4324b047..facff017c 100644 --- a/configure.ac +++ b/configure.ac @@ -164,7 +164,11 @@ AS_IF([test "x$enable_warnings" = "xyes"], [sun], [], [AX_CXXFLAGS_WARN_ALL])]) +LOG4CPLUS_AIX_XLC_LDFLAGS= AS_CASE([$ax_cv_cxx_compiler_vendor], + [ibm], + [AS_VAR_APPEND([CXXFLAGS], [" -qroconst"]) + AS_VAR_APPEND([LOG4CPLUS_AIX_XLC_LDFLAGS], [" -qmkshrobj=-300"])], [gnu|clang], [AX_CXXFLAGS_GCC_OPTION([-fdiagnostics-show-caret]) AS_IF([test "x$enable_warnings" = "xyes"], @@ -271,6 +275,7 @@ AS_CASE([$ax_cv_cxx_compiler_vendor], dnl Adding -library=Crun is always necessary. AX_CXXFLAGS_SUN_OPTION([-library=Crun])]) +AC_SUBST([LOG4CPLUS_AIX_XLC_LDFLAGS]) AX_DECLSPEC([LOG4CPLUS_DECLSPEC]) AS_IF([test "x$ac_cv_declspec" = "xyes" dnl diff --git a/include/Makefile.in b/include/Makefile.in index 6bc275ce1..42b7566c3 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -162,6 +162,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/loggingserver/Makefile.in b/loggingserver/Makefile.in index bb41b4ea5..3698e2e7d 100644 --- a/loggingserver/Makefile.in +++ b/loggingserver/Makefile.in @@ -154,6 +154,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/qt4debugappender/Makefile.in b/qt4debugappender/Makefile.in index 1f9b1cfdf..02cac9c48 100644 --- a/qt4debugappender/Makefile.in +++ b/qt4debugappender/Makefile.in @@ -195,6 +195,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/src/Makefile.am b/src/Makefile.am index c0c35bb14..6923779aa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -157,4 +157,6 @@ endif LOG4CPLUS_VERSION_LT_FLAGS=$(VERSION_INFO_OPTION) $(RELEASE_OPTION) #liblog4cplus_a_LIBADD = @LIBOBJS@ @ALLOCA@ -liblog4cplus_la_LDFLAGS = -no-undefined $(LOG4CPLUS_VERSION_LT_FLAGS) +liblog4cplus_la_LDFLAGS = -no-undefined \ + $(LOG4CPLUS_VERSION_LT_FLAGS) \ + $(LOG4CPLUS_AIX_XLC_LDFLAGS) diff --git a/src/Makefile.in b/src/Makefile.in index bf434a68c..f4991ce88 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -207,6 +207,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ @@ -446,7 +447,10 @@ liblog4cplus_la_SOURCES = $(LIB_SRC) LOG4CPLUS_VERSION_LT_FLAGS = $(VERSION_INFO_OPTION) $(RELEASE_OPTION) #liblog4cplus_a_LIBADD = @LIBOBJS@ @ALLOCA@ -liblog4cplus_la_LDFLAGS = -no-undefined $(LOG4CPLUS_VERSION_LT_FLAGS) +liblog4cplus_la_LDFLAGS = -no-undefined \ + $(LOG4CPLUS_VERSION_LT_FLAGS) \ + $(LOG4CPLUS_AIX_XLC_LDFLAGS) + all: all-am .SUFFIXES: diff --git a/tests/Makefile.in b/tests/Makefile.in index bf958a192..2599ee20e 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -174,6 +174,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/appender_test/Makefile.in b/tests/appender_test/Makefile.in index 9e42a4d0f..7f2a4539b 100644 --- a/tests/appender_test/Makefile.in +++ b/tests/appender_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/configandwatch_test/Makefile.in b/tests/configandwatch_test/Makefile.in index 8629b499a..5075f3bae 100644 --- a/tests/configandwatch_test/Makefile.in +++ b/tests/configandwatch_test/Makefile.in @@ -153,6 +153,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/customloglevel_test/Makefile.in b/tests/customloglevel_test/Makefile.in index 894da3359..019468a4d 100644 --- a/tests/customloglevel_test/Makefile.in +++ b/tests/customloglevel_test/Makefile.in @@ -154,6 +154,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/fileappender_test/Makefile.in b/tests/fileappender_test/Makefile.in index 9068a0769..5666e2572 100644 --- a/tests/fileappender_test/Makefile.in +++ b/tests/fileappender_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/filter_test/Makefile.in b/tests/filter_test/Makefile.in index 6b4b6b495..d6c99524c 100644 --- a/tests/filter_test/Makefile.in +++ b/tests/filter_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/hierarchy_test/Makefile.in b/tests/hierarchy_test/Makefile.in index d116f991c..f4e74ba8c 100644 --- a/tests/hierarchy_test/Makefile.in +++ b/tests/hierarchy_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/loglog_test/Makefile.in b/tests/loglog_test/Makefile.in index ba32ea080..66d79202b 100644 --- a/tests/loglog_test/Makefile.in +++ b/tests/loglog_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/ndc_test/Makefile.in b/tests/ndc_test/Makefile.in index 33432b8dc..1262fee8c 100644 --- a/tests/ndc_test/Makefile.in +++ b/tests/ndc_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/ostream_test/Makefile.in b/tests/ostream_test/Makefile.in index 477159c83..3e6f257dc 100644 --- a/tests/ostream_test/Makefile.in +++ b/tests/ostream_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/patternlayout_test/Makefile.in b/tests/patternlayout_test/Makefile.in index aeea34fb1..ee38332d2 100644 --- a/tests/patternlayout_test/Makefile.in +++ b/tests/patternlayout_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/performance_test/Makefile.in b/tests/performance_test/Makefile.in index e80e08046..e0be44f46 100644 --- a/tests/performance_test/Makefile.in +++ b/tests/performance_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/priority_test/Makefile.in b/tests/priority_test/Makefile.in index f0ca22024..2252861c8 100644 --- a/tests/priority_test/Makefile.in +++ b/tests/priority_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/propertyconfig_test/Makefile.in b/tests/propertyconfig_test/Makefile.in index 18047da56..d0b55aed0 100644 --- a/tests/propertyconfig_test/Makefile.in +++ b/tests/propertyconfig_test/Makefile.in @@ -153,6 +153,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/socket_test/Makefile.in b/tests/socket_test/Makefile.in index 0cbb4fa26..9658b3775 100644 --- a/tests/socket_test/Makefile.in +++ b/tests/socket_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/thread_test/Makefile.in b/tests/thread_test/Makefile.in index caead4d33..6e0c86b0c 100644 --- a/tests/thread_test/Makefile.in +++ b/tests/thread_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ diff --git a/tests/timeformat_test/Makefile.in b/tests/timeformat_test/Makefile.in index 2100fc076..9b5f97e71 100644 --- a/tests/timeformat_test/Makefile.in +++ b/tests/timeformat_test/Makefile.in @@ -152,6 +152,7 @@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ +LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@ LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@ LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@ LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@ From 1dd905455423f29a24f0f52280aea3cc4443af62 Mon Sep 17 00:00:00 2001 From: John Smits Date: Tue, 10 Sep 2013 21:46:18 +0200 Subject: [PATCH 115/226] mingw-log4cplus.spec: Improve. Provided by: John Smits --- mingw-log4cplus.spec | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mingw-log4cplus.spec b/mingw-log4cplus.spec index 722689a3f..056934868 100755 --- a/mingw-log4cplus.spec +++ b/mingw-log4cplus.spec @@ -29,6 +29,9 @@ log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modeled after the Java log4j API. +# Strip removes essential information from the .dll.a file, so disable it +%define __strip /bin/true + # Win32 %package -n mingw32-log4cplus Summary: MinGW compiled log4cplus library for the Win32 target @@ -59,7 +62,7 @@ Headers for the MinGW compiled log4cplus library for the Win64 target %setup -q -n log4cplus-%{version} %build -%mingw_configure --enable-shared +%mingw_configure %mingw_make %{?_smp_mflags} %install @@ -72,7 +75,7 @@ find $RPM_BUILD_ROOT -name macosx.h -delete find $RPM_BUILD_ROOT -name windowsh-inc.h -delete find $RPM_BUILD_ROOT -name cygwin-win32.h -delete find $RPM_BUILD_ROOT -name syncprims-win32.h -delete -find $RPM_BUILD_ROOT -name liblog4cplus.a -delete +# find $RPM_BUILD_ROOT -name liblog4cplus.a -delete find $RPM_BUILD_ROOT -name .svn -type d -exec find '{}' -delete \; # Win32 @@ -93,6 +96,7 @@ find $RPM_BUILD_ROOT -name .svn -type d -exec find '{}' -delete \; %{mingw32_includedir}/log4cplus/thread/*.h %attr(644,root,root) %{mingw32_libdir}/*.dll.a +%{mingw32_libdir}/liblog4cplus.a %{mingw32_libdir}/pkgconfig/log4cplus.pc # Win64 @@ -113,6 +117,7 @@ find $RPM_BUILD_ROOT -name .svn -type d -exec find '{}' -delete \; %{mingw64_includedir}/log4cplus/thread/*.h %attr(644,root,root) %{mingw64_libdir}/*.dll.a +%{mingw64_libdir}/liblog4cplus.a %{mingw64_libdir}/pkgconfig/log4cplus.pc %changelog From 001de37f0cbc8e41fe3750c6457c65b0dccd1530 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 15 Sep 2013 08:40:06 +0200 Subject: [PATCH 116/226] win32.h: Limit the use of MS's secure foo_s() functions to Visual Studio 2005 and later and Mingw-w64 with major version 2 or later when __MSVCRT_VERSION__ >= 0x900. README: Document the new behaviour. --- README | 14 ++++++++++++++ include/log4cplus/config/win32.h | 8 ++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README b/README index 829a940de..35687ac93 100644 --- a/README +++ b/README @@ -149,6 +149,20 @@ attribute ignored." This can be worked around by adding affected version of GCC have this option. +MinGW and MSVCRT version +------------------------ + +log4cplus can use functions like `_vsnprintf_s()` (Microsoft's secure +version of `vsnprintf()`). MinGW tool--chains (by default) link to the +system MSVCRT.DLL. Unfortunately, older systems, like Windows XP, ship +with MSVCRT.DLL that lacks these functions. It is possible to compile +log4cplus with MinGW tool--chains but _without_ using the Microsoft's +secure functions by defining `__MSVCRT_VERSION__` to value less than +`0x900` and vice versa. + + $ ../configure CPPFLAGS="-D__MSVCRT_VERSION__=0x700" + + Windows and TLS --------------- diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index c5b0d3d31..160048333 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -74,8 +74,12 @@ #define LOG4CPLUS_HAVE__VSNPRINTF #define LOG4CPLUS_HAVE__VSNWPRINTF -#if defined (_MSC_VER) \ - || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3) +// Limit the use of foo_s() functions to builds using Visual Studio +// 2005 and its run time library. In MinGW land, limit the foo_s() +// functions to MinGw-w64 toolchain and __MSVCRT_VERSION__ >= 0x0900. +#if (defined (_MSC_VER) && _MSC_VER >= 1400) \ + || (defined (__MSVCRT_VERSION__) && __MSVCRT_VERSION__ >= 0x0900 \ + && defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 2) // MS secure versions of vprintf(). # define LOG4CPLUS_HAVE_VSPRINTF_S # define LOG4CPLUS_HAVE_VSWPRINTF_S From ac0ce6b29b9cac1d4701618803c95944f2dc0b22 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 23 Sep 2013 14:20:26 +0200 Subject: [PATCH 117/226] timehelper.cxx (getFormattedTime): Remove unnecessary assignment. --- src/timehelper.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/timehelper.cxx b/src/timehelper.cxx index 70af7d371..eb5ca7388 100644 --- a/src/timehelper.cxx +++ b/src/timehelper.cxx @@ -268,15 +268,14 @@ Time::getFormattedTime(const log4cplus::tstring& fmt_orig, bool use_gmtime) cons internal::gft_scratch_pad & gft_sp = internal::get_gft_scratch_pad (); gft_sp.reset (); - gft_sp.fmt.assign (fmt_orig); std::size_t const fmt_orig_size = gft_sp.fmt.size (); - gft_sp.ret.reserve (fmt_orig_size + fmt_orig_size / 3); + gft_sp.ret.reserve (fmt_orig_size + fmt_orig_size / 2); State state = TEXT; // Walk the format string and process all occurences of %q, %Q and %s. - for (log4cplus::tstring::const_iterator fmt_it = gft_sp.fmt.begin (); - fmt_it != gft_sp.fmt.end (); ++fmt_it) + for (log4cplus::tstring::const_iterator fmt_it = fmt_orig.begin (); + fmt_it != fmt_orig.end (); ++fmt_it) { switch (state) { @@ -345,7 +344,7 @@ Time::getFormattedTime(const log4cplus::tstring& fmt_orig, bool use_gmtime) cons // Finally call strftime/wcsftime to format the rest of the string. - gft_sp.ret.swap (gft_sp.fmt); + gft_sp.fmt.swap (gft_sp.ret); std::size_t buffer_size = gft_sp.fmt.size () + 1; std::size_t len; From d182f063a859912f94cca5931b820d536ee0075e Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 29 Sep 2013 13:25:48 +0200 Subject: [PATCH 118/226] ChangeLog: Prepare for 1.1.2-RC3. --- ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index f0acc44db..cf28cf967 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +log4cplus 1.1.2-RC3 + +- Fixed build issues on HP-UX with aCC. + +- Fixed build issues on Haiku. + +- Added mingw-log4cplus.spec to allow cross-compilation from Fedora. + +- Fixed build issues on AIX with XLC. + +- Fixed build issues related to Microsoft's foo_s() functions with + some version of MinGw tool-chain. + +- Tiny speedup of getFormattedTime(). + + log4cplus 1.1.2-RC2 - Fixed crash of DLL builds on Windows when _WIN32_WINNT>=0x0600. From 86351b0c3152c8f75036548d8d03077e52db149a Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 29 Sep 2013 13:33:03 +0200 Subject: [PATCH 119/226] ChangeLog: Use MinGW spelling. --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cf28cf967..1c0319166 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,7 +9,7 @@ log4cplus 1.1.2-RC3 - Fixed build issues on AIX with XLC. - Fixed build issues related to Microsoft's foo_s() functions with - some version of MinGw tool-chain. + some version of MinGW tool-chain. - Tiny speedup of getFormattedTime(). From 8a1e11b9cf465d43806326f4b7670e3944591090 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 29 Sep 2013 13:36:16 +0200 Subject: [PATCH 120/226] ChangeLog: Mention John Smits. --- ChangeLog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1c0319166..ca42fd170 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,8 @@ log4cplus 1.1.2-RC3 - Fixed build issues on Haiku. -- Added mingw-log4cplus.spec to allow cross-compilation from Fedora. +- Added mingw-log4cplus.spec to allow cross-compilation from + Fedora. (John Smits) - Fixed build issues on AIX with XLC. From 97b0e2fd59d401c864a7fd9739859e0dc78724a4 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 29 Sep 2013 13:42:47 +0200 Subject: [PATCH 121/226] ChangeLog: Mention newer android/android.toolchain.cmake. --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index ca42fd170..6eed6e149 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,9 @@ log4cplus 1.1.2-RC3 - Tiny speedup of getFormattedTime(). +- Imported newer android/android.toolchain.cmake from OpenCV + repository. + log4cplus 1.1.2-RC2 From 16c72bdc02129209bc3149ba9bb6ceffa565200e Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 6 Oct 2013 13:24:35 +0200 Subject: [PATCH 122/226] README: Convert to Markdown. --- README | 259 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 135 insertions(+), 124 deletions(-) diff --git a/README b/README index 35687ac93..5deade4f3 100644 --- a/README +++ b/README @@ -1,3 +1,5 @@ +% log4cplus README + Short Description ================= @@ -10,17 +12,17 @@ Latest Project Information ========================== The latest up-to-date information for this project can be found at -http://log4cplus.sourceforge.net. Please submit bugs, patches, -feature requests, etc. there. +[log4cplus.sourceforge.net](http://log4cplus.sourceforge.net). Please +submit bugs, patches, feature requests, etc., there. Tested on the following platforms ================================= -- Linux/AMD64 with GCC 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) +- Linux/AMD64 with GCC 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) - Linux/AMD64 with Sun C++ 5.12 Linux_i386 2011/11/16 -- Linux/AMD64 with Clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) - (based on LLVM 3.0) +- Linux/AMD64 with Clang version 3.2-1~exp9ubuntu1 + (tags/RELEASE_32/final) (based on LLVM 3.2) - Linux/AMD64 with Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1 Build 20120410 - FreeBSD/AMD64 with GCC 3.4.6, 4.2.1 and 4.3.3 @@ -37,17 +39,17 @@ Tested on the following platforms Configure script options ======================== ---enable-debugging ------------------- +`--enable-debugging` +-------------------- This option is disabled by default. This option mainly affects GCC -builds but it also has some limitted effect on non-GCC builds. It -turns on debugging information generation, undefines NDEBUG symbol, -adds '-fkeep-inline-functions' and '-fstack-check' (GCC). +builds but it also has some limited effect on non-GCC builds. It +turns on debugging information generation, undefines `NDEBUG` symbol +and adds `-fstack-check` (GCC). ---enable-warnings ------------------ +`--enable-warnings` +------------------- This option is enabled by default. It adds platform / compiler dependent warning options to compiler command line. @@ -69,16 +71,16 @@ decoration on the resulting library file, e.g., the `-1.2` in `liblog4cplus-1.2.so.2.0.0`. ---enable-profiling ------------------- +`--enable-profiling` +-------------------- This option is disabled by default. This option adds profiling -information generation compiler option -pg to GCC and Sun CC / Solaris -Studio builds. +information generation compiler option `-pg` to GCC and Sun CC / +Solaris Studio builds. ---enable-threads ----------------- +`--enable-threads` +------------------ This option is enabled by default. It turns on detection of necessary compiler and linker flags that enable POSIX threading support. @@ -89,50 +91,51 @@ script. One of the know deficiencies is Solaris Studio on Linux. See one of the later note for details. ---with-working-locale ---------------------- +`--with-working-locale` +----------------------- -This is one of three locale and wchar_t <-> char conversion related -options. It is disabled by default. +This is one of three locale and `wchar_t` <-> `char` conversion +related options. It is disabled by default. It is know to work well with GCC on Linux. Other platforms generally have lesser locale support in their implementations of the C++ -standard library. It is known not to work well on any *BSD. +standard library. It is known not to work well on any BSDs. See also docs/unicode.txt. ---with-working-c-locale ------------------------ +`--with-working-c-locale` +------------------------- -This is second of wchar_t <-> char conversion related options. It is -disabled by default. +This is second of `wchar_t` <-> `char` conversion related options. It +is disabled by default. -It is known to work well on most *NIX platforms, including recent Cygwin. +It is known to work well on most Unix--like platforms, including +recent Cygwin. ---with-iconv ------------- +`--with-iconv` +-------------- -This is third of wchar_t <-> char conversion related options. It is +This is third of `wchar_t` <-> `char` conversion related options. It is disabled by default. -The conversion using iconv() function always uses "UTF-8" and -"WCHAR_T" as source/target encodings. It is known to work well on -platforms with GNU iconv. Different implementations of iconv() might -not support "WCHAR_T" encoding selector. +The conversion using iconv() function always uses `"UTF-8"` and +`"WCHAR_T"` as source/target encoding. It is known to work well on +platforms with GNU iconv. Different implementations of `iconv()` +might not support `"WCHAR_T"` encoding selector. -Either system provided iconv() or library provided libiconv() are -detected and accepted. Also both SUSv3 and GNU iconv() function +Either system provided `iconv()` or library provided `libiconv()` are +detected and accepted. Also both SUSv3 and GNU `iconv()` function signatures are accepted. ---with-qt ---------- +`--with-qt` +----------- This option is disabled by default. It enables compilation of a separate shared library (liblog4cplusqt4debugappender) that implements -Qt4DebugAppender. It requires Qt4 and pkg-config to be installed. +`Qt4DebugAppender`. It requires Qt4 and pkg-config to be installed. Notes @@ -142,11 +145,14 @@ Cygwin/MinGW ------------ Some version of GCC (3.4.x and probably some of 4.x series too) on -Windows (both Mingw and Cygwin) produces lots of warnings of the form -"warning: inline function 'void foo()' is declared as dllimport: -attribute ignored." This can be worked around by adding --Wno-attributes option to GCC command. Unfortunatelly, not all -affected version of GCC have this option. +Windows (both Mingw and Cygwin) produces lots of warnings of the form: + +> warning: inline function 'void foo()' is declared as dllimport: + attribute ignored + +This can be worked around by adding `-Wno-attributes` option to GCC +command. Unfortunately, not all affected version of GCC have this +option. MinGW and MSVCRT version @@ -168,28 +174,31 @@ Windows and TLS log4cplus uses thread-local storage (TLS) for NDC, MDC and to optimize use of some temporary objects. On Windows there are two ways to get -TLS: (1) using TlsAlloc() etc. functions, and (2) using -__declspec(thread). While method (2) generates faster code, it has -some limitations prior to Windows Vista. If log4cplus.dll is loaded -at run time using LoadLibrary() (or as a dependency of such loaded -library), then accessing __declspec(thread) variables can cause -general protection fault (GPF) errors. This is because Windows prior -to Windows Vista do not extend the TLS for libraries loaded at run -time using LoadLibrary(). To allow using the best available method, -log4cplus enables the method (2) by checking _WIN32_WINNT >= 0x0600 -condition, when compiling log4cplus targetted to Windows Vista or -later. +TLS: + +(1) using `TlsAlloc()`, etc., functions +(2) using `__declspec(thread)` + +While method (2) generates faster code, it has some limitations prior +to Windows Vista. If log4cplus.dll is loaded at run time using +`LoadLibrary()` (or as a dependency of such loaded library), then +accessing `__declspec(thread)` variables can cause general protection +fault (GPF) errors. This is because Windows prior to Windows Vista do +not extend the TLS for libraries loaded at run time using +LoadLibrary(). To allow using the best available method, log4cplus +enables the method (2) by checking `_WIN32_WINNT >= 0x0600` condition, +when compiling log4cplus targeted to Windows Vista or later. Threads and signals ------------------- -log4cplus is not safe to be used from async signals' handlers. This -is a property of most threaded programmes in general. If you are +log4cplus is not safe to be used from asynchronous signals' handlers. +This is a property of most threaded programmes in general. If you are going to use log4cplus in threaded application and if you want to use log4cplus from signal handlers then your only option is to block signals in all threads but one that will handle all signals. On POSIX -platforms, this is possible using the sigwait() call. log4cplus +platforms, this is possible using the `sigwait()` call. log4cplus enables this approach by blocking all signals in any threads created through its threads helpers. @@ -197,44 +206,44 @@ through its threads helpers. IBM's XL C/C++ compiler ----------------------- -IBM's XL C/C++ compiler executable has many variants ([1]). To -compile log4cplus with threading support specify one of the compiler -variants that support threading using the CXX variable on configure -script command line. E.g.: +IBM's XL C/C++ compiler executable has [many variants][1]. To compile +log4cplus with threading support specify one of the compiler variants +that support threading using the `CXX` variable on configure script +command line. E.g.: -$ ../configure --enable-threads CXX=xlC_r + $ ../configure --enable-threads CXX=xlC_r -[1] +[1]: http://pic.dhe.ibm.com/infocenter/comphelp/v121v141/index.jsp?topic=%2Fcom.ibm.xlcpp121.aix.doc%2Fcompiler_ref%2Ftucmpinv.html AIX reentrancy problem ---------------------- There appears to be a reentracy problem with AIX 5.3 and xlC 8 which -can result into a deadlock condition in some curcumstances. It is +can result into a deadlock condition in some circumstances. It is unknown whether the problem manifests with other versions of either the OS or the compiler, too. The problem was initially reported in a -bug report #3056687 ([1]). +bug report [#103][2]. The core of the problem is that IBM's/xlC's standard C++ IOStreams implementation uses global non recursive lock to protect some of its state. The application in the bug report was trying to do logging -using log4cplus from inside overflow() member function of a class -derived from std::streambuf class. log4cplus itself uses -std::ostringstream. This resulted into an attempt to recursivly lock -the global non recursive lock and a deadlock. +using log4cplus from inside `overflow()` member function of a class +derived from `std::streambuf` class. log4cplus itself uses +`std::ostringstream`. This resulted into an attempt to recursively +lock the global non recursive lock and a deadlock. -[1] +[2]: http://sourceforge.net/p/log4cplus/bugs/103/ Solaris / SunOS --------------- Some older version of this operating system might have problems -linking log4cplus due to missing __tls_get_addr ([1]) in their +linking log4cplus due to [missing `__tls_get_addr`][3] in their unpatched state. -[1] +[3]: https://groups.google.com/d/msg/comp.unix.solaris/AAMqkK0QZ6U/zlkVKA1L_QcJ Solaris Studio @@ -242,16 +251,17 @@ Solaris Studio Solaris Studio compilers' default standard C++ library is very non-standard. It seems that it is not conforming enough in, e.g., Sun -C++ 5.12 Linux_i386 2011/11/16 (missing std::time_t, etc.), but it +C++ 5.12 Linux_i386 2011/11/16 (missing `std::time_t`, etc.), but it works well enough on Solaris with Sun C++ 5.8 2005/10/13. Thus -log4cplus adds -library=stlport4 to the CXXFLAGS environment variable, -unless a switch matching -library=(stlport4|stdcxx4|Cstd) is already -present there. If you want to override the default supplied by -log4cplus, just set it into CXXFLAGS on configure script command line. +log4cplus adds `-library=stlport4` to the `CXXFLAGS` environment +variable, unless a switch matching `-library=(stlport4|stdcxx4|Cstd)` +is already present there. If you want to override the default +supplied by log4cplus, just set it into `CXXFLAGS` on configure script +command line. -Solaris Studio supports the __func__ symbol which can be used by +Solaris Studio supports the `__func__` symbol which can be used by log4cplus to record function name in logged events. To enable this -feature, add '-features=extensions' switch to CXXFLAGS for configure +feature, add `-features=extensions` switch to `CXXFLAGS` for configure script. Subsequently, you will have to add this switch to your application's build flags as well. @@ -259,16 +269,19 @@ application's build flags as well. Solaris Studio on GNU/Linux --------------------------- -The autotools and our configure.in combo does not handle Solaris +The autotools and our configure.ac combo does not handle Solaris Studio compiler on Linux well enough and needs a little help with configuration of POSIX threads: -$ COMMON_FLAGS="-L/lib/x86_64-linux-gnu/ -L/usr/lib/x86_64-linux-gnu/ \ --mt=yes -O" + $ COMMON_FLAGS="-L/lib/x86_64-linux-gnu/ \ + -L/usr/lib/x86_64-linux-gnu/ -mt=yes -O" -$ ../configure --enable-threads=yes CC=/opt/solarisstudio12.3/bin/cc \ -CXX=/opt/solarisstudio12.3/bin/CC CFLAGS="$COMMON_FLAGS" \ -CXXFLAGS="$COMMON_FLAGS" LDFLAGS="-lpthread" + $ ../configure --enable-threads=yes \ + CC=/opt/solarisstudio12.3/bin/cc \ + CXX=/opt/solarisstudio12.3/bin/CC \ + CFLAGS="$COMMON_FLAGS" \ + CXXFLAGS="$COMMON_FLAGS" \ + LDFLAGS="-lpthread" HP-UX with aCC @@ -296,55 +309,53 @@ This change is permanent and global. See also Haiku ticket [#8368](http://dev.haiku-os.org/ticket/8368). -Qt / Win32 / MSVC ------------------ - -In order to use log4cplus in Qt programs it is necessary to set -following option: +Qt4 / Win32 / MSVC +------------------ -Treat WChar_t As Built in Type: No (/Zc:wchar_t-) +In order to use log4cplus in Qt4 programs it is necessary to set +following option: `Treat WChar_t As Built in Type: No (/Zc:wchar_t-)` -Set this option for log4cplus project and Qt4DebugAppender project in -MS Visual Studio. Remember to use Unicode versions of log4cplus +Set this option for log4cplus project and `Qt4DebugAppender` project +in MS Visual Studio. Remember to use Unicode versions of log4cplus libraries with Qt. It is also necessary to make clear distinction between debug and release builds of Qt project and log4cplus. Do not use log4cplus release library with debug version of Qt program or vice versa. -For registering Qt4DebugAppender library at run-time call this method: - -log4cplus::Qt4DebugAppender::registerAppender() ; +For registering Qt4DebugAppender library at runtime, call this +function: `log4cplus::Qt4DebugAppender::registerAppender()` Add these lines to qmake project file for using log4cplus and -Qt4DebugAppender: - -INCLUDEPATH += C:\log4cplus\include -win32 { - CONFIG(debug, debug|release) { - LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplusUD - LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplus-Qt4DebugAppender - } else { - LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplusU - LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplus-Qt4DebugAppender +`Qt4DebugAppender`: + + INCLUDEPATH += C:\log4cplus\include + win32 { + CONFIG(debug, debug|release) { + LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplusUD + LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplus-Qt4DebugAppender + } else { + LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplusU + LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplus-Qt4DebugAppender + } } -} -LOG4CPLUS_*_FMT() and UNICODE ------------------------------ +`LOG4CPLUS_*_FMT()` and UNICODE +------------------------------- -Beware, the %s specifier does not work the same way on *NIX as it does -on Windows with Visual Studio. With Visual Studio the %s specifier -changes its meaning conveniently by printing wchar_t string when used -with wprintf() and char strings when used with wprintf(). On the -other hand, *NIX keeps the meaning of printing char strings when used -with both wprintf() and printf(). It is necessary to use %ls (C99) -specifier or %S (SUSv2) specifier to print wchar_t strings on *NIX. +Beware, the `%s` specifier does not work the same way on Unix--like +platforms as it does on Windows with Visual Studio. With Visual Studio +the `%s` specifier changes its meaning conveniently by printing +`wchar_t` string when used with `wprintf()` and `char` strings when +used with `printf()`. On the other hand, Unix--like platforms keeps +the meaning of printing `char` strings when used with both `wprintf()` +and `printf()`. It is necessary to use `%ls` (C99) specifier or `%S` +(SUSv2) specifier to print `wchar_t` strings on Unix--like platforms. -The common ground for both platforms appears to be use of %ls and -wchar_t string to print strings with unmodified formatting string -argument on both *NIX and Windows. The conversion of wchar_t back to -char then depends on C locale. +The common ground for both platforms appears to be use of `%ls` and +`wchar_t` string to print strings with unmodified formatting string +argument on both Unix--like platforms and Windows. The conversion of +`wchar_t` back to `char` then depends on C locale. C++11 support @@ -364,7 +375,7 @@ log4cplus does not support too old or broken C++ compilers: - Visual C++ prior to 7.1 - GCC prior to 3.2 -- All Borland/CodeGear/Embarcadero C++ compilers +- Older versions of Borland/CodeGear/Embarcadero C++ compilers Unsupported platforms @@ -374,7 +385,7 @@ log4cplus requires some minimal set of C and/or C++ library functions. Some systems/platforms fail to provide these functions and thus log4cplus cannot be supported there: -- Windows CE - missing implementations of functions +- Windows CE - missing implementations of `` functions License From 25057b96c86e4ad515367c0955ad8738087eedf0 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 11 Oct 2013 00:22:22 +0200 Subject: [PATCH 123/226] layout.h: Document MDC conversion pattern. tests/patternlayout_test/main.cxx: Demonstrate use of MDC. --- include/log4cplus/layout.h | 11 +++++++++++ tests/patternlayout_test/main.cxx | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/log4cplus/layout.h b/include/log4cplus/layout.h index 7a2100038..81d822b0a 100644 --- a/include/log4cplus/layout.h +++ b/include/log4cplus/layout.h @@ -435,6 +435,17 @@ namespace log4cplus { *
* * + * + * + * + * + * + * * * diff --git a/tests/patternlayout_test/main.cxx b/tests/patternlayout_test/main.cxx index 777182445..ba5466bc8 100644 --- a/tests/patternlayout_test/main.cxx +++ b/tests/patternlayout_test/main.cxx @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -24,7 +25,9 @@ main() SharedObjectPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); - log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%m/%d/%y %H:%M:%S,%Q} [%t] %-5p %c{2} %%%x%% - %m [%l]%n"); + log4cplus::getMDC ().put (LOG4CPLUS_TEXT ("key"), + LOG4CPLUS_TEXT ("MDC value")); + log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%m/%d/%y %H:%M:%S,%Q} [%t] %-5p %c{2} %%%x%% - %X{key} - %m [%l]%n"); // std::tstring pattern = LOG4CPLUS_TEXT("%d{%c} [%t] %-5p [%.15c{3}] %%%x%% - %m [%l]%n"); append_1->setLayout( std::auto_ptr(new PatternLayout(pattern)) ); Logger::getRoot().addAppender(append_1); From 2e3db88591c4558a6ddc33be84efed3ecc0277ea Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 11 Oct 2013 11:20:38 +0200 Subject: [PATCH 124/226] Add AbstractSocket::shutdown() and implement it for Unix-like and Windows platforms. Patch provided by: palladin --- ConfigureChecks.cmake | 1 + configure | 13 +++++++++++++ configure.ac | 1 + include/log4cplus/config.h.in | 6 ++++++ include/log4cplus/config/defines.hxx.in | 3 +++ include/log4cplus/helpers/socket.h | 3 ++- src/socket-unix.cxx | 6 ++++++ src/socket-win32.cxx | 18 ++++++++++++------ src/socket.cxx | 9 ++++++++- 9 files changed, 52 insertions(+), 8 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 947803214..3dca88ed9 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -69,6 +69,7 @@ check_function_exists(htons LOG4CPLUS_HAVE_HTONS ) check_function_exists(ntohs LOG4CPLUS_HAVE_NTOHS ) check_function_exists(htonl LOG4CPLUS_HAVE_HTONL ) check_function_exists(ntohl LOG4CPLUS_HAVE_NTOHL ) +check_function_exists(shutdown LOG4CPLUS_HAVE_SHUTDOWN ) check_function_exists(vsnprintf LOG4CPLUS_HAVE_VSNPRINTF ) check_function_exists(_vsnprintf LOG4CPLUS_HAVE__VSNPRINTF ) check_function_exists(vsprintf_s LOG4CPLUS_HAVE_VSPRINTF_S ) diff --git a/configure b/configure index 63488fc6e..9f433dfb9 100755 --- a/configure +++ b/configure @@ -9952,6 +9952,19 @@ fi done + for ac_func in shutdown +do : + ac_fn_cxx_check_func "$LINENO" "shutdown" "ac_cv_func_shutdown" +if test "x$ac_cv_func_shutdown" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SHUTDOWN 1 +_ACEOF + $as_echo "#define LOG4CPLUS_HAVE_SHUTDOWN 1" >>confdefs.h + +fi +done + + for ac_func in mbstowcs do : ac_fn_cxx_check_func "$LINENO" "mbstowcs" "ac_cv_func_mbstowcs" diff --git a/configure.ac b/configure.ac index facff017c..5cf02bc1f 100644 --- a/configure.ac +++ b/configure.ac @@ -464,6 +464,7 @@ LOG4CPLUS_CHECK_FUNCS([htons], [LOG4CPLUS_HAVE_HTONS]) LOG4CPLUS_CHECK_FUNCS([ntohs], [LOG4CPLUS_HAVE_NTOHS]) LOG4CPLUS_CHECK_FUNCS([htonl], [LOG4CPLUS_HAVE_HTONL]) LOG4CPLUS_CHECK_FUNCS([ntohl], [LOG4CPLUS_HAVE_NTOHL]) +LOG4CPLUS_CHECK_FUNCS([shutdown], [LOG4CPLUS_HAVE_SHUTDOWN]) LOG4CPLUS_CHECK_FUNCS([mbstowcs], [LOG4CPLUS_HAVE_MBSTOWCS]) LOG4CPLUS_CHECK_FUNCS([wcstombs], [LOG4CPLUS_HAVE_WCSTOMBS]) AS_IF([test "x$with_iconv" = "xyes"], diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index c6e6eb44a..c71b850bd 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -123,6 +123,9 @@ /* Have PTHREAD_PRIO_INHERIT. */ #undef HAVE_PTHREAD_PRIO_INHERIT +/* Define to 1 if you have the `shutdown' function. */ +#undef HAVE_SHUTDOWN + /* Define to 1 if you have the `stat' function. */ #undef HAVE_STAT @@ -337,6 +340,9 @@ /* */ #undef LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO +/* */ +#undef LOG4CPLUS_HAVE_SHUTDOWN + /* */ #undef LOG4CPLUS_HAVE_STAT diff --git a/include/log4cplus/config/defines.hxx.in b/include/log4cplus/config/defines.hxx.in index 286f9836b..7eb9bbbb7 100644 --- a/include/log4cplus/config/defines.hxx.in +++ b/include/log4cplus/config/defines.hxx.in @@ -121,6 +121,9 @@ /* */ #undef LOG4CPLUS_HAVE_NTOHS +/* Define to 1 if you have the `shutdown' function. */ +#undef LOG4CPLUS_HAVE_SHUTDOWN + /* */ #undef LOG4CPLUS_HAVE_PIPE diff --git a/include/log4cplus/helpers/socket.h b/include/log4cplus/helpers/socket.h index b2f7031eb..eb52d84c0 100644 --- a/include/log4cplus/helpers/socket.h +++ b/include/log4cplus/helpers/socket.h @@ -63,7 +63,7 @@ namespace log4cplus { /// Close socket virtual void close(); virtual bool isOpen() const; - + virtual void shutdown(); AbstractSocket& operator=(const AbstractSocket& rhs); protected: @@ -124,6 +124,7 @@ namespace log4cplus { SocketState& state); LOG4CPLUS_EXPORT SOCKET_TYPE acceptSocket(SOCKET_TYPE sock, SocketState& state); LOG4CPLUS_EXPORT int closeSocket(SOCKET_TYPE sock); + LOG4CPLUS_EXPORT int shutdownSocket(SOCKET_TYPE sock); LOG4CPLUS_EXPORT long read(SOCKET_TYPE sock, SocketBuffer& buffer); LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock, diff --git a/src/socket-unix.cxx b/src/socket-unix.cxx index 038be0d30..22bd49d7b 100644 --- a/src/socket-unix.cxx +++ b/src/socket-unix.cxx @@ -311,6 +311,12 @@ closeSocket(SOCKET_TYPE sock) } +int +shutdownSocket(SOCKET_TYPE sock) +{ + return ::shutdown(to_os_socket (sock), SHUT_RDWR); +} + long read(SOCKET_TYPE sock, SocketBuffer& buffer) diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index 1504f96cf..adfc80e67 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -97,7 +97,7 @@ init_winsock_worker () case WS_INITIALIZING: log4cplus::thread::yield (); continue; - + default: assert (0); loglog->error (LOG4CPLUS_TEXT ("Unknown WinSock state."), true); @@ -224,7 +224,7 @@ connectSocket(const tstring& hostn, unsigned short port, bool udp, SocketState& INT ret = WSAStringToAddress (const_cast(hostn.c_str ()), AF_INET, 0, reinterpret_cast(&insock), &insock_size); - if (ret == SOCKET_ERROR || insock_size != static_cast(sizeof (insock))) + if (ret == SOCKET_ERROR || insock_size != static_cast(sizeof (insock))) { state = bad_address; goto error; @@ -281,6 +281,12 @@ closeSocket(SOCKET_TYPE sock) } +int +shutdownSocket(SOCKET_TYPE sock) +{ + return ::shutdown (to_os_socket (sock), SD_BOTH); +} + long read(SOCKET_TYPE sock, SocketBuffer& buffer) @@ -289,9 +295,9 @@ read(SOCKET_TYPE sock, SocketBuffer& buffer) os_socket_type const osSocket = to_os_socket (sock); do - { - res = ::recv(osSocket, - buffer.getBuffer() + read, + { + res = ::recv(osSocket, + buffer.getBuffer() + read, static_cast(buffer.getMaxSize() - read), 0); if (res == SOCKET_ERROR) @@ -308,7 +314,7 @@ read(SOCKET_TYPE sock, SocketBuffer& buffer) read += res; } while (read < static_cast(buffer.getMaxSize())); - + return read; } diff --git a/src/socket.cxx b/src/socket.cxx index bcf377b58..a4328333c 100644 --- a/src/socket.cxx +++ b/src/socket.cxx @@ -83,6 +83,14 @@ AbstractSocket::close() } +void +AbstractSocket::shutdown() +{ + if(sock != INVALID_SOCKET_VALUE) { + shutdownSocket(sock); + } +} + bool AbstractSocket::isOpen() const @@ -92,7 +100,6 @@ AbstractSocket::isOpen() const - AbstractSocket& AbstractSocket::operator=(const AbstractSocket& rhs) { From 2eca42b9560253f70408ed3778953c10ea4f66d8 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 11 Oct 2013 14:15:29 +0200 Subject: [PATCH 125/226] global-init.cxx: Fix bug #278. Clean up TLS storage key on POSIX platforms. Patch provided by: J. Riesmeier --- src/global-init.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/global-init.cxx b/src/global-init.cxx index 178d9535e..73996634a 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -551,6 +551,9 @@ struct _static_log4cplus_initializer { // Last thread cleanup. log4cplus::threadCleanup (); + + log4cplus::thread::impl::tls_cleanup ( + log4cplus::internal::tls_storage_key); } } static initializer; From 382e08f8bc715906c06703383219e2a122a9ffdb Mon Sep 17 00:00:00 2001 From: Ray Logel Date: Sun, 13 Oct 2013 22:58:13 +0200 Subject: [PATCH 126/226] Implement %E pattern layout formatter for expansion of environment variable values. layout.h: Document %E pattern layout formatter. patternlayout.cxx: Implement. Patch provided by: Ray Logel --- include/log4cplus/layout.h | 12 ++++++++++ src/patternlayout.cxx | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/include/log4cplus/layout.h b/include/log4cplus/layout.h index 81d822b0a..16a6d31de 100644 --- a/include/log4cplus/layout.h +++ b/include/log4cplus/layout.h @@ -311,6 +311,18 @@ namespace log4cplus { * * * + * + * + * + * + * + * * * *
Conversion Character
XUsed to output the MDC (mapped diagnostic context) + * associated with the thread that generated the logging + * event. It takes optional key parameter. Without the key + * paramter (%%X), it outputs the whole MDC map. With the key + * (%%X{key}), it outputs just the key's value. + *
"%%"The sequence "%%" outputs a single percent sign. *
EUsed to output the value of a given environment variable. The + * name of is supplied as an argument in brackets. If the variable does + * exist then empty string will be used. + * + * For example, the pattern %E{HOME} will output the contents + * of the HOME environment variable. + *
FUsed to output the file name where the logging request was diff --git a/src/patternlayout.cxx b/src/patternlayout.cxx index 811c9fc38..074785cbf 100644 --- a/src/patternlayout.cxx +++ b/src/patternlayout.cxx @@ -199,6 +199,21 @@ class DatePatternConverter : public PatternConverter { }; +/** + * This PatternConverter is used to format an environment variable + */ +class EnvPatternConverter : public PatternConverter { +public: + EnvPatternConverter(const FormattingInfo& info, + const log4cplus::tstring& env); + virtual void convert(tstring & result, + const spi::InternalLoggingEvent& event); + +private: + log4cplus::tstring envKey; +}; + + //! This pattern is used to format miliseconds since process start. class RelativeTimestampConverter: public PatternConverter { public: @@ -525,6 +540,30 @@ DatePatternConverter::convert(tstring & result, } +//////////////////////////////////////////////// +// EnvPatternConverter methods: +//////////////////////////////////////////////// + + +EnvPatternConverter::EnvPatternConverter( + const FormattingInfo& info, const tstring& env) + : PatternConverter(info) + , envKey(env) +{ } + + +void +EnvPatternConverter::convert(tstring & result, + const spi::InternalLoggingEvent&) +{ + if (! internal::get_env_var (result, envKey)) + { + // Variable doesn't exist, return empty string. + result.clear (); + } +} + + // // // @@ -842,6 +881,12 @@ PatternParser::finalizeConverter(tchar c) } break; + case LOG4CPLUS_TEXT('E'): + pc = new EnvPatternConverter(formattingInfo, extractOption()); + //getLogLog().debug("Environment converter."); + //formattingInfo.dump(getLogLog()); + break; + case LOG4CPLUS_TEXT('F'): pc = new BasicPatternConverter (formattingInfo, From 90789ffdbd5db193a147db098fab45124f4f2984 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 22 Oct 2013 21:24:54 +0200 Subject: [PATCH 127/226] configure.ac: Bump SO version to 9. This is for the recent AbstractSocket::shutdown() addition. --- configure | 2 +- configure.ac | 2 +- cygport/log4cplus.cygport | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 9f433dfb9..81c36c03c 100755 --- a/configure +++ b/configure @@ -4220,7 +4220,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=8:1:1 +LT_VERSION=9:0:0 LT_RELEASE=1.1 diff --git a/configure.ac b/configure.ac index 5cf02bc1f..aa06bfed5 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=8:1:1 +LT_VERSION=9:0:0 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) diff --git a/cygport/log4cplus.cygport b/cygport/log4cplus.cygport index 19ef16e4e..0d4d08a1c 100644 --- a/cygport/log4cplus.cygport +++ b/cygport/log4cplus.cygport @@ -12,12 +12,12 @@ SRC_URI="mirror://sourceforge/log4cplus/log4cplus-stable/${PV%-rc*}/${P}.tar.xz" PATCH_URI="configure.ac-relax-libtool-version.patch configure.ac-disable-__thread-keyword.patch" -PKG_NAMES="lib${PN}1.1_7 lib${PN}qt4debugappender1.1_7 +PKG_NAMES="lib${PN}1.1_9 lib${PN}qt4debugappender1.1_9 lib${PN}-devel lib${PN}qt4debugappender-devel" -liblog4cplus1_1_7_SUMMARY="${SUMMARY} (runtime)" -liblog4cplus1_1_7_CONTENTS="usr/bin/cyglog4cplus-1-1-7.dll" -liblog4cplusqt4debugappender1_1_7_SUMMARY="${SUMMARY} (Qt4 runtime)" -liblog4cplusqt4debugappender1_1_7_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-7.dll" +liblog4cplus1_1_9_SUMMARY="${SUMMARY} (runtime)" +liblog4cplus1_1_9_CONTENTS="usr/bin/cyglog4cplus-1-1-9.dll" +liblog4cplusqt4debugappender1_1_9_SUMMARY="${SUMMARY} (Qt4 runtime)" +liblog4cplusqt4debugappender1_1_9_CONTENTS="usr/bin/cyglog4cplusqt4*-1-1-9.dll" liblog4cplus_devel_SUMMARY="${SUMMARY} (development)" liblog4cplus_devel_CONTENTS="--exclude=*qt4* usr/include/ usr/lib/ usr/share/doc/" liblog4cplusqt4debugappender_devel_SUMMARY="${SUMMARY} (Qt4 development)" From bd2dfe9ef0817277a7d41fadecd84addaf943fe3 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 22 Oct 2013 21:29:00 +0200 Subject: [PATCH 128/226] ChangeLog: Update for 1.1.2 release. --- ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6eed6e149..753511c74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +log4cplus 1.1.2 + +- Added AbstractSocket::shutdown(). + +- Added missing documentation of MDC pattern layout converter. + +- Fixed bug #278 - TLS key leak. + +- Implemented %E{ENVVAR} pattern layout formatter for expansion of environment + variables. + log4cplus 1.1.2-RC3 - Fixed build issues on HP-UX with aCC. From f8b5009b52f4bec9d73500d41acf4a3941f3cdae Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 6 Nov 2013 17:10:47 +0100 Subject: [PATCH 129/226] m4/ax_macro_va_args.m4: Include as well to get std namespace declared. This fixes the following error on HP-UX with aCC: Error 697: "conftest.cpp", line 21 # Only namespace names are valid here. using namespace std; ^^^ --- configure | 2 ++ m4/ax_macro_va_args.m4 | 2 ++ 2 files changed, 4 insertions(+) diff --git a/configure b/configure index 81c36c03c..d841a6c11 100755 --- a/configure +++ b/configure @@ -7518,6 +7518,7 @@ else #include #include +#include int main () @@ -7570,6 +7571,7 @@ else #include #include +#include int main () diff --git a/m4/ax_macro_va_args.m4 b/m4/ax_macro_va_args.m4 index bf1df41fe..1150e2d94 100644 --- a/m4/ax_macro_va_args.m4 +++ b/m4/ax_macro_va_args.m4 @@ -16,6 +16,7 @@ AC_CACHE_CHECK([for C99 variadic macros], [ac_cv_c99_variadic_macros], [[ #include #include +#include ]], [[ using namespace std; @@ -48,6 +49,7 @@ AC_CACHE_CHECK([for GNU style variadic macros], [ac_cv_gnu_variadic_macros], [[ #include #include +#include ]], [[ using namespace std; From 8f7940b2150be2e0e440d4b5735274f14fe11229 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 11 Nov 2013 11:41:27 +0100 Subject: [PATCH 130/226] configure.ac (--enable-symbols-visibility-options): Add new configure script option to allow turning off use of compiler and platform specific symbols visibility options. Also add default values descriptions to some more flags. --- configure | 38 +++++++++++++++++++++++++++++++------- configure.ac | 46 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/configure b/configure index d841a6c11..19be65ca8 100755 --- a/configure +++ b/configure @@ -785,6 +785,7 @@ enable_debugging enable_warnings enable_so_version enable_release_version +enable_symbols_visibility_options enable_profiling enable_threads with_qt @@ -1437,12 +1438,16 @@ Optional Features: --disable-dependency-tracking speeds up one-time build --enable-debugging Turns off optimization and adds switches that - generate debugging information. - --enable-warnings Use compiler warnings option, e.g. -Wall. Enabled by - default. - --enable-so-version Use libtool -version-info option. + generate debugging information. [default=no] + --enable-warnings Use compiler warnings option, e.g. -Wall. + [default=yes] + --enable-so-version Use libtool -version-info option. [default=yes] --enable-release-version - Use libtool -release option. + Use libtool -release option. [default=yes] + --enable-symbols-visibility-options + Use platform and compiler specific symbols + visibility options, where they are available. + [default=yes] --enable-profiling Compile with profiling compiler options. --enable-threads=yes/no Use this option to create a singled-threaded version of this library @@ -4396,6 +4401,22 @@ fi +# Check whether --enable-symbols-visibility-options was given. +if test "${enable_symbols_visibility_options+set}" = set; then : + enableval=$enable_symbols_visibility_options; case "${enableval}" in #( + yes) : + ;; #( + no) : + ;; #( + *) : + as_fn_error $? "bad value ${enableval} for --enable-symbols-visibility-options" "$LINENO" 5 ;; +esac +else + enable_symbols_visibility_options=yes +fi + + + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -7190,6 +7211,7 @@ esac esac +if test "x$enable_symbols_visibility_options" = "xyes"; then : @@ -7365,7 +7387,7 @@ fi { continue_checks=; unset continue_checks;} -if test "x$ac_cv_declspec" = "xyes" || test "x$ac_cv__attribute__visibility" = "xyes" || test "x$ac_cv__global" = "xyes"; then : + if test "x$ac_cv_declspec" = "xyes" || test "x$ac_cv__attribute__visibility" = "xyes" || test "x$ac_cv__global" = "xyes"; then : case $ax_cv_cxx_compiler_vendor in #( gnu|clang) : { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for gcc -fvisibility=hidden" >&5 @@ -7432,7 +7454,8 @@ case ".$var" in ;; esac ;; #( - sun) : + + sun) : { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXXFLAGS for sun/cc -xldscope=hidden" >&5 $as_echo_n "checking CXXFLAGS for sun/cc -xldscope=hidden... " >&6; } if ${ax_cv_cxxflags_sun_option__xldscope_hidden+:} false; then : @@ -7501,6 +7524,7 @@ esac ;; esac fi +fi diff --git a/configure.ac b/configure.ac index aa06bfed5..a87879943 100644 --- a/configure.ac +++ b/configure.ac @@ -75,7 +75,7 @@ dnl Debugging or release build? AC_ARG_ENABLE([debugging], [AS_HELP_STRING([--enable-debugging], [Turns off optimization and adds switches that generate debugging - information.])], + information. [default=no]])], [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-debugging])], [enable_debugging=no]) @@ -99,14 +99,15 @@ dnl Turn warnings on/off? AC_ARG_ENABLE([warnings], [AC_HELP_STRING([--enable-warnings], - [Use compiler warnings option, e.g. -Wall. Enabled by default.])], + [Use compiler warnings option, e.g. -Wall. [default=yes]])], [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-warnings])], [enable_warnings=yes]) dnl Enable SO version. AC_ARG_ENABLE([so-version], - [AC_HELP_STRING([--enable-so-version], [Use libtool -version-info option.])], + [AC_HELP_STRING([--enable-so-version], + [Use libtool -version-info option. [default=yes]])], [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-so-version])], [enable_so_version=yes]) AM_CONDITIONAL([ENABLE_VERSION_INFO_OPTION], @@ -115,12 +116,23 @@ AM_CONDITIONAL([ENABLE_VERSION_INFO_OPTION], dnl Enable release version. AC_ARG_ENABLE([release-version], - [AC_HELP_STRING([--enable-release-version], [Use libtool -release option.])], + [AC_HELP_STRING([--enable-release-version], + [Use libtool -release option. [default=yes]])], [LOG4CPLUS_CHECK_YESNO([${enableval}], [--enable-release-version])], [enable_release_version=yes]) AM_CONDITIONAL([ENABLE_RELEASE_OPTION], [test "x$enable_release_version" = "xyes"]) +dnl Enable use of symbol visibility options. + +AC_ARG_ENABLE([symbols-visibility-options], + [AC_HELP_STRING([--enable-symbols-visibility-options], + [Use platform and compiler specific symbols visibility options, + where they are available. [default=yes]])], + [LOG4CPLUS_CHECK_YESNO([${enableval}], + [--enable-symbols-visibility-options])], + [enable_symbols_visibility_options=yes]) + dnl Check for c/c++ compilers. AC_PROG_CXX @@ -277,16 +289,22 @@ AS_CASE([$ax_cv_cxx_compiler_vendor], AX_CXXFLAGS_SUN_OPTION([-library=Crun])]) AC_SUBST([LOG4CPLUS_AIX_XLC_LDFLAGS]) -AX_DECLSPEC([LOG4CPLUS_DECLSPEC]) -AS_IF([test "x$ac_cv_declspec" = "xyes" dnl - || test "x$ac_cv__attribute__visibility" = "xyes" dnl - || test "x$ac_cv__global" = "xyes"], - [AS_CASE([$ax_cv_cxx_compiler_vendor], - [gnu|clang], - [AX_CXXFLAGS_GCC_OPTION([-fvisibility=hidden])], - - [sun], - [AX_CXXFLAGS_SUN_OPTION([-xldscope=hidden])])]) +AS_IF([test "x$enable_symbols_visibility_options" = "xyes"], + [AX_DECLSPEC([LOG4CPLUS_DECLSPEC]) + AS_IF([test "x$ac_cv_declspec" = "xyes" dnl + || test "x$ac_cv__attribute__visibility" = "xyes" dnl + || test "x$ac_cv__global" = "xyes"], + [AS_CASE([$ax_cv_cxx_compiler_vendor], + [gnu|clang], + [AX_CXXFLAGS_GCC_OPTION([-fvisibility=hidden])], + + dnl Adding -Bhidden or -Bhidden_def to CXXFLAGS causes configure + dnl tests to fail because main() becomes hidden. + dnl[hp], + dnl[AS_VAR_APPEND([CXXFLAGS], [" -Bhidden -Wl,-a"])], + + [sun], + [AX_CXXFLAGS_SUN_OPTION([-xldscope=hidden])])])]) AX_C99_VARIADIC_MACROS AH_TEMPLATE([LOG4CPLUS_HAVE_C99_VARIADIC_MACROS]) From 747b81a800563949161bc4eb2b223ec0a20808ce Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 11 Nov 2013 11:55:49 +0100 Subject: [PATCH 131/226] README: Describe --enable-symbols-visibility-options option. --- README | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README b/README index 5deade4f3..d94190399 100644 --- a/README +++ b/README @@ -71,6 +71,14 @@ decoration on the resulting library file, e.g., the `-1.2` in `liblog4cplus-1.2.so.2.0.0`. +`--enable-symbols-visibility-options` +------------------------------------- + +This option is enabled by default. It enables use of compiler and +platform specific option for symbols visibility. See also the +[Visibility](http://gcc.gnu.org/wiki/Visibility) page on GCC Wiki. + + `--enable-profiling` -------------------- From 16085cd03fba1839d6d8b9f49e0e214f61043f0a Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Nov 2013 20:49:13 +0100 Subject: [PATCH 132/226] README: Add a note about issues with aCC on IA64 HP-UX. --- README | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README b/README index d94190399..71c60ed65 100644 --- a/README +++ b/README @@ -297,7 +297,27 @@ HP-UX with aCC It is necessary to turn on C++98 mode of aCC by providing the `-AA` flag: - $ ../configure --enable-threds=yes CXXFLAGS="-AA" + $ ../configure --enable-threads=yes CXXFLAGS="-AA" + + +HP-UX with `aCC` on IA64 +------------------------ + +There is a problem on I64 HP-UX with `aCC` (HP C/aC++ B3910B +A.06.20). The problem manifests as +[unsatisfied symbols during linking of `loggingserver`][9]: + + ld: Unsatisfied symbol "virtual table of loggingserver::ClientThread" in file loggingserver.o + +The problem appears to be a deficiency in `aCC` and its support of +`__declspec(dllexport)`. To work around this issue, add +`--disable-symbols-visibility-options` to `configure` script command +line: + + $ ../configure --disable-symbols-visibility-options \ + --enable-threads=yes CXXFLAGS="-AA" + +[9]: http://h30499.www3.hp.com/t5/Languages-and-Scripting/Building-Log4cplus-fails-with-quot-ld-Unsatisfied-symbol-virtual/td-p/6261411#.UoHtgPmet8G Haiku From 40dea65c2c2e5a70d18150502180163cccbf13ee Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 12 Nov 2013 20:50:19 +0100 Subject: [PATCH 133/226] CMakeLists.txt (ENABLE_SYMBOLS_VISIBILITY): Add this option to work around IA64 HP-UX aCC linking issue. ConfigureChecks.cmake: Use the new option. --- CMakeLists.txt | 8 +++++++- ConfigureChecks.cmake | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23cebf92b..b10c60063 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,11 @@ if (CMAKE_TOOLCHAIN_FILE) set (LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to") endif () +# Remove when CMake >= 2.8.4 is required +set (CMAKE_LEGACY_CYGWIN_WIN32 0) project (log4cplus) -cmake_minimum_required (VERSION 2.8.0) +cmake_minimum_required (VERSION 2.8.4) include (Log4CPlusUtils.cmake) log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include" @@ -48,6 +50,10 @@ option(UNICODE "Build with tchar = wchar_t" ${UNICODE_DEFAULT}) option(WITH_ICONV "Use iconv() for char->wchar_t conversion." OFF) + +option(ENABLE_SYMBOLS_VISIBILITY + "Enable compiler and platform specific options for symbols visibility" + ON) set(_WIN32_WINNT 0x0500 CACHE STRING "Define Windows API version to use.") diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 3dca88ed9..2090bd6bf 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -197,7 +197,7 @@ if(NOT DEFINED LOG4CPLUS_DECLSPEC_EXPORT) endif() endif() -if(NOT DEFINED LOG4CPLUS_DECLSPEC_EXPORT) +if(NOT DEFINED LOG4CPLUS_DECLSPEC_EXPORT OR NOT ENABLE_SYMBOLS_VISIBILITY) set(LOG4CPLUS_DECLSPEC_EXPORT "") set(LOG4CPLUS_DECLSPEC_IMPORT "") set(LOG4CPLUS_DECLSPEC_PRIVATE "") From 661bad65b1419d5cd246ff3e5c93e26bea637351 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 25 Nov 2013 13:11:26 +0100 Subject: [PATCH 134/226] syncprims.h (LOG4CPLUS_INLINES_ARE_EXPORTED): Do not define for any version of GCC to fix MinGW build issues that have resurfaced with GCC 4.8.x. --- include/log4cplus/config/win32.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/log4cplus/config/win32.h b/include/log4cplus/config/win32.h index 160048333..2ade3b914 100644 --- a/include/log4cplus/config/win32.h +++ b/include/log4cplus/config/win32.h @@ -179,7 +179,11 @@ # define LOG4CPLUS_HAVE___ATOMIC_ADD_FETCH # define LOG4CPLUS_HAVE___ATOMIC_SUB_FETCH # endif -# define LOG4CPLUS_INLINES_ARE_EXPORTED +// This has worked for some versions of MinGW with GCC 4.7+ but it +// appears to be broken again in 4.8.x. Thus, we disable this for GCC +// completely forever. +// +//# define LOG4CPLUS_INLINES_ARE_EXPORTED # endif # define LOG4CPLUS_HAVE_FUNCTION_MACRO # define LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS From 0b847228db88863728ca3e98fb8527f00f3731f8 Mon Sep 17 00:00:00 2001 From: Maxym Date: Wed, 27 Nov 2013 16:36:12 +0100 Subject: [PATCH 135/226] CMakeLists.txt (LOG4CPLUS_BUILD_LOGGINGSERVER): New option to allow disabling of loggingserver build. --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b10c60063..c030d0916 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ set (log4cplus_postfix "") option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) +option(LOG4CPLUS_BUILD_LOGGINGSERVER "Build the logging server." ON) + find_package (Threads) message (STATUS "Threads: ${CMAKE_THREAD_LIBS_INIT}") @@ -97,7 +99,11 @@ if (LOG4CPLUS_BUILD_TESTING) endif (LOG4CPLUS_BUILD_TESTING) add_subdirectory (src) -add_subdirectory (loggingserver) + +if (LOG4CPLUS_BUILD_LOGGINGSERVER) + add_subdirectory (loggingserver) +endif (LOG4CPLUS_BUILD_LOGGINGSERVER) + if (LOG4CPLUS_BUILD_TESTING) add_subdirectory (tests) endif (LOG4CPLUS_BUILD_TESTING) From 6214e58f253d2c20578e1967e60a401fe1ae91a8 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 28 Nov 2013 00:33:13 +0100 Subject: [PATCH 136/226] loggingmacros.h (LOG4CPLUS_MACRO_FUNCTION): Allow users to override this function-like macro. --- include/log4cplus/loggingmacros.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/include/log4cplus/loggingmacros.h b/include/log4cplus/loggingmacros.h index 4177388fe..37cfaec60 100644 --- a/include/log4cplus/loggingmacros.h +++ b/include/log4cplus/loggingmacros.h @@ -140,24 +140,22 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, } // namespace log4cplus -#undef LOG4CPLUS_MACRO_FUNCTION -#define LOG4CPLUS_MACRO_FUNCTION() 0 -#if ! defined (LOG4CPLUS_DISABLE_FUNCTION_MACRO) +#if ! defined (LOG4CPLUS_DISABLE_FUNCTION_MACRO) \ + && ! defined (LOG4CPLUS_MACRO_FUNCTION) # if defined (LOG4CPLUS_HAVE_FUNCSIG_MACRO) -# undef LOG4CPLUS_MACRO_FUNCTION # define LOG4CPLUS_MACRO_FUNCTION() __FUNCSIG__ # elif defined (LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO) -# undef LOG4CPLUS_MACRO_FUNCTION # define LOG4CPLUS_MACRO_FUNCTION() __PRETTY_FUNCTION__ # elif defined (LOG4CPLUS_HAVE_FUNCTION_MACRO) -# undef LOG4CPLUS_MACRO_FUNCTION # define LOG4CPLUS_MACRO_FUNCTION() __FUNCTION__ # elif defined (LOG4CPLUS_HAVE_FUNC_SYMBOL) -# undef LOG4CPLUS_MACRO_FUNCTION # define LOG4CPLUS_MACRO_FUNCTION() __func__ # endif #endif +#if ! defined (LOG4CPLUS_MACRO_FUNCTION) +# define LOG4CPLUS_MACRO_FUNCTION() 0 +#endif // Make TRACE and DEBUG log level unlikely and INFO, WARN, ERROR and // FATAL log level likely. From fcceb2da07bd7e7813ad6d0be92a403b5468a4ee Mon Sep 17 00:00:00 2001 From: Maxym Date: Thu, 28 Nov 2013 18:45:17 +0100 Subject: [PATCH 137/226] CMakeLists.txt: More reliable Android platform detection. --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c030d0916..9f5b6ca0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,12 @@ # This block needs to stay before the project (log4cplus) line so that # the output files placed into Android's libs directory. if (CMAKE_TOOLCHAIN_FILE) - # Android: set output folder to ${CMAKE_BINARY_DIR} - set (LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH - "root for library output, set this to change where android libs are compiled to") + get_filename_component(TOOL_CHAIN_FILE_NAME "${CMAKE_TOOLCHAIN_FILE}" NAME_WE) + if("${TOOL_CHAIN_FILE_NAME}" MATCHES "android.toolchain") + # Android: set output folder to ${CMAKE_BINARY_DIR} + set (LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH + "root for library output, set this to change where Android libs are compiled to") + endif() endif () # Remove when CMake >= 2.8.4 is required set (CMAKE_LEGACY_CYGWIN_WIN32 0) From 5c2739a0ba030c70b343e66b8cd18b6e9768b2bc Mon Sep 17 00:00:00 2001 From: Maxym Date: Thu, 28 Nov 2013 19:19:45 +0100 Subject: [PATCH 138/226] CMakeLists.txt: Allow overriding ConfigureChecks.cmake with user supplied file. This helps to work around CMake issues when building for Apple iOS. --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f5b6ca0f..996b7a42b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,13 @@ endif () set (log4cplus "log4cplus${log4cplus_postfix}") -include(ConfigureChecks.cmake) +if(LOG4CPLUS_CONFIGURE_CHECKS_PATH AND EXISTS ${LOG4CPLUS_CONFIGURE_CHECKS_PATH}) + message(STATUS "Custom ConfigureChecks script found: ${LOG4CPLUS_CONFIGURE_CHECKS_PATH}") +else() + set(LOG4CPLUS_CONFIGURE_CHECKS_PATH "ConfigureChecks.cmake") +endif() + +include(${LOG4CPLUS_CONFIGURE_CHECKS_PATH}) # Prepare defines.hxx.cmake from defines.hxx.in by doing a bit of # string manipulation. From 37cc39ee9a1da25c282b0ed7b1b8d33ddfc48c42 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 28 Nov 2013 21:49:55 +0100 Subject: [PATCH 139/226] android/android.toolchain.cmake: Update from OpenCV project. --- android/android.toolchain.cmake | 49 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index d7f09c788..1b9880e1d 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -318,7 +318,7 @@ set( CMAKE_SYSTEM_VERSION 1 ) # rpath makes low sence for Android set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) -set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS) if( CMAKE_HOST_WIN32 ) file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) @@ -484,7 +484,9 @@ else() message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" ) endif() -if( NOT ANDROID_NDK_HOST_X64 ) +# CMAKE_HOST_SYSTEM_PROCESSOR on MacOS X always says i386 on Intel platform +# So we do not trust ANDROID_NDK_HOST_X64 on Apple hosts +if( NOT ANDROID_NDK_HOST_X64 AND NOT CMAKE_HOST_APPLE) set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) endif() @@ -632,27 +634,30 @@ endif() macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath ) foreach( __toolchain ${${__availableToolchainsLst}} ) - if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) - string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) - else() - set( __gcc_toolchain "${__toolchain}" ) - endif() - __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" ) - if( __machine ) - string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" ) - if( __machine MATCHES i686 ) - set( __arch "x86" ) - elseif( __machine MATCHES arm ) - set( __arch "arm" ) - elseif( __machine MATCHES mipsel ) - set( __arch "mipsel" ) + # Skip renderscript folder. It's not C++ toolchain + if (NOT ${__toolchain} STREQUAL "renderscript") + if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) + string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) + else() + set( __gcc_toolchain "${__toolchain}" ) + endif() + __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" ) + if( __machine ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" ) + if( __machine MATCHES i686 ) + set( __arch "x86" ) + elseif( __machine MATCHES arm ) + set( __arch "arm" ) + elseif( __machine MATCHES mipsel ) + set( __arch "mipsel" ) + endif() + list( APPEND __availableToolchainMachines "${__machine}" ) + list( APPEND __availableToolchainArchs "${__arch}" ) + list( APPEND __availableToolchainCompilerVersions "${__version}" ) + list( APPEND ${__availableToolchainsVar} "${__toolchain}" ) endif() - list( APPEND __availableToolchainMachines "${__machine}" ) - list( APPEND __availableToolchainArchs "${__arch}" ) - list( APPEND __availableToolchainCompilerVersions "${__version}" ) - list( APPEND ${__availableToolchainsVar} "${__toolchain}" ) + unset( __gcc_toolchain ) endif() - unset( __gcc_toolchain ) endforeach() endmacro() @@ -713,7 +718,7 @@ __INIT_VARIABLE( ANDROID_ABI OBSOLETE_ARM_TARGET OBSOLETE_ARM_TARGETS VALUES ${A # verify that target ABI is supported list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx ) if( __androidAbiIdx EQUAL -1 ) - string( REPLACE ";" "\", \"", PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" ) + string( REPLACE ";" "\", \"" PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" ) message( FATAL_ERROR "Specified ANDROID_ABI = \"${ANDROID_ABI}\" is not supported by this cmake toolchain or your NDK/toolchain. Supported values are: \"${PRINTABLE_ANDROID_SUPPORTED_ABIS}\" " ) From 694f3ee79ea7bb8a6ce9f4d929b0ba46efb30d7f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 29 Nov 2013 10:43:55 +0100 Subject: [PATCH 140/226] fileappender.cxx (RollingFileAppender::RollingFileAppender): Avoid trimming MaxFileSize value here so that RollingFileAppener::init() can do it instead and also show a warning about it. --- src/fileappender.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fileappender.cxx b/src/fileappender.cxx index 1d1a782e9..131cb0504 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -447,7 +447,6 @@ RollingFileAppender::RollingFileAppender(const Properties& properties) && tmp.compare (len - 2, 2, LOG4CPLUS_TEXT("KB")) == 0) tmpMaxFileSize *= 1024; // convert to kilobytes } - tmpMaxFileSize = (std::max)(tmpMaxFileSize, MINIMUM_ROLLING_LOG_SIZE); } properties.getInt (tmpMaxBackupIndex, LOG4CPLUS_TEXT("MaxBackupIndex")); From d90b627e65cff167050879b83d63fbe731140f3d Mon Sep 17 00:00:00 2001 From: Maxym Date: Mon, 2 Dec 2013 14:14:19 +0100 Subject: [PATCH 141/226] iOS: Add iOS folder in the root. The folder is organized in pretty much the same way as android folder. it contains iOS.cmake toolchain file (https://code.google.com/p/ios-cmake/), custom ConfigureChecks.cmake and readme, which shortly describes how to use the script. --- iOS/ConfigureChecks.cmake | 160 +++++++++++++++++++++++++++ iOS/README.txt | 13 +++ iOS/iOS.cmake | 193 +++++++++++++++++++++++++++++++++ iOS/scripts/cmake_ios_armv7.sh | 18 +++ iOS/scripts/cmake_ios_i386.sh | 19 ++++ 5 files changed, 403 insertions(+) create mode 100644 iOS/ConfigureChecks.cmake create mode 100644 iOS/README.txt create mode 100644 iOS/iOS.cmake create mode 100755 iOS/scripts/cmake_ios_armv7.sh create mode 100755 iOS/scripts/cmake_ios_i386.sh diff --git a/iOS/ConfigureChecks.cmake b/iOS/ConfigureChecks.cmake new file mode 100644 index 000000000..196fff021 --- /dev/null +++ b/iOS/ConfigureChecks.cmake @@ -0,0 +1,160 @@ +include(CheckIncludeFiles) +include(CheckFunctionExists) +include(CheckLibraryExists) +include(CheckSymbolExists) +include(CheckTypeSize) +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) + +#check_include_files(dlfcn.h HAVE_DLFCN_H ) + +set(LOG4CPLUS_HAVE_ERRNO_H 1) +set(LOG4CPLUS_HAVE_ICONV_H 1) +set(LOG4CPLUS_HAVE_LIMITS_H 1) +set(LOG4CPLUS_HAVE_SYS_TYPES_H 1) +set(LOG4CPLUS_HAVE_SYS_SOCKET_H 1) +set(LOG4CPLUS_HAVE_SYS_SYSCALL_H 1) +set(LOG4CPLUS_HAVE_SYS_TIME_H 1) +set(LOG4CPLUS_HAVE_SYS_TIMEB_H 1) +set(LOG4CPLUS_HAVE_SYS_STAT_H 1) +set(LOG4CPLUS_HAVE_SYS_FILE_H 1) +set(LOG4CPLUS_HAVE_SYSLOG_H 1) +set(LOG4CPLUS_HAVE_ARPA_INET_H 1) +set(LOG4CPLUS_HAVE_NETINET_IN_H 1) +set(LOG4CPLUS_HAVE_NETINET_TCP_H 1) +set(LOG4CPLUS_HAVE_NETDB_H 1) +set(LOG4CPLUS_HAVE_UNISTD_H 1) +set(LOG4CPLUS_HAVE_FCNTL_H 1) +set(LOG4CPLUS_HAVE_STDIO_H 1) +set(LOG4CPLUS_HAVE_STDARG_H 1) +set(LOG4CPLUS_HAVE_STDLIB_H 1) +set(LOG4CPLUS_HAVE_TIME_H 1) +set(LOG4CPLUS_HAVE_WCHAR_H 1) +set(LOG4CPLUS_HAVE_POLL_H 1) + + +# set(HAVE_INTTYPES_H 1) +# set(HAVE_MEMORY_H 1) +# set(HAVE_STDINT_H 1) +# set(HAVE_STRINGS_H 1) +# set(HAVE_STRING_H 1) + + +#check_include_files("stdlib.h;stdio.h;stdarg.h;string.h;float.h" STDC_HEADERS ) + +find_library(LIBADVAPI32 advapi32) +find_library(LIBKERNEL32 kernel32) +find_library(LIBNSL nsl) +find_library(LIBRT rt) +find_library(LIBICONV iconv) +find_library(LIBPOSIX4 posix4) +find_library(LIBCPOSIX cposix) +find_library(LIBSOCKET socket) +find_library(LIBWS2_32 ws2_32) + +set(LOG4CPLUS_HAVE_GMTIME_R 1) +set(LOG4CPLUS_HAVE_LOCALTIME_R 1) +set(LOG4CPLUS_HAVE_GETTIMEOFDAY 1) +set(LOG4CPLUS_HAVE_GETPID 1) +set(LOG4CPLUS_HAVE_POLL 1) +set(LOG4CPLUS_HAVE_PIPE 1) +#set(LOG4CPLUS_HAVE_PIPE2 ) +set(LOG4CPLUS_HAVE_FTIME 1) +set(LOG4CPLUS_HAVE_STAT 1) +set(LOG4CPLUS_HAVE_LSTAT 1) +set(LOG4CPLUS_HAVE_FCNTL 1) +set(LOG4CPLUS_HAVE_FLOCK 1) +set(LOG4CPLUS_HAVE_LOCKF 1) +set(LOG4CPLUS_HAVE_HTONS 1) +set(LOG4CPLUS_HAVE_NTOHS 1) +set(LOG4CPLUS_HAVE_HTONL 1) +set(LOG4CPLUS_HAVE_NTOHL 1) +set(LOG4CPLUS_HAVE_SHUTDOWN 1) +set(LOG4CPLUS_HAVE_VSNPRINTF 1) +#set(LOG4CPLUS_HAVE__VSNPRINTF ) +#set(LOG4CPLUS_HAVE_VSPRINTF_S ) +#set(LOG4CPLUS_HAVE_VSWPRINTF_S ) +#set(LOG4CPLUS_HAVE_VFPRINTF_S ) +#set(LOG4CPLUS_HAVE_VFWPRINTF_S ) +#set(LOG4CPLUS_HAVE__VSNPRINTF_S ) +#set(LOG4CPLUS_HAVE__VSNWPRINTF_S ) +set(LOG4CPLUS_HAVE_MBSTOWCS 1) +set(LOG4CPLUS_HAVE_WCSTOMBS 1) + + +set(LOG4CPLUS_HAVE_ENAMETOOLONG 1) +set(LOG4CPLUS_HAVE_GETTID 1) +set(LOG4CPLUS_HAVE_FUNCTION_MACRO 1) +set(LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO 1) +set(LOG4CPLUS_HAVE_FUNC_SYMBOL 1) + +set(LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH 1) +set(LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH 1) + +set(LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS 1) +set(LOG4CPLUS_HAVE_C99_VARIADIC_MACROS 1) + +#set(LOG4CPLUS_HAVE_CLOCK_GETTIME ) +#set(LOG4CPLUS_HAVE_CLOCK_NANOSLEEP ) +set(LOG4CPLUS_HAVE_NANOSLEEP 1) + +#set(LOG4CPLUS_HAVE_ICONV_OPEN ) +#set(LOG4CPLUS_HAVE_ICONV_CLOSE ) +#set(LOG4CPLUS_HAVE_ICONV ) + +#set(LOG4CPLUS_HAVE_GETHOSTBYNAME_R) +set(LOG4CPLUS_HAVE_GETADDRINFO 1) + + +set(LOG4CPLUS_DECLSPEC_EXPORT "__attribute__ ((visibility(\"default\")))" ) +set(LOG4CPLUS_DECLSPEC_IMPORT "__attribute__ ((visibility(\"default\")))" ) +set(LOG4CPLUS_DECLSPEC_PRIVATE "__attribute__ ((visibility(\"hidden\")))" ) + +set(LOG4CPLUS_HAVE_TLS_SUPPORT 1) +set(LOG4CPLUS_THREAD_LOCAL_VAR "__thread") + +#set(LOG4CPLUS_HAVE_CXX11_ATOMICS ) + +#set(socklen_t) + +set(HAVE_STDLIB_H ${LOG4CPLUS_HAVE_STDLIB_H} ) +set(HAVE_SYS_STAT_H ${LOG4CPLUS_HAVE_SYS_STAT_H} ) +set(HAVE_SYS_TYPES_H ${LOG4CPLUS_HAVE_SYS_TYPES_H} ) +set(HAVE_SYS_FILE_H ${LOG4CPLUS_HAVE_SYS_FILE_H} ) +set(HAVE_UNISTD_H ${LOG4CPLUS_HAVE_UNISTD_H} ) + + +set(HAVE_FTIME ${LOG4CPLUS_HAVE_FTIME} ) +set(HAVE_GETPID ${LOG4CPLUS_HAVE_GETPID} ) +set(HAVE_GETTIMEOFDAY ${LOG4CPLUS_HAVE_GETTIMEOFDAY} ) +set(HAVE_GETADDRINFO ${LOG4CPLUS_HAVE_GETADDRINFO} ) +set(HAVE_GETHOSTBYNAME_R ${LOG4CPLUS_HAVE_GETHOSTBYNAME_R} ) +set(HAVE_GMTIME_R ${LOG4CPLUS_HAVE_GMTIME_R} ) +set(HAVE_HTONL ${LOG4CPLUS_HAVE_HTONL} ) +set(HAVE_HTONS ${LOG4CPLUS_HAVE_HTONS} ) +set(HAVE_ICONV_OPEN ${LOG4CPLUS_HAVE_ICONV_OPEN} ) +set(HAVE_ICONV_CLOSE ${LOG4CPLUS_HAVE_ICONV_CLOSE} ) +set(HAVE_ICONV ${LOG4CPLUS_HAVE_ICONV} ) +set(HAVE_LSTAT ${LOG4CPLUS_HAVE_LSTAT} ) +set(HAVE_FCNTL ${LOG4CPLUS_HAVE_FCNTL} ) +set(HAVE_LOCKF ${LOG4CPLUS_HAVE_LOCKF} ) +set(HAVE_FLOCK ${LOG4CPLUS_HAVE_FLOCK} ) +set(HAVE_LOCALTIME_R ${LOG4CPLUS_HAVE_LOCALTIME_R} ) +set(HAVE_NTOHL ${LOG4CPLUS_HAVE_NTOHL} ) +set(HAVE_NTOHS ${LOG4CPLUS_HAVE_NTOHS} ) +set(HAVE_STAT ${LOG4CPLUS_HAVE_STAT} ) + +set(HAVE_VFPRINTF_S ${LOG4CPLUS_HAVE_VFPRINTF_S} ) +set(HAVE_VFWPRINTF_S ${LOG4CPLUS_HAVE_VFWPRINTF_S} ) +set(HAVE_VSNPRINTF ${LOG4CPLUS_HAVE_VSNPRINTF} ) +set(HAVE_VSPRINTF_S ${LOG4CPLUS_HAVE_VSPRINTF_S} ) +set(HAVE_VSWPRINTF_S ${LOG4CPLUS_HAVE_VSWPRINTF_S} ) +set(HAVE__VSNPRINTF ${LOG4CPLUS_HAVE__VSNPRINTF} ) +set(HAVE__VSNPRINTF_S ${LOG4CPLUS_HAVE__VSNPRINTF_S} ) +set(HAVE__VSNWPRINTF_S ${LOG4CPLUS_HAVE__VSNWPRINTF_S} ) + +set(HAVE_FUNCTION_MACRO ${LOG4CPLUS_HAVE_FUNCTION_MACRO} ) +set(HAVE_PRETTY_FUNCTION_MACRO ${LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO} ) + +set(HAVE___SYNC_ADD_AND_FETCH ${LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH} ) +set(HAVE___SYNC_SUB_AND_FETCH ${LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH} ) diff --git a/iOS/README.txt b/iOS/README.txt new file mode 100644 index 000000000..528b9b74e --- /dev/null +++ b/iOS/README.txt @@ -0,0 +1,13 @@ +NOTE: log4cplus build for iOS is based on iOS.cmake toolchain file, + orininally taken from https://code.google.com/p/ios-cmake/ + +To build the library for iOS, being in current folder, perform the steps below: +For armv7 architecture: +$ ./scripts/cmake_ios_armv7.sh +$ cmake --build ./build_armv7 --config "Release" +$ cmake --build ./build_armv7 --config "Debug" + +For i386 architecture: +$ ./scripts/cmake_ios_i386.sh +$ cmake --build ./build_i386 --config "Release" +$ cmake --build ./build_i386 --config "Debug" diff --git a/iOS/iOS.cmake b/iOS/iOS.cmake new file mode 100644 index 000000000..c0134645d --- /dev/null +++ b/iOS/iOS.cmake @@ -0,0 +1,193 @@ +# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake +# files which are included with CMake 2.8.4 +# It has been altered for iOS development + +# Options: +# +# IOS_PLATFORM = OS (default) or SIMULATOR +# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders +# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch. +# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch. +# +# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder +# By default this location is automatcially chosen based on the IOS_PLATFORM value above. +# If set manually, it will override the default location and force the user of a particular Developer Platform +# +# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder +# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value. +# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path. +# If set manually, this will force the use of a specific SDK version + +# Macros: +# +# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE) +# A convenience macro for setting xcode specific properties on targets +# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1") +# +# find_host_package (PROGRAM ARGS) +# A macro used to find executable programs on the host system, not within the iOS environment. +# Thanks to the android-cmake project for providing the command + + +# Standard settings +set (CMAKE_SYSTEM_NAME Darwin) +set (CMAKE_SYSTEM_VERSION 1) +set (UNIX True) +set (APPLE True) +set (IOS True) + +# Required as of cmake 2.8.10 +set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE) + +# Determine the cmake host system version so we know where to find the iOS SDKs +find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin) +if (CMAKE_UNAME) + exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) + string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") +endif (CMAKE_UNAME) + +# Force the compilers to gcc for iOS +include (CMakeForceCompiler) +CMAKE_FORCE_C_COMPILER (gcc gcc) +CMAKE_FORCE_CXX_COMPILER (g++ g++) + +# Skip the platform compiler checks for cross compiling +set (CMAKE_CXX_COMPILER_WORKS TRUE) +set (CMAKE_C_COMPILER_WORKS TRUE) + +# All iOS/Darwin specific settings - some may be redundant +set (CMAKE_SHARED_LIBRARY_PREFIX "lib") +set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") +set (CMAKE_SHARED_MODULE_PREFIX "lib") +set (CMAKE_SHARED_MODULE_SUFFIX ".so") +set (CMAKE_MODULE_EXISTS 1) +set (CMAKE_DL_LIBS "") + +set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") +set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") +set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") + +# Hidden visibilty is required for cxx on iOS +set (CMAKE_C_FLAGS_INIT "") +set (CMAKE_CXX_FLAGS_INIT "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden") + +set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") +set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") + +set (CMAKE_PLATFORM_HAS_INSTALLNAME 1) +set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names") +set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names") +set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") +set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") +set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") + +# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree +# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache +# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun) +# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex +if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool) +endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + +# Setup iOS platform unless specified manually with IOS_PLATFORM +if (NOT DEFINED IOS_PLATFORM) + set (IOS_PLATFORM "OS") +endif (NOT DEFINED IOS_PLATFORM) +set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform") + +# Check the platform selection and setup for developer root +if (${IOS_PLATFORM} STREQUAL "OS") + set (IOS_PLATFORM_LOCATION "iPhoneOS.platform") + + # This causes the installers to properly locate the output libraries + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos") +elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR") + set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform") + + # This causes the installers to properly locate the output libraries + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator") +else (${IOS_PLATFORM} STREQUAL "OS") + message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR") +endif (${IOS_PLATFORM} STREQUAL "OS") + +# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT +# Note Xcode 4.3 changed the installation location, choose the most recent one available +set (XCODE_POST_43_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer") +set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer") +if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) + if (EXISTS ${XCODE_POST_43_ROOT}) + set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT}) + elseif(EXISTS ${XCODE_PRE_43_ROOT}) + set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT}) + endif (EXISTS ${XCODE_POST_43_ROOT}) +endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) +set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform") + +# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT +if (NOT DEFINED CMAKE_IOS_SDK_ROOT) + file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*") + if (_CMAKE_IOS_SDKS) + list (SORT _CMAKE_IOS_SDKS) + list (REVERSE _CMAKE_IOS_SDKS) + list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT) + else (_CMAKE_IOS_SDKS) + message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.") + endif (_CMAKE_IOS_SDKS) + message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}") +endif (NOT DEFINED CMAKE_IOS_SDK_ROOT) +set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK") + +# Set the sysroot default to the most recent SDK +set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") + +# set the architecture for iOS +# NOTE: Currently both ARCHS_STANDARD_32_BIT and ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually +if (${IOS_PLATFORM} STREQUAL "OS") + set (IOS_ARCH armv6 armv7) +else (${IOS_PLATFORM} STREQUAL "OS") + set (IOS_ARCH i386) +endif (${IOS_PLATFORM} STREQUAL "OS") + +set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS") + +# Set the find root to the iOS developer roots and to user defined paths +set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root") + +# default to searching for frameworks first +set (CMAKE_FIND_FRAMEWORK FIRST) + +# set up the default search directories for frameworks +set (CMAKE_SYSTEM_FRAMEWORK_PATH + ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks + ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks + ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks +) + +# only search the iOS sdks, not the remainder of the host filesystem +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + + +# This little macro lets you set any XCode specific property +macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) + set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE}) +endmacro (set_xcode_property) + + +# This macro lets you find executable programs on the host system +macro (find_host_package) + set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + set (IOS FALSE) + + find_package(${ARGN}) + + set (IOS TRUE) + set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) + set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endmacro (find_host_package) + diff --git a/iOS/scripts/cmake_ios_armv7.sh b/iOS/scripts/cmake_ios_armv7.sh new file mode 100755 index 000000000..0bee3392e --- /dev/null +++ b/iOS/scripts/cmake_ios_armv7.sh @@ -0,0 +1,18 @@ +#!/bin/sh +scripts_dir=`cd $(dirname $0);pwd` +cd $scripts_dir/.. + +mkdir -p build_armv7 +cd build_armv7 + +cmake -G "Xcode" -DBUILD_SHARED_LIBS="FALSE" \ + -DCMAKE_TOOLCHAIN_FILE=$scripts_dir/../iOS.cmake \ + -DLOG4CPLUS_SINGLE_THREADED="TRUE" \ + -DLOG4CPLUS_BUILD_TESTING="OFF" \ + -DLOG4CPLUS_QT4="OFF" \ + -DLOG4CPLUS_BUILD_LOGGINGSERVER="OFF" \ + -DLOG4CPLUS_CONFIGURE_CHECKS_PATH=$scripts_dir/../ConfigureChecks.cmake \ + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=$scripts_dir/../build_armv7/Binaries \ + $@ \ + $scripts_dir/../.. + diff --git a/iOS/scripts/cmake_ios_i386.sh b/iOS/scripts/cmake_ios_i386.sh new file mode 100755 index 000000000..31fee0197 --- /dev/null +++ b/iOS/scripts/cmake_ios_i386.sh @@ -0,0 +1,19 @@ +#!/bin/sh +scripts_dir=`cd $(dirname $0);pwd` +cd $scripts_dir/.. + +mkdir -p build_i386 +cd build_i386 + +cmake -G "Xcode" -DBUILD_SHARED_LIBS="FALSE" \ + -DIOS_PLATFORM="SIMULATOR" \ + -DCMAKE_TOOLCHAIN_FILE=$scripts_dir/../iOS.cmake \ + -DLOG4CPLUS_SINGLE_THREADED="TRUE" \ + -DLOG4CPLUS_BUILD_TESTING="OFF" \ + -DLOG4CPLUS_QT4="OFF" \ + -DLOG4CPLUS_BUILD_LOGGINGSERVER="OFF" \ + -DLOG4CPLUS_CONFIGURE_CHECKS_PATH=$scripts_dir/../ConfigureChecks.cmake \ + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=$scripts_dir/../build_i386/Binaries \ + $@ \ + $scripts_dir/../.. + From 08b722527c8fbc8e4a6d50a25acdffa583e897a5 Mon Sep 17 00:00:00 2001 From: Maxym Date: Mon, 2 Dec 2013 14:17:20 +0100 Subject: [PATCH 142/226] CMakeLists.txt: Skip find_package(Threads) if LOG4CPLUS_SINGLE_THREADED version is requested. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 996b7a42b..ddac4536c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,10 @@ option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) option(LOG4CPLUS_BUILD_LOGGINGSERVER "Build the logging server." ON) -find_package (Threads) -message (STATUS "Threads: ${CMAKE_THREAD_LIBS_INIT}") +if(NOT LOG4CPLUS_SINGLE_THREADED) + find_package (Threads) + message (STATUS "Threads: ${CMAKE_THREAD_LIBS_INIT}") +endif(NOT LOG4CPLUS_SINGLE_THREADED) set(BUILD_SHARED_LIBS TRUE CACHE BOOL "If TRUE, log4cplus is built as a shared library, otherwise as a static library") From 50f80c8f3fad666b5f924150a9f4673e308cba7b Mon Sep 17 00:00:00 2001 From: Maxym Date: Mon, 2 Dec 2013 14:19:13 +0100 Subject: [PATCH 143/226] CMakeLists.txt: Use absolute path for LOG4CPLUS_CONFIGURE_CHECKS_PATH. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddac4536c..5ad30840c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,10 @@ endif () set (log4cplus "log4cplus${log4cplus_postfix}") +if(LOG4CPLUS_CONFIGURE_CHECKS_PATH) + get_filename_component(LOG4CPLUS_CONFIGURE_CHECKS_PATH "${LOG4CPLUS_CONFIGURE_CHECKS_PATH}" ABSOLUTE) +endif() + if(LOG4CPLUS_CONFIGURE_CHECKS_PATH AND EXISTS ${LOG4CPLUS_CONFIGURE_CHECKS_PATH}) message(STATUS "Custom ConfigureChecks script found: ${LOG4CPLUS_CONFIGURE_CHECKS_PATH}") else() From 8bab4d34894ef64f2f10c9a8268a4db9d6430b2c Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 29 Dec 2013 22:33:12 +0100 Subject: [PATCH 144/226] .dir-locals.el: Add from trunk. --- .dir-locals.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 000000000..9a7bcdb11 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,15 @@ +;;; Directory Local Variables +;;; See Info node `(emacs) Directory Variables' for more information. + +((nil + (fill-column . 79) + (indent-tabs-mode) + (show-trailing-whitespace . t) + (whitespace-style face trailing lines-tail space-before-tab indentation empty) + (whitespace-newline . t)) + (c++-mode + (tab-width . 4) + (whitespace-action warn-read-only auto-cleanup)) + (cmake-mode + (whitespace-action warn-read-only auto-cleanup))) + From 56724cf607bbb1c704883c53ecc5ed08b6271cea Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 29 Dec 2013 22:33:56 +0100 Subject: [PATCH 145/226] timehelper.cxx: Fix compilation issue in single threaded mode on Windows. --- src/timehelper.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/timehelper.cxx b/src/timehelper.cxx index eb5ca7388..df19cf0a9 100644 --- a/src/timehelper.cxx +++ b/src/timehelper.cxx @@ -53,6 +53,8 @@ #define LOG4CPLUS_NEED_LOCALTIME_R #endif +#include + namespace log4cplus { namespace helpers { From 14d9d24347ba53fc59e364078ac6a5fab95dcaa5 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 29 Dec 2013 22:41:34 +0100 Subject: [PATCH 146/226] Use GNUInstallDirs to specify better default installation directories on GNU platforms. --- CMakeLists.txt | 11 +++++++---- loggingserver/CMakeLists.txt | 2 +- qt4debugappender/CMakeLists.txt | 8 ++++---- src/CMakeLists.txt | 23 +++++++++++------------ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ad30840c..15f5a04b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,9 @@ set (CMAKE_LEGACY_CYGWIN_WIN32 0) project (log4cplus) cmake_minimum_required (VERSION 2.8.4) +enable_language (CXX) +include(GNUInstallDirs) + include (Log4CPlusUtils.cmake) log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include" log4cplus_version_major log4cplus_version_minor log4cplus_version_patch) @@ -61,13 +64,13 @@ option(WITH_ICONV "Use iconv() for char->wchar_t conversion." option(ENABLE_SYMBOLS_VISIBILITY "Enable compiler and platform specific options for symbols visibility" ON) - + set(_WIN32_WINNT 0x0500 CACHE STRING "Define Windows API version to use.") if (NOT ${BUILD_SHARED_LIBS}) - # set S-prefix for static build + # set S-prefix for static build set (log4cplus_postfix "${log4cplus_postfix}S") -endif() +endif() if (UNICODE) set (log4cplus_postfix "${log4cplus_postfix}U") @@ -97,7 +100,7 @@ file(READ include/log4cplus/config/defines.hxx.in FILE_BUFFER) string(REGEX REPLACE "#undef[^a-zA-Z0-9_]+([a-zA-Z0-9_]+)" "#cmakedefine \\1 @\\1@" FILE_BUFFER "${FILE_BUFFER}") set(DEFINES_HXX_CMAKE - ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx.cmake) + ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx.cmake) set(DEFINES_HXX ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx) file(WRITE ${DEFINES_HXX_CMAKE} ${FILE_BUFFER}) diff --git a/loggingserver/CMakeLists.txt b/loggingserver/CMakeLists.txt index 3b0b0f7a8..e53512050 100644 --- a/loggingserver/CMakeLists.txt +++ b/loggingserver/CMakeLists.txt @@ -11,4 +11,4 @@ message (STATUS "Sources: ${loggingserver_sources}") add_executable (loggingserver ${loggingserver_sources}) target_link_libraries (loggingserver ${log4cplus}) -install(TARGETS loggingserver DESTINATION bin) +install(TARGETS loggingserver DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/qt4debugappender/CMakeLists.txt b/qt4debugappender/CMakeLists.txt index 87e682c5f..17ad56902 100644 --- a/qt4debugappender/CMakeLists.txt +++ b/qt4debugappender/CMakeLists.txt @@ -26,9 +26,9 @@ if (WIN32) endif () install (TARGETS ${qt4debugappender} - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install (FILES ../include/log4cplus/qt4debugappender.h - DESTINATION include/log4cplus) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 852897972..8f3070cb2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -107,9 +107,9 @@ if (WIN32) target_link_libraries (${log4cplus} ws2_32 advapi32) endif () -install(TARGETS ${log4cplus} LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin) +install(TARGETS ${log4cplus} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES ../include/log4cplus/appender.h ../include/log4cplus/asyncappender.h @@ -139,10 +139,10 @@ install(FILES ../include/log4cplus/appender.h ../include/log4cplus/version.h ../include/log4cplus/win32debugappender.h ../include/log4cplus/win32consoleappender.h - DESTINATION include/log4cplus ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus ) install(FILES ../include/log4cplus/boost/deviceappender.hxx - DESTINATION include/log4cplus/boost ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/boost ) install(FILES ../include/log4cplus/helpers/appenderattachableimpl.h @@ -160,12 +160,12 @@ install(FILES ../include/log4cplus/helpers/appenderattachableimpl.h ../include/log4cplus/helpers/stringhelper.h ../include/log4cplus/helpers/thread-config.h ../include/log4cplus/helpers/timehelper.h - DESTINATION include/log4cplus/helpers ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/helpers ) install(FILES ../include/log4cplus/internal/env.h ../include/log4cplus/internal/internal.h ../include/log4cplus/internal/socket.h - DESTINATION include/log4cplus/internal ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/internal ) install(FILES ../include/log4cplus/spi/appenderattachable.h ../include/log4cplus/spi/factory.h @@ -175,7 +175,7 @@ install(FILES ../include/log4cplus/spi/appenderattachable.h ../include/log4cplus/spi/loggingevent.h ../include/log4cplus/spi/objectregistry.h ../include/log4cplus/spi/rootlogger.h - DESTINATION include/log4cplus/spi ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/spi ) install(FILES ../include/log4cplus/thread/impl/syncprims-impl.h # ../include/log4cplus/thread/impl/syncprims-pmsm.h @@ -183,16 +183,15 @@ install(FILES ../include/log4cplus/thread/impl/syncprims-impl.h ../include/log4cplus/thread/impl/syncprims-win32.h ../include/log4cplus/thread/impl/threads-impl.h ../include/log4cplus/thread/impl/tls.h - DESTINATION include/log4cplus/thread/impl ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/thread/impl ) install(FILES ../include/log4cplus/thread/syncprims-pub-impl.h ../include/log4cplus/thread/syncprims.h ../include/log4cplus/thread/threads.h - DESTINATION include/log4cplus/thread ) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/thread ) install(FILES ../include/log4cplus/config/macosx.h ../include/log4cplus/config/win32.h ../include/log4cplus/config/windowsh-inc.h ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx - DESTINATION include/log4cplus/config ) - + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/config ) From 2e6c1d4d3085498a9bf0ff813d5b12ee488c8ebc Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 31 Dec 2013 08:40:57 +0100 Subject: [PATCH 147/226] AUTHORS: Add recent contributors. --- AUTHORS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AUTHORS b/AUTHORS index f6e3cbaea..88b9255cc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -22,3 +22,5 @@ Jukka Lantto Konstantin Baumann Yaqian Shen Sergey Nikulov +Ray Logel +Maxym From 11b5f685b1b27056ba3cf851077e3c04aeac1d87 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 31 Dec 2013 08:54:33 +0100 Subject: [PATCH 148/226] ChangeLog: Update for 1.1.3-RC1. --- ChangeLog | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 753511c74..30448d86d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +log4cplus 1.1.3-RC1 + +- Added --enable-symbols-visibility-options to configure script to allow + turning off use of compiler and platform specific symbols visibility + options. + +- Added ENABLE_SYMBOLS_VISIBILITY setting for CMake build system to the same + effect as above. + +- Disabled LOG4CPLUS_INLINES_ARE_EXPORTED to fix linking issues on MinGW GCC + 4.8.x. + +- Added LOG4CPLUS_BUILD_LOGGINGSERVER setting for CMake build system to allow + disabling loggingserver. (Maxym) + +- Allow users overriding LOG4CPLUS_MACRO_FUNCTION. + +- Improved Android platform detection in CMake build system. (Maxym) + +- Allow overriding ConfigureChecks.cmake with user supplied file to help with + issues on iOS platform. + +- Updated android.toolchain.cmake from OpenCV project. + +- Added iOS support to CMake build system. (Maxym) + +- Fixed compilation issue of single-threaded builds on Windows. + +- Improved CMake build system's default installation directories for GNU + platforms by using GNUInstallDirs module. + + log4cplus 1.1.2 - Added AbstractSocket::shutdown(). @@ -7,7 +39,8 @@ log4cplus 1.1.2 - Fixed bug #278 - TLS key leak. - Implemented %E{ENVVAR} pattern layout formatter for expansion of environment - variables. + variables. (Ray Logel) + log4cplus 1.1.2-RC3 From 2904b98d4111346b8bac896b6db44d9601cf21b4 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 31 Dec 2013 08:56:19 +0100 Subject: [PATCH 149/226] scripts/propagate-version.pl: Adjust also CMakeLists.txt. --- scripts/propagate-version.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/propagate-version.pl b/scripts/propagate-version.pl index 1a32f3ae6..2a12d2374 100755 --- a/scripts/propagate-version.pl +++ b/scripts/propagate-version.pl @@ -99,5 +99,12 @@ BEGIN || $line =~ s/\d+ ([._\-]) \d+ ([._\-]) \d+ /$major$1$minor$2$so_current_adjusted/gx; print $line; - } + } + + local @ARGV = ("CMakeLists.txt"); + while (my $line = <>) + { + $line =~ s/(set\s*\(log4cplus_soversion\s*)\d+(\))/$1$so_current$2/x; + print $line; + } } From 61397068e830277309d947fe31e3bc06028c30ca Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 31 Dec 2013 08:57:16 +0100 Subject: [PATCH 150/226] Propagate version 1.1.3 through the source. --- CMakeLists.txt | 2 +- configure | 22 +++++++++++----------- configure.ac | 4 ++-- cygport/log4cplus.cygport | 2 +- docs/doxygen.config | 4 ++-- docs/webpage_doxygen.config | 4 ++-- include/log4cplus/version.h | 12 ++++++------ log4cplus.spec | 2 +- mingw-log4cplus.spec | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15f5a04b8..3ea86be14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include (Log4CPlusUtils.cmake) log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include" log4cplus_version_major log4cplus_version_minor log4cplus_version_patch) message("-- Generating build for Log4cplus version ${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") -set (log4cplus_soversion 7) +set (log4cplus_soversion 9) set (log4cplus_postfix "") option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) diff --git a/configure b/configure index 19be65ca8..a8b8d7944 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for log4cplus 1.1.2. +# Generated by GNU Autoconf 2.69 for log4cplus 1.1.3. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='log4cplus' PACKAGE_TARNAME='log4cplus' -PACKAGE_VERSION='1.1.2' -PACKAGE_STRING='log4cplus 1.1.2' +PACKAGE_VERSION='1.1.3' +PACKAGE_STRING='log4cplus 1.1.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1354,7 +1354,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures log4cplus 1.1.2 to adapt to many kinds of systems. +\`configure' configures log4cplus 1.1.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1425,7 +1425,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of log4cplus 1.1.2:";; + short | recursive ) echo "Configuration of log4cplus 1.1.3:";; esac cat <<\_ACEOF @@ -1556,7 +1556,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -log4cplus configure 1.1.2 +log4cplus configure 1.1.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2103,7 +2103,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by log4cplus $as_me 1.1.2, which was +It was created by log4cplus $as_me 1.1.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3039,7 +3039,7 @@ fi # Define the identity of the package. PACKAGE='log4cplus' - VERSION='1.1.2' + VERSION='1.1.3' # Some tools Automake needs. @@ -4225,7 +4225,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=9:0:0 +LT_VERSION=9:1:0 LT_RELEASE=1.1 @@ -21803,7 +21803,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by log4cplus $as_me 1.1.2, which was +This file was extended by log4cplus $as_me 1.1.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21869,7 +21869,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -log4cplus config.status 1.1.2 +log4cplus config.status 1.1.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index a87879943..84458f275 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl autoconf-2.69 dnl automake-1.12.6 dnl libtool-2.4.2 -AC_INIT([log4cplus],[1.1.2]) +AC_INIT([log4cplus],[1.1.3]) AC_CANONICAL_TARGET AC_CONFIG_SRCDIR([src/logger.cxx]) AC_CONFIG_MACRO_DIR([m4]) @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=9:0:0 +LT_VERSION=9:1:0 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) diff --git a/cygport/log4cplus.cygport b/cygport/log4cplus.cygport index 0d4d08a1c..4d70fab05 100644 --- a/cygport/log4cplus.cygport +++ b/cygport/log4cplus.cygport @@ -1,5 +1,5 @@ NAME=log4cplus -VERSION=1.1.2-rc1 +VERSION=1.1.3-rc1 RELEASE=1 CATEGORY="Libs" SUMMARY="C++ logging library" diff --git a/docs/doxygen.config b/docs/doxygen.config index a42bbc308..b49512c51 100644 --- a/docs/doxygen.config +++ b/docs/doxygen.config @@ -32,7 +32,7 @@ PROJECT_NAME = log4cplus # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.1.2 +PROJECT_NUMBER = 1.1.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = log4cplus-1.1.2/docs +OUTPUT_DIRECTORY = log4cplus-1.1.3/docs # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output diff --git a/docs/webpage_doxygen.config b/docs/webpage_doxygen.config index 9dcd9e8ca..88ea32b2a 100644 --- a/docs/webpage_doxygen.config +++ b/docs/webpage_doxygen.config @@ -32,7 +32,7 @@ PROJECT_NAME = log4cplus # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.1.2 +PROJECT_NUMBER = 1.1.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = webpage_docs-1.1.2 +OUTPUT_DIRECTORY = webpage_docs-1.1.3 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output diff --git a/include/log4cplus/version.h b/include/log4cplus/version.h index eb5d47cbc..0481df955 100644 --- a/include/log4cplus/version.h +++ b/include/log4cplus/version.h @@ -1,16 +1,16 @@ // -*- C++ -*- // Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. -// +// // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -38,8 +38,8 @@ #define LOG4CPLUS_MAKE_VERSION_STR(major, minor, point) \ #major "." #minor "." #point -#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 2) -#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 2) +#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 3) +#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 3) namespace log4cplus diff --git a/log4cplus.spec b/log4cplus.spec index 539596b73..2bc4eb3a4 100644 --- a/log4cplus.spec +++ b/log4cplus.spec @@ -1,5 +1,5 @@ Name: log4cplus -Version: 1.1.2 +Version: 1.1.3 Release: 1 Summary: log4cplus, C++ logging library diff --git a/mingw-log4cplus.spec b/mingw-log4cplus.spec index 056934868..b7d5e03aa 100755 --- a/mingw-log4cplus.spec +++ b/mingw-log4cplus.spec @@ -1,12 +1,12 @@ Name: log4cplus -Version: 1.1.2 +Version: 1.1.3 Release: 1%{?dist} Summary: log4cplus, C++ logging library License: Apache Group: Development/Libraries URL: http://log4cplus.sourceforge.net/ -Source0: http://downloads.sourceforge.net/project/log4cplus/log4cplus-stable/1.1.2/log4cplus-1.1.2.tar.gz +Source0: http://downloads.sourceforge.net/project/log4cplus/log4cplus-stable/1.1.3/log4cplus-1.1.3.tar.gz BuildArch: noarch From b526b76468d662ebc37b58c908d9558ec4daf2a6 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 3 Jan 2014 08:16:03 +0100 Subject: [PATCH 151/226] Log4CPlusCPack.cmake: Use PROJECT_SOURCE_DIR variable instead of CMAKE_SOURCE_DIR to allow using log4cplus as sub-project of another CMake project. Suggested by: Kyle --- Log4CPlusCPack.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Log4CPlusCPack.cmake b/Log4CPlusCPack.cmake index 45882b5cb..5986f62cf 100644 --- a/Log4CPlusCPack.cmake +++ b/Log4CPlusCPack.cmake @@ -1,6 +1,5 @@ set(CPACK_PACKAGE_NAME log4cplus) set(CPACK_PACKAGE_VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "log4cplus is a log4j-inspired logging library for C++") -set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) +set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) include(CPack) - From 0f104f57a0b0abad54102356a42325ae2db874ad Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 15 Mar 2014 22:07:18 +0100 Subject: [PATCH 152/226] Rename prepare_dist_from_bzr.sh to prepare_dist_from_git.sh --- scripts/{prepare_dist_from_bzr.sh => prepare_dist_from_git.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{prepare_dist_from_bzr.sh => prepare_dist_from_git.sh} (100%) diff --git a/scripts/prepare_dist_from_bzr.sh b/scripts/prepare_dist_from_git.sh similarity index 100% rename from scripts/prepare_dist_from_bzr.sh rename to scripts/prepare_dist_from_git.sh From 94326e4d6d4b0ac4c2535cdf4ee1d9102e176db5 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 15 Mar 2014 22:50:30 +0100 Subject: [PATCH 153/226] scripts/prepare_dist_from_git.sh: Change to use Git. --- scripts/prepare_dist_from_git.sh | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/prepare_dist_from_git.sh b/scripts/prepare_dist_from_git.sh index efaf8b8a1..262d61151 100755 --- a/scripts/prepare_dist_from_git.sh +++ b/scripts/prepare_dist_from_git.sh @@ -6,7 +6,7 @@ THIS_SCRIPT=`basename "$0"` function usage { - echo "$THIS_SCRIPT []" + echo "$THIS_SCRIPT [] []" } function gpg_sign @@ -32,24 +32,26 @@ function find_archiver command_exists "$1" && echo "$1" || echo ':' } -BZR_URL="$1" -if [[ -z "$BZR_URL" ]] ; then +GIT_URL="$1" +if [[ -z "$GIT_URL" ]] ; then usage exit 1 fi -if [[ -z "$2" ]] ; then - BZR_URL=${BZR_URL%/} - BZR_BASE_URL=${BZR_URL%/*} - BZR_BRANCH_NAME=${BZR_URL#$BZR_BASE_URL} - BZR_BRANCH_NAME=${BZR_BRANCH_NAME#/} - SRC_DIR=$BZR_BRANCH_NAME +GIT_BRANCH="$2" +if [[ -z "$GIT_BRANCH" ]] ; then + usage + exit 1 +fi + +if [[ -z "$3" ]] ; then + SRC_DIR=$GIT_BRANCH else - SRC_DIR="$2" + SRC_DIR="$3" fi -if [[ ! -z "$3" ]] ; then - GPG_KEY="$3" +if [[ ! -z "$4" ]] ; then + GPG_KEY="$4" else GPG_KEY= fi @@ -71,11 +73,12 @@ BZIP2=${BZIP2:-$(find_archiver bzip2)} GZIP=${GZIP:-$(find_archiver gzip)} SEVENZA=${SEVENZA:-$(find_archiver 7za)} LRZIP=${LRZIP:-$(find_archiver lrzip)} -BZR=${BZR:-bzr} +GIT=${GIT:-git} GPG=${GPG:-gpg} -$BZR export --per-file-timestamps -v "$SRC_DIR" "$BZR_URL" -$BZR version-info "$BZR_URL" >"$SRC_DIR/REVISION" +$GIT clone -v --depth=1 "$GIT_URL" "$SRC_DIR" +(cd "$SRC_DIR" && $GIT rev-parse >REVISION) +rm -rf "$SRC_DIR/.git" pushd "$SRC_DIR" $SHELL ./scripts/fix-timestamps.sh From 6cf03c29fe9926a2d337c4e1955d3118e7bbf303 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 24 Feb 2014 21:03:30 +0100 Subject: [PATCH 154/226] snprintf.cxx (snprintf_buf::print_va_list): Exit on EILSEQ to fix infinite loop. --- src/snprintf.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/snprintf.cxx b/src/snprintf.cxx index 5c2c477d1..3c9e13426 100644 --- a/src/snprintf.cxx +++ b/src/snprintf.cxx @@ -227,6 +227,17 @@ snprintf_buf::print_va_list (tchar const * & str, tchar const * fmt, printed = vsntprintf (&buf[0], buf_size - 1, fmt, args); if (printed == -1) { +#if defined (EILSEQ) + if (errno == EILSEQ) + { + LogLog::getLogLog ()->error ( + LOG4CPLUS_TEXT ("Character conversion error when printing")); + // Return zero to terminate the outer loop in + // snprintf_buf::print(). + return 0; + } +#endif + buf_size *= 2; buf.resize (buf_size); } From e40ac23f5bbc8499148651e3cf9b0c470fde25cf Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 16 Mar 2014 18:50:12 +0100 Subject: [PATCH 155/226] scripts/prepare_dist_from_git.sh: Check out requested branch and not HEAD. --- scripts/prepare_dist_from_git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare_dist_from_git.sh b/scripts/prepare_dist_from_git.sh index 262d61151..206c8de78 100755 --- a/scripts/prepare_dist_from_git.sh +++ b/scripts/prepare_dist_from_git.sh @@ -76,7 +76,7 @@ LRZIP=${LRZIP:-$(find_archiver lrzip)} GIT=${GIT:-git} GPG=${GPG:-gpg} -$GIT clone -v --depth=1 "$GIT_URL" "$SRC_DIR" +$GIT clone -v --depth=1 "$GIT_URL" -b "$GIT_BRANCH" "$SRC_DIR" (cd "$SRC_DIR" && $GIT rev-parse >REVISION) rm -rf "$SRC_DIR/.git" From 3a66bd997c484473df14649628b0b4c22615e735 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 16 Mar 2014 20:02:33 +0100 Subject: [PATCH 156/226] .travis.yml: Add. --- .travis.yml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..ed037bea7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,61 @@ +language: cpp +compiler: + - gcc +env: + - PARAM_THREADS="--enable-threads --with-working-c-locale" + CXXFLAGS="" + - PARAM_THREADS="--enable-threads --with-working-locale" + CXXFLAGS="" + - PARAM_THREADS="--enable-threads --with-working-c-locale" + CXXFLAGS="-DUNICODE" + - PARAM_THREADS="--enable-threads --with-working-locale" + CXXFLAGS="-DUNICODE" + - PARAM_THREADS="--disable-threads --with-working-locale" + CXXFLAGS="" + - PARAM_THREADS="--disable-threads --with-working-locale" + CXXFLAGS="-DUNICODE" + - PARAM_THREADS="--enable-threads --with-iconv" + CXXFLAGS="" + - PARAM_THREADS="--enable-threads --with-iconv" + CXXFLAGS="-DUNICODE" + - PARAM_THREADS="--disable-threads --with-iconv" + CXXFLAGS="" + - PARAM_THREADS="--disable-threads --with-iconv" + CXXFLAGS="-DUNICODE" +before_install: + - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add - + - sudo add-apt-repository --yes + 'deb http://ppa.launchpad.net/canonical-x/x-staging/ubuntu precise main' + - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test + - sudo apt-get update -qq + - sudo apt-get install -q + gcc-4.8 + g++-4.8 + libstdc++-4.8-dev + llvm-3.4 + clang-3.4 + swig + python + - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 + --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 + - sudo update-alternatives --config gcc +before_script: + - sh ./scripts/fix-timestamps.sh + - mkdir objdir + - cd objdir +script: ../configure $PARAM_THREADS + CXXFLAGS="$CXXFLAGS" + SWIG_FLAGS="$SWIG_FLAGS" + && make +after_failure: + - cat config.log + - cat tests/testsuite.log +branches: + only: + - 1.1.x +notifications: + recipients: + - vhaisman@gmail.com + email: + on_success: always + on_failure: always From a08ac9706609e84918eeeb93fda7052832b3ae46 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 19 Mar 2014 21:16:03 +0100 Subject: [PATCH 157/226] ChangeLog: Update with 1.1.3-RC2 changes. --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 30448d86d..f7ed3d895 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +log4cplus 1.1.3-RC2 + +- Fixed bug #295 - infinite loop when underlying *printf() function returned + EILSEQ. + +- Use PROJECT_SOURCE_DIR variable instead of CMAKE_SOURCE_DIR to allow using + log4cplus as sub-project of another CMake project. + + log4cplus 1.1.3-RC1 - Added --enable-symbols-visibility-options to configure script to allow From 934b5ceb95f5188956a2fef7cf0814eeea5df9dd Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 2 Apr 2014 19:11:05 +0200 Subject: [PATCH 158/226] thread/syncprims-pub-impl.h: Fix bug #298. -- int to pointer cast error on Xcode 5.1 --- include/log4cplus/thread/syncprims-pub-impl.h | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/include/log4cplus/thread/syncprims-pub-impl.h b/include/log4cplus/thread/syncprims-pub-impl.h index dd53bce0b..15e045cd9 100644 --- a/include/log4cplus/thread/syncprims-pub-impl.h +++ b/include/log4cplus/thread/syncprims-pub-impl.h @@ -1,16 +1,16 @@ // -*- C++ -*- // Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. -// +// // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -38,9 +38,11 @@ #if defined (LOG4CPLUS_SINGLE_THREADED) # define LOG4CPLUS_THREADED(x) +# define LOG4CPLUS_THREADED2(x, y) (y) #else # include # define LOG4CPLUS_THREADED(x) (x) +# define LOG4CPLUS_THREADED2(x, y) (x) #endif @@ -61,8 +63,9 @@ MutexImplBase::~MutexImplBase () // LOG4CPLUS_INLINE_EXPORT -Mutex::Mutex (Mutex::Type t) - : mtx (LOG4CPLUS_THREADED (new impl::Mutex (t)) + 0) +Mutex::Mutex (Mutex::Type LOG4CPLUS_THREADED (t)) + : mtx (LOG4CPLUS_THREADED2 (new impl::Mutex (t), + static_cast(0))) { } @@ -105,7 +108,8 @@ SemaphoreImplBase::~SemaphoreImplBase () LOG4CPLUS_INLINE_EXPORT Semaphore::Semaphore (unsigned LOG4CPLUS_THREADED (max), unsigned LOG4CPLUS_THREADED (initial)) - : sem (LOG4CPLUS_THREADED (new impl::Semaphore (max, initial)) + 0) + : sem (LOG4CPLUS_THREADED2 (new impl::Semaphore (max, initial), + static_cast(0))) { } @@ -147,7 +151,8 @@ FairMutexImplBase::~FairMutexImplBase () LOG4CPLUS_INLINE_EXPORT FairMutex::FairMutex () - : mtx (LOG4CPLUS_THREADED (new impl::FairMutex) + 0) + : mtx (LOG4CPLUS_THREADED2 (new impl::FairMutex, + static_cast(0))) { } @@ -189,7 +194,8 @@ ManualResetEventImplBase::~ManualResetEventImplBase () LOG4CPLUS_INLINE_EXPORT ManualResetEvent::ManualResetEvent (bool LOG4CPLUS_THREADED (sig)) - : ev (LOG4CPLUS_THREADED (new impl::ManualResetEvent (sig)) + 0) + : ev (LOG4CPLUS_THREADED2 (new impl::ManualResetEvent (sig), + static_cast(0))) { } @@ -251,7 +257,8 @@ SharedMutexImplBase::~SharedMutexImplBase () LOG4CPLUS_INLINE_EXPORT SharedMutex::SharedMutex () - : sm (LOG4CPLUS_THREADED (new impl::SharedMutex) + 0) + : sm (LOG4CPLUS_THREADED2 (new impl::SharedMutex, + static_cast(0))) { } @@ -292,7 +299,7 @@ SharedMutex::wrunlock () const } -} } // namespace log4cplus { namespace thread { +} } // namespace log4cplus { namespace thread { #endif // LOG4CPLUS_ENABLE_SYNCPRIMS_PUB_IMPL From c379ef631f982a3171ff5d14fedd8cd4723b9566 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 4 May 2014 18:16:03 +0200 Subject: [PATCH 159/226] README: Document a work-around for Android's emutls issue. --- README | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README b/README index 71c60ed65..8fc5b0b45 100644 --- a/README +++ b/README @@ -198,6 +198,21 @@ enables the method (2) by checking `_WIN32_WINNT >= 0x0600` condition, when compiling log4cplus targeted to Windows Vista or later. +Android, TLS and CMake +---------------------- + +[log4cplus] uses thread--local storage (TLS, see "Windows and TLS" for +details). On the Android platform, when [log4cplus] is being compiled using +the `android/android.toolchain.cmake`, you might get errors featuring the +`__emutls` symbol: + + + global-init.cxx:268:46: error: log4cplus::internal::__emutls_t._ZN9log4cplus8internal3ptdE causes a section type conflict with log4cplus::internal::ptd + +To work around this issue, invoke CMake with +`-DANDROID_FUNCTION_LEVEL_LINKING:BOOL=OFF` option. + + Threads and signals ------------------- From 8fbddc694f383f0392ef12eb2ffe3740a2a0cd6b Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 7 May 2014 16:30:56 +0200 Subject: [PATCH 160/226] src/CMakeLists.txt: Do not set SOVERSION and VERSION properties for Android builds. --- src/CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8f3070cb2..72a99fc3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,10 +96,16 @@ if (LOG4CPLUS_WITH_ICONV AND LIBICONV) endif () target_link_libraries (${log4cplus} ${log4cplus_LIBS}) -set_target_properties (${log4cplus} PROPERTIES - VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}" - SOVERSION "${log4cplus_soversion}" - COMPILE_FLAGS "-DINSIDE_LOG4CPLUS") +if (ANDROID) + # Android does not seem to have SO version support. + set_target_properties (${log4cplus} PROPERTIES + COMPILE_FLAGS "-DINSIDE_LOG4CPLUS") +else () + set_target_properties (${log4cplus} PROPERTIES + VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}" + SOVERSION "${log4cplus_soversion}" + COMPILE_FLAGS "-DINSIDE_LOG4CPLUS") +endif () if (WIN32) set_target_properties (${log4cplus} PROPERTIES From df656345904b37ac497ae6d9f029956318af1844 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Wed, 7 May 2014 21:39:54 +0200 Subject: [PATCH 161/226] scripts/prepare_dist_from_git.sh: Generate correct REVISION file contents. --- scripts/prepare_dist_from_git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare_dist_from_git.sh b/scripts/prepare_dist_from_git.sh index 206c8de78..1e3c6ebd7 100755 --- a/scripts/prepare_dist_from_git.sh +++ b/scripts/prepare_dist_from_git.sh @@ -77,7 +77,7 @@ GIT=${GIT:-git} GPG=${GPG:-gpg} $GIT clone -v --depth=1 "$GIT_URL" -b "$GIT_BRANCH" "$SRC_DIR" -(cd "$SRC_DIR" && $GIT rev-parse >REVISION) +(cd "$SRC_DIR" && $GIT rev-parse @ >REVISION) rm -rf "$SRC_DIR/.git" pushd "$SRC_DIR" From 68794ad6a570563a1d58d52dc14c308e590d5411 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 12 Jun 2014 10:49:45 +0200 Subject: [PATCH 162/226] ChangeLog: Update for 1.1.3-RC3. --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index f7ed3d895..2181d23ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +log4cplus 1.1.3-RC3 + +- Fixed bug #298. -- int to pointer cast error on Xcode 5.1. + +- Documented a work-around for Android's emutls issue. + +- Stopped using SOVERSION and VERSION properties in Android CMake builds. + + log4cplus 1.1.3-RC2 - Fixed bug #295 - infinite loop when underlying *printf() function returned From f3ad691caa7941ea7a27464106b9858ec66b5f2f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 17 Aug 2014 20:49:48 +0200 Subject: [PATCH 163/226] Initialize log4cplus early if possible. Use GCC constructor function attribute when it is present. --- Makefile.in | 4 +- acinclude.m4 | 1 + configure | 55 ++++++ configure.ac | 4 + include/Makefile.in | 4 +- include/log4cplus/config.h.in | 6 + include/log4cplus/config.hxx | 7 + include/log4cplus/config/defines.hxx.in | 3 + loggingserver/Makefile.in | 4 +- m4/ax_gcc_func_attribute.m4 | 219 ++++++++++++++++++++++++ qt4debugappender/Makefile.in | 4 +- src/Makefile.in | 4 +- src/global-init.cxx | 22 ++- tests/Makefile.in | 4 +- tests/appender_test/Makefile.in | 4 +- tests/configandwatch_test/Makefile.in | 4 +- tests/customloglevel_test/Makefile.in | 4 +- tests/fileappender_test/Makefile.in | 4 +- tests/filter_test/Makefile.in | 4 +- tests/hierarchy_test/Makefile.in | 4 +- tests/loglog_test/Makefile.in | 4 +- tests/ndc_test/Makefile.in | 4 +- tests/ostream_test/Makefile.in | 4 +- tests/patternlayout_test/Makefile.in | 4 +- tests/performance_test/Makefile.in | 4 +- tests/priority_test/Makefile.in | 4 +- tests/propertyconfig_test/Makefile.in | 4 +- tests/socket_test/Makefile.in | 4 +- tests/thread_test/Makefile.in | 4 +- tests/timeformat_test/Makefile.in | 4 +- 30 files changed, 376 insertions(+), 29 deletions(-) create mode 100644 m4/ax_gcc_func_attribute.m4 diff --git a/Makefile.in b/Makefile.in index 4805f8000..d4c9f12f1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -80,7 +80,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ diff --git a/acinclude.m4 b/acinclude.m4 index 6a3ca19ab..d75e786b9 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -16,3 +16,4 @@ m4_include([m4/ax_gethostbyname_r.m4]) m4_include([m4/ax_getaddrinfo.m4]) m4_include([m4/ax_log4cplus_wrappers.m4]) m4_include([m4/pkg.m4]) +m4_include([m4/ax_gcc_func_attribute.m4]) diff --git a/configure b/configure index a8b8d7944..9137a4990 100755 --- a/configure +++ b/configure @@ -7755,6 +7755,61 @@ fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((constructor))" >&5 +$as_echo_n "checking for __attribute__((constructor))... " >&6; } +if ${ax_cv_have_func_attribute_constructor+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + int foo( void ) __attribute__((constructor)); + +int +main () +{ + + ; + return 0; +} + +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + if test -s conftest.err; then : + ax_cv_have_func_attribute_constructor=no +else + ax_cv_have_func_attribute_constructor=yes +fi +else + ax_cv_have_func_attribute_constructor=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_func_attribute_constructor" >&5 +$as_echo "$ax_cv_have_func_attribute_constructor" >&6; } + + if test yes = $ax_cv_have_func_attribute_constructor; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR 1 +_ACEOF + +fi + + + + +if test "x$ax_cv_have_func_attribute_constructor" = "xyes"; then : + $as_echo "#define LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR 1" >>confdefs.h + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } if ${ac_cv_search_strerror+:} false; then : diff --git a/configure.ac b/configure.ac index 84458f275..236d93c0e 100644 --- a/configure.ac +++ b/configure.ac @@ -331,6 +331,10 @@ AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_SYMBOL]) AS_IF([test "x$ac_cv_have___func___symbol" = "xyes"], [AC_DEFINE([LOG4CPLUS_HAVE_FUNC_SYMBOL])]) +AX_GCC_FUNC_ATTRIBUTE([constructor]) +AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR]) +AS_IF([test "x$ax_cv_have_func_attribute_constructor" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR])]) dnl Checks for libraries. diff --git a/include/Makefile.in b/include/Makefile.in index 42b7566c3..c0b11174c 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -74,7 +74,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index c71b850bd..ca6c850fc 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -33,6 +33,9 @@ /* Define to 1 if you have the `ftime' function. */ #undef HAVE_FTIME +/* Define to 1 if the system has the `constructor' function attribute */ +#undef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR + /* */ #undef HAVE_GETADDRINFO @@ -250,6 +253,9 @@ /* */ #undef LOG4CPLUS_HAVE_FUNCTION_MACRO +/* */ +#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR + /* */ #undef LOG4CPLUS_HAVE_FUNC_SYMBOL diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index 9e3c69362..d0a1dec99 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -143,6 +143,13 @@ # pragma once #endif +#if defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR) +# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \ + __attribute__ ((__constructor__ ((prio)))) +#else +# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) /* empty */ +#endif + #include #if defined(__cplusplus) diff --git a/include/log4cplus/config/defines.hxx.in b/include/log4cplus/config/defines.hxx.in index 7eb9bbbb7..85977502f 100644 --- a/include/log4cplus/config/defines.hxx.in +++ b/include/log4cplus/config/defines.hxx.in @@ -256,4 +256,7 @@ /* Define to 1 if you have the `iconv_open' function. */ #undef LOG4CPLUS_HAVE_ICONV_OPEN +/* Define to 1 if the system has the `constructor' function attribute */ +#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR + #endif // LOG4CPLUS_CONFIG_DEFINES_HXX diff --git a/loggingserver/Makefile.in b/loggingserver/Makefile.in index 3698e2e7d..2e2e312bb 100644 --- a/loggingserver/Makefile.in +++ b/loggingserver/Makefile.in @@ -75,7 +75,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/m4/ax_gcc_func_attribute.m4 b/m4/ax_gcc_func_attribute.m4 new file mode 100644 index 000000000..de11303e7 --- /dev/null +++ b/m4/ax_gcc_func_attribute.m4 @@ -0,0 +1,219 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE) +# +# DESCRIPTION +# +# This macro checks if the compiler supports one of GCC's function +# attributes; many other compilers also provide function attributes with +# the same syntax. Compiler warnings are used to detect supported +# attributes as unsupported ones are ignored by default so quieting +# warnings when using this macro will yield false positives. +# +# The ATTRIBUTE parameter holds the name of the attribute to be checked. +# +# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_. +# +# The macro caches its result in the ax_cv_have_func_attribute_ +# variable. +# +# The macro currently supports the following function attributes: +# +# alias +# aligned +# alloc_size +# always_inline +# artificial +# cold +# const +# constructor +# deprecated +# destructor +# dllexport +# dllimport +# error +# externally_visible +# flatten +# format +# format_arg +# gnu_inline +# hot +# ifunc +# leaf +# malloc +# noclone +# noinline +# nonnull +# noreturn +# nothrow +# optimize +# pure +# unused +# used +# visibility +# warning +# warn_unused_result +# weak +# weakref +# +# Unsuppored function attributes will be tested with a prototype returning +# an int and not accepting any arguments and the result of the check might +# be wrong or meaningless so use with care. +# +# LICENSE +# +# Copyright (c) 2013 Gabriele Svelto +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ + AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1]) + + AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + m4_case([$1], + [alias], [ + int foo( void ) { return 0; } + int bar( void ) __attribute__(($1("foo"))); + ], + [aligned], [ + int foo( void ) __attribute__(($1(32))); + ], + [alloc_size], [ + void *foo(int a) __attribute__(($1(1))); + ], + [always_inline], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [artificial], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [cold], [ + int foo( void ) __attribute__(($1)); + ], + [const], [ + int foo( void ) __attribute__(($1)); + ], + [constructor], [ + int foo( void ) __attribute__(($1)); + ], + [deprecated], [ + int foo( void ) __attribute__(($1(""))); + ], + [destructor], [ + int foo( void ) __attribute__(($1)); + ], + [dllexport], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [dllimport], [ + int foo( void ) __attribute__(($1)); + ], + [error], [ + int foo( void ) __attribute__(($1(""))); + ], + [externally_visible], [ + int foo( void ) __attribute__(($1)); + ], + [flatten], [ + int foo( void ) __attribute__(($1)); + ], + [format], [ + int foo(const char *p, ...) __attribute__(($1(printf, 1, 2))); + ], + [format_arg], [ + char *foo(const char *p) __attribute__(($1(1))); + ], + [gnu_inline], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [hot], [ + int foo( void ) __attribute__(($1)); + ], + [ifunc], [ + int my_foo( void ) { return 0; } + static int (*resolve_foo(void))(void) { return my_foo; } + int foo( void ) __attribute__(($1("resolve_foo"))); + ], + [leaf], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [malloc], [ + void *foo( void ) __attribute__(($1)); + ], + [noclone], [ + int foo( void ) __attribute__(($1)); + ], + [noinline], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [nonnull], [ + int foo(char *p) __attribute__(($1(1))); + ], + [noreturn], [ + void foo( void ) __attribute__(($1)); + ], + [nothrow], [ + int foo( void ) __attribute__(($1)); + ], + [optimize], [ + __attribute__(($1(3))) int foo( void ) { return 0; } + ], + [pure], [ + int foo( void ) __attribute__(($1)); + ], + [unused], [ + int foo( void ) __attribute__(($1)); + ], + [used], [ + int foo( void ) __attribute__(($1)); + ], + [visibility], [ + int foo_def( void ) __attribute__(($1("default"))); + int foo_hid( void ) __attribute__(($1("hidden"))); + int foo_int( void ) __attribute__(($1("internal"))); + int foo_pro( void ) __attribute__(($1("protected"))); + ], + [warning], [ + int foo( void ) __attribute__(($1(""))); + ], + [warn_unused_result], [ + int foo( void ) __attribute__(($1)); + ], + [weak], [ + int foo( void ) __attribute__(($1)); + ], + [weakref], [ + static int foo( void ) { return 0; } + static int bar( void ) __attribute__(($1("foo"))); + ], + [ + m4_warn([syntax], [Unsupported attribute $1, the test may fail]) + int foo( void ) __attribute__(($1)); + ] + )], []) + ], + dnl GCC doesn't exit with an error if an unknown attribute is + dnl provided but only outputs a warning, so accept the attribute + dnl only if no warning were issued. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([ac_var], [no])], + [AS_VAR_SET([ac_var], [yes])])], + [AS_VAR_SET([ac_var], [no])]) + ]) + + AS_IF([test yes = AS_VAR_GET([ac_var])], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1, + [Define to 1 if the system has the `$1' function attribute])], []) + + AS_VAR_POPDEF([ac_var]) +]) diff --git a/qt4debugappender/Makefile.in b/qt4debugappender/Makefile.in index 02cac9c48..1d8d1c9ef 100644 --- a/qt4debugappender/Makefile.in +++ b/qt4debugappender/Makefile.in @@ -74,7 +74,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/src/Makefile.in b/src/Makefile.in index f4991ce88..1bc3288cd 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -74,7 +74,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/src/global-init.cxx b/src/global-init.cxx index 73996634a..a16c63d7b 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -50,7 +50,7 @@ LOG4CPLUS_EXPORT tostream & tcerr = std::cerr; #endif // UNICODE -namespace +namespace { @@ -72,7 +72,7 @@ struct DefaultContext enum DCState -{ +{ DC_UNINITIALIZED, DC_INITIALIZED, DC_DESTROYED @@ -82,7 +82,7 @@ enum DCState static DCState default_context_state; static DefaultContext * default_context; - + struct destroy_default_context { ~destroy_default_context () @@ -109,7 +109,7 @@ alloc_dc () throw std::logic_error ("alloc_dc() called in DC_INITIALIZED state."); default_context = new DefaultContext; - + if (default_context_state == DC_DESTROYED) default_context->loglog.error ( LOG4CPLUS_TEXT ("Re-initializing default context after it has") @@ -162,7 +162,7 @@ getTTCCLayoutTimeBase () LogLevelManager & -getLogLevelManager () +getLogLevelManager () { return get_dc ()->log_level_manager; } @@ -175,7 +175,7 @@ getDefaultHierarchy () } -NDC & +NDC & getNDC () { return get_dc ()->ndc; @@ -419,7 +419,7 @@ thread_callback (LPVOID /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpReserved*/) { // Perform actions based on the reason for calling. switch (fdwReason) - { + { case DLL_PROCESS_ATTACH: { // We cannot initialize log4cplus directly here. This is because @@ -540,6 +540,14 @@ struct _static_log4cplus_initializer #else namespace { +static void +_log4cplus_initializer_func () LOG4CPLUS_CONSTRUCTOR_FUNC(65535 / 2); +static void +_log4cplus_initializer_func () +{ + log4cplus::initializeLog4cplus(); +} + struct _static_log4cplus_initializer { _static_log4cplus_initializer () diff --git a/tests/Makefile.in b/tests/Makefile.in index 2599ee20e..ca22b29b3 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -73,7 +73,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/appender_test/Makefile.in b/tests/appender_test/Makefile.in index 7f2a4539b..fd8c7b37b 100644 --- a/tests/appender_test/Makefile.in +++ b/tests/appender_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/configandwatch_test/Makefile.in b/tests/configandwatch_test/Makefile.in index 5075f3bae..c25b9ddcf 100644 --- a/tests/configandwatch_test/Makefile.in +++ b/tests/configandwatch_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/customloglevel_test/Makefile.in b/tests/customloglevel_test/Makefile.in index 019468a4d..0b72bc493 100644 --- a/tests/customloglevel_test/Makefile.in +++ b/tests/customloglevel_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/fileappender_test/Makefile.in b/tests/fileappender_test/Makefile.in index 5666e2572..9a33154fa 100644 --- a/tests/fileappender_test/Makefile.in +++ b/tests/fileappender_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/filter_test/Makefile.in b/tests/filter_test/Makefile.in index d6c99524c..b1f268c8b 100644 --- a/tests/filter_test/Makefile.in +++ b/tests/filter_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/hierarchy_test/Makefile.in b/tests/hierarchy_test/Makefile.in index f4e74ba8c..38f666dde 100644 --- a/tests/hierarchy_test/Makefile.in +++ b/tests/hierarchy_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/loglog_test/Makefile.in b/tests/loglog_test/Makefile.in index 66d79202b..906a89656 100644 --- a/tests/loglog_test/Makefile.in +++ b/tests/loglog_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/ndc_test/Makefile.in b/tests/ndc_test/Makefile.in index 1262fee8c..b74b46a67 100644 --- a/tests/ndc_test/Makefile.in +++ b/tests/ndc_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/ostream_test/Makefile.in b/tests/ostream_test/Makefile.in index 3e6f257dc..dddfe53ca 100644 --- a/tests/ostream_test/Makefile.in +++ b/tests/ostream_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/patternlayout_test/Makefile.in b/tests/patternlayout_test/Makefile.in index ee38332d2..2357f6c46 100644 --- a/tests/patternlayout_test/Makefile.in +++ b/tests/patternlayout_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/performance_test/Makefile.in b/tests/performance_test/Makefile.in index e0be44f46..1a68144a5 100644 --- a/tests/performance_test/Makefile.in +++ b/tests/performance_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/priority_test/Makefile.in b/tests/priority_test/Makefile.in index 2252861c8..d67c2b74e 100644 --- a/tests/priority_test/Makefile.in +++ b/tests/priority_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/propertyconfig_test/Makefile.in b/tests/propertyconfig_test/Makefile.in index d0b55aed0..2d8114745 100644 --- a/tests/propertyconfig_test/Makefile.in +++ b/tests/propertyconfig_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/socket_test/Makefile.in b/tests/socket_test/Makefile.in index 9658b3775..7ad2f948d 100644 --- a/tests/socket_test/Makefile.in +++ b/tests/socket_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/thread_test/Makefile.in b/tests/thread_test/Makefile.in index 6e0c86b0c..2569119b0 100644 --- a/tests/thread_test/Makefile.in +++ b/tests/thread_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/timeformat_test/Makefile.in b/tests/timeformat_test/Makefile.in index 9b5f97e71..d90c84c54 100644 --- a/tests/timeformat_test/Makefile.in +++ b/tests/timeformat_test/Makefile.in @@ -76,7 +76,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_gethostbyname_r.m4 \ $(top_srcdir)/m4/ax_getaddrinfo.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ - $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs From 3ed66eaba528921c9a4bbe862116c850f92e58d6 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 17 Aug 2014 22:20:24 +0200 Subject: [PATCH 164/226] Check for init_priority GCC variable attribute and use it. --- Makefile.in | 1 + acinclude.m4 | 1 + configure | 59 ++++++++++ configure.ac | 5 + include/Makefile.in | 1 + include/log4cplus/config.h.in | 6 + include/log4cplus/config.hxx | 9 ++ include/log4cplus/config/defines.hxx.in | 3 + loggingserver/Makefile.in | 1 + m4/ax_gcc_var_attribute.m4 | 141 ++++++++++++++++++++++++ qt4debugappender/Makefile.in | 1 + src/Makefile.in | 1 + src/global-init.cxx | 9 +- tests/Makefile.in | 1 + tests/appender_test/Makefile.in | 1 + tests/configandwatch_test/Makefile.in | 1 + tests/customloglevel_test/Makefile.in | 1 + tests/fileappender_test/Makefile.in | 1 + tests/filter_test/Makefile.in | 1 + tests/hierarchy_test/Makefile.in | 1 + tests/loglog_test/Makefile.in | 1 + tests/ndc_test/Makefile.in | 1 + tests/ostream_test/Makefile.in | 1 + tests/patternlayout_test/Makefile.in | 1 + tests/performance_test/Makefile.in | 1 + tests/priority_test/Makefile.in | 1 + tests/propertyconfig_test/Makefile.in | 1 + tests/socket_test/Makefile.in | 1 + tests/thread_test/Makefile.in | 1 + tests/timeformat_test/Makefile.in | 1 + 30 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 m4/ax_gcc_var_attribute.m4 diff --git a/Makefile.in b/Makefile.in index d4c9f12f1..c74f2b027 100644 --- a/Makefile.in +++ b/Makefile.in @@ -82,6 +82,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/acinclude.m4 b/acinclude.m4 index d75e786b9..73a09d7b4 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -17,3 +17,4 @@ m4_include([m4/ax_getaddrinfo.m4]) m4_include([m4/ax_log4cplus_wrappers.m4]) m4_include([m4/pkg.m4]) m4_include([m4/ax_gcc_func_attribute.m4]) +m4_include([m4/ax_gcc_var_attribute.m4]) diff --git a/configure b/configure index 9137a4990..b032b0d10 100755 --- a/configure +++ b/configure @@ -7810,6 +7810,65 @@ if test "x$ax_cv_have_func_attribute_constructor" = "xyes"; then : fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((init_priority))" >&5 +$as_echo_n "checking for __attribute__((init_priority))... " >&6; } +if ${ax_cv_have_var_attribute_init_priority+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + struct bar { bar() {} ~bar() {} }; + bar b __attribute__((init_priority(65535/2))); + +int +main () +{ + + + + ; + return 0; +} + +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + if test -s conftest.err; then : + ax_cv_have_var_attribute_init_priority=no +else + ax_cv_have_var_attribute_init_priority=yes +fi +else + ax_cv_have_var_attribute_init_priority=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_var_attribute_init_priority" >&5 +$as_echo "$ax_cv_have_var_attribute_init_priority" >&6; } + + if test yes = $ax_cv_have_var_attribute_init_priority; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_VAR_ATTRIBUTE_INIT_PRIORITY 1 +_ACEOF + +fi + + + + +if test "x$ax_cv_have_var_attribute_init_priority" = "xyes"; then : + $as_echo "#define LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY 1" >>confdefs.h + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } if ${ac_cv_search_strerror+:} false; then : diff --git a/configure.ac b/configure.ac index 236d93c0e..02c3b98b3 100644 --- a/configure.ac +++ b/configure.ac @@ -336,6 +336,11 @@ AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR]) AS_IF([test "x$ax_cv_have_func_attribute_constructor" = "xyes"], [AC_DEFINE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR])]) +AX_GCC_VAR_ATTRIBUTE([init_priority]) +AH_TEMPLATE([LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY]) +AS_IF([test "x$ax_cv_have_var_attribute_init_priority" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY])]) + dnl Checks for libraries. AC_SEARCH_LIBS([strerror], [cposix]) diff --git a/include/Makefile.in b/include/Makefile.in index c0b11174c..a78f1554c 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -76,6 +76,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index ca6c850fc..1f2ef9511 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -157,6 +157,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if the system has the `init_priority' variable attribute */ +#undef HAVE_VAR_ATTRIBUTE_INIT_PRIORITY + /* Define to 1 if you have the `vfprintf_s' function. */ #undef HAVE_VFPRINTF_S @@ -394,6 +397,9 @@ /* */ #undef LOG4CPLUS_HAVE_UNISTD_H +/* */ +#undef LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY + /* */ #undef LOG4CPLUS_HAVE_VFPRINTF_S diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index d0a1dec99..608e76239 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -150,6 +150,15 @@ # define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) /* empty */ #endif +#if defined (LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY) +# define LOG4CPLUS_INIT_PRIORITY(prio) \ + __attribute__ ((__init_priority__ ((prio)))) +#else +# define LOG4CPLUS_INIT_PRIORITY(prio) /* empty */ +#endif + +#define LOG4CPLUS_INIT_PRIORITY_BASE (65535 / 2) + #include #if defined(__cplusplus) diff --git a/include/log4cplus/config/defines.hxx.in b/include/log4cplus/config/defines.hxx.in index 85977502f..2f4158e62 100644 --- a/include/log4cplus/config/defines.hxx.in +++ b/include/log4cplus/config/defines.hxx.in @@ -259,4 +259,7 @@ /* Define to 1 if the system has the `constructor' function attribute */ #undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR +/* Define to 1 if the system has the `init_priority' variable attribute */ +#undef LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY + #endif // LOG4CPLUS_CONFIG_DEFINES_HXX diff --git a/loggingserver/Makefile.in b/loggingserver/Makefile.in index 2e2e312bb..15bc33f22 100644 --- a/loggingserver/Makefile.in +++ b/loggingserver/Makefile.in @@ -77,6 +77,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/m4/ax_gcc_var_attribute.m4 b/m4/ax_gcc_var_attribute.m4 new file mode 100644 index 000000000..4f60f6da1 --- /dev/null +++ b/m4/ax_gcc_var_attribute.m4 @@ -0,0 +1,141 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_gcc_var_attribute.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_VAR_ATTRIBUTE(ATTRIBUTE) +# +# DESCRIPTION +# +# This macro checks if the compiler supports one of GCC's variable +# attributes; many other compilers also provide variable attributes with +# the same syntax. Compiler warnings are used to detect supported +# attributes as unsupported ones are ignored by default so quieting +# warnings when using this macro will yield false positives. +# +# The ATTRIBUTE parameter holds the name of the attribute to be checked. +# +# If ATTRIBUTE is supported define HAVE_VAR_ATTRIBUTE_. +# +# The macro caches its result in the ax_cv_have_var_attribute_ +# variable. +# +# The macro currently supports the following variable attributes: +# +# aligned +# cleanup +# common +# nocommon +# deprecated +# mode +# packed +# tls_model +# unused +# used +# vector_size +# weak +# dllimport +# dllexport +# init_priority +# +# Unsuppored variable attributes will be tested against a global integer +# variable and without any arguments given to the attribute itself; the +# result of this check might be wrong or meaningless so use with care. +# +# LICENSE +# +# Copyright (c) 2013 Gabriele Svelto +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AC_DEFUN([AX_GCC_VAR_ATTRIBUTE], [ + AS_VAR_PUSHDEF([ac_var], [ax_cv_have_var_attribute_$1]) + + AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + m4_case([$1], + [aligned], [ + int foo __attribute__(($1(32))); + ], + [cleanup], [ + int bar(int *t) { return *t; }; + ], + [common], [ + int foo __attribute__(($1)); + ], + [nocommon], [ + int foo __attribute__(($1)); + ], + [deprecated], [ + int foo __attribute__(($1)) = 0; + ], + [mode], [ + long foo __attribute__(($1(word))); + ], + [packed], [ + struct bar { + int baz __attribute__(($1)); + }; + ], + [tls_model], [ + __thread int bar1 __attribute__(($1("global-dynamic"))); + __thread int bar2 __attribute__(($1("local-dynamic"))); + __thread int bar3 __attribute__(($1("initial-exec"))); + __thread int bar4 __attribute__(($1("local-exec"))); + ], + [unused], [ + int foo __attribute__(($1)); + ], + [used], [ + int foo __attribute__(($1)); + ], + [vector_size], [ + int foo __attribute__(($1(16))); + ], + [weak], [ + int foo __attribute__(($1)); + ], + [dllimport], [ + int foo __attribute__(($1)); + ], + [dllexport], [ + int foo __attribute__(($1)); + ], + [init_priority], [ + struct bar { bar() {} ~bar() {} }; + bar b __attribute__(($1(65535/2))); + ], + [ + m4_warn([syntax], [Unsupported attribute $1, the test may fail]) + int foo __attribute__(($1)); + ] + )], [ + m4_case([$1], + [cleanup], [ + int foo __attribute__(($1(bar))) = 0; + foo = foo + 1; + ], + [] + )]) + ], + dnl GCC doesn't exit with an error if an unknown attribute is + dnl provided but only outputs a warning, so accept the attribute + dnl only if no warning were issued. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([ac_var], [no])], + [AS_VAR_SET([ac_var], [yes])])], + [AS_VAR_SET([ac_var], [no])]) + ]) + + AS_IF([test yes = AS_VAR_GET([ac_var])], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_VAR_ATTRIBUTE_$1), 1, + [Define to 1 if the system has the `$1' variable attribute])], []) + + AS_VAR_POPDEF([ac_var]) +]) diff --git a/qt4debugappender/Makefile.in b/qt4debugappender/Makefile.in index 1d8d1c9ef..e16da01be 100644 --- a/qt4debugappender/Makefile.in +++ b/qt4debugappender/Makefile.in @@ -76,6 +76,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/src/Makefile.in b/src/Makefile.in index 1bc3288cd..602785c76 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -76,6 +76,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/src/global-init.cxx b/src/global-init.cxx index a16c63d7b..7d1985f36 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -91,7 +91,8 @@ struct destroy_default_context default_context = 0; default_context_state = DC_DESTROYED; } -} static destroy_default_context_; +} static destroy_default_context_ +LOG4CPLUS_INIT_PRIORITY (LOG4CPLUS_INIT_PRIORITY_BASE + 1); static @@ -541,7 +542,8 @@ struct _static_log4cplus_initializer namespace { static void -_log4cplus_initializer_func () LOG4CPLUS_CONSTRUCTOR_FUNC(65535 / 2); +_log4cplus_initializer_func () + LOG4CPLUS_CONSTRUCTOR_FUNC (LOG4CPLUS_INIT_PRIORITY_BASE); static void _log4cplus_initializer_func () { @@ -563,7 +565,8 @@ struct _static_log4cplus_initializer log4cplus::thread::impl::tls_cleanup ( log4cplus::internal::tls_storage_key); } -} static initializer; +} static initializer +LOG4CPLUS_INIT_PRIORITY (LOG4CPLUS_INIT_PRIORITY_BASE); } // namespace diff --git a/tests/Makefile.in b/tests/Makefile.in index ca22b29b3..2893fb8cd 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -75,6 +75,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/appender_test/Makefile.in b/tests/appender_test/Makefile.in index fd8c7b37b..38fce9357 100644 --- a/tests/appender_test/Makefile.in +++ b/tests/appender_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/configandwatch_test/Makefile.in b/tests/configandwatch_test/Makefile.in index c25b9ddcf..a3ddef2d0 100644 --- a/tests/configandwatch_test/Makefile.in +++ b/tests/configandwatch_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/customloglevel_test/Makefile.in b/tests/customloglevel_test/Makefile.in index 0b72bc493..e36349ed2 100644 --- a/tests/customloglevel_test/Makefile.in +++ b/tests/customloglevel_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/fileappender_test/Makefile.in b/tests/fileappender_test/Makefile.in index 9a33154fa..1bcc14edf 100644 --- a/tests/fileappender_test/Makefile.in +++ b/tests/fileappender_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/filter_test/Makefile.in b/tests/filter_test/Makefile.in index b1f268c8b..2e96a4029 100644 --- a/tests/filter_test/Makefile.in +++ b/tests/filter_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/hierarchy_test/Makefile.in b/tests/hierarchy_test/Makefile.in index 38f666dde..9b3ff9295 100644 --- a/tests/hierarchy_test/Makefile.in +++ b/tests/hierarchy_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/loglog_test/Makefile.in b/tests/loglog_test/Makefile.in index 906a89656..2886a84e8 100644 --- a/tests/loglog_test/Makefile.in +++ b/tests/loglog_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/ndc_test/Makefile.in b/tests/ndc_test/Makefile.in index b74b46a67..aa115057f 100644 --- a/tests/ndc_test/Makefile.in +++ b/tests/ndc_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/ostream_test/Makefile.in b/tests/ostream_test/Makefile.in index dddfe53ca..8b771563a 100644 --- a/tests/ostream_test/Makefile.in +++ b/tests/ostream_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/patternlayout_test/Makefile.in b/tests/patternlayout_test/Makefile.in index 2357f6c46..47d1f0a79 100644 --- a/tests/patternlayout_test/Makefile.in +++ b/tests/patternlayout_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/performance_test/Makefile.in b/tests/performance_test/Makefile.in index 1a68144a5..a170c3de8 100644 --- a/tests/performance_test/Makefile.in +++ b/tests/performance_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/priority_test/Makefile.in b/tests/priority_test/Makefile.in index d67c2b74e..8bf8a03e5 100644 --- a/tests/priority_test/Makefile.in +++ b/tests/priority_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/propertyconfig_test/Makefile.in b/tests/propertyconfig_test/Makefile.in index 2d8114745..8be8afb62 100644 --- a/tests/propertyconfig_test/Makefile.in +++ b/tests/propertyconfig_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/socket_test/Makefile.in b/tests/socket_test/Makefile.in index 7ad2f948d..2c22a7c6b 100644 --- a/tests/socket_test/Makefile.in +++ b/tests/socket_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/thread_test/Makefile.in b/tests/thread_test/Makefile.in index 2569119b0..aba2a81b0 100644 --- a/tests/thread_test/Makefile.in +++ b/tests/thread_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) diff --git a/tests/timeformat_test/Makefile.in b/tests/timeformat_test/Makefile.in index d90c84c54..e3c248e6e 100644 --- a/tests/timeformat_test/Makefile.in +++ b/tests/timeformat_test/Makefile.in @@ -78,6 +78,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \ $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4/ax_gcc_var_attribute.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) From 439414a49a07d7119f0a58b252a853e8e6fc4dab Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 21 Aug 2014 21:57:59 +0200 Subject: [PATCH 165/226] Fix log level string constants initialization issue. (SF bug #303) Based on patch by: Ray Logel --- src/global-init.cxx | 4 +- src/loglevel.cxx | 144 ++++++++++++++++++++++++++------------------ 2 files changed, 90 insertions(+), 58 deletions(-) diff --git a/src/global-init.cxx b/src/global-init.cxx index 7d1985f36..99e1bf61a 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -300,7 +300,8 @@ alloc_ptd () } // namespace internal -void initializeFactoryRegistry(); +void initializeFactoryRegistry (); +void initializeLogLevelStrings (); //! Thread local storage clean up function for POSIX threads. @@ -372,6 +373,7 @@ initializeLog4cplus() dc->TTCCLayout_time_base = helpers::Time::gettimeofday (); Logger::getRoot(); initializeFactoryRegistry(); + initializeLogLevelStrings(); initialized = true; } diff --git a/src/loglevel.cxx b/src/loglevel.cxx index 6b2e0dcaf..5b17d8956 100644 --- a/src/loglevel.cxx +++ b/src/loglevel.cxx @@ -32,39 +32,35 @@ namespace log4cplus namespace { -static tstring const ALL_STRING (LOG4CPLUS_TEXT("ALL")); -static tstring const TRACE_STRING (LOG4CPLUS_TEXT("TRACE")); -static tstring const DEBUG_STRING (LOG4CPLUS_TEXT("DEBUG")); -static tstring const INFO_STRING (LOG4CPLUS_TEXT("INFO")); -static tstring const WARN_STRING (LOG4CPLUS_TEXT("WARN")); -static tstring const ERROR_STRING (LOG4CPLUS_TEXT("ERROR")); -static tstring const FATAL_STRING (LOG4CPLUS_TEXT("FATAL")); -static tstring const OFF_STRING (LOG4CPLUS_TEXT("OFF")); -static tstring const NOTSET_STRING (LOG4CPLUS_TEXT("NOTSET")); -static tstring const UNKNOWN_STRING (LOG4CPLUS_TEXT("UNKNOWN")); - - -struct log_levels_table_rec -{ - LogLevel const ll; - tstring const * const str; -}; - - -#define DEF_LLTAB_REC(x) { x ## _LOG_LEVEL, &(x ## _STRING) } +// The strings here are not simple tstring constants to allow using these +// strings and log4cplus itself in client code during static variables +// initialization. If they are simple tstring constants then, due to undefined +// order of initialization between translation units, they might be +// uninitialized before they are used by the client code. One possible solution +// to this is to use compiler specific attributes and/or pragmas to influence +// initialization order/priority. Another solution is using function local +// static variables, which are initialized on first use. We choose this +// implementation because it is more portable than compiler specific means. + +#define DEF_LL_STRING(_logLevel) \ +static tstring const & _logLevel ## _STRING () \ +{ \ + static tstring const str (LOG4CPLUS_TEXT (#_logLevel)); \ + return str; \ +} -static log_levels_table_rec const log_levels_table[8] = { - DEF_LLTAB_REC (OFF), - DEF_LLTAB_REC (FATAL), - DEF_LLTAB_REC (ERROR), - DEF_LLTAB_REC (WARN), - DEF_LLTAB_REC (INFO), - DEF_LLTAB_REC (DEBUG), - DEF_LLTAB_REC (TRACE), - DEF_LLTAB_REC (ALL), -}; +DEF_LL_STRING (OFF) +DEF_LL_STRING (FATAL) +DEF_LL_STRING (ERROR) +DEF_LL_STRING (WARN) +DEF_LL_STRING (INFO) +DEF_LL_STRING (DEBUG) +DEF_LL_STRING (TRACE) +DEF_LL_STRING (ALL) +DEF_LL_STRING (NOTSET) +DEF_LL_STRING (UNKNOWN) -#undef DEF_LLTAB_REC +#undef DEF_LL_STRING static @@ -72,17 +68,17 @@ tstring const & defaultLogLevelToStringMethod(LogLevel ll) { switch(ll) { - case OFF_LOG_LEVEL: return OFF_STRING; - case FATAL_LOG_LEVEL: return FATAL_STRING; - case ERROR_LOG_LEVEL: return ERROR_STRING; - case WARN_LOG_LEVEL: return WARN_STRING; - case INFO_LOG_LEVEL: return INFO_STRING; - case DEBUG_LOG_LEVEL: return DEBUG_STRING; - case TRACE_LOG_LEVEL: return TRACE_STRING; - //case ALL_LOG_LEVEL: return ALL_STRING; - case NOT_SET_LOG_LEVEL: return NOTSET_STRING; + case OFF_LOG_LEVEL: return OFF_STRING(); + case FATAL_LOG_LEVEL: return FATAL_STRING(); + case ERROR_LOG_LEVEL: return ERROR_STRING(); + case WARN_LOG_LEVEL: return WARN_STRING(); + case INFO_LOG_LEVEL: return INFO_STRING(); + case DEBUG_LOG_LEVEL: return DEBUG_STRING(); + case TRACE_LOG_LEVEL: return TRACE_STRING(); + //case ALL_LOG_LEVEL: return ALL_STRING(); + case NOT_SET_LOG_LEVEL: return NOTSET_STRING(); }; - + return internal::empty_str; } @@ -91,28 +87,58 @@ static LogLevel defaultStringToLogLevelMethod(const tstring& s) { - std::size_t const tbl_size - = sizeof (log_levels_table) / sizeof (log_levels_table[0]); +#if __cplusplus < 201103L + if (s.empty ()) + return NOT_SET_LOG_LEVEL; + + // The above check is only necessary prior to C++11 standard. Since C++11, + // accessing str[0] is always safe as it returns '\0' for empty string. +#endif - for (log_levels_table_rec const * it = log_levels_table; - it != log_levels_table + tbl_size; ++it) + switch (s[0]) { - if (*it->str == s) - return it->ll; +#define DEF_LLMATCH(_chr, _logLevel) \ + case _chr: if (s == _logLevel ## _STRING ()) \ + return _logLevel ## _LOG_LEVEL; break; + + DEF_LLMATCH ('O', OFF); + DEF_LLMATCH ('F', FATAL); + DEF_LLMATCH ('E', ERROR); + DEF_LLMATCH ('W', WARN); + DEF_LLMATCH ('I', INFO); + DEF_LLMATCH ('D', DEBUG); + DEF_LLMATCH ('T', TRACE); + DEF_LLMATCH ('A', ALL); + +#undef DEF_LLMATCH } - + return NOT_SET_LOG_LEVEL; } } // namespace +void +initializeLogLevelStrings () +{ + OFF_STRING(); + FATAL_STRING(); + ERROR_STRING(); + WARN_STRING(); + INFO_STRING(); + DEBUG_STRING(); + TRACE_STRING(); + ALL_STRING(); + NOTSET_STRING(); +} + ////////////////////////////////////////////////////////////////////////////// // LogLevelManager ctors and dtor ////////////////////////////////////////////////////////////////////////////// -LogLevelManager::LogLevelManager() +LogLevelManager::LogLevelManager() { LogLevelToStringMethodRec rec; rec.func = defaultLogLevelToStringMethod; @@ -123,7 +149,7 @@ LogLevelManager::LogLevelManager() } -LogLevelManager::~LogLevelManager() +LogLevelManager::~LogLevelManager() { } @@ -155,11 +181,11 @@ LogLevelManager::toString(LogLevel ll) const return *ret; } - return UNKNOWN_STRING; + return UNKNOWN_STRING(); } -LogLevel +LogLevel LogLevelManager::fromString(const tstring& arg) const { tstring s = helpers::toUpper(arg); @@ -171,12 +197,16 @@ LogLevelManager::fromString(const tstring& arg) const if (ret != NOT_SET_LOG_LEVEL) return ret; } - + + helpers::getLogLog ().error ( + LOG4CPLUS_TEXT ("Unrecognized log level: ") + + arg); + return NOT_SET_LOG_LEVEL; } -void +void LogLevelManager::pushToStringMethod(LogLevelToStringMethod newToString) { LogLevelToStringMethodRec rec; @@ -186,7 +216,7 @@ LogLevelManager::pushToStringMethod(LogLevelToStringMethod newToString) } -void +void LogLevelManager::pushToStringMethod(LogLevelToStringMethod_1_0 newToString) { LogLevelToStringMethodRec rec; @@ -196,11 +226,11 @@ LogLevelManager::pushToStringMethod(LogLevelToStringMethod_1_0 newToString) } -void +void LogLevelManager::pushFromStringMethod(StringToLogLevelMethod newFromString) { fromStringMethods.push_back (newFromString); } - + } // namespace log4cplus From 8d4b59f242427d280558aa3bc11c0c1646611680 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Thu, 21 Aug 2014 22:19:18 +0200 Subject: [PATCH 166/226] Bump log4cplus library's libtool revision number. --- configure | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index b032b0d10..ceafdad2d 100755 --- a/configure +++ b/configure @@ -4225,7 +4225,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=9:1:0 +LT_VERSION=9:2:0 LT_RELEASE=1.1 diff --git a/configure.ac b/configure.ac index 02c3b98b3..0ec28954d 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=9:1:0 +LT_VERSION=9:2:0 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) From f43e5459ff7520934565019e8e5703ef67c8acb1 Mon Sep 17 00:00:00 2001 From: sfzhang Date: Sat, 23 Aug 2014 02:54:04 +0800 Subject: [PATCH 167/226] add setCurrentThreadName(,2) to modify the thread name --- include/log4cplus/thread/threads.h | 2 ++ src/threads.cxx | 34 ++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/thread/threads.h b/include/log4cplus/thread/threads.h index dbd152c5f..82149c4b0 100644 --- a/include/log4cplus/thread/threads.h +++ b/include/log4cplus/thread/threads.h @@ -39,6 +39,8 @@ namespace log4cplus { namespace thread { LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName(); LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName2(); +LOG4CPLUS_EXPORT void setCurrentThreadName(const log4cplus::tstring & name); +LOG4CPLUS_EXPORT void setCurrentThreadName2(const log4cplus::tstring & name); LOG4CPLUS_EXPORT void yield(); LOG4CPLUS_EXPORT void blockAllSignals(); diff --git a/src/threads.cxx b/src/threads.cxx index b9da69869..cab1c5b62 100644 --- a/src/threads.cxx +++ b/src/threads.cxx @@ -94,6 +94,10 @@ yield() #endif } +#if defined(LOG4CPLUS_SINGLE_THREADED) +static log4cplus::tstring thread_name(LOG4CPLUS_TEXT("single")); +static log4cplus::tstring thread_name2(thread_name); +#endif LOG4CPLUS_EXPORT log4cplus::tstring const & @@ -108,7 +112,11 @@ getCurrentThreadName() tmp.str ().swap (name); } #else - static log4cplus::tstring const name (LOG4CPLUS_TEXT ("single")); + log4cplus::tstring & name = thread_name; + if (LOG4CPLUS_UNLIKELY(name.empty())) + { + name = LOG4CPLUS_TEXT("single"); + } #endif return name; @@ -160,13 +168,35 @@ getCurrentThreadName2() } #else - static log4cplus::tstring const name (getCurrentThreadName ()); + log4cplus::tstring & name = thread_name2; + if (LOG4CPLUS_UNLIKELY(name.empty())) + { + name = getCurrentThreadName(); + } #endif return name; } +LOG4CPLUS_EXPORT void setCurrentThreadName(const log4cplus::tstring & name) +{ +#if ! defined (LOG4CPLUS_SINGLE_THREADED) + log4cplus::internal::get_thread_name_str() = name; +#else + thread_name = name; +#endif +} + +LOG4CPLUS_EXPORT void setCurrentThreadName2(const log4cplus::tstring & name) +{ +#if ! defined (LOG4CPLUS_SINGLE_THREADED) + log4cplus::internal::get_thread_name2_str() = name; +#else + thread_name2 = name; +#endif +} + } } // namespace log4cplus { namespace thread { From 3994c9bf2416b5e2acbd08c370182a8df9eb454a Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 24 Aug 2014 22:51:37 +0200 Subject: [PATCH 168/226] threads.cxx: Use init priority for thread_name and thread_name2. --- src/threads.cxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/threads.cxx b/src/threads.cxx index cab1c5b62..c35593b88 100644 --- a/src/threads.cxx +++ b/src/threads.cxx @@ -45,7 +45,7 @@ # include # include #elif defined (LOG4CPLUS_USE_WIN32_THREADS) -# include +# include #endif #include #include @@ -78,7 +78,7 @@ blockAllSignals() sigset_t signal_set; sigfillset (&signal_set); pthread_sigmask (SIG_BLOCK, &signal_set, 0); -#endif +#endif } @@ -95,8 +95,10 @@ yield() } #if defined(LOG4CPLUS_SINGLE_THREADED) -static log4cplus::tstring thread_name(LOG4CPLUS_TEXT("single")); -static log4cplus::tstring thread_name2(thread_name); +static log4cplus::tstring thread_name(LOG4CPLUS_TEXT("single")) + LOG4CPLUS_INIT_PRIORITY (LOG4CPLUS_INIT_PRIORITY_BASE - 1); +static log4cplus::tstring thread_name2(thread_name) + LOG4CPLUS_INIT_PRIORITY (LOG4CPLUS_INIT_PRIORITY_BASE - 1); #endif LOG4CPLUS_EXPORT @@ -141,7 +143,7 @@ get_current_thread_name_alt (log4cplus::tostream * s) #elif defined (__CYGWIN__) unsigned long tid = cygwin::get_current_win32_thread_id (); os << tid; - + #else os << getCurrentThreadName (); @@ -222,7 +224,7 @@ namespace log4cplus { namespace thread { namespace impl { #if defined(LOG4CPLUS_USE_PTHREADS) -void* +void* ThreadStart::threadStartFuncWorker(void * arg) #elif defined(LOG4CPLUS_USE_WIN32_THREADS) unsigned @@ -455,7 +457,7 @@ AbstractThread::~AbstractThread() { } -} } // namespace log4cplus { namespace thread { +} } // namespace log4cplus { namespace thread { #endif // LOG4CPLUS_SINGLE_THREADED From fe7a458e60aab73206fc40026619a91e331579d3 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 24 Aug 2014 22:53:44 +0200 Subject: [PATCH 169/226] Mention Zhang Shengfa. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 88b9255cc..c6be13258 100644 --- a/AUTHORS +++ b/AUTHORS @@ -24,3 +24,4 @@ Yaqian Shen Sergey Nikulov Ray Logel Maxym +Zhang Shengfa From 40f7adb609c40b1b7e2abbb1f4e323ae527d7d52 Mon Sep 17 00:00:00 2001 From: sfzhang Date: Tue, 26 Aug 2014 01:55:15 +0800 Subject: [PATCH 170/226] allow user to omit variadic arguments in LOG4CPLUS_*_FMT --- include/log4cplus/loggingmacros.h | 76 +++++++++++++++---------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/include/log4cplus/loggingmacros.h b/include/log4cplus/loggingmacros.h index 37cfaec60..4e108b85d 100644 --- a/include/log4cplus/loggingmacros.h +++ b/include/log4cplus/loggingmacros.h @@ -231,7 +231,7 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_RESTORE_DOWHILE_WARNING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, logFmt, ...) \ +#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, ...) \ LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ @@ -240,7 +240,7 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, _l.isEnabledFor (log4cplus::logLevel), logLevel)) { \ LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \ log4cplus::tchar const * _logEvent \ - = _snpbuf.print (logFmt, __VA_ARGS__); \ + = _snpbuf.print (__VA_ARGS__); \ log4cplus::detail::macro_forced_log (_l, \ log4cplus::logLevel, _logEvent, \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ @@ -249,7 +249,7 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_RESTORE_DOWHILE_WARNING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, logFmt, logArgs...) \ +#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, logArgs...) \ LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \ do { \ log4cplus::Logger const & _l \ @@ -258,7 +258,7 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, _l.isEnabledFor (log4cplus::logLevel), logLevel)) { \ LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \ log4cplus::tchar const * _logEvent \ - = _snpbuf.print (logFmt, logArgs); \ + = _snpbuf.print (logArgs); \ log4cplus::detail::macro_forced_log (_l, \ log4cplus::logLevel, _logEvent, \ __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION ()); \ @@ -285,11 +285,11 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, TRACE_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_TRACE_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, TRACE_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_TRACE_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, TRACE_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_TRACE_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, TRACE_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_TRACE_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, TRACE_LOG_LEVEL, logArgs) #endif #else @@ -316,20 +316,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, DEBUG_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, DEBUG_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_DEBUG_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, DEBUG_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, DEBUG_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_DEBUG_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, DEBUG_LOG_LEVEL, logArgs) #endif #else #define LOG4CPLUS_DEBUG(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #define LOG4CPLUS_DEBUG_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_DEBUG_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_DEBUG_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_DEBUG_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -346,20 +346,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, INFO_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, INFO_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_INFO_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, INFO_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, INFO_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_INFO_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, INFO_LOG_LEVEL, logArgs) #endif #else #define LOG4CPLUS_INFO(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #define LOG4CPLUS_INFO_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_INFO_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_INFO_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_INFO_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -376,20 +376,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, WARN_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, WARN_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_WARN_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, WARN_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, WARN_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_WARN_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, WARN_LOG_LEVEL, logArgs) #endif #else #define LOG4CPLUS_WARN(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #define LOG4CPLUS_WARN_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_WARN_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_WARN_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_WARN_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -406,20 +406,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, ERROR_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, ERROR_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_ERROR_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, ERROR_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, ERROR_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_ERROR_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, ERROR_LOG_LEVEL, logArgs) #endif #else #define LOG4CPLUS_ERROR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #define LOG4CPLUS_ERROR_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_ERROR_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_ERROR_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_ERROR_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif @@ -436,20 +436,20 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &, LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, FATAL_LOG_LEVEL) #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, ...) \ - LOG4CPLUS_MACRO_FMT_BODY (logger, FATAL_LOG_LEVEL, logFmt, __VA_ARGS__) +#define LOG4CPLUS_FATAL_FMT(logger, ...) \ + LOG4CPLUS_MACRO_FMT_BODY (logger, FATAL_LOG_LEVEL, __VA_ARGS__) #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, logArgs...) \ - LOG4CPLUS_MACRO_FMT_BODY(logger, FATAL_LOG_LEVEL, logFmt, logArgs) +#define LOG4CPLUS_FATAL_FMT(logger, logArgs...) \ + LOG4CPLUS_MACRO_FMT_BODY(logger, FATAL_LOG_LEVEL, logArgs) #endif #else #define LOG4CPLUS_FATAL(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #define LOG4CPLUS_FATAL_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING() #if defined (LOG4CPLUS_HAVE_C99_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_FATAL_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING() #elif defined (LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS) -#define LOG4CPLUS_FATAL_FMT(logger, logFmt, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() +#define LOG4CPLUS_FATAL_FMT(logger, logArgs...) LOG4CPLUS_DOWHILE_NOTHING() #endif #endif From d8268ccf110312ae6e5254b9e85fd58e42dacebc Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 2 Sep 2014 07:55:17 +0200 Subject: [PATCH 171/226] iOS.cmake: Update from upstream source. --- iOS/iOS.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iOS/iOS.cmake b/iOS/iOS.cmake index c0134645d..df2e3faca 100644 --- a/iOS/iOS.cmake +++ b/iOS/iOS.cmake @@ -28,7 +28,6 @@ # A macro used to find executable programs on the host system, not within the iOS environment. # Thanks to the android-cmake project for providing the command - # Standard settings set (CMAKE_SYSTEM_NAME Darwin) set (CMAKE_SYSTEM_VERSION 1) @@ -48,8 +47,9 @@ endif (CMAKE_UNAME) # Force the compilers to gcc for iOS include (CMakeForceCompiler) -CMAKE_FORCE_C_COMPILER (gcc gcc) -CMAKE_FORCE_CXX_COMPILER (g++ g++) +CMAKE_FORCE_C_COMPILER (/usr/bin/clang Apple) +CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ Apple) +set(CMAKE_AR ar CACHE FILEPATH "" FORCE) # Skip the platform compiler checks for cross compiling set (CMAKE_CXX_COMPILER_WORKS TRUE) @@ -70,7 +70,7 @@ set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") # Hidden visibilty is required for cxx on iOS set (CMAKE_C_FLAGS_INIT "") -set (CMAKE_CXX_FLAGS_INIT "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden") +set (CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden -isysroot ${CMAKE_OSX_SYSROOT}") set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") From 13c399ec295aad44bca865b90ef6f9d8a600bd11 Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Thu, 2 Oct 2014 08:08:23 +0300 Subject: [PATCH 172/226] Add .rc file to include DLL version information on Windows --- src/CMakeLists.txt | 8 ++++++++ src/log4cplus.rc.in | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/log4cplus.rc.in diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72a99fc3a..75c06186c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,6 +71,14 @@ endif (UNICODE) if (WIN32) add_definitions (-DMINGW_HAS_SECURE_API=1) add_definitions (-D_WIN32_WINNT=${_WIN32_WINNT}) + + if (BUILD_SHARED_LIBS) + set(log4cplus_build_shared 1) + else () + set(log4cplus_build_shared 0) + endif () + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/log4cplus.rc.in ${CMAKE_CURRENT_BINARY_DIR}/log4cplus.rc @ONLY) + list(APPEND log4cplus_sources ${CMAKE_CURRENT_BINARY_DIR}/log4cplus.rc) endif (WIN32) add_library (${log4cplus} ${log4cplus_sources}) diff --git a/src/log4cplus.rc.in b/src/log4cplus.rc.in new file mode 100644 index 000000000..542f71142 --- /dev/null +++ b/src/log4cplus.rc.in @@ -0,0 +1,43 @@ +#include + +#ifdef NDEBUG +#define VER_DEBUG 0 +#else +#define VER_DEBUG VS_FF_DEBUG +#endif + +#if @log4cplus_build_shared@ +#define VER_FILETYPE VFT_DLL +#else +#define VER_FILETYPE VFT_STATIC_LIB +#endif + +#define VER_BINARY @log4cplus_version_major@,@log4cplus_version_minor@,@log4cplus_version_patch@,0 +#define VER_STR "@log4cplus_version_major@.@log4cplus_version_minor@.@log4cplus_version_patch@" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_BINARY +PRODUCTVERSION VER_BINARY +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS VER_DEBUG +FILEOS VOS_NT_WINDOWS32 +FILETYPE VER_FILETYPE +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "log4cplus" + VALUE "FileDescription", "log4cplus logging library" + VALUE "FileVersion", VER_STR + VALUE "InternalName", "@log4cplus@" + VALUE "ProductName", "@log4cplus@" + VALUE "ProductVersion", VER_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1200 + END +END From f1ee76345248dd0d9cf55ced193407bd71d70f6f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sat, 4 Oct 2014 08:00:50 +0200 Subject: [PATCH 173/226] AUTHORS: Mention Oskari Timperi. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index c6be13258..7651e8ebe 100644 --- a/AUTHORS +++ b/AUTHORS @@ -25,3 +25,4 @@ Sergey Nikulov Ray Logel Maxym Zhang Shengfa +Oskari Timperi From 4108fb13274ef542f9fe84e50bafe8ee87bb0891 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 24 Oct 2014 14:15:53 +0200 Subject: [PATCH 174/226] patternlayout.cxx: Allow negative maximal length in pattern specifier to make trimming of end instead of beginning possible. E.g., allow %.-1p to get initial letters of log level. --- src/patternlayout.cxx | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/patternlayout.cxx b/src/patternlayout.cxx index 074785cbf..7c98a82a4 100644 --- a/src/patternlayout.cxx +++ b/src/patternlayout.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -75,7 +76,8 @@ namespace pattern struct FormattingInfo { int minLen; std::size_t maxLen; - bool leftAlign; + bool leftAlign : 1; + bool trimStart : 1; FormattingInfo() { reset(); } void reset(); @@ -104,7 +106,8 @@ class PatternConverter private: int minLen; std::size_t maxLen; - bool leftAlign; + bool leftAlign : 1; + bool trimStart : 1; }; @@ -312,20 +315,22 @@ class PatternParser // FormattingInfo methods: //////////////////////////////////////////////// -void +void FormattingInfo::reset() { minLen = -1; - maxLen = 0x7FFFFFFF; + maxLen = std::numeric_limits::max (); leftAlign = false; + trimStart = true; } -void +void FormattingInfo::dump(helpers::LogLog& loglog) { tostringstream buf; buf << LOG4CPLUS_TEXT("min=") << minLen << LOG4CPLUS_TEXT(", max=") << maxLen - << LOG4CPLUS_TEXT(", leftAlign=") << std::boolalpha << leftAlign; + << LOG4CPLUS_TEXT(", leftAlign=") << std::boolalpha << leftAlign + << LOG4CPLUS_TEXT(", trimStart=") << std::boolalpha << trimStart; loglog.debug(buf.str()); } @@ -341,6 +346,7 @@ PatternConverter::PatternConverter(const FormattingInfo& i) minLen = i.minLen; maxLen = i.maxLen; leftAlign = i.leftAlign; + trimStart = i.trimStart; } @@ -354,7 +360,12 @@ PatternConverter::formatAndAppend( std::size_t len = s.length(); if (len > maxLen) - output << s.substr(len - maxLen); + { + if (trimStart) + output << s.substr(len - maxLen); + else + output << s.substr(0, maxLen); + } else if (static_cast(len) < minLen) { std::ios_base::fmtflags const original_flags = output.flags (); @@ -804,7 +815,9 @@ PatternParser::parse() case DOT_STATE: currentLiteral += c; - if(c >= LOG4CPLUS_TEXT('0') && c <= LOG4CPLUS_TEXT('9')) { + if (c == LOG4CPLUS_TEXT('-')) + formattingInfo.trimStart = false; + else if(c >= LOG4CPLUS_TEXT('0') && c <= LOG4CPLUS_TEXT('9')) { formattingInfo.maxLen = c - LOG4CPLUS_TEXT('0'); state = MAX_STATE; } From 758a4b29908960472f28bd2a7926e08ae3b5d445 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 16 Dec 2014 14:13:06 +0100 Subject: [PATCH 175/226] Revert most of 439414a to avoid crashes on startup with log4cplus static library. --- src/global-init.cxx | 4 +-- src/loglevel.cxx | 81 ++++++++++++++------------------------------- 2 files changed, 26 insertions(+), 59 deletions(-) diff --git a/src/global-init.cxx b/src/global-init.cxx index 99e1bf61a..7d1985f36 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -300,8 +300,7 @@ alloc_ptd () } // namespace internal -void initializeFactoryRegistry (); -void initializeLogLevelStrings (); +void initializeFactoryRegistry(); //! Thread local storage clean up function for POSIX threads. @@ -373,7 +372,6 @@ initializeLog4cplus() dc->TTCCLayout_time_base = helpers::Time::gettimeofday (); Logger::getRoot(); initializeFactoryRegistry(); - initializeLogLevelStrings(); initialized = true; } diff --git a/src/loglevel.cxx b/src/loglevel.cxx index 5b17d8956..87a8f344f 100644 --- a/src/loglevel.cxx +++ b/src/loglevel.cxx @@ -32,35 +32,16 @@ namespace log4cplus namespace { -// The strings here are not simple tstring constants to allow using these -// strings and log4cplus itself in client code during static variables -// initialization. If they are simple tstring constants then, due to undefined -// order of initialization between translation units, they might be -// uninitialized before they are used by the client code. One possible solution -// to this is to use compiler specific attributes and/or pragmas to influence -// initialization order/priority. Another solution is using function local -// static variables, which are initialized on first use. We choose this -// implementation because it is more portable than compiler specific means. - -#define DEF_LL_STRING(_logLevel) \ -static tstring const & _logLevel ## _STRING () \ -{ \ - static tstring const str (LOG4CPLUS_TEXT (#_logLevel)); \ - return str; \ -} - -DEF_LL_STRING (OFF) -DEF_LL_STRING (FATAL) -DEF_LL_STRING (ERROR) -DEF_LL_STRING (WARN) -DEF_LL_STRING (INFO) -DEF_LL_STRING (DEBUG) -DEF_LL_STRING (TRACE) -DEF_LL_STRING (ALL) -DEF_LL_STRING (NOTSET) -DEF_LL_STRING (UNKNOWN) - -#undef DEF_LL_STRING +static tstring const ALL_STRING (LOG4CPLUS_TEXT("ALL")); +static tstring const TRACE_STRING (LOG4CPLUS_TEXT("TRACE")); +static tstring const DEBUG_STRING (LOG4CPLUS_TEXT("DEBUG")); +static tstring const INFO_STRING (LOG4CPLUS_TEXT("INFO")); +static tstring const WARN_STRING (LOG4CPLUS_TEXT("WARN")); +static tstring const ERROR_STRING (LOG4CPLUS_TEXT("ERROR")); +static tstring const FATAL_STRING (LOG4CPLUS_TEXT("FATAL")); +static tstring const OFF_STRING (LOG4CPLUS_TEXT("OFF")); +static tstring const NOTSET_STRING (LOG4CPLUS_TEXT("NOTSET")); +static tstring const UNKNOWN_STRING (LOG4CPLUS_TEXT("UNKNOWN")); static @@ -68,15 +49,15 @@ tstring const & defaultLogLevelToStringMethod(LogLevel ll) { switch(ll) { - case OFF_LOG_LEVEL: return OFF_STRING(); - case FATAL_LOG_LEVEL: return FATAL_STRING(); - case ERROR_LOG_LEVEL: return ERROR_STRING(); - case WARN_LOG_LEVEL: return WARN_STRING(); - case INFO_LOG_LEVEL: return INFO_STRING(); - case DEBUG_LOG_LEVEL: return DEBUG_STRING(); - case TRACE_LOG_LEVEL: return TRACE_STRING(); - //case ALL_LOG_LEVEL: return ALL_STRING(); - case NOT_SET_LOG_LEVEL: return NOTSET_STRING(); + case OFF_LOG_LEVEL: return OFF_STRING; + case FATAL_LOG_LEVEL: return FATAL_STRING; + case ERROR_LOG_LEVEL: return ERROR_STRING; + case WARN_LOG_LEVEL: return WARN_STRING; + case INFO_LOG_LEVEL: return INFO_STRING; + case DEBUG_LOG_LEVEL: return DEBUG_STRING; + case TRACE_LOG_LEVEL: return TRACE_STRING; + //case ALL_LOG_LEVEL: return ALL_STRING; + case NOT_SET_LOG_LEVEL: return NOTSET_STRING; }; return internal::empty_str; @@ -98,8 +79,11 @@ defaultStringToLogLevelMethod(const tstring& s) switch (s[0]) { #define DEF_LLMATCH(_chr, _logLevel) \ - case _chr: if (s == _logLevel ## _STRING ()) \ - return _logLevel ## _LOG_LEVEL; break; + case LOG4CPLUS_TEXT (_chr): \ + if (s == _logLevel ## _STRING) \ + return _logLevel ## _LOG_LEVEL; \ + else \ + break; DEF_LLMATCH ('O', OFF); DEF_LLMATCH ('F', FATAL); @@ -119,21 +103,6 @@ defaultStringToLogLevelMethod(const tstring& s) } // namespace -void -initializeLogLevelStrings () -{ - OFF_STRING(); - FATAL_STRING(); - ERROR_STRING(); - WARN_STRING(); - INFO_STRING(); - DEBUG_STRING(); - TRACE_STRING(); - ALL_STRING(); - NOTSET_STRING(); -} - - ////////////////////////////////////////////////////////////////////////////// // LogLevelManager ctors and dtor ////////////////////////////////////////////////////////////////////////////// @@ -181,7 +150,7 @@ LogLevelManager::toString(LogLevel ll) const return *ret; } - return UNKNOWN_STRING(); + return UNKNOWN_STRING; } From b35007018ae4d19c41380ea80ae55d4baedf9d9a Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Tue, 16 Dec 2014 14:20:29 +0100 Subject: [PATCH 176/226] Add .gitignore file from master. --- .gitignore | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..7cc0be609 --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +*.user +*.ncb +*.suo +*.sdf +*.opensdf +.#* +*~ +*.bak +ipch/ +autom4te.cache/ +objdir*/ +Win32/ +x64/ + +.idea + +# LaTeX/PDF produciton byproducts +*.aux +*.log +*.tex +*.toc +*.xwm +*.pdf +*.ref_rename_step + +# Compiler produced temporaries +*.s +*.ii + +# Patches +*.patch +*.diff + +# +# From Github's C++.gitignore: +# + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app From 1131d59dcbfcba8cb84cfb77c094df4c8ddaa9e4 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 4 Jan 2015 17:14:44 +0100 Subject: [PATCH 177/226] ChangeLog: Prepare for 1.1.3-RC4. --- ChangeLog | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2181d23ea..bb285aeaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +log4cplus 1.1.3-RC4 + +- Allow negative maximal length in pattern specifier to make trimming of end + instead of beginning possible. E.g., allow %.-1p to get initial letters of + log level. + +- Visual Studio DLL builds now have a resource with basic information about + the library. (Oskari Timperi) + +- LOG4CPLUS_*_FMT() macros can now be invoked with just formatting string, + without additional arguments. (Zhang Shengfa) + +- Added setCurrentThreadName() and setCurrentThreadName2() to allow setting + current thread name to custom string instead of the default stringified + thread ID. (Zhang Shengfa) + + log4cplus 1.1.3-RC3 - Fixed bug #298. -- int to pointer cast error on Xcode 5.1. From 9d322a8dde4c5c9cf23546f3371f9d649d52f70c Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Sun, 4 Jan 2015 17:18:15 +0100 Subject: [PATCH 178/226] Bump SO version for new interfaces. --- CMakeLists.txt | 2 +- configure | 2 +- configure.ac | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ea86be14..fe7a444b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include (Log4CPlusUtils.cmake) log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include" log4cplus_version_major log4cplus_version_minor log4cplus_version_patch) message("-- Generating build for Log4cplus version ${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") -set (log4cplus_soversion 9) +set (log4cplus_soversion 10) set (log4cplus_postfix "") option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) diff --git a/configure b/configure index ceafdad2d..0470e5d7f 100755 --- a/configure +++ b/configure @@ -4225,7 +4225,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=9:2:0 +LT_VERSION=10:3:1 LT_RELEASE=1.1 diff --git a/configure.ac b/configure.ac index 0ec28954d..95da96ac1 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=9:2:0 +LT_VERSION=10:3:1 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) From b0b166f8838eda2b1e0f5deb24977559b8733785 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 26 Jan 2015 19:49:18 +0100 Subject: [PATCH 179/226] Avoid "most vexing parse" isseu with LOG4CPLUS_C_STR_TO_TSTRING(STRING) when STRING is an identifier. --- include/log4cplus/tstring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/log4cplus/tstring.h b/include/log4cplus/tstring.h index 587aaa15e..7829b4e2f 100644 --- a/include/log4cplus/tstring.h +++ b/include/log4cplus/tstring.h @@ -122,7 +122,7 @@ LOG4CPLUS_EXPORT std::wstring towstring(char const *); #else // UNICODE -#define LOG4CPLUS_C_STR_TO_TSTRING(STRING) std::string(STRING) +#define LOG4CPLUS_C_STR_TO_TSTRING(STRING) (std::string(STRING)) #define LOG4CPLUS_STRING_TO_TSTRING(STRING) STRING #define LOG4CPLUS_TSTRING_TO_STRING(STRING) STRING From e07bc76c7522ddfb5710f0ff7a90a739b6446d5f Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 26 Jan 2015 17:44:22 +0100 Subject: [PATCH 180/226] Fix bug in LogLevelMatchFilter with AcceptOnMatch default value. When AcceptOnMatch property is missing then the default should stay true. This was introduced abuot 5 years ago in 1.1 branch during Properties API changes. --- src/filter.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/filter.cxx b/src/filter.cxx index 55de56c3a..65108342a 100644 --- a/src/filter.cxx +++ b/src/filter.cxx @@ -110,8 +110,7 @@ LogLevelMatchFilter::LogLevelMatchFilter(const helpers::Properties& properties) { init(); - properties.getBool (acceptOnMatch = false, - LOG4CPLUS_TEXT("AcceptOnMatch")); + properties.getBool (acceptOnMatch, LOG4CPLUS_TEXT("AcceptOnMatch")); tstring const & log_level_to_match = properties.getProperty( LOG4CPLUS_TEXT("LogLevelToMatch") ); From b022b042e0972c17d0918c137e9e55f2514190c3 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 26 Jan 2015 22:45:14 +0100 Subject: [PATCH 181/226] Fix StringMatchFilter bug when AcceptOnMatch is not provided. It should default to true but was false. --- src/filter.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/filter.cxx b/src/filter.cxx index 65108342a..4a3752b6c 100644 --- a/src/filter.cxx +++ b/src/filter.cxx @@ -223,8 +223,7 @@ StringMatchFilter::StringMatchFilter(const helpers::Properties& properties) { init(); - properties.getBool (acceptOnMatch = false, - LOG4CPLUS_TEXT("AcceptOnMatch")); + properties.getBool (acceptOnMatch, LOG4CPLUS_TEXT("AcceptOnMatch")); stringToMatch = properties.getProperty( LOG4CPLUS_TEXT("StringToMatch") ); } From 47d23fe043a30dd78b11cc57dbb1129195ac6c2d Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Mon, 26 Jan 2015 23:14:31 +0100 Subject: [PATCH 182/226] Fix bug in LogLevelMatchFilter when AcceptOnMatch is not provided. The default should be true but was false. --- src/filter.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/filter.cxx b/src/filter.cxx index 4a3752b6c..2542f4802 100644 --- a/src/filter.cxx +++ b/src/filter.cxx @@ -134,7 +134,7 @@ LogLevelMatchFilter::decide(const InternalLoggingEvent& event) const } bool matchOccured = (logLevelToMatch == event.getLogLevel()); - + if(matchOccured) { return (acceptOnMatch ? ACCEPT : DENY); } @@ -160,8 +160,7 @@ LogLevelRangeFilter::LogLevelRangeFilter(const helpers::Properties& properties) { init(); - properties.getBool (acceptOnMatch = false, - LOG4CPLUS_TEXT("AcceptOnMatch")); + properties.getBool (acceptOnMatch, LOG4CPLUS_TEXT("AcceptOnMatch")); tstring const & log_level_min = properties.getProperty( LOG4CPLUS_TEXT("LogLevelMin") ); From d63a51f49207e0eb1d1c7c41ea03bcc5cffbf749 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 6 Jul 2015 14:07:44 +0200 Subject: [PATCH 183/226] Fix GitHub bug #92. Truncate seconds away from next rollover time. (cherry picked from commit b114cc48f67afb7b526f4a55cf5d7fb120cd7bd7) --- src/fileappender.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fileappender.cxx b/src/fileappender.cxx index 131cb0504..9b53d59e7 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #if defined (__BORLANDC__) @@ -809,11 +810,16 @@ DailyRollingFileAppender::rollover(bool alreadyLocked) Time -DailyRollingFileAppender::calculateNextRolloverTime(const Time& t) const +DailyRollingFileAppender::calculateNextRolloverTime(const Time& t_) const { + // Round down the time to whole minutes. + Time const t ( + t_.getTime () + - static_cast(std::fmod (t_.getTime (), 60))); + switch(schedule) { - case MONTHLY: + case MONTHLY: { struct tm nextMonthTime; t.localtime(&nextMonthTime); From da3d29549ef93cd9b64cf1c4268eee9b73591b77 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 6 Jul 2015 15:04:00 +0200 Subject: [PATCH 184/226] Fix GitHub bug #92 also for other DailyRollingFileAppender schedules. (cherry picked from commit 45fb51af036ab5023c12faf3dc37d77536a3a9cf) --- src/fileappender.cxx | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/fileappender.cxx b/src/fileappender.cxx index 9b53d59e7..4ad641ed5 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -635,6 +635,30 @@ DailyRollingFileAppender::DailyRollingFileAppender( } +namespace +{ + + +static +Time +round_time (Time const & t, time_t seconds) +{ + return Time ( + t.getTime () + - static_cast(std::fmod (t.getTime (), seconds))); +} + + +static +Time +round_time_and_add (Time const & t, Time const & seconds) +{ + return round_time (t, seconds.sec ()) + seconds; +} + + +} // namespace + void DailyRollingFileAppender::init(DailyRollingFileSchedule sch) @@ -810,13 +834,8 @@ DailyRollingFileAppender::rollover(bool alreadyLocked) Time -DailyRollingFileAppender::calculateNextRolloverTime(const Time& t_) const +DailyRollingFileAppender::calculateNextRolloverTime(const Time& t) const { - // Round down the time to whole minutes. - Time const t ( - t_.getTime () - - static_cast(std::fmod (t_.getTime (), 60))); - switch(schedule) { case MONTHLY: @@ -832,14 +851,14 @@ DailyRollingFileAppender::calculateNextRolloverTime(const Time& t_) const LOG4CPLUS_TEXT("DailyRollingFileAppender::calculateNextRolloverTime()-") LOG4CPLUS_TEXT(" setTime() returned error")); // Set next rollover to 31 days in future. - ret = (t + Time(2678400)); + ret = round_time (t, 24 * 60 * 60) + Time(2678400); } return ret; } case WEEKLY: - return (t + Time(7 * 24 * 60 * 60)); + return round_time (t, 24 * 60 * 60) + Time (7 * 24 * 60 * 60); default: helpers::getLogLog ().error ( @@ -848,16 +867,16 @@ DailyRollingFileAppender::calculateNextRolloverTime(const Time& t_) const // Fall through. case DAILY: - return (t + Time(24 * 60 * 60)); + return round_time_and_add (t, Time (24 * 60 * 60)); case TWICE_DAILY: - return (t + Time(12 * 60 * 60)); + return round_time_and_add (t, Time (12 * 60 * 60)); case HOURLY: - return (t + Time(60 * 60)); + return round_time_and_add (t, Time (60 * 60)); case MINUTELY: - return (t + Time(60)); + return round_time_and_add (t, Time (60)); }; } From 70978e7a2a0d5fe397309b915076830afcf25c4a Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Tue, 7 Jul 2015 10:59:11 +0200 Subject: [PATCH 185/226] Fix GitHub bug #92. Fix fmod() ambiguity error. (cherry picked from commit 62dcb1c94b837bf181da75b075f6e8a6a01edaaf) --- src/fileappender.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fileappender.cxx b/src/fileappender.cxx index 4ad641ed5..9b343c750 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -645,7 +645,9 @@ round_time (Time const & t, time_t seconds) { return Time ( t.getTime () - - static_cast(std::fmod (t.getTime (), seconds))); + - static_cast(std::fmod ( + static_cast(t.getTime ()), + static_cast(seconds)))); } From cafbd1d7e74a50305ea887559bda902692cca828 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Wed, 15 Jul 2015 07:36:46 +0200 Subject: [PATCH 186/226] Allow turning off library name decoration in CMake builds. See also GitHub issue #98. (cherry picked from commit ff24b0ae94f1b0f8c500f08e1bb300d7454275e8) --- CMakeLists.txt | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe7a444b1..2b047fb77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,21 +67,25 @@ option(ENABLE_SYMBOLS_VISIBILITY set(_WIN32_WINNT 0x0500 CACHE STRING "Define Windows API version to use.") -if (NOT ${BUILD_SHARED_LIBS}) - # set S-prefix for static build - set (log4cplus_postfix "${log4cplus_postfix}S") -endif() +option(LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME + "Turns on resulting file name decoration for static and UNICODE builds." ON) +if (LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME) + if (NOT ${BUILD_SHARED_LIBS}) + # set S-prefix for static build + set (log4cplus_postfix "${log4cplus_postfix}S") + endif () + + if (UNICODE) + set (log4cplus_postfix "${log4cplus_postfix}U") + endif (UNICODE) +endif (LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME) -if (UNICODE) - set (log4cplus_postfix "${log4cplus_postfix}U") -endif (UNICODE) +set (log4cplus "log4cplus${log4cplus_postfix}") if (WITH_ICONV) set(LOG4CPLUS_WITH_ICONV 1) endif () -set (log4cplus "log4cplus${log4cplus_postfix}") - if(LOG4CPLUS_CONFIGURE_CHECKS_PATH) get_filename_component(LOG4CPLUS_CONFIGURE_CHECKS_PATH "${LOG4CPLUS_CONFIGURE_CHECKS_PATH}" ABSOLUTE) endif() From f2b2a5a5ed578a696757b355d19d6c76166f39cf Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Tue, 21 Jul 2015 20:34:41 +0200 Subject: [PATCH 187/226] Update for 1.1.3-RC5. --- ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index bb285aeaf..e2a522385 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +log4cplus 1.1.3-RC5 + +- Fixed "most vexing parse" issue when using LOG4CPLUS_C_STR_TO_TSTRING(). + +- Fixed AcceptOnMatch property function in filters default to true value. + +- Fixed GitHub bug #92. DailyRollingFileAppender rollover time was drifting. + +- Added LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME option to CMake builds to + produce log4cplus library without Unicode and/or static library decoration. + + log4cplus 1.1.3-RC4 - Allow negative maximal length in pattern specifier to make trimming of end From 7da5a1eeabe44c696f6f398a0146a5a2030cb7c5 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Tue, 21 Jul 2015 20:37:21 +0200 Subject: [PATCH 188/226] We use Git now. Fix the release.txt procedure. --- docs/release.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release.txt b/docs/release.txt index c55dd4001..a0c422fa4 100644 --- a/docs/release.txt +++ b/docs/release.txt @@ -4,7 +4,7 @@ This describes the release procedure: 2. Tag revision on branch. - 3. Run scripts/prepare_dist_from_bzr.sh to prepare tarballs. + 3. Run scripts/prepare_dist_from_git.sh to prepare tarballs. 4. Upload tarballs to SourceForge. From 789babc2bc2607ea111d37e9792d5c10648ad8f1 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Wed, 4 Nov 2015 15:09:03 +0100 Subject: [PATCH 189/226] Whitespace cleanup in sockets files. --- include/log4cplus/helpers/socket.h | 4 ++-- src/socket-unix.cxx | 26 +++++++++++++------------- src/socket.cxx | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/log4cplus/helpers/socket.h b/include/log4cplus/helpers/socket.h index eb52d84c0..b73c7e016 100644 --- a/include/log4cplus/helpers/socket.h +++ b/include/log4cplus/helpers/socket.h @@ -41,7 +41,7 @@ namespace log4cplus { not_opened, bad_address, connection_failed, - broken_pipe, + broken_pipe, invalid_access_mode, message_truncated, accept_interrupted @@ -63,7 +63,7 @@ namespace log4cplus { /// Close socket virtual void close(); virtual bool isOpen() const; - virtual void shutdown(); + virtual void shutdown(); AbstractSocket& operator=(const AbstractSocket& rhs); protected: diff --git a/src/socket-unix.cxx b/src/socket-unix.cxx index 22bd49d7b..6182ae5a4 100644 --- a/src/socket-unix.cxx +++ b/src/socket-unix.cxx @@ -51,7 +51,7 @@ #if defined (LOG4CPLUS_HAVE_ARPA_INET_H) #include #endif - + #if defined (LOG4CPLUS_HAVE_ERRNO_H) #include #endif @@ -76,7 +76,7 @@ namespace log4cplus { namespace helpers { // from lockfile.cxx -LOG4CPLUS_PRIVATE bool trySetCloseOnExec (int fd, +LOG4CPLUS_PRIVATE bool trySetCloseOnExec (int fd, helpers::LogLog & loglog = helpers::getLogLog ()); @@ -115,7 +115,7 @@ get_host_by_name (char const * hostname, std::string * name, struct addrinfo const & ai = *res; assert (ai.ai_family == AF_INET); - + if (name) *name = ai.ai_canonname; @@ -227,7 +227,7 @@ connectSocket(const tstring& hostn, unsigned short port, bool udp, SocketState& == -1 && (errno == EINTR)) ; - if (retval == INVALID_OS_SOCKET_VALUE) + if (retval == INVALID_OS_SOCKET_VALUE) { ::close(sock); return INVALID_SOCKET_VALUE; @@ -290,7 +290,7 @@ acceptSocket(SOCKET_TYPE sock, SocketState& state) while( (clientSock = accept_wrap (accept, to_os_socket (sock), - reinterpret_cast(&net_client), &len)) + reinterpret_cast(&net_client), &len)) == -1 && (errno == EINTR)) ; @@ -322,9 +322,9 @@ long read(SOCKET_TYPE sock, SocketBuffer& buffer) { long res, readbytes = 0; - + do - { + { res = ::read(to_os_socket (sock), buffer.getBuffer() + readbytes, buffer.getMaxSize() - readbytes); if( res <= 0 ) { @@ -332,7 +332,7 @@ read(SOCKET_TYPE sock, SocketBuffer& buffer) } readbytes += res; } while( readbytes < static_cast(buffer.getMaxSize()) ); - + return readbytes; } @@ -417,7 +417,7 @@ setTCPNoDelay (SOCKET_TYPE sock, bool val) if ((result = setsockopt(sock, level, TCP_NODELAY, &enabled, sizeof(enabled))) != 0) set_last_socket_error (errno); - + return result; #else @@ -495,7 +495,7 @@ ServerSocket::accept () { interrupt_pipe.revents = 0; accept_fd.revents = 0; - + int ret = poll (pollfds, 2, -1); switch (ret) { @@ -504,7 +504,7 @@ ServerSocket::accept () if (errno == EINTR) // Signal has interrupted the call. Just re-run it. continue; - + set_last_socket_error (errno); return Socket (INVALID_SOCKET_VALUE, not_opened, errno); @@ -536,7 +536,7 @@ ServerSocket::accept () } // Return Socket with state set to accept_interrupted. - + return Socket (INVALID_SOCKET_VALUE, accept_interrupted, 0); } else if ((accept_fd.revents & POLLIN) == POLLIN) @@ -550,7 +550,7 @@ ServerSocket::accept () int eno = 0; if (clientSock == INVALID_SOCKET_VALUE) eno = get_last_socket_error (); - + return Socket (clientSock, st, eno); } else diff --git a/src/socket.cxx b/src/socket.cxx index a4328333c..938de0a0d 100644 --- a/src/socket.cxx +++ b/src/socket.cxx @@ -88,7 +88,7 @@ AbstractSocket::shutdown() { if(sock != INVALID_SOCKET_VALUE) { shutdownSocket(sock); - } + } } From f23420ec2236a70927df3a6717b40f2c82b6e1ab Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 8 Nov 2015 18:36:28 +0100 Subject: [PATCH 190/226] t/1.1.x/sockets-internal-socket-h Import internal/socket.h from master and accommodate for 1.1.x. Signed-off-by: Vaclav Haisman --- include/log4cplus/internal/socket.h | 133 +++++++++++++++++++++++++--- 1 file changed, 121 insertions(+), 12 deletions(-) diff --git a/include/log4cplus/internal/socket.h b/include/log4cplus/internal/socket.h index e1402e3a2..2f8c5f844 100644 --- a/include/log4cplus/internal/socket.h +++ b/include/log4cplus/internal/socket.h @@ -5,18 +5,18 @@ // Author: Vaclav Haisman // // -// Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. -// +// Copyright (C) 2010-2015, Vaclav Haisman. All rights reserved. +// // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. -// +// // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -28,7 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/** @file +/** @file * This header contains declaration internal to log4cplus. They must never be * visible from user accesible headers or exported in DLL/shared libray. */ @@ -57,25 +57,134 @@ #include #endif +#ifdef LOG4CPLUS_HAVE_UNISTD_H +#include +#endif + +#if defined (LOG4CPLUS_HAVE_NETDB_H) +#include +#endif + namespace log4cplus { namespace helpers { - #if defined(_WIN32) typedef SOCKET os_socket_type; +os_socket_type const INVALID_OS_SOCKET_VALUE = INVALID_SOCKET; + +struct ADDRINFOT_deleter +{ + void + operator () (ADDRINFOA * ptr) const + { + FreeAddrInfoA(ptr); + } + + void + operator () (ADDRINFOW * ptr) const + { + FreeAddrInfoW(ptr); + } +}; + + +struct socket_closer +{ + void + operator () (SOCKET s) + { + if (s && s != INVALID_OS_SOCKET_VALUE) + { + DWORD const eno = WSAGetLastError(); + ::closesocket(s); + WSASetLastError(eno); + } + } +}; + + #else typedef int os_socket_type; +os_socket_type const INVALID_OS_SOCKET_VALUE = -1; + + +struct addrinfo_deleter +{ + void + operator () (struct addrinfo * ptr) const + { + freeaddrinfo(ptr); + } +}; + + +struct socket_closer +{ + void + operator () (os_socket_type s) + { + if (s >= 0) + { + int const eno = errno; + close(s); + errno = eno; + } + } +}; + #endif -os_socket_type const INVALID_OS_SOCKET_VALUE -#if defined(_WIN32) - = INVALID_SOCKET; +struct socket_holder +{ + os_socket_type sock; + + socket_holder() + : sock(INVALID_OS_SOCKET_VALUE) + { } + + socket_holder(os_socket_type s) + : sock(s) + { } + + ~socket_holder() + { + socket_closer()(sock); + } + + void + reset(os_socket_type s = INVALID_OS_SOCKET_VALUE) + { + if (sock != INVALID_OS_SOCKET_VALUE) + socket_closer()(sock); + + sock = s; + } + + os_socket_type + detach() + { + os_socket_type s = sock; + sock = INVALID_OS_SOCKET_VALUE; + return s; + } + +#if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) + socket_holder (socket_holder &&) = delete; + socket_holder (socket_holder const &) = delete; + + socket_holder operator = (socket_holder &&) = delete; + socket_holder operator = (socket_holder const &) = delete; + #else - = -1; +private: + socket_holder (socket_holder const &); + socket_holder operator = (socket_holder const &); + #endif +}; static inline @@ -112,7 +221,7 @@ get_last_socket_error () } // namespace helpers { -} // namespace log4cplus { +} // namespace log4cplus { #endif // LOG4CPLUS_INTERNAL_SOCKET_H_ From 3123439f35f0fd6a69890a7b9c8f54fe4e25d367 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 8 Nov 2015 18:36:28 +0100 Subject: [PATCH 191/226] t/1.1.x/sockets-use-socket-holder Use socket_holder in socket-unix.cxx. Signed-off-by: Vaclav Haisman --- src/socket-unix.cxx | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/socket-unix.cxx b/src/socket-unix.cxx index 6182ae5a4..6b3fabf6f 100644 --- a/src/socket-unix.cxx +++ b/src/socket-unix.cxx @@ -162,8 +162,8 @@ get_host_by_name (char const * hostname, std::string * name, SOCKET_TYPE openSocket(unsigned short port, SocketState& state) { - int sock = ::socket(AF_INET, SOCK_STREAM, 0); - if(sock < 0) { + socket_holder sock_holder (::socket(AF_INET, SOCK_STREAM, 0)); + if(sock_holder.sock < 0) { return INVALID_SOCKET_VALUE; } @@ -174,7 +174,8 @@ openSocket(unsigned short port, SocketState& state) int optval = 1; socklen_t optlen = sizeof (optval); - int ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, &optval, optlen ); + int ret = setsockopt (sock_holder.sock, SOL_SOCKET, SO_REUSEADDR, &optval, + optlen); if (ret != 0) { int const eno = errno; @@ -182,20 +183,16 @@ openSocket(unsigned short port, SocketState& state) + helpers::convertIntegerToString (eno)); } - int retval = bind(sock, reinterpret_cast(&server), - sizeof(server)); + int retval = bind(sock_holder.sock, + reinterpret_cast(&server), sizeof(server)); if (retval < 0) - goto error; + return INVALID_SOCKET_VALUE; - if (::listen(sock, 10)) - goto error; + if (::listen(sock_holder.sock, 10)) + return INVALID_SOCKET_VALUE; state = ok; - return to_log4cplus_socket (sock); - -error: - close (sock); - return INVALID_SOCKET_VALUE; + return to_log4cplus_socket (sock_holder.detach ()); } @@ -203,7 +200,6 @@ SOCKET_TYPE connectSocket(const tstring& hostn, unsigned short port, bool udp, SocketState& state) { struct sockaddr_in server; - int sock; int retval; std::memset (&server, 0, sizeof (server)); @@ -215,26 +211,23 @@ connectSocket(const tstring& hostn, unsigned short port, bool udp, SocketState& server.sin_port = htons(port); server.sin_family = AF_INET; - sock = ::socket(AF_INET, (udp ? SOCK_DGRAM : SOCK_STREAM), 0); - if(sock < 0) { + socket_holder sock_holder ( + ::socket(AF_INET, (udp ? SOCK_DGRAM : SOCK_STREAM), 0)); + if (sock_holder.sock < 0) return INVALID_SOCKET_VALUE; - } socklen_t namelen = sizeof (server); while ( - (retval = ::connect(sock, reinterpret_cast(&server), - namelen)) + (retval = ::connect(sock_holder.sock, + reinterpret_cast(&server), namelen)) == -1 && (errno == EINTR)) ; if (retval == INVALID_OS_SOCKET_VALUE) - { - ::close(sock); return INVALID_SOCKET_VALUE; - } state = ok; - return to_log4cplus_socket (sock); + return to_log4cplus_socket (sock_holder.detach ()); } From fd19bdb48328394c8dfdcf225e2c2371733b126c Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 8 Nov 2015 18:36:28 +0100 Subject: [PATCH 192/226] t/1.1.x/sockets-loggingserver-leak-fix Fix sockets and memory leak in loggingserver discussed in GitHub issue #112. Signed-off-by: Vaclav Haisman --- loggingserver/loggingserver.cxx | 228 ++++++++++++++++++++++++++------ 1 file changed, 187 insertions(+), 41 deletions(-) diff --git a/loggingserver/loggingserver.cxx b/loggingserver/loggingserver.cxx index 31c0d8aae..7bc1e6f9d 100644 --- a/loggingserver/loggingserver.cxx +++ b/loggingserver/loggingserver.cxx @@ -19,22 +19,154 @@ // limitations under the License. #include +#include #include #include #include #include #include #include +#include +#include namespace loggingserver { -class ClientThread : public log4cplus::thread::AbstractThread + +typedef std::list ThreadQueueType; + + +class ReaperThread + : public log4cplus::thread::AbstractThread +{ +public: + ReaperThread (log4cplus::thread::Mutex & mtx_, + log4cplus::thread::ManualResetEvent & ev_, + ThreadQueueType & queue_) + : mtx (mtx_) + , ev (ev_) + , queue (queue_) + , stop (false) + { } + + virtual + ~ReaperThread () + { } + + virtual void run (); + + void signal_exit (); + +private: + log4cplus::thread::Mutex & mtx; + log4cplus::thread::ManualResetEvent & ev; + ThreadQueueType & queue; + bool stop; +}; + + +typedef log4cplus::helpers::SharedObjectPtr ReaperThreadPtr; + + +void +ReaperThread::signal_exit () +{ + log4cplus::thread::MutexGuard guard (mtx); + stop = true; + ev.signal (); +} + + +void +ReaperThread::run () +{ + ThreadQueueType q; + + while (true) + { + ev.timed_wait (30 * 1000); + + { + log4cplus::thread::MutexGuard guard (mtx); + + // Check exit condition as the very first thing. + if (stop) + { + std::cout << "Reaper thread is stopping..." << std::endl; + return; + } + + ev.reset (); + q.swap (queue); + } + + if (! q.empty ()) + { + std::cout << "Reaper thread is reaping " << q.size () << " threads." + << std::endl; + + for (ThreadQueueType::iterator it = q.begin (), end_it = q.end (); + it != end_it; ++it) + { + AbstractThread & t = **it; + t.join (); + } + + q.clear (); + } + } +} + + + +/** + This class wraps ReaperThread thread and its queue. + */ +class Reaper +{ +public: + Reaper () + { + reaper_thread = ReaperThreadPtr (new ReaperThread (mtx, ev, queue)); + reaper_thread->start (); + } + + ~Reaper () + { + reaper_thread->signal_exit (); + reaper_thread->join (); + } + + void visit (log4cplus::thread::AbstractThreadPtr const & thread_ptr); + +private: + log4cplus::thread::Mutex mtx; + log4cplus::thread::ManualResetEvent ev; + ThreadQueueType queue; + ReaperThreadPtr reaper_thread; +}; + + +void +Reaper::visit (log4cplus::thread::AbstractThreadPtr const & thread_ptr) +{ + log4cplus::thread::MutexGuard guard (mtx); + queue.push_back (thread_ptr); + ev.signal (); +} + + + + +class ClientThread + : public log4cplus::thread::AbstractThread { public: - ClientThread(log4cplus::helpers::Socket clientsock) - : clientsock(clientsock) + ClientThread(log4cplus::helpers::Socket clientsock_, Reaper & reaper_) + : self_reference (log4cplus::thread::AbstractThreadPtr (this)) + , clientsock(clientsock_) + , reaper (reaper_) { std::cout << "Received a client connection!!!!" << std::endl; } @@ -47,17 +179,59 @@ class ClientThread : public log4cplus::thread::AbstractThread virtual void run(); private: + log4cplus::thread::AbstractThreadPtr self_reference; log4cplus::helpers::Socket clientsock; + Reaper & reaper; }; -} +void +loggingserver::ClientThread::run() +{ + try + { + while (1) + { + if (!clientsock.isOpen()) + break; + + log4cplus::helpers::SocketBuffer msgSizeBuffer(sizeof(unsigned int)); + if (!clientsock.read(msgSizeBuffer)) + break; + + unsigned int msgSize = msgSizeBuffer.readInt(); + + log4cplus::helpers::SocketBuffer buffer(msgSize); + if (!clientsock.read(buffer)) + break; + + log4cplus::spi::InternalLoggingEvent event + = log4cplus::helpers::readFromBuffer(buffer); + log4cplus::Logger logger + = log4cplus::Logger::getInstance(event.getLoggerName()); + logger.callAppenders(event); + } + } + catch (...) + { + reaper.visit (self_reference); + self_reference = log4cplus::thread::AbstractThreadPtr (); + throw; + } + + reaper.visit (self_reference); + self_reference = log4cplus::thread::AbstractThreadPtr (); +} +} // namespace loggingserver + int main(int argc, char** argv) { + log4cplus::initialize (); + if(argc < 3) { std::cout << "Usage: port config_file" << std::endl; return 1; @@ -70,49 +244,21 @@ main(int argc, char** argv) log4cplus::helpers::ServerSocket serverSocket(port); if (!serverSocket.isOpen()) { - std::cout << "Could not open server socket, maybe port " + std::cerr << "Could not open server socket, maybe port " << port << " is already in use." << std::endl; return 2; } - while(1) { - loggingserver::ClientThread *thr = - new loggingserver::ClientThread(serverSocket.accept()); + loggingserver::Reaper reaper; + + for (;;) + { + loggingserver::ClientThread *thr = + new loggingserver::ClientThread(serverSocket.accept(), reaper); thr->start(); } - return 0; -} - - -//////////////////////////////////////////////////////////////////////////////// -// loggingserver::ClientThread implementation -//////////////////////////////////////////////////////////////////////////////// + log4cplus::Logger::shutdown(); - -void -loggingserver::ClientThread::run() -{ - while(1) { - if(!clientsock.isOpen()) { - return; - } - log4cplus::helpers::SocketBuffer msgSizeBuffer(sizeof(unsigned int)); - if(!clientsock.read(msgSizeBuffer)) { - return; - } - - unsigned int msgSize = msgSizeBuffer.readInt(); - - log4cplus::helpers::SocketBuffer buffer(msgSize); - if(!clientsock.read(buffer)) { - return; - } - - log4cplus::spi::InternalLoggingEvent event - = log4cplus::helpers::readFromBuffer(buffer); - log4cplus::Logger logger - = log4cplus::Logger::getInstance(event.getLoggerName()); - logger.callAppenders(event); - } + return 0; } From 77389655bf6f5ffda0e7622ba0417364846d6c08 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Tue, 10 Nov 2015 21:47:33 +0100 Subject: [PATCH 193/226] Update ChangeLog. --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index e2a522385..e546cdeb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +log4cplus 1.1.3-RC6 + +- Fixed GitHub issue #112 - sockets and memory leak in loggingserver. + + log4cplus 1.1.3-RC5 - Fixed "most vexing parse" issue when using LOG4CPLUS_C_STR_TO_TSTRING(). From dc130ac588fa31c4440c233ad5c7c521aac35d9a Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 18 Dec 2015 09:12:45 +0100 Subject: [PATCH 194/226] Fix possibly broken format of .dir-locals.el. --- .dir-locals.el | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 9a7bcdb11..ef507e566 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,15 +1,14 @@ ;;; Directory Local Variables ;;; See Info node `(emacs) Directory Variables' for more information. -((nil - (fill-column . 79) - (indent-tabs-mode) - (show-trailing-whitespace . t) - (whitespace-style face trailing lines-tail space-before-tab indentation empty) - (whitespace-newline . t)) - (c++-mode - (tab-width . 4) - (whitespace-action warn-read-only auto-cleanup)) - (cmake-mode - (whitespace-action warn-read-only auto-cleanup))) - +((nil . + ((fill-column . 79) + (indent-tabs-mode) + (show-trailing-whitespace . t) + (whitespace-style face trailing lines-tail space-before-tab indentation empty) + (whitespace-newline . t))) + (c++-mode . + ((tab-width . 4) + (whitespace-action warn-read-only auto-cleanup))) + (cmake-mode . + ((whitespace-action warn-read-only auto-cleanup)))) From 7b329b75d2e644e82ef6dbd1e2d433ba5682cc7b Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Thu, 17 Dec 2015 17:56:59 +0100 Subject: [PATCH 195/226] Use InterlockedAdd() to load WinSock state. --- src/socket-win32.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index adfc80e67..2acd047be 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -89,7 +89,8 @@ init_winsock_worker () // Wait for state change. while (true) { - switch (winsock_state) + LONG state = InterlockedAdd (&winsock_state, 0); + switch (state) { case WS_INITIALIZED: return; From b2ca6deb3662ec7a2270a4403bef5c7b1f1f73d0 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 11 Dec 2015 13:05:15 +0100 Subject: [PATCH 196/226] Remove redundant comparison in socket-unix.cxx. Resolve SF#321. Patch provided by: Garima at users dot sourceforge dot net --- src/socket-unix.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socket-unix.cxx b/src/socket-unix.cxx index 6b3fabf6f..24d8fe0e9 100644 --- a/src/socket-unix.cxx +++ b/src/socket-unix.cxx @@ -373,7 +373,7 @@ getHostname (bool fqdn) break; } #if defined (LOG4CPLUS_HAVE_ENAMETOOLONG) - else if (ret != 0 && errno == ENAMETOOLONG) + else if (errno == ENAMETOOLONG) // Out buffer was too short. Retry with buffer twice the size. hn.resize (hn.size () * 2, 0); #endif From cd0d4c9b897e9c605b47ab060a924d650859e3a1 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Tue, 15 Dec 2015 07:58:40 +0100 Subject: [PATCH 197/226] Fix compilation with Visual Studio 2010 (SF#322). Avoid delete'd constructor and move assignment operator since Visual Studio 2010 does not support it. --- include/log4cplus/internal/socket.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/log4cplus/internal/socket.h b/include/log4cplus/internal/socket.h index 2f8c5f844..988c1a1b9 100644 --- a/include/log4cplus/internal/socket.h +++ b/include/log4cplus/internal/socket.h @@ -171,18 +171,13 @@ struct socket_holder return s; } -#if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) - socket_holder (socket_holder &&) = delete; - socket_holder (socket_holder const &) = delete; - - socket_holder operator = (socket_holder &&) = delete; - socket_holder operator = (socket_holder const &) = delete; - -#else private: socket_holder (socket_holder const &); socket_holder operator = (socket_holder const &); +#if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) + socket_holder (socket_holder &&); + socket_holder operator = (socket_holder &&); #endif }; From dfa775f1ff8497668f24176ba0f41d197e55925b Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 18 Dec 2015 10:00:49 +0100 Subject: [PATCH 198/226] Fix build issue (SF#322) on Windows. Fix missing `FreeAddrInfoW()` and `FreeAddrInfoA()` symbols by bumping required version of Windows from XP SP1 to XP SP2. --- msvc10/log4cplus.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msvc10/log4cplus.props b/msvc10/log4cplus.props index 5ca303bc3..4865c2e1f 100755 --- a/msvc10/log4cplus.props +++ b/msvc10/log4cplus.props @@ -9,7 +9,7 @@ ..\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;INSIDE_LOG4CPLUS;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;NTDDI_VERSION=0x05010200;INSIDE_LOG4CPLUS;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true $(IntDir)$(ProjectName).pch $(IntDir) From 6da550695d024b2a2705db5ec819c33980ef4ac8 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 18 Dec 2015 10:02:37 +0100 Subject: [PATCH 199/226] Use _WINSOCK_DEPRECATED_NO_WARNINGS for Windows builds. --- msvc10/log4cplus.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msvc10/log4cplus.props b/msvc10/log4cplus.props index 4865c2e1f..1094604f3 100755 --- a/msvc10/log4cplus.props +++ b/msvc10/log4cplus.props @@ -9,7 +9,7 @@ ..\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;NTDDI_VERSION=0x05010200;INSIDE_LOG4CPLUS;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;NTDDI_VERSION=0x05010200;INSIDE_LOG4CPLUS;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) true $(IntDir)$(ProjectName).pch $(IntDir) From 83bf3fddba4b21517115f83cd0cc4ea4e6513f45 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 8 Jan 2016 19:59:19 +0100 Subject: [PATCH 200/226] Use InterlockedExchangeAdd. Use InterlockedExchangeAdd instead of InterlockedAdd. The former is supported by older MinGW and in this situation it does not matter which one we use in this situation. This fixes SF#324. (cherry picked from commit 3636758821e8c3c393644e5c25bd057e392b5445) --- src/socket-win32.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socket-win32.cxx b/src/socket-win32.cxx index 2acd047be..aee68dbfe 100644 --- a/src/socket-win32.cxx +++ b/src/socket-win32.cxx @@ -89,7 +89,7 @@ init_winsock_worker () // Wait for state change. while (true) { - LONG state = InterlockedAdd (&winsock_state, 0); + LONG state = InterlockedExchangeAdd (&winsock_state, 0); switch (state) { case WS_INITIALIZED: From 5a9e82a6f30834d705e96f855e58c8a1f78ff306 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 15 Jan 2016 19:32:44 +0100 Subject: [PATCH 201/226] Detect GCC attribute __deprecated__. Detec GCC attribute `__deprecated__` and define `LOG4CPLUS_ATTRIBUTE_DEPRECATED` if it found. Related to GitHub bug #137. --- include/log4cplus/config.hxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index 608e76239..dfd984150 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -120,12 +120,14 @@ #if defined (__GNUC__) && __GNUC__ >= 3 # define LOG4CPLUS_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # define LOG4CPLUS_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# define LOG4CPLUS_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) __builtin_expect ((exp), (c)) #else # if ! defined (LOG4CPLUS_ATTRIBUTE_NORETURN) # define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */ # endif # define LOG4CPLUS_ATTRIBUTE_PURE /* empty */ +# define LOG4CPLUS_ATTRIBUTE_DEPRECATED /* empty */ # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) (exp) #endif From 3c39e40f0f1601a1009a9c3d9511728f8a26ebba Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 15 Jan 2016 19:35:03 +0100 Subject: [PATCH 202/226] Fix missing thread's alternative name. GitHub bug #137. --- include/log4cplus/spi/loggingevent.h | 11 +++++++++++ src/loggingevent.cxx | 29 ++++++++++++++++++++++++++-- src/socketappender.cxx | 7 ++++--- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/include/log4cplus/spi/loggingevent.h b/include/log4cplus/spi/loggingevent.h index e57bd6e14..c2d4596fc 100644 --- a/include/log4cplus/spi/loggingevent.h +++ b/include/log4cplus/spi/loggingevent.h @@ -66,12 +66,23 @@ namespace log4cplus { LogLevel loglevel, const log4cplus::tstring& message, const char* filename, int line); + //! This constructor is deprecated in favor of the next one because + //! of the additional `thread2` parameter. InternalLoggingEvent(const log4cplus::tstring& logger, LogLevel loglevel, const log4cplus::tstring& ndc, MappedDiagnosticContextMap const & mdc, const log4cplus::tstring& message, const log4cplus::tstring& thread, log4cplus::helpers::Time time, const log4cplus::tstring& file, + int line) LOG4CPLUS_ATTRIBUTE_DEPRECATED; + + InternalLoggingEvent(const log4cplus::tstring& logger, + LogLevel loglevel, const log4cplus::tstring& ndc, + MappedDiagnosticContextMap const & mdc, + const log4cplus::tstring& message, + const log4cplus::tstring& thread, + const log4cplus::tstring& thread2, + log4cplus::helpers::Time time, const log4cplus::tstring& file, int line); InternalLoggingEvent (); diff --git a/src/loggingevent.cxx b/src/loggingevent.cxx index 5279a1e87..bc0fe8399 100644 --- a/src/loggingevent.cxx +++ b/src/loggingevent.cxx @@ -44,7 +44,7 @@ InternalLoggingEvent::InternalLoggingEvent(const log4cplus::tstring& logger, , thread() , timestamp(log4cplus::helpers::Time::gettimeofday()) , file(filename - ? LOG4CPLUS_C_STR_TO_TSTRING(filename) + ? LOG4CPLUS_C_STR_TO_TSTRING(filename) : log4cplus::tstring()) , function () , line(line_) @@ -79,6 +79,30 @@ InternalLoggingEvent::InternalLoggingEvent(const log4cplus::tstring& logger, } +InternalLoggingEvent::InternalLoggingEvent(const log4cplus::tstring& logger, + LogLevel loglevel, const log4cplus::tstring& ndc_, + MappedDiagnosticContextMap const & mdc_, const log4cplus::tstring& message_, + const log4cplus::tstring& thread_, const log4cplus::tstring& thread2_, + log4cplus::helpers::Time time, const log4cplus::tstring& file_, int line_) + : message(message_) + , loggerName(logger) + , ll(loglevel) + , ndc(ndc_) + , mdc(mdc_) + , thread(thread_) + , thread2(thread2_) + , timestamp(time) + , file(file_) + , function () + , line(line_) + , threadCached(true) + , thread2Cached(true) + , ndcCached(true) + , mdcCached(true) +{ +} + + InternalLoggingEvent::InternalLoggingEvent () : ll (NOT_SET_LOG_LEVEL) , function () @@ -98,6 +122,7 @@ InternalLoggingEvent::InternalLoggingEvent( , ndc(rhs.getNDC()) , mdc(rhs.getMDCCopy()) , thread(rhs.getThread()) + , thread2(rhs.getThread2()) , timestamp(rhs.getTimestamp()) , file(rhs.getFile()) , function(rhs.getFunction()) @@ -174,7 +199,7 @@ InternalLoggingEvent::setFunction (log4cplus::tstring const & func) } -const log4cplus::tstring& +const log4cplus::tstring& InternalLoggingEvent::getMessage() const { return message; diff --git a/src/socketappender.cxx b/src/socketappender.cxx index 87db0bab1..f16ad9fc6 100644 --- a/src/socketappender.cxx +++ b/src/socketappender.cxx @@ -26,6 +26,7 @@ #include #include #include +#include namespace log4cplus { @@ -168,7 +169,7 @@ SocketAppender::~SocketAppender() // SocketAppender public methods ////////////////////////////////////////////////////////////////////////////// -void +void SocketAppender::close() { helpers::getLogLog().debug( @@ -315,8 +316,8 @@ readFromBuffer(SocketBuffer& buffer) // TODO: Pass MDC through. spi::InternalLoggingEvent ev (loggerName, ll, ndc, - MappedDiagnosticContextMap (), message, thread, Time(sec, usec), file, - line); + MappedDiagnosticContextMap (), message, thread, internal::empty_str, + Time(sec, usec), file, line); ev.setFunction (function); return ev; } From dcdff7e248f09bf8d19826814a30862e195db8f5 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 15 Jan 2016 19:44:14 +0100 Subject: [PATCH 203/226] Bump SO versions for last changes. GitHub bug #137. --- CMakeLists.txt | 2 +- configure | 2 +- configure.ac | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b047fb77..6595e9966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include (Log4CPlusUtils.cmake) log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include" log4cplus_version_major log4cplus_version_minor log4cplus_version_patch) message("-- Generating build for Log4cplus version ${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}") -set (log4cplus_soversion 10) +set (log4cplus_soversion 11) set (log4cplus_postfix "") option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) diff --git a/configure b/configure index 0470e5d7f..b26a8c2c8 100755 --- a/configure +++ b/configure @@ -4225,7 +4225,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=10:3:1 +LT_VERSION=11:4:2 LT_RELEASE=1.1 diff --git a/configure.ac b/configure.ac index 95da96ac1..293a9c234 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=10:3:1 +LT_VERSION=11:4:2 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) From 803f3acc030b9b1935fed97e062bfdb30d1d54af Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sat, 16 Jan 2016 18:39:52 +0100 Subject: [PATCH 204/226] Another small fix for GitHub bug #137. --- src/loggingevent.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/loggingevent.cxx b/src/loggingevent.cxx index bc0fe8399..fb67a1df2 100644 --- a/src/loggingevent.cxx +++ b/src/loggingevent.cxx @@ -270,6 +270,7 @@ InternalLoggingEvent::swap (InternalLoggingEvent & other) swap (function, other.function); swap (line, other.line); swap (threadCached, other.threadCached); + swap (thread2Cached, other.thread2Cached); swap (ndcCached, other.ndcCached); } From d44daac2d36f8d1a4fa9b7f984bf80f53494f624 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 14 Mar 2016 13:41:29 +0100 Subject: [PATCH 205/226] Fix/work around GitHub bug #155. Here we check that we can get CRT's heap handle because if we do not then the following `delete` will fail with access violation in `RtlFreeHeap()`. How is it possible that the CRT heap handle is NULL? This function can be called from TLS initializer/terminator by loader when log4cplus is compiled and linked to as a static library. In case of other threads temination, it should do its job and free per-thread data. However, when the whole process is being terminated, it is called after the CRT has been uninitialized and the CRT heap is not available any more. In such case, instead of crashing, we just give up and leak the memory for the short while before the process terminates anyway. It is possible to work around this situation in user application by calling `threadCleanup()` manually before `main()` exits. --- src/global-init.cxx | 78 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 8 deletions(-) diff --git a/src/global-init.cxx b/src/global-init.cxx index 7d1985f36..e74227b05 100644 --- a/src/global-init.cxx +++ b/src/global-init.cxx @@ -387,9 +387,38 @@ initialize () void threadCleanup () { - // Do thread-specific cleanup. - internal::per_thread_data * ptd = internal::get_ptd (false); - delete ptd; + // Here we check that we can get CRT's heap handle because if we do not + // then the following `delete` will fail with access violation in + // `RtlFreeHeap()`. + // + // How is it possible that the CRT heap handle is NULL? + // + // This function can be called from TLS initializer/terminator by loader + // when log4cplus is compiled and linked to as a static library. In case of + // other threads temination, it should do its job and free per-thread + // data. However, when the whole process is being terminated, it is called + // after the CRT has been uninitialized and the CRT heap is not available + // any more. In such case, instead of crashing, we just give up and leak + // the memory for the short while before the process terminates anyway. + // + // It is possible to work around this situation in user application by + // calling `threadCleanup()` manually before `main()` exits. +#if defined (_WIN32) + if (_get_heap_handle() != 0) + { +#endif + // Do thread-specific cleanup. + internal::per_thread_data * ptd = internal::get_ptd (false); + delete ptd; +#if defined (_WIN32) + } + else + { + OutputDebugString ( + LOG4CPLUS_TEXT ("log4cplus: ") + LOG4CPLUS_TEXT ("CRT heap is already gone in threadCleanup()\n")); + } +#endif internal::set_ptd (0); } @@ -463,6 +492,25 @@ thread_callback (LPVOID /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpReserved*/) } // switch } + +static +void NTAPI +thread_callback_initializer(LPVOID hinstDLL, DWORD fdwReason, LPVOID lpReserved) +{ + if (fdwReason == DLL_PROCESS_ATTACH + || fdwReason == DLL_THREAD_ATTACH) + thread_callback(hinstDLL, fdwReason, lpReserved); +} + +static +void NTAPI +thread_callback_terminator(LPVOID hinstDLL, DWORD fdwReason, LPVOID lpReserved) +{ + if (fdwReason == DLL_THREAD_DETACH + || fdwReason == DLL_PROCESS_DETACH) + thread_callback(hinstDLL, fdwReason, lpReserved); +} + #endif @@ -489,22 +537,36 @@ extern "C" // This magic has been pieced together from several sources: // - // - +// - `internal_shared.h` in CRT source in Visual Studio 2015 + +#pragma data_seg (push, old_seg) +#ifdef _WIN64 +#pragma const_seg (".CRT$XLY") +extern const +#else +#pragma data_seg (".CRT$XLY") +#endif +PIMAGE_TLS_CALLBACK log4cplus_p_thread_callback_initializer = log4cplus::thread_callback_initializer; +#pragma data_seg (pop, old_seg) #pragma data_seg (push, old_seg) #ifdef _WIN64 -#pragma const_seg (".CRT$XLX") +#pragma const_seg (".CRT$XLAA") extern const #else -#pragma data_seg (".CRT$XLX") +#pragma data_seg (".CRT$XLAA") #endif -PIMAGE_TLS_CALLBACK log4cplus_p_thread_callback = log4cplus::thread_callback; +PIMAGE_TLS_CALLBACK log4cplus_p_thread_callback_terminator = log4cplus::thread_callback_terminator; #pragma data_seg (pop, old_seg) + #ifdef _WIN64 #pragma comment (linker, "/INCLUDE:_tls_used") -#pragma comment (linker, "/INCLUDE:log4cplus_p_thread_callback") +#pragma comment (linker, "/INCLUDE:log4cplus_p_thread_callback_initializer") +#pragma comment (linker, "/INCLUDE:log4cplus_p_thread_callback_terminator") #else #pragma comment (linker, "/INCLUDE:__tls_used") -#pragma comment (linker, "/INCLUDE:_log4cplus_p_thread_callback") +#pragma comment (linker, "/INCLUDE:_log4cplus_p_thread_callback_initializer") +#pragma comment (linker, "/INCLUDE:_log4cplus_p_thread_callback_terminator") #endif } // extern "C" From fc607a3a659463aaded2aa2a9fd89739cfefc7ea Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 17 Jan 2016 18:31:53 +0100 Subject: [PATCH 206/226] Fix GitHub bug #136. Adjust weekly, daily and twice daily rollover time for `DailyRollingFileAppender` by time zone offset so that the rollover happens at midnight, etc., of local time instead of UTC time. --- src/fileappender.cxx | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/fileappender.cxx b/src/fileappender.cxx index 9b343c750..8a454e6ec 100644 --- a/src/fileappender.cxx +++ b/src/fileappender.cxx @@ -659,6 +659,33 @@ round_time_and_add (Time const & t, Time const & seconds) } +static +long +local_time_offset (Time t) +{ + tm time_local, time_gmt; + + t.localtime (&time_local); + t.gmtime (&time_gmt); + + t.setTime (&time_local); + Time t2 = t; + + t.setTime (&time_gmt); + Time t3 = t; + + return t2.sec () - t3.sec (); +} + + +static +Time +adjust_for_time_zone (Time const & t, long tzoffset) +{ + return t - Time (tzoffset); +} + + } // namespace @@ -860,7 +887,10 @@ DailyRollingFileAppender::calculateNextRolloverTime(const Time& t) const } case WEEKLY: - return round_time (t, 24 * 60 * 60) + Time (7 * 24 * 60 * 60); + { + Time next = round_time (t, 24 * 60 * 60) + Time (7 * 24 * 60 * 60); + return adjust_for_time_zone (next, local_time_offset (next)); + } default: helpers::getLogLog ().error ( @@ -869,10 +899,16 @@ DailyRollingFileAppender::calculateNextRolloverTime(const Time& t) const // Fall through. case DAILY: - return round_time_and_add (t, Time (24 * 60 * 60)); + { + Time next = round_time_and_add (t, Time (24 * 60 * 60)); + return adjust_for_time_zone (next, local_time_offset (next)); + } case TWICE_DAILY: - return round_time_and_add (t, Time (12 * 60 * 60)); + { + Time next = round_time_and_add (t, Time (12 * 60 * 60)); + return adjust_for_time_zone (next, local_time_offset (next)); + } case HOURLY: return round_time_and_add (t, Time (60 * 60)); From 54a381eb35094ccb1b14b6df2620049ba7d1bc8f Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Wed, 3 Aug 2016 16:25:30 +0200 Subject: [PATCH 207/226] Fix CMake/Visual Studio 2010 compilation. GitHub issue #188. --- CMakeLists.txt | 3 ++- src/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6595e9966..00c1a9a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,8 @@ option(ENABLE_SYMBOLS_VISIBILITY "Enable compiler and platform specific options for symbols visibility" ON) -set(_WIN32_WINNT 0x0500 CACHE STRING "Define Windows API version to use.") +set(_WIN32_WINNT 0x0501 CACHE STRING "Define Windows API version to use.") +set(NTDDI_VERSION 0x05010200 CACHE STRING "Define Windows API version for NTDDI_VERSION") option(LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME "Turns on resulting file name decoration for static and UNICODE builds." ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 75c06186c..43e034f88 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,6 +71,7 @@ endif (UNICODE) if (WIN32) add_definitions (-DMINGW_HAS_SECURE_API=1) add_definitions (-D_WIN32_WINNT=${_WIN32_WINNT}) + add_definitions (-DNTDDI_VERSION=${NTDDI_VERSION}) if (BUILD_SHARED_LIBS) set(log4cplus_build_shared 1) From 03b4a53663809b637f2e7eac461b4c2dacbafa2d Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 5 Aug 2016 21:20:31 +0200 Subject: [PATCH 208/226] Update ChangeLog for 1.1.3-RC7. --- ChangeLog | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index e546cdeb5..3fe95eac4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +log4cplus 1.1.3-RC7 + +- Fixed SF#322. -- C++11 construct that should not be present. + +- Fixed FreeAddrInfoA and FreeAddrInfoW not found. -- This required bump to + minimal version to Windows XP SP2. + +- Fixed missing thread's alternative name. -- GitHub bug #137. + +- Fixed GitHub bug #155. -- Process shutdown issues. + +- Fix GitHub bug #136. -- Adjust weekly, daily and twice daily rollover time + for `DailyRollingFileAppender` by time zone offset so that the rollover + happens at midnight, etc., of local time instead of UTC time. + +- Fix CMake/Visual Studio 2010 compilation. -- GitHub issue #188. + + log4cplus 1.1.3-RC6 - Fixed GitHub issue #112 - sockets and memory leak in loggingserver. From 41dc4c1bcbe2d21d329d66e76377b01ae639a909 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 3 Oct 2016 18:56:36 +0200 Subject: [PATCH 209/226] Fix GitHub bug #195. Check if queue thread pointer is not NULL and if it is running before trying to join it. --- src/asyncappender.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/asyncappender.cxx b/src/asyncappender.cxx index eddf0f0ec..d509db1c1 100644 --- a/src/asyncappender.cxx +++ b/src/asyncappender.cxx @@ -1,15 +1,15 @@ // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. -// +// // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -159,7 +159,9 @@ AsyncAppender::close () if (ret & (thread::Queue::ERROR_BIT | thread::Queue::ERROR_AFTER)) getErrorHandler ()->error ( LOG4CPLUS_TEXT ("Error in AsyncAppender::close")); - queue_thread->join (); + + if (queue_thread && queue_thread->isRunning ()) + queue_thread->join (); } From ded813ca0385a2e677865c422192e913108c8f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Haisman?= Date: Fri, 19 Aug 2016 07:11:03 +0200 Subject: [PATCH 210/226] Fix SF#333. AsyncAppender's appenders need to be closed so that accumulated logs get flushed onto disk. --- src/asyncappender.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/asyncappender.cxx b/src/asyncappender.cxx index d509db1c1..fe55bf7ff 100644 --- a/src/asyncappender.cxx +++ b/src/asyncappender.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. +// Copyright (C) 2009-2016, Vaclav Haisman. All rights reserved. // // Redistribution and use in source and binary forms, with or without modifica- // tion, are permitted provided that the following conditions are met: @@ -162,6 +162,8 @@ AsyncAppender::close () if (queue_thread && queue_thread->isRunning ()) queue_thread->join (); + + removeAllAppenders(); } From aede48057a81b8b87affc6940f1512cb89974de9 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Fri, 11 Nov 2016 23:10:32 +0100 Subject: [PATCH 211/226] Update android.toolchain.cmake from OpenCV. --- android/android.toolchain.cmake | 807 ++++++++++++++++---------------- 1 file changed, 396 insertions(+), 411 deletions(-) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index 1b9880e1d..1d69b7504 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -1,5 +1,5 @@ # Copyright (c) 2010-2011, Ethan Rublee -# Copyright (c) 2011-2013, Andrey Kamaev +# Copyright (c) 2011-2014, Andrey Kamaev # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -12,9 +12,9 @@ # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # -# 3. The name of the copyright holders may be used to endorse or promote -# products derived from this software without specific prior written -# permission. +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -29,28 +29,19 @@ # POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------ -# Android CMake toolchain file, for use with the Android NDK r5-r8 -# Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended). +# Android CMake toolchain file, for use with the Android NDK r5-r10d +# Requires cmake 2.6.3 or newer (2.8.9 or newer is recommended). # See home page: https://github.com/taka-no-me/android-cmake # -# The file is mantained by the OpenCV project. The latest version can be get at -# http://code.opencv.org/projects/opencv/repository/revisions/master/changes/android/android.toolchain.cmake -# # Usage Linux: # $ export ANDROID_NDK=/absolute/path/to/the/android-ndk # $ mkdir build && cd build # $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake .. # $ make -j8 # -# Usage Linux (using standalone toolchain): -# $ export ANDROID_STANDALONE_TOOLCHAIN=/absolute/path/to/android-toolchain -# $ mkdir build && cd build -# $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake .. -# $ make -j8 -# # Usage Windows: # You need native port of make to build your project. -# Android NDK r7 (or newer) already has make.exe on board. +# Android NDK r7 (and newer) already has make.exe on board. # For older NDK you have to install it separately. # For example, this one: http://gnuwin32.sourceforge.net/packages/make.htm # @@ -66,51 +57,64 @@ # ANDROID_NDK=/opt/android-ndk - path to the NDK root. # Can be set as environment variable. Can be set only at first cmake run. # -# ANDROID_STANDALONE_TOOLCHAIN=/opt/android-toolchain - path to the -# standalone toolchain. This option is not used if full NDK is found -# (ignored if ANDROID_NDK is set). -# Can be set as environment variable. Can be set only at first cmake run. -# # ANDROID_ABI=armeabi-v7a - specifies the target Application Binary # Interface (ABI). This option nearly matches to the APP_ABI variable # used by ndk-build tool from Android NDK. # # Possible targets are: -# "armeabi" - matches to the NDK ABI with the same name. -# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. -# "armeabi-v7a" - matches to the NDK ABI with the same name. -# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. +# "armeabi" - ARMv5TE based CPU with software floating point operations +# "armeabi-v7a" - ARMv7 based devices with hardware FPU instructions +# this ABI target is used by default +# "armeabi-v7a-hard with NEON" - ARMv7 based devices with hardware FPU instructions and hardfp # "armeabi-v7a with NEON" - same as armeabi-v7a, but # sets NEON as floating-point unit # "armeabi-v7a with VFPV3" - same as armeabi-v7a, but -# sets VFPV3 as floating-point unit (has 32 registers instead of 16). -# "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP. -# "x86" - matches to the NDK ABI with the same name. -# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. -# "mips" - matches to the NDK ABI with the same name -# (It is not tested on real devices by the authos of this toolchain) -# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. +# sets VFPV3 as floating-point unit (has 32 registers instead of 16) +# "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP +# "x86" - IA-32 instruction set +# "mips" - MIPS32 instruction set +# +# 64-bit ABIs for NDK r10 and newer: +# "arm64-v8a" - ARMv8 AArch64 instruction set +# "x86_64" - Intel64 instruction set (r1) +# "mips64" - MIPS64 instruction set (r6) # # ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for. # Option is read-only when standalone toolchain is used. +# Note: building for "android-L" requires explicit configuration. # -# ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.6 - the name of compiler +# ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 - the name of compiler # toolchain to be used. The list of possible values depends on the NDK -# version. For NDK r8c the possible values are: +# version. For NDK r10c the possible values are: # -# * arm-linux-androideabi-4.4.3 +# * aarch64-linux-android-4.9 +# * aarch64-linux-android-clang3.4 +# * aarch64-linux-android-clang3.5 # * arm-linux-androideabi-4.6 -# * arm-linux-androideabi-clang3.1 -# * mipsel-linux-android-4.4.3 +# * arm-linux-androideabi-4.8 +# * arm-linux-androideabi-4.9 (default) +# * arm-linux-androideabi-clang3.4 +# * arm-linux-androideabi-clang3.5 +# * mips64el-linux-android-4.9 +# * mips64el-linux-android-clang3.4 +# * mips64el-linux-android-clang3.5 # * mipsel-linux-android-4.6 -# * mipsel-linux-android-clang3.1 -# * x86-4.4.3 +# * mipsel-linux-android-4.8 +# * mipsel-linux-android-4.9 +# * mipsel-linux-android-clang3.4 +# * mipsel-linux-android-clang3.5 # * x86-4.6 -# * x86-clang3.1 +# * x86-4.8 +# * x86-4.9 +# * x86-clang3.4 +# * x86-clang3.5 +# * x86_64-4.9 +# * x86_64-clang3.4 +# * x86_64-clang3.5 # # ANDROID_FORCE_ARM_BUILD=OFF - set ON to generate 32-bit ARM instructions -# instead of Thumb. Is not available for "x86" (inapplicable) and -# "armeabi-v6 with VFP" (is forced to be ON) ABIs. +# instead of Thumb. Is not available for "armeabi-v6 with VFP" +# (is forced to be ON) ABI. # # ANDROID_NO_UNDEFINED=ON - set ON to show all undefined symbols as linker # errors even if they are not used. @@ -119,13 +123,6 @@ # libraries. Automatically turned for NDK r5x and r6x due to GLESv2 # problems. # -# LIBRARY_OUTPUT_PATH_ROOT=${CMAKE_SOURCE_DIR} - where to output binary -# files. See additional details below. -# -# ANDROID_SET_OBSOLETE_VARIABLES=ON - if set, then toolchain defines some -# obsolete variables which were used by previous versions of this file for -# backward compatibility. -# # ANDROID_STL=gnustl_static - specify the runtime to use. # # Possible values are: @@ -158,6 +155,10 @@ # Implies -frtti -fno-exceptions. # Available for NDK r7b and newer. # Silently degrades to gnustl_static if not available. +# c++_static -> Use the LLVM libc++ runtime as a static library. +# Implies -frtti -fexceptions. +# c++_shared -> Use the LLVM libc++ runtime as a static library. +# Implies -frtti -fno-exceptions. # # ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on # chosen runtime. If disabled, then the user is responsible for settings @@ -182,116 +183,10 @@ # ANDROID and BUILD_ANDROID will be set to true, you may test any of these # variables to make necessary Android-specific configuration changes. # -# Also ARMEABI or ARMEABI_V7A or X86 or MIPS will be set true, mutually -# exclusive. NEON option will be set true if VFP is set to NEON. +# Also ARMEABI or ARMEABI_V7A or ARMEABI_V7A_HARD or X86 or MIPS or ARM64_V8A or X86_64 or MIPS64 +# will be set true, mutually exclusive. NEON option will be set true +# if VFP is set to NEON. # -# LIBRARY_OUTPUT_PATH_ROOT should be set in cache to determine where Android -# libraries will be installed. -# Default is ${CMAKE_SOURCE_DIR}, and the android libs will always be -# under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME} -# (depending on the target ABI). This is convenient for Android packaging. -# -# Change Log: -# - initial version December 2010 -# - April 2011 -# [+] added possibility to build with NDK (without standalone toolchain) -# [+] support cross-compilation on Windows (native, no cygwin support) -# [+] added compiler option to force "char" type to be signed -# [+] added toolchain option to compile to 32-bit ARM instructions -# [+] added toolchain option to disable SWIG search -# [+] added platform "armeabi-v7a with VFPV3" -# [~] ARM_TARGETS renamed to ARM_TARGET -# [+] EXECUTABLE_OUTPUT_PATH is set by toolchain (required on Windows) -# [~] Fixed bug with ANDROID_API_LEVEL variable -# [~] turn off SWIG search if it is not found first time -# - May 2011 -# [~] ANDROID_LEVEL is renamed to ANDROID_API_LEVEL -# [+] ANDROID_API_LEVEL is detected by toolchain if not specified -# [~] added guard to prevent changing of output directories on the first -# cmake pass -# [~] toolchain exits with error if ARM_TARGET is not recognized -# - June 2011 -# [~] default NDK path is updated for version r5c -# [+] variable CMAKE_SYSTEM_PROCESSOR is set based on ARM_TARGET -# [~] toolchain install directory is added to linker paths -# [-] removed SWIG-related stuff from toolchain -# [+] added macro find_host_package, find_host_program to search -# packages/programs on the host system -# [~] fixed path to STL library -# - July 2011 -# [~] fixed options caching -# [~] search for all supported NDK versions -# [~] allowed spaces in NDK path -# - September 2011 -# [~] updated for NDK r6b -# - November 2011 -# [*] rewritten for NDK r7 -# [+] x86 toolchain support (experimental) -# [+] added "armeabi-v6 with VFP" ABI for ARMv6 processors. -# [~] improved compiler and linker flags management -# [+] support different build flags for Release and Debug configurations -# [~] by default compiler flags the same as used by ndk-build (but only -# where reasonable) -# [~] ANDROID_NDK_TOOLCHAIN_ROOT is splitted to ANDROID_STANDALONE_TOOLCHAIN -# and ANDROID_TOOLCHAIN_ROOT -# [~] ARM_TARGET is renamed to ANDROID_ABI -# [~] ARMEABI_NDK_NAME is renamed to ANDROID_NDK_ABI_NAME -# [~] ANDROID_API_LEVEL is renamed to ANDROID_NATIVE_API_LEVEL -# - January 2012 -# [+] added stlport_static support (experimental) -# [+] added special check for cygwin -# [+] filtered out hidden files (starting with .) while globbing inside NDK -# [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6 -# [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags -# - February 2012 -# [+] updated for NDK r7b -# [~] fixed cmake try_compile() command -# [~] Fix for missing install_name_tool on OS X -# - March 2012 -# [~] fixed incorrect C compiler flags -# [~] fixed CMAKE_SYSTEM_PROCESSOR change on ANDROID_ABI change -# [+] improved toolchain loading speed -# [+] added assembler language support (.S) -# [+] allowed preset search paths and extra search suffixes -# - April 2012 -# [+] updated for NDK r7c -# [~] fixed most of problems with compiler/linker flags and caching -# [+] added option ANDROID_FUNCTION_LEVEL_LINKING -# - May 2012 -# [+] updated for NDK r8 -# [+] added mips architecture support -# - August 2012 -# [+] updated for NDK r8b -# [~] all intermediate files generated by toolchain are moved to CMakeFiles -# [~] libstdc++ and libsupc are removed from explicit link libraries -# [+] added CCache support (via NDK_CCACHE environment or cmake variable) -# [+] added gold linker support for NDK r8b -# [~] fixed mips linker flags for NDK r8b -# - September 2012 -# [+] added NDK release name detection (see ANDROID_NDK_RELEASE) -# [+] added support for all C++ runtimes from NDK -# (system, gabi++, stlport, gnustl) -# [+] improved warnings on known issues of NDKs -# [~] use gold linker as default if available (NDK r8b) -# [~] globally turned off rpath -# [~] compiler options are aligned with NDK r8b -# - October 2012 -# [~] fixed C++ linking: explicitly link with math library (OpenCV #2426) -# - November 2012 -# [+] updated for NDK r8c -# [+] added support for clang compiler -# - December 2012 -# [+] suppress warning about unused CMAKE_TOOLCHAIN_FILE variable -# [+] adjust API level to closest compatible as NDK does -# [~] fixed ccache full path search -# [+] updated for NDK r8d -# [~] compiler options are aligned with NDK r8d -# - March 2013 -# [+] updated for NDK r8e (x86 version) -# [+] support x86_64 version of NDK -# - April 2013 -# [+] support non-release NDK layouts (from Linaro git and Android git) -# [~] automatically detect if explicit link to crtbegin_*.o is needed # ------------------------------------------------------------------------------ cmake_minimum_required( VERSION 2.6.3 ) @@ -302,146 +197,146 @@ if( DEFINED CMAKE_CROSSCOMPILING ) endif() if( CMAKE_TOOLCHAIN_FILE ) - # touch toolchain variable only to suppress "unused variable" warning + # touch toolchain variable to suppress "unused variable" warning endif() +# inherit settings in recursive loads get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE ) if( _CMAKE_IN_TRY_COMPILE ) include( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL ) endif() # this one is important -set( CMAKE_SYSTEM_NAME Linux ) +if( CMAKE_VERSION VERSION_GREATER "3.0.99" ) + set( CMAKE_SYSTEM_NAME Android ) +else() + set( CMAKE_SYSTEM_NAME Linux ) +endif() + # this one not so much set( CMAKE_SYSTEM_VERSION 1 ) -# rpath makes low sence for Android +# rpath makes low sense for Android +set( CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "" ) set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) -set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) -if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS) +# NDK search paths +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r10d -r10c -r10b -r10 -r9d -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +if( NOT DEFINED ANDROID_NDK_SEARCH_PATHS ) if( CMAKE_HOST_WIN32 ) file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) - set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}/android-ndk" "$ENV{SystemDrive}/NVPACK/android-ndk" ) + set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}" "$ENV{SystemDrive}/NVPACK" ) else() file( TO_CMAKE_PATH "$ENV{HOME}" ANDROID_NDK_SEARCH_PATHS ) - set( ANDROID_NDK_SEARCH_PATHS /opt/android-ndk "${ANDROID_NDK_SEARCH_PATHS}/NVPACK/android-ndk" ) + set( ANDROID_NDK_SEARCH_PATHS /opt "${ANDROID_NDK_SEARCH_PATHS}/NVPACK" ) endif() endif() -if(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH) +if( NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH ) set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain ) endif() -set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" ) +# known ABIs +set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a-hard with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" ) +set( ANDROID_SUPPORTED_ABIS_arm64 "arm64-v8a" ) set( ANDROID_SUPPORTED_ABIS_x86 "x86" ) -set( ANDROID_SUPPORTED_ABIS_mipsel "mips" ) +set( ANDROID_SUPPORTED_ABIS_x86_64 "x86_64" ) +set( ANDROID_SUPPORTED_ABIS_mips "mips" ) +set( ANDROID_SUPPORTED_ABIS_mips64 "mips64" ) -set( ANDROID_DEFAULT_NDK_API_LEVEL 8 ) +# API level defaults +set( ANDROID_DEFAULT_NDK_API_LEVEL 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_arm64 21 ) set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_x86_64 21 ) set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_mips64 21 ) macro( __LIST_FILTER listvar regex ) - if( ${listvar} ) - foreach( __val ${${listvar}} ) - if( __val MATCHES "${regex}" ) - list( REMOVE_ITEM ${listvar} "${__val}" ) - endif() - endforeach() - endif() + if( ${listvar} ) + foreach( __val ${${listvar}} ) + if( __val MATCHES "${regex}" ) + list( REMOVE_ITEM ${listvar} "${__val}" ) + endif() + endforeach() + endif() endmacro() macro( __INIT_VARIABLE var_name ) - set( __test_path 0 ) - foreach( __var ${ARGN} ) - if( __var STREQUAL "PATH" ) - set( __test_path 1 ) - break() - endif() - endforeach() - if( __test_path AND NOT EXISTS "${${var_name}}" ) - unset( ${var_name} CACHE ) - endif() - if( "${${var_name}}" STREQUAL "" ) - set( __values 0 ) + set( __test_path 0 ) foreach( __var ${ARGN} ) - if( __var STREQUAL "VALUES" ) - set( __values 1 ) - elseif( NOT __var STREQUAL "PATH" ) - set( __obsolete 0 ) - if( __var MATCHES "^OBSOLETE_.*$" ) - string( REPLACE "OBSOLETE_" "" __var "${__var}" ) - set( __obsolete 1 ) - endif() - if( __var MATCHES "^ENV_.*$" ) - string( REPLACE "ENV_" "" __var "${__var}" ) - set( __value "$ENV{${__var}}" ) - elseif( DEFINED ${__var} ) - set( __value "${${__var}}" ) - else() - if( __values ) - set( __value "${__var}" ) - else() - set( __value "" ) - endif() - endif() - if( NOT "${__value}" STREQUAL "" ) - if( __test_path ) - if( EXISTS "${__value}" ) - file( TO_CMAKE_PATH "${__value}" ${var_name} ) - if( __obsolete AND NOT _CMAKE_IN_TRY_COMPILE ) - message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." ) - endif() - break() - endif() - else() - set( ${var_name} "${__value}" ) - if( __obsolete AND NOT _CMAKE_IN_TRY_COMPILE ) - message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." ) - endif() + if( __var STREQUAL "PATH" ) + set( __test_path 1 ) break() - endif() endif() - endif() endforeach() - unset( __value ) - unset( __values ) - unset( __obsolete ) - elseif( __test_path ) - file( TO_CMAKE_PATH "${${var_name}}" ${var_name} ) - endif() - unset( __test_path ) + + if( __test_path AND NOT EXISTS "${${var_name}}" ) + unset( ${var_name} CACHE ) + endif() + + if( " ${${var_name}}" STREQUAL " " ) + set( __values 0 ) + foreach( __var ${ARGN} ) + if( __var STREQUAL "VALUES" ) + set( __values 1 ) + elseif( NOT __var STREQUAL "PATH" ) + if( __var MATCHES "^ENV_.*$" ) + string( REPLACE "ENV_" "" __var "${__var}" ) + set( __value "$ENV{${__var}}" ) + elseif( DEFINED ${__var} ) + set( __value "${${__var}}" ) + elseif( __values ) + set( __value "${__var}" ) + else() + set( __value "" ) + endif() + + if( NOT " ${__value}" STREQUAL " " AND (NOT __test_path OR EXISTS "${__value}") ) + set( ${var_name} "${__value}" ) + break() + endif() + endif() + endforeach() + unset( __value ) + unset( __values ) + endif() + + if( __test_path ) + file( TO_CMAKE_PATH "${${var_name}}" ${var_name} ) + endif() + unset( __test_path ) endmacro() macro( __DETECT_NATIVE_API_LEVEL _var _path ) - SET( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*$" ) - FILE( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" ) - if( NOT __apiFileContent ) - message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." ) - endif() - string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" ) - unset( __apiFileContent ) - unset( __ndkApiLevelRegex ) + set( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" ) + file( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" ) + if( NOT __apiFileContent ) + message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." ) + endif() + string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" ) + unset( __apiFileContent ) + unset( __ndkApiLevelRegex ) endmacro() macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root ) if( EXISTS "${_root}" ) - file( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" ) - __LIST_FILTER( __gccExePath "^[.].*" ) - list( LENGTH __gccExePath __gccExePathsCount ) - if( NOT __gccExePathsCount EQUAL 1 AND NOT _CMAKE_IN_TRY_COMPILE ) - message( WARNING "Could not determine machine name for compiler from ${_root}" ) - set( ${_var} "" ) + file( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" ) + __LIST_FILTER( __gccExePath "^[.].*" ) + list( LENGTH __gccExePath __gccExePathsCount ) + if( NOT __gccExePathsCount EQUAL 1 AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "Could not determine machine name for compiler from ${_root}" ) + set( ${_var} "" ) + else() + get_filename_component( __gccExeName "${__gccExePath}" NAME_WE ) + string( REPLACE "-gcc" "" ${_var} "${__gccExeName}" ) + endif() + unset( __gccExePath ) + unset( __gccExePathsCount ) + unset( __gccExeName ) else() - get_filename_component( __gccExeName "${__gccExePath}" NAME_WE ) - string( REPLACE "-gcc" "" ${_var} "${__gccExeName}" ) + set( ${_var} "" ) endif() - unset( __gccExePath ) - unset( __gccExePathsCount ) - unset( __gccExeName ) - else() - set( ${_var} "" ) - endif() endmacro() @@ -464,7 +359,7 @@ endif() # detect current host platform -if( NOT DEFINED ANDROID_NDK_HOST_X64 AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64") +if( NOT DEFINED ANDROID_NDK_HOST_X64 AND (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64" OR CMAKE_HOST_APPLE) ) set( ANDROID_NDK_HOST_X64 1 CACHE BOOL "Try to use 64-bit compiler toolchain" ) mark_as_advanced( ANDROID_NDK_HOST_X64 ) endif() @@ -484,24 +379,24 @@ else() message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" ) endif() -# CMAKE_HOST_SYSTEM_PROCESSOR on MacOS X always says i386 on Intel platform -# So we do not trust ANDROID_NDK_HOST_X64 on Apple hosts -if( NOT ANDROID_NDK_HOST_X64 AND NOT CMAKE_HOST_APPLE) +if( NOT ANDROID_NDK_HOST_X64 ) set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) endif() # see if we have path to Android NDK -__INIT_VARIABLE( ANDROID_NDK PATH ENV_ANDROID_NDK ) +if( NOT ANDROID_NDK AND NOT ANDROID_STANDALONE_TOOLCHAIN ) + __INIT_VARIABLE( ANDROID_NDK PATH ENV_ANDROID_NDK ) +endif() if( NOT ANDROID_NDK ) # see if we have path to Android standalone toolchain - __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN OBSOLETE_ANDROID_NDK_TOOLCHAIN_ROOT OBSOLETE_ENV_ANDROID_NDK_TOOLCHAIN_ROOT ) + __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN ) if( NOT ANDROID_STANDALONE_TOOLCHAIN ) #try to find Android NDK in one of the the default locations set( __ndkSearchPaths ) foreach( __ndkSearchPath ${ANDROID_NDK_SEARCH_PATHS} ) foreach( suffix ${ANDROID_SUPPORTED_NDK_VERSIONS} ) - list( APPEND __ndkSearchPaths "${__ndkSearchPath}${suffix}" ) + list( APPEND __ndkSearchPaths "${__ndkSearchPath}/android-ndk${suffix}" ) endforeach() endforeach() __INIT_VARIABLE( ANDROID_NDK PATH VALUES ${__ndkSearchPaths} ) @@ -528,12 +423,15 @@ if( ANDROID_NDK ) set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE ) set( BUILD_WITH_ANDROID_NDK True ) if( EXISTS "${ANDROID_NDK}/RELEASE.TXT" ) - file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? ) - string( REGEX MATCH r[0-9]+[a-z]? ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" ) + file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX "r[0-9]+[a-z]?" ) + string( REGEX MATCH "r([0-9]+)([a-z]?)" ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" ) else() set( ANDROID_NDK_RELEASE "r1x" ) set( ANDROID_NDK_RELEASE_FULL "unreleased" ) endif() + string( REGEX REPLACE "r([0-9]+)([a-z]?)" "\\1*1000" ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE}" ) + string( FIND " abcdefghijklmnopqastuvwxyz" "${CMAKE_MATCH_2}" __ndkReleaseLetterNum ) + math( EXPR ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE_NUM}+${__ndkReleaseLetterNum}" ) elseif( ANDROID_STANDALONE_TOOLCHAIN ) get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE ) # try to detect change @@ -556,7 +454,7 @@ else() or export ANDROID_STANDALONE_TOOLCHAIN=~/my-android-toolchain or put the toolchain or NDK in the default path: - sudo ln -s ~/my-android-ndk ${ANDROID_NDK_SEARCH_PATH} + sudo ln -s ~/my-android-ndk ${ANDROID_NDK_SEARCH_PATH}/android-ndk sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" ) endif() @@ -614,12 +512,18 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN ) if( NOT __availableToolchainMachines ) message( FATAL_ERROR "Could not determine machine name of your toolchain. Probably your Android standalone toolchain is broken." ) endif() - if( __availableToolchainMachines MATCHES i686 ) + if( __availableToolchainMachines MATCHES x86_64 ) + set( __availableToolchainArchs "x86_64" ) + elseif( __availableToolchainMachines MATCHES i686 ) set( __availableToolchainArchs "x86" ) + elseif( __availableToolchainMachines MATCHES aarch64 ) + set( __availableToolchainArchs "arm64" ) elseif( __availableToolchainMachines MATCHES arm ) set( __availableToolchainArchs "arm" ) + elseif( __availableToolchainMachines MATCHES mips64el ) + set( __availableToolchainArchs "mips64" ) elseif( __availableToolchainMachines MATCHES mipsel ) - set( __availableToolchainArchs "mipsel" ) + set( __availableToolchainArchs "mips" ) endif() execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" -dumpversion OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE ) @@ -634,30 +538,47 @@ endif() macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath ) foreach( __toolchain ${${__availableToolchainsLst}} ) - # Skip renderscript folder. It's not C++ toolchain - if (NOT ${__toolchain} STREQUAL "renderscript") - if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) - string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) + if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) + SET( __toolchainVersionRegex "^TOOLCHAIN_VERSION[\t ]+:=[\t ]+(.*)$" ) + FILE( STRINGS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}/setup.mk" __toolchainVersionStr REGEX "${__toolchainVersionRegex}" ) + if( __toolchainVersionStr ) + string( REGEX REPLACE "${__toolchainVersionRegex}" "\\1" __toolchainVersionStr "${__toolchainVersionStr}" ) + string( REGEX REPLACE "-clang3[.][0-9]$" "-${__toolchainVersionStr}" __gcc_toolchain "${__toolchain}" ) else() - set( __gcc_toolchain "${__toolchain}" ) + string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) endif() - __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" ) - if( __machine ) - string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" ) - if( __machine MATCHES i686 ) - set( __arch "x86" ) - elseif( __machine MATCHES arm ) - set( __arch "arm" ) - elseif( __machine MATCHES mipsel ) - set( __arch "mipsel" ) - endif() + unset( __toolchainVersionStr ) + unset( __toolchainVersionRegex ) + else() + set( __gcc_toolchain "${__toolchain}" ) + endif() + __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" ) + if( __machine ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" ) + if( __machine MATCHES x86_64 ) + set( __arch "x86_64" ) + elseif( __machine MATCHES i686 ) + set( __arch "x86" ) + elseif( __machine MATCHES aarch64 ) + set( __arch "arm64" ) + elseif( __machine MATCHES arm ) + set( __arch "arm" ) + elseif( __machine MATCHES mips64el ) + set( __arch "mips64" ) + elseif( __machine MATCHES mipsel ) + set( __arch "mips" ) + else() + set( __arch "" ) + endif() + #message("machine: !${__machine}!\narch: !${__arch}!\nversion: !${__version}!\ntoolchain: !${__toolchain}!\n") + if (__arch) list( APPEND __availableToolchainMachines "${__machine}" ) list( APPEND __availableToolchainArchs "${__arch}" ) list( APPEND __availableToolchainCompilerVersions "${__version}" ) list( APPEND ${__availableToolchainsVar} "${__toolchain}" ) endif() - unset( __gcc_toolchain ) endif() + unset( __gcc_toolchain ) endforeach() endmacro() @@ -682,11 +603,12 @@ if( BUILD_WITH_ANDROID_NDK ) endif() if( NOT __availableToolchains ) file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" ) - if( __availableToolchains ) + if( __availableToolchainsLst ) list(SORT __availableToolchainsLst) # we need clang to go after gcc endif() __LIST_FILTER( __availableToolchainsLst "^[.]" ) __LIST_FILTER( __availableToolchainsLst "llvm" ) + __LIST_FILTER( __availableToolchainsLst "renderscript" ) __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 ) __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" ) @@ -714,7 +636,7 @@ if( NOT ANDROID_SUPPORTED_ABIS ) endif() # choose target ABI -__INIT_VARIABLE( ANDROID_ABI OBSOLETE_ARM_TARGET OBSOLETE_ARM_TARGETS VALUES ${ANDROID_SUPPORTED_ABIS} ) +__INIT_VARIABLE( ANDROID_ABI VALUES ${ANDROID_SUPPORTED_ABIS} ) # verify that target ABI is supported list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx ) if( __androidAbiIdx EQUAL -1 ) @@ -730,28 +652,45 @@ if( ANDROID_ABI STREQUAL "x86" ) set( X86 true ) set( ANDROID_NDK_ABI_NAME "x86" ) set( ANDROID_ARCH_NAME "x86" ) - set( ANDROID_ARCH_FULLNAME "x86" ) set( ANDROID_LLVM_TRIPLE "i686-none-linux-android" ) set( CMAKE_SYSTEM_PROCESSOR "i686" ) +elseif( ANDROID_ABI STREQUAL "x86_64" ) + set( X86 true ) + set( X86_64 true ) + set( ANDROID_NDK_ABI_NAME "x86_64" ) + set( ANDROID_ARCH_NAME "x86_64" ) + set( CMAKE_SYSTEM_PROCESSOR "x86_64" ) + set( ANDROID_LLVM_TRIPLE "x86_64-none-linux-android" ) +elseif( ANDROID_ABI STREQUAL "mips64" ) + set( MIPS64 true ) + set( ANDROID_NDK_ABI_NAME "mips64" ) + set( ANDROID_ARCH_NAME "mips64" ) + set( ANDROID_LLVM_TRIPLE "mips64el-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "mips64" ) elseif( ANDROID_ABI STREQUAL "mips" ) set( MIPS true ) set( ANDROID_NDK_ABI_NAME "mips" ) set( ANDROID_ARCH_NAME "mips" ) - set( ANDROID_ARCH_FULLNAME "mipsel" ) set( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" ) set( CMAKE_SYSTEM_PROCESSOR "mips" ) +elseif( ANDROID_ABI STREQUAL "arm64-v8a" ) + set( ARM64_V8A true ) + set( ANDROID_NDK_ABI_NAME "arm64-v8a" ) + set( ANDROID_ARCH_NAME "arm64" ) + set( ANDROID_LLVM_TRIPLE "aarch64-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "aarch64" ) + set( VFPV3 true ) + set( NEON true ) elseif( ANDROID_ABI STREQUAL "armeabi" ) set( ARMEABI true ) set( ANDROID_NDK_ABI_NAME "armeabi" ) set( ANDROID_ARCH_NAME "arm" ) - set( ANDROID_ARCH_FULLNAME "arm" ) set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" ) set( CMAKE_SYSTEM_PROCESSOR "armv5te" ) elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" ) set( ARMEABI_V6 true ) set( ANDROID_NDK_ABI_NAME "armeabi" ) set( ANDROID_ARCH_NAME "arm" ) - set( ANDROID_ARCH_FULLNAME "arm" ) set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" ) set( CMAKE_SYSTEM_PROCESSOR "armv6" ) # need always fallback to older platform @@ -760,14 +699,12 @@ elseif( ANDROID_ABI STREQUAL "armeabi-v7a") set( ARMEABI_V7A true ) set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) set( ANDROID_ARCH_NAME "arm" ) - set( ANDROID_ARCH_FULLNAME "arm" ) set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" ) set( ARMEABI_V7A true ) set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) set( ANDROID_ARCH_NAME "arm" ) - set( ANDROID_ARCH_FULLNAME "arm" ) set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) set( VFPV3 true ) @@ -775,7 +712,14 @@ elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" ) set( ARMEABI_V7A true ) set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) set( ANDROID_ARCH_NAME "arm" ) - set( ANDROID_ARCH_FULLNAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) + set( VFPV3 true ) + set( NEON true ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a-hard with NEON" ) + set( ARMEABI_V7A_HARD true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a-hard" ) + set( ANDROID_ARCH_NAME "arm" ) set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) set( VFPV3 true ) @@ -791,7 +735,7 @@ if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMa endif() if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 ) - __INIT_VARIABLE( ANDROID_FORCE_ARM_BUILD OBSOLETE_FORCE_ARM VALUES OFF ) + __INIT_VARIABLE( ANDROID_FORCE_ARM_BUILD VALUES OFF ) set( ANDROID_FORCE_ARM_BUILD ${ANDROID_FORCE_ARM_BUILD} CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1" FORCE ) mark_as_advanced( ANDROID_FORCE_ARM_BUILD ) else() @@ -809,7 +753,7 @@ if( ANDROID_TOOLCHAIN_NAME ) To configure the toolchain set CMake variable ANDROID_TOOLCHAIN_NAME to one of the following values:\n${toolchains_list}\n" ) endif() list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch ) - if( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME ) + if( NOT __toolchainArch STREQUAL ANDROID_ARCH_NAME ) message( SEND_ERROR "Selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." ) endif() else() @@ -820,7 +764,7 @@ else() math( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" ) foreach( __idx RANGE ${__availableToolchainsCount} ) list( GET __availableToolchainArchs ${__idx} __toolchainArch ) - if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME ) + if( __toolchainArch STREQUAL ANDROID_ARCH_NAME ) list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion ) string( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}") if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion ) @@ -849,15 +793,16 @@ unset( __availableToolchainCompilerVersions ) # choose native API level __INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL ) -string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" ) +string( REPLACE "android-" "" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" ) +string( STRIP "${ANDROID_NATIVE_API_LEVEL}" ANDROID_NATIVE_API_LEVEL ) # adjust API level set( __real_api_level ${ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME}} ) foreach( __level ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) - if( NOT __level GREATER ANDROID_NATIVE_API_LEVEL AND NOT __level LESS __real_api_level ) + if( (__level LESS ANDROID_NATIVE_API_LEVEL OR __level STREQUAL ANDROID_NATIVE_API_LEVEL) AND NOT __level LESS __real_api_level ) set( __real_api_level ${__level} ) endif() endforeach() -if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL EQUAL __real_api_level ) +if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL STREQUAL __real_api_level ) message( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'") set( ANDROID_NATIVE_API_LEVEL ${__real_api_level} ) endif() @@ -869,12 +814,13 @@ if( __levelIdx EQUAL -1 ) else() if( BUILD_WITH_ANDROID_NDK ) __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" ) - if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL ) + if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL AND NOT __realApiLevel GREATER 9000 ) message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." ) endif() unset( __realApiLevel ) endif() set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE ) + set( CMAKE_ANDROID_API ${ANDROID_NATIVE_API_LEVEL} ) if( CMAKE_VERSION VERSION_GREATER "2.8" ) list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS ) set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) @@ -886,30 +832,21 @@ unset( __levelIdx ) # remember target ABI set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE ) if( CMAKE_VERSION VERSION_GREATER "2.8" ) - list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} ) - set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} ) + list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME} ) + set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME}} ) endif() # runtime choice (STL, rtti, exceptions) if( NOT ANDROID_STL ) - # honor legacy ANDROID_USE_STLPORT - if( DEFINED ANDROID_USE_STLPORT ) - if( ANDROID_USE_STLPORT ) - set( ANDROID_STL stlport_static ) - endif() - message( WARNING "You are using an obsolete variable ANDROID_USE_STLPORT to select the STL variant. Use -DANDROID_STL=stlport_static instead." ) - endif() - if( NOT ANDROID_STL ) set( ANDROID_STL gnustl_static ) - endif() endif() set( ANDROID_STL "${ANDROID_STL}" CACHE STRING "C++ runtime" ) set( ANDROID_STL_FORCE_FEATURES ON CACHE BOOL "automatically configure rtti and exceptions support based on C++ runtime" ) mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES ) if( BUILD_WITH_ANDROID_NDK ) - if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared)$") + if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared|c\\+\\+_static|c\\+\\+_shared)$") message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". The possible values are: none -> Do not configure the runtime. @@ -921,15 +858,19 @@ The possible values are: stlport_shared -> Use the STLport runtime as a shared library. gnustl_static -> (default) Use the GNU STL as a static library. gnustl_shared -> Use the GNU STL as a shared library. + c++_shared -> Use the LLVM libc++ runtime as a shared library. + c++_static -> Use the LLVM libc++ runtime as a static library. " ) endif() elseif( BUILD_WITH_STANDALONE_TOOLCHAIN ) - if( NOT "${ANDROID_STL}" MATCHES "^(none|gnustl_static|gnustl_shared)$") + if( NOT "${ANDROID_STL}" MATCHES "^(none|gnustl_static|gnustl_shared|c\\+\\+_static|c\\+\\+_shared)$") message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". The possible values are: none -> Do not configure the runtime. gnustl_static -> (default) Use the GNU STL as a static library. gnustl_shared -> Use the GNU STL as a shared library. + c++_shared -> Use the LLVM libc++ runtime as a shared library. + c++_static -> Use the LLVM libc++ runtime as a static library. " ) endif() endif() @@ -975,8 +916,12 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN ) set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" ) if( NOT ANDROID_STL STREQUAL "none" ) - set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" ) - if( ARMEABI_V7A AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/include/c++/${ANDROID_COMPILER_VERSION}" ) + if( NOT EXISTS "${ANDROID_STL_INCLUDE_DIRS}" ) + # old location ( pre r8c ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" ) + endif() + if( (ARMEABI_V7A OR ARMEABI_V7A_HARD) AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" ) list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" ) elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" ) list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" ) @@ -984,9 +929,9 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN ) list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" ) endif() # always search static GNU STL to get the location of libsupc++.a - if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" ) + if( (ARMEABI_V7A OR ARMEABI_V7A_HARD) AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" ) set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb" ) - elseif( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" ) + elseif( (ARMEABI_V7A OR ARMEABI_V7A_HARD) AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" ) set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}" ) elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libstdc++.a" ) set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb" ) @@ -1007,7 +952,7 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN ) " ) endif() if( ANDROID_STL STREQUAL "gnustl_shared" ) - if( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) + if( (ARMEABI_V7A OR ARMEABI_V7A_HARD) AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" ) set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" ) @@ -1025,7 +970,7 @@ if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" ) string( REGEX MATCH "[0-9]+[.][0-9]+" ANDROID_CLANG_VERSION "${ANDROID_CLANG_VERSION}") elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" ) string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}") - string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) + string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-${ANDROID_COMPILER_VERSION}" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) if( NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}/bin/clang${TOOL_OS_SUFFIX}" ) message( FATAL_ERROR "Could not find the Clang compiler driver" ) endif() @@ -1058,20 +1003,20 @@ if( BUILD_WITH_ANDROID_NDK ) set( ANDROID_EXCEPTIONS ON ) set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" ) elseif( ANDROID_STL MATCHES "gabi" ) - if( ANDROID_NDK_RELEASE STRLESS "r7" ) - message( FATAL_ERROR "gabi++ is not awailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.") + if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 + message( FATAL_ERROR "gabi++ is not available in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.") endif() set( ANDROID_RTTI ON ) set( ANDROID_EXCEPTIONS OFF ) set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/gabi++/include" ) set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${ANDROID_NDK_ABI_NAME}/libgabi++_static.a" ) elseif( ANDROID_STL MATCHES "stlport" ) - if( NOT ANDROID_NDK_RELEASE STRLESS "r8d" ) + if( NOT ANDROID_NDK_RELEASE_NUM LESS 8004 ) # before r8d set( ANDROID_EXCEPTIONS ON ) else() set( ANDROID_EXCEPTIONS OFF ) endif() - if( ANDROID_NDK_RELEASE STRLESS "r7" ) + if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 set( ANDROID_RTTI OFF ) else() set( ANDROID_RTTI ON ) @@ -1092,15 +1037,22 @@ if( BUILD_WITH_ANDROID_NDK ) else() set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" ) endif() - set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" ) + set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" "${__libstl}/include/backward" ) if( EXISTS "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" ) set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" ) else() set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) endif() + elseif( ANDROID_STL MATCHES "c\\+\\+" ) + set( ANDROID_EXCEPTIONS ON ) + set( ANDROID_RTTI ON ) + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/llvm-libc++" ) + set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libc++_static.a" ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/android/support/include" "${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include" "${ANDROID_NDK}/sources/cxx-stl/llvm-libc++abi/libcxxabi/include" ) else() message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" ) endif() + # find libsupc++.a - rtti & exceptions if( ANDROID_STL STREQUAL "system_re" OR ANDROID_STL MATCHES "gnustl" ) set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r8b or newer @@ -1130,14 +1082,8 @@ endif() # case of shared STL linkage if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl ) string( REPLACE "_static.a" "_shared.so" __libstl "${__libstl}" ) - if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" ) - get_filename_component( __libstlname "${__libstl}" NAME ) - execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess ) - if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}") - message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" ) - endif() - unset( __fileCopyProcess ) - unset( __libstlname ) + if( NOT EXISTS "${__libstl}" ) + message( FATAL_ERROR "Unable to find shared library ${__libstl}" ) endif() endif() @@ -1178,7 +1124,12 @@ if( NOT CMAKE_C_COMPILER ) endif() set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" ) set( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" ) - set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) + if( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" ) + # Use gcc-ar if we have it for better LTO support. + set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) + else() + set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) + endif() set( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" ) set( CMAKE_NM "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" ) set( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" ) @@ -1202,10 +1153,14 @@ endif() include( CMakeForceCompiler ) CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU ) if( ANDROID_COMPILER_IS_CLANG ) - set( CMAKE_C_COMPILER_ID Clang) + set( CMAKE_C_COMPILER_ID Clang ) endif() set( CMAKE_C_PLATFORM_ID Linux ) -set( CMAKE_C_SIZEOF_DATA_PTR 4 ) +if( X86_64 OR MIPS64 OR ARM64_V8A ) + set( CMAKE_C_SIZEOF_DATA_PTR 8 ) +else() + set( CMAKE_C_SIZEOF_DATA_PTR 4 ) +endif() set( CMAKE_C_HAS_ISYSROOT 1 ) set( CMAKE_C_COMPILER_ABI ELF ) CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU ) @@ -1213,7 +1168,7 @@ if( ANDROID_COMPILER_IS_CLANG ) set( CMAKE_CXX_COMPILER_ID Clang) endif() set( CMAKE_CXX_PLATFORM_ID Linux ) -set( CMAKE_CXX_SIZEOF_DATA_PTR 4 ) +set( CMAKE_CXX_SIZEOF_DATA_PTR ${CMAKE_C_SIZEOF_DATA_PTR} ) set( CMAKE_CXX_HAS_ISYSROOT 1 ) set( CMAKE_CXX_COMPILER_ABI ELF ) set( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C ) @@ -1225,6 +1180,14 @@ set( CMAKE_ASM_COMPILER_FORCED TRUE ) set( CMAKE_COMPILER_IS_GNUASM 1) set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm ) +foreach( lang C CXX ASM ) + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_CLANG_VERSION} ) + else() + set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_COMPILER_VERSION} ) + endif() +endforeach() + # flags and definitions remove_definitions( -DANDROID ) add_definitions( -DANDROID ) @@ -1254,8 +1217,15 @@ else() endif() # NDK flags -if( ARMEABI OR ARMEABI_V7A ) - set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables" ) +if (ARM64_V8A ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" ) + endif() +elseif( ARMEABI OR ARMEABI_V7A OR ARMEABI_V7A_HARD) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 ) set( ANDROID_CXX_FLAGS_RELEASE "-mthumb -fomit-frame-pointer -fno-strict-aliasing" ) set( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" ) @@ -1270,17 +1240,15 @@ if( ARMEABI OR ARMEABI_V7A ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" ) endif() endif() -elseif( X86 ) +elseif( X86 OR X86_64 ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) if( NOT ANDROID_COMPILER_IS_CLANG ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" ) - else() - set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fPIC" ) endif() set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" ) set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" ) -elseif( MIPS ) - set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0" ) +elseif( MIPS OR MIPS64 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-strict-aliasing -finline-functions -funwind-tables -fmessage-length=0" ) set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer" ) set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer" ) if( NOT ANDROID_COMPILER_IS_CLANG ) @@ -1303,7 +1271,16 @@ if( NOT ANDROID_COMPILER_VERSION VERSION_LESS "4.6" ) endif() # ABI-specific flags -if( ARMEABI_V7A ) +if( ARMEABI_V7A_HARD ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=hard -mhard-float -D_NDK_MATH_NO_SOFTFP=1" ) + if( NEON ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" ) + elseif( VFPV3 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" ) + endif() +elseif( ARMEABI_V7A ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp" ) if( NEON ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" ) @@ -1312,6 +1289,7 @@ if( ARMEABI_V7A ) else() set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" ) endif() + elseif( ARMEABI_V6 ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" ) # vfp == vfpv2 elseif( ARMEABI ) @@ -1358,14 +1336,14 @@ if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" ) endif() # variables controlling optional build flags -if (ANDROID_NDK_RELEASE STRLESS "r7") +if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 # libGLESv2.so in NDK's prior to r7 refers to missing external symbols. # So this flag option is required for all projects using OpenGL from native. __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON ) else() __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF ) endif() -__INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON ) +__INIT_VARIABLE( ANDROID_NO_UNDEFINED VALUES ON ) __INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON ) __INIT_VARIABLE( ANDROID_GOLD_LINKER VALUES ON ) __INIT_VARIABLE( ANDROID_NOEXECSTACK VALUES ON ) @@ -1373,8 +1351,8 @@ __INIT_VARIABLE( ANDROID_RELRO VALUES ON ) set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" ) set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) -set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) -set( ANDROID_GOLD_LINKER ${ANDROID_GOLD_LINKER} CACHE BOOL "Enables gold linker (only avaialble for NDK r8b for ARM and x86 architectures on linux-86 and darwin-x86 hosts)" ) +set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Put each function in separate section and enable garbage collection of unused input sections at link time" ) +set( ANDROID_GOLD_LINKER ${ANDROID_GOLD_LINKER} CACHE BOOL "Enables gold linker" ) set( ANDROID_NOEXECSTACK ${ANDROID_NOEXECSTACK} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) set( ANDROID_RELRO ${ANDROID_RELRO} CACHE BOOL "Enables RELRO - a memory corruption mitigation technique" ) mark_as_advanced( ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_FUNCTION_LEVEL_LINKING ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO ) @@ -1388,6 +1366,10 @@ if( ARMEABI_V7A ) set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--fix-cortex-a8" ) endif() +if( ARMEABI_V7A_HARD ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-warn-mismatch -lm_hard" ) +endif() + if( ANDROID_NO_UNDEFINED ) if( MIPS ) # there is some sysroot-related problem in mips linker... @@ -1409,9 +1391,9 @@ if( ANDROID_FUNCTION_LEVEL_LINKING ) endif() if( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" ) - if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE STRGREATER "r8b") AND (ARMEABI OR ARMEABI_V7A OR X86) ) + if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE_NUM GREATER 8002) AND (ARMEABI OR ARMEABI_V7A OR ARMEABI_V7A_HARD OR X86) ) set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" ) - elseif( ANDROID_NDK_RELEASE STRGREATER "r8b") + elseif( ANDROID_NDK_RELEASE_NUM GREATER 8002 ) # after r8b set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" ) elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE ) message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342 @@ -1435,13 +1417,7 @@ if( ANDROID_RELRO ) endif() if( ANDROID_COMPILER_IS_CLANG ) - set( ANDROID_CXX_FLAGS "-Qunused-arguments ${ANDROID_CXX_FLAGS}" ) - if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD ) - set( ANDROID_CXX_FLAGS_RELEASE "-target thumbv7-none-linux-androideabi ${ANDROID_CXX_FLAGS_RELEASE}" ) - set( ANDROID_CXX_FLAGS_DEBUG "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS_DEBUG}" ) - else() - set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS}" ) - endif() + set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} -Qunused-arguments ${ANDROID_CXX_FLAGS}" ) if( BUILD_WITH_ANDROID_NDK ) set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" ) endif() @@ -1481,6 +1457,16 @@ if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" ) set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" ) endif() +# pie/pic +if( NOT (ANDROID_NATIVE_API_LEVEL LESS 16) AND (NOT DEFINED ANDROID_APP_PIE OR ANDROID_APP_PIE) AND (CMAKE_VERSION VERSION_GREATER 2.8.8) ) + set( CMAKE_POSITION_INDEPENDENT_CODE TRUE ) + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie") +else() + set( CMAKE_POSITION_INDEPENDENT_CODE FALSE ) + set( CMAKE_CXX_FLAGS "-fpic ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fpic ${CMAKE_C_FLAGS}" ) +endif() + # configure rtti if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES ) if( ANDROID_RTTI ) @@ -1503,7 +1489,8 @@ endif() # global includes and link directories include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} ) -link_directories( "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ) +get_filename_component(__android_install_path "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ABSOLUTE) # avoid CMP0015 policy warning +link_directories( "${__android_install_path}" ) # detect if need link crtbegin_so.o explicitly if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK ) @@ -1543,18 +1530,34 @@ if( ANDROID_EXPLICIT_CRT_LINK ) endif() # setup output directories -set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" ) set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" ) -if(NOT _CMAKE_IN_TRY_COMPILE) - if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" ) - set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" ) - else() - set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" ) - endif() - set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" ) +if( DEFINED LIBRARY_OUTPUT_PATH_ROOT + OR EXISTS "${CMAKE_SOURCE_DIR}/AndroidManifest.xml" + OR (EXISTS "${CMAKE_SOURCE_DIR}/../AndroidManifest.xml" AND EXISTS "${CMAKE_SOURCE_DIR}/../jni/") ) + set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "Root for binaries output, set this to change where Android libs are installed to" ) + if( NOT _CMAKE_IN_TRY_COMPILE ) + if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" ) + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" ) + else() + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" ) + endif() + set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for Android libs" ) + endif() endif() +# copy shaed stl library to build directory +if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" AND DEFINED LIBRARY_OUTPUT_PATH ) + get_filename_component( __libstlname "${__libstl}" NAME ) + execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess ) + if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}") + message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" ) + endif() + unset( __fileCopyProcess ) + unset( __libstlname ) +endif() + + # set these global flags for cmake client scripts to change behavior set( ANDROID True ) set( BUILD_ANDROID True ) @@ -1612,25 +1615,10 @@ macro( find_host_program ) endmacro() -macro( ANDROID_GET_ABI_RAWNAME TOOLCHAIN_FLAG VAR ) - if( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI" ) - set( ${VAR} "armeabi" ) - elseif( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI_V7A" ) - set( ${VAR} "armeabi-v7a" ) - elseif( "${TOOLCHAIN_FLAG}" STREQUAL "X86" ) - set( ${VAR} "x86" ) - elseif( "${TOOLCHAIN_FLAG}" STREQUAL "MIPS" ) - set( ${VAR} "mips" ) - else() - set( ${VAR} "unknown" ) - endif() -endmacro() - - # export toolchain settings for the try_compile() command -if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" ) +if( NOT _CMAKE_IN_TRY_COMPILE ) set( __toolchain_config "") - foreach( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN ANDROID_SET_OBSOLETE_VARIABLES + foreach( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN ANDROID_NDK_HOST_X64 ANDROID_NDK ANDROID_NDK_LAYOUT @@ -1649,9 +1637,10 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" ) ANDROID_RELRO ANDROID_LIBM_PATH ANDROID_EXPLICIT_CRT_LINK + ANDROID_APP_PIE ) if( DEFINED ${__var} ) - if( "${__var}" MATCHES " ") + if( ${__var} MATCHES " ") set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" CACHE INTERNAL \"\" )\n" ) else() set( __toolchain_config "${__toolchain_config}set( ${__var} ${${__var}} CACHE INTERNAL \"\" )\n" ) @@ -1663,19 +1652,22 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" ) endif() -# set some obsolete variables for backward compatibility -set( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" ) -mark_as_advanced( ANDROID_SET_OBSOLETE_VARIABLES ) -if( ANDROID_SET_OBSOLETE_VARIABLES ) - set( ANDROID_API_LEVEL ${ANDROID_NATIVE_API_LEVEL} ) - set( ARM_TARGET "${ANDROID_ABI}" ) - set( ARMEABI_NDK_NAME "${ANDROID_NDK_ABI_NAME}" ) +# force cmake to produce / instead of \ in build commands for Ninja generator +if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 ) + # it is a bad hack after all + # CMake generates Ninja makefiles with UNIX paths only if it thinks that we are going to build with MinGW + set( CMAKE_COMPILER_IS_MINGW TRUE ) # tell CMake that we are MinGW + set( CMAKE_CROSSCOMPILING TRUE ) # stop recursion + enable_language( C ) + enable_language( CXX ) + # unset( CMAKE_COMPILER_IS_MINGW ) # can't unset because CMake does not convert back-slashes in response files without it + unset( MINGW ) endif() # Variables controlling behavior or set by cmake toolchain: -# ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips" -# ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version) +# ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a-hard with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips", "arm64-v8a", "x86_64", "mips64" +# ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14,15,16,17,18,19,21 (depends on NDK version) # ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none # ANDROID_FORBID_SYGWIN : ON/OFF # ANDROID_NO_UNDEFINED : ON/OFF @@ -1686,47 +1678,43 @@ endif() # ANDROID_RELRO : ON/OFF # ANDROID_FORCE_ARM_BUILD : ON/OFF # ANDROID_STL_FORCE_FEATURES : ON/OFF -# ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF +# ANDROID_LIBM_PATH : path to libm.so (set to something like $(TOP)/out/target/product//obj/lib/libm.so) to workaround unresolved `sincos` # Can be set only at the first run: -# ANDROID_NDK -# ANDROID_STANDALONE_TOOLCHAIN +# ANDROID_NDK : path to your NDK install +# NDK_CCACHE : path to your ccache executable # ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain # ANDROID_NDK_HOST_X64 : try to use x86_64 toolchain (default for x64 host systems) # ANDROID_NDK_LAYOUT : the inner NDK structure (RELEASE, LINARO, ANDROID) # LIBRARY_OUTPUT_PATH_ROOT : -# NDK_CCACHE : -# Obsolete: -# ANDROID_API_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL -# ARM_TARGET : superseded by ANDROID_ABI -# ARM_TARGETS : superseded by ANDROID_ABI (can be set only) -# ANDROID_NDK_TOOLCHAIN_ROOT : superseded by ANDROID_STANDALONE_TOOLCHAIN (can be set only) -# ANDROID_USE_STLPORT : superseded by ANDROID_STL=stlport_static -# ANDROID_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL (completely removed) +# ANDROID_STANDALONE_TOOLCHAIN # # Primary read-only variables: # ANDROID : always TRUE # ARMEABI : TRUE for arm v6 and older devices # ARMEABI_V6 : TRUE for arm v6 # ARMEABI_V7A : TRUE for arm v7a +# ARMEABI_V7A_HARD : TRUE for arm v7a with hardfp +# ARM64_V8A : TRUE for arm64-v8a # NEON : TRUE if NEON unit is enabled # VFPV3 : TRUE if VFP version 3 is enabled # X86 : TRUE if configured for x86 +# X86_64 : TRUE if configured for x86_64 # MIPS : TRUE if configured for mips -# BUILD_ANDROID : always TRUE +# MIPS64 : TRUE if configured for mips64 # BUILD_WITH_ANDROID_NDK : TRUE if NDK is used # BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used # ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform -# ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86" or "mips" depending on ANDROID_ABI -# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d, r8e; set only for NDK -# ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI +# ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "armeabi-v7a-hard", "x86", "mips", "arm64-v8a", "x86_64", "mips64" depending on ANDROID_ABI +# ANDROID_NDK_RELEASE : from r5 to r10d; set only for NDK +# ANDROID_NDK_RELEASE_NUM : numeric ANDROID_NDK_RELEASE version (1000*major+minor) +# ANDROID_ARCH_NAME : "arm", "x86", "mips", "arm64", "x86_64", "mips64" depending on ANDROID_ABI # ANDROID_SYSROOT : path to the compiler sysroot # TOOL_OS_SUFFIX : "" or ".exe" depending on host platform # ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used -# Obsolete: -# ARMEABI_NDK_NAME : superseded by ANDROID_NDK_ABI_NAME # # Secondary (less stable) read-only variables: -# ANDROID_COMPILER_VERSION : GCC version used +# ANDROID_COMPILER_VERSION : GCC version used (not Clang version) +# ANDROID_CLANG_VERSION : version of clang compiler if clang is used # ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform # ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI # ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux" @@ -1737,13 +1725,10 @@ endif() # ANDROID_RTTI : if rtti is enabled by the runtime # ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime # ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used -# ANDROID_CLANG_VERSION : version of clang compiler if clang is used -# ANDROID_LIBM_PATH : path to libm.so (set to something like $(TOP)/out/target/product//obj/lib/libm.so) to workaround unresolved `sincos` # # Defaults: # ANDROID_DEFAULT_NDK_API_LEVEL # ANDROID_DEFAULT_NDK_API_LEVEL_${ARCH} # ANDROID_NDK_SEARCH_PATHS -# ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH # ANDROID_SUPPORTED_ABIS_${ARCH} # ANDROID_SUPPORTED_NDK_VERSIONS From ec6f5447307100e1e0d8d252b17262f9d1734c45 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 23 Jan 2017 12:56:50 +0100 Subject: [PATCH 212/226] Make sure HierarchyLocker dtor does not call terminate(). GitHub issue #215. Mark `~HierarchyLocker()` with `noexcept(false)` to avoid unlikely but possible `terminate()` call and a warning message during compilation. --- include/log4cplus/config.hxx | 7 +++++++ include/log4cplus/hierarchylocker.h | 15 +++++++-------- src/hierarchylocker.cxx | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index dfd984150..63a010d2c 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -109,6 +109,13 @@ # define LOG4CPLUS_HAVE_RVALUE_REFS #endif +#if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) \ + || __has_feature(cxx_noexcept) +# define LOG4CPLUS_NOEXCEPT_FALSE noexcept(false) +#else +# define LOG4CPLUS_NOEXCEPT_FALSE /* empty */ +#endif + #if ! defined (UNICODE) && defined (__GNUC__) && __GNUC__ >= 3 # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, format_index, first_arg_index) \ __attribute__ ((format (archetype, format_index, first_arg_index))) diff --git a/include/log4cplus/hierarchylocker.h b/include/log4cplus/hierarchylocker.h index ed2766470..9f18aacb5 100644 --- a/include/log4cplus/hierarchylocker.h +++ b/include/log4cplus/hierarchylocker.h @@ -48,25 +48,25 @@ namespace log4cplus public: // ctor & dtor HierarchyLocker(Hierarchy& h); - ~HierarchyLocker(); - + ~HierarchyLocker() LOG4CPLUS_NOEXCEPT_FALSE; + /** * Calls the resetConfiguration() method on the locked Hierarchy. */ - void resetConfiguration(); - + void resetConfiguration(); + /** * Calls the getInstance() method on the locked Hierarchy. */ Logger getInstance(const log4cplus::tstring& name); - + /** * Calls the getInstance() method on the locked Hierarchy. */ Logger getInstance(const log4cplus::tstring& name, spi::LoggerFactory& factory); - + void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender); - + private: // Data Hierarchy& h; @@ -77,4 +77,3 @@ namespace log4cplus } // end namespace log4cplus #endif // LOG4CPLUS_HIERARCHY_LOCKER_HEADER_ - diff --git a/src/hierarchylocker.cxx b/src/hierarchylocker.cxx index b7e77a79a..3a8dfa472 100644 --- a/src/hierarchylocker.cxx +++ b/src/hierarchylocker.cxx @@ -61,7 +61,7 @@ HierarchyLocker::HierarchyLocker(Hierarchy& _h) } -HierarchyLocker::~HierarchyLocker() +HierarchyLocker::~HierarchyLocker() LOG4CPLUS_NOEXCEPT_FALSE { try { for(LoggerList::iterator it=loggerList.begin(); it!=loggerList.end(); ++it) { From 1acc2fd9da7529ed1f9d1324186dedc73da20f45 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 23 Jan 2017 13:37:52 +0100 Subject: [PATCH 213/226] Define `LOG4CPLUS_NOEXCEPT_FALSE` for Visual Studio 2015+. --- include/log4cplus/config.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index 63a010d2c..3ffc67cd9 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -110,7 +110,8 @@ #endif #if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) \ - || __has_feature(cxx_noexcept) + || __has_feature(cxx_noexcept) \ + || (defined (_MSC_VER) && _MSC_VER >= 1900) # define LOG4CPLUS_NOEXCEPT_FALSE noexcept(false) #else # define LOG4CPLUS_NOEXCEPT_FALSE /* empty */ From fb937803bd9f78d8150c7c2a7ce79551c98c5934 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 23 Jan 2017 14:30:00 +0100 Subject: [PATCH 214/226] Define `LOG4CPLUS_NOEXCEPT_FALSE` for Visual Studio 2015+. --- include/log4cplus/config.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index 3ffc67cd9..1c1489417 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -109,9 +109,9 @@ # define LOG4CPLUS_HAVE_RVALUE_REFS #endif -#if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) \ - || __has_feature(cxx_noexcept) \ - || (defined (_MSC_VER) && _MSC_VER >= 1900) +#if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) \ + && (__has_feature(cxx_noexcept) \ + || (defined (_MSC_VER) && _MSC_VER >= 1900)) # define LOG4CPLUS_NOEXCEPT_FALSE noexcept(false) #else # define LOG4CPLUS_NOEXCEPT_FALSE /* empty */ From 04d39f48741205e081f6a5a6d95f2d0e10814f73 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 29 Jan 2017 17:41:03 +0100 Subject: [PATCH 215/226] Fix NULL pointer dereference of queue in AsyncAppender code. GH#205. --- src/asyncappender.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/asyncappender.cxx b/src/asyncappender.cxx index fe55bf7ff..2013d100c 100644 --- a/src/asyncappender.cxx +++ b/src/asyncappender.cxx @@ -155,15 +155,21 @@ AsyncAppender::init_queue_thread (unsigned queue_len) void AsyncAppender::close () { - unsigned ret = queue->signal_exit (); - if (ret & (thread::Queue::ERROR_BIT | thread::Queue::ERROR_AFTER)) - getErrorHandler ()->error ( - LOG4CPLUS_TEXT ("Error in AsyncAppender::close")); + if (queue) + { + unsigned ret = queue->signal_exit (); + if (ret & (thread::Queue::ERROR_BIT | thread::Queue::ERROR_AFTER)) + getErrorHandler ()->error ( + LOG4CPLUS_TEXT ("Error in AsyncAppender::close")); + } if (queue_thread && queue_thread->isRunning ()) queue_thread->join (); removeAllAppenders(); + + queue_thread = 0; + queue = 0; } From fd97ff429ee06dc29dd3df76617e7a4be4efd1e6 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 29 Jan 2017 19:23:51 +0100 Subject: [PATCH 216/226] Fix syncprims error message format. --- src/syncprims.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syncprims.cxx b/src/syncprims.cxx index bd6da2322..1c3ef0a76 100644 --- a/src/syncprims.cxx +++ b/src/syncprims.cxx @@ -40,7 +40,7 @@ syncprims_throw_exception (char const * const msg, char const * const file, int line) { std::ostringstream oss; - oss << file << ":" << line << msg; + oss << file << ":" << line << ": " << msg; throw std::runtime_error (oss.str ()); } From 3ddb69a055dac142b486951008e4c29e72d5cfce Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 29 Jan 2017 19:26:32 +0100 Subject: [PATCH 217/226] Print exception message in Queue implementation. It is better to print the error message than to hide it. --- src/queue.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/queue.cxx b/src/queue.cxx index a45d365e2..085e6643d 100644 --- a/src/queue.cxx +++ b/src/queue.cxx @@ -79,7 +79,9 @@ Queue::put_event (spi::InternalLoggingEvent const & ev) } catch (std::runtime_error const & e) { - (void)e; + log4cplus::helpers::getLogLog().error( + LOG4CPLUS_TEXT("put_event() exception: ") + + LOG4CPLUS_C_STR_TO_TSTRING(e.what())); return ret_flags; } @@ -114,7 +116,9 @@ Queue::signal_exit (bool drain) } catch (std::runtime_error const & e) { - (void)e; + log4cplus::helpers::getLogLog().error( + LOG4CPLUS_TEXT("signal_exit() exception: ") + + LOG4CPLUS_C_STR_TO_TSTRING(e.what())); ret_flags |= ERROR_BIT; return ret_flags; } @@ -174,7 +178,9 @@ Queue::get_events (queue_storage_type * buf) } catch (std::runtime_error const & e) { - (void)e; + log4cplus::helpers::getLogLog().error( + LOG4CPLUS_TEXT("get_events() exception: ") + + LOG4CPLUS_C_STR_TO_TSTRING(e.what())); ret_flags |= ERROR_BIT; } From da867ad2fcc4b8220c3b1b66cc4f2b12b75d3a73 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman Date: Fri, 2 Jan 2015 14:30:35 +0100 Subject: [PATCH 218/226] Check for constructor attribute with and without priority support. --- configure | 56 +++++++++++++++++++++++++ configure.ac | 5 +++ include/log4cplus/config.h.in | 7 ++++ include/log4cplus/config.hxx | 5 ++- include/log4cplus/config/defines.hxx.in | 4 ++ m4/ax_gcc_func_attribute.m4 | 4 ++ 6 files changed, 80 insertions(+), 1 deletion(-) diff --git a/configure b/configure index b26a8c2c8..f7022d778 100755 --- a/configure +++ b/configure @@ -7756,6 +7756,62 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((constructor_priority))" >&5 +$as_echo_n "checking for __attribute__((constructor_priority))... " >&6; } +if ${ax_cv_have_func_attribute_constructor_priority+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + int foo( void ) __attribute__((__constructor__(65535/2))); + +int +main () +{ + + ; + return 0; +} + +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + if test -s conftest.err; then : + ax_cv_have_func_attribute_constructor_priority=no +else + ax_cv_have_func_attribute_constructor_priority=yes +fi +else + ax_cv_have_func_attribute_constructor_priority=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_func_attribute_constructor_priority" >&5 +$as_echo "$ax_cv_have_func_attribute_constructor_priority" >&6; } + + if test yes = $ax_cv_have_func_attribute_constructor_priority; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY 1 +_ACEOF + +fi + + + + +if test "x$ax_cv_have_func_attribute_constructor_priority" = "xyes"; then : + $as_echo "#define LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY 1" >>confdefs.h + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((constructor))" >&5 $as_echo_n "checking for __attribute__((constructor))... " >&6; } if ${ax_cv_have_func_attribute_constructor+:} false; then : diff --git a/configure.ac b/configure.ac index 293a9c234..9d6d65803 100644 --- a/configure.ac +++ b/configure.ac @@ -331,6 +331,11 @@ AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_SYMBOL]) AS_IF([test "x$ac_cv_have___func___symbol" = "xyes"], [AC_DEFINE([LOG4CPLUS_HAVE_FUNC_SYMBOL])]) +AX_GCC_FUNC_ATTRIBUTE([constructor_priority]) +AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY]) +AS_IF([test "x$ax_cv_have_func_attribute_constructor_priority" = "xyes"], + [AC_DEFINE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY])]) + AX_GCC_FUNC_ATTRIBUTE([constructor]) AH_TEMPLATE([LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR]) AS_IF([test "x$ax_cv_have_func_attribute_constructor" = "xyes"], diff --git a/include/log4cplus/config.h.in b/include/log4cplus/config.h.in index 1f2ef9511..f2d8819f0 100644 --- a/include/log4cplus/config.h.in +++ b/include/log4cplus/config.h.in @@ -36,6 +36,10 @@ /* Define to 1 if the system has the `constructor' function attribute */ #undef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR +/* Define to 1 if the system has the `constructor_priority' function attribute + */ +#undef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY + /* */ #undef HAVE_GETADDRINFO @@ -259,6 +263,9 @@ /* */ #undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR +/* */ +#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY + /* */ #undef LOG4CPLUS_HAVE_FUNC_SYMBOL diff --git a/include/log4cplus/config.hxx b/include/log4cplus/config.hxx index 1c1489417..c1331c8bd 100644 --- a/include/log4cplus/config.hxx +++ b/include/log4cplus/config.hxx @@ -153,9 +153,12 @@ # pragma once #endif -#if defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR) +#if defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY) # define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \ __attribute__ ((__constructor__ ((prio)))) +#elif defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR) +# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \ + __attribute__ ((__constructor__)) #else # define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) /* empty */ #endif diff --git a/include/log4cplus/config/defines.hxx.in b/include/log4cplus/config/defines.hxx.in index 2f4158e62..b87b4a484 100644 --- a/include/log4cplus/config/defines.hxx.in +++ b/include/log4cplus/config/defines.hxx.in @@ -256,6 +256,10 @@ /* Define to 1 if you have the `iconv_open' function. */ #undef LOG4CPLUS_HAVE_ICONV_OPEN +/* Define to 1 if the system has the `constructor' function attribute + with priority */ +#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY + /* Define to 1 if the system has the `constructor' function attribute */ #undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR diff --git a/m4/ax_gcc_func_attribute.m4 b/m4/ax_gcc_func_attribute.m4 index de11303e7..5ffe071d1 100644 --- a/m4/ax_gcc_func_attribute.m4 +++ b/m4/ax_gcc_func_attribute.m4 @@ -31,6 +31,7 @@ # cold # const # constructor +# constructor_priority for constructor attribute with priority # deprecated # destructor # dllexport @@ -103,6 +104,9 @@ AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ [const], [ int foo( void ) __attribute__(($1)); ], + [constructor_priority], [ + int foo( void ) __attribute__((__constructor__(65535/2))); + ], [constructor], [ int foo( void ) __attribute__(($1)); ], From 9f570f078d619ed722f54737678599c3d3aaef20 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 29 Jan 2017 22:56:59 +0100 Subject: [PATCH 219/226] `sem_wait` is interruptible by signals, handle it. --- include/log4cplus/thread/impl/syncprims-pthreads.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/log4cplus/thread/impl/syncprims-pthreads.h b/include/log4cplus/thread/impl/syncprims-pthreads.h index 0d3167c8b..ed559b086 100644 --- a/include/log4cplus/thread/impl/syncprims-pthreads.h +++ b/include/log4cplus/thread/impl/syncprims-pthreads.h @@ -245,11 +245,17 @@ inline void Semaphore::lock () const { + int ret; + while (( #if defined (LOG4CPLUS_USE_NAMED_POSIX_SEMAPHORE) - int ret = sem_wait (sem); + ret = sem_wait (sem) #else - int ret = sem_wait (&sem); + ret = sem_wait (&sem) #endif + ) == -1 + && errno == EINTR) + { /* try again after signal */ } + if (ret != 0) LOG4CPLUS_THROW_RTE ("Semaphore::lock"); } From 06c879bfa2b4f3c8447e88b1b26f8f7f5f8a7cb9 Mon Sep 17 00:00:00 2001 From: Dmitry Belous Date: Sun, 24 Jul 2016 17:25:43 +0200 Subject: [PATCH 220/226] Disable TLS support for iOS. configure.ac: added conditional around AX_TLS_SUPPORT to not call it if iOS target system configure.ac: added comment about TLS check guards for iOS --- configure | 3 +++ configure.ac | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/configure b/configure index f7022d778..07a53596f 100755 --- a/configure +++ b/configure @@ -9520,6 +9520,7 @@ esac ;; esac + if test "$target_os" != "darwin" -o "$target_cpu" != "arm"; then : @@ -9846,6 +9847,8 @@ fi fi +fi + if test "x$ac_cv_thread_local" = "xyes"; then : diff --git a/configure.ac b/configure.ac index 9d6d65803..7aff0892d 100644 --- a/configure.ac +++ b/configure.ac @@ -451,7 +451,11 @@ dnl Multi threaded library. AS_IF([test "x$ac_cv_cxx11_atomics" = "xyes"], [AC_DEFINE([LOG4CPLUS_HAVE_CXX11_ATOMICS])]) - AX_TLS_SUPPORT + dnl Check if TLS is supported, but only if it isn't iOS target, because it + dnl is forbidden by Apple Store to use __tlv_* functions. + AS_IF([test "$target_os" != "darwin" -o "$target_cpu" != "arm"], + [AX_TLS_SUPPORT]) + AH_TEMPLATE([LOG4CPLUS_HAVE_TLS_SUPPORT]) AH_TEMPLATE([LOG4CPLUS_THREAD_LOCAL_VAR]) AS_IF([test "x$ac_cv_thread_local" = "xyes"], From cf114b9918ba986adc12b558b02977df1d24989e Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 30 Jan 2017 12:27:50 +0100 Subject: [PATCH 221/226] Don't try to use language level TLS on Cygwin. Cygwin passes the compilation and link test in configure script but fails during linking of the real code, so we want to avoid it. See GCC PR64697. --- configure | 3 ++- configure.ac | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 07a53596f..1c1b847eb 100755 --- a/configure +++ b/configure @@ -9520,7 +9520,8 @@ esac ;; esac - if test "$target_os" != "darwin" -o "$target_cpu" != "arm"; then : + if test \( "$target_os" != "darwin" -o "$target_cpu" != "arm" \) \ + -a "$target_os" != "cygwin"; then : diff --git a/configure.ac b/configure.ac index 7aff0892d..9235aee27 100644 --- a/configure.ac +++ b/configure.ac @@ -452,8 +452,11 @@ dnl Multi threaded library. [AC_DEFINE([LOG4CPLUS_HAVE_CXX11_ATOMICS])]) dnl Check if TLS is supported, but only if it isn't iOS target, because it - dnl is forbidden by Apple Store to use __tlv_* functions. - AS_IF([test "$target_os" != "darwin" -o "$target_cpu" != "arm"], + dnl is forbidden by Apple Store to use __tlv_* functions. Also, Cygwin + dnl passes the compilation and link test here but fails during linking of + dnl the real code, so we want to avoid it too. See GCC PR64697. + AS_IF([test \( "$target_os" != "darwin" -o "$target_cpu" != "arm" \) \ + -a "$target_os" != "cygwin"], [AX_TLS_SUPPORT]) AH_TEMPLATE([LOG4CPLUS_HAVE_TLS_SUPPORT]) From d0050220f4abc47256d6b5530960895cca90ea70 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Mon, 30 Jan 2017 21:50:49 +0100 Subject: [PATCH 222/226] Allow filters configuration for AsyncAppender. Allow filters configuration (and other properties) for AsyncAppender by calling base Appender ctor with properties argument. This was suggested in SF#297 by Markus von Arx. --- src/asyncappender.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/asyncappender.cxx b/src/asyncappender.cxx index 2013d100c..d0f239326 100644 --- a/src/asyncappender.cxx +++ b/src/asyncappender.cxx @@ -100,6 +100,7 @@ AsyncAppender::AsyncAppender (SharedAppenderPtr const & app, AsyncAppender::AsyncAppender (helpers::Properties const & props) + : Appender (props) { tstring const & appender_name ( props.getProperty (LOG4CPLUS_TEXT ("Appender"))); From 9cbf4a5005fd2bc500402aebe7eb0161cc2c0156 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 2 Jul 2017 11:17:24 +0200 Subject: [PATCH 223/226] Small tweaks to SocketBuffer. --- src/socketbuffer.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/socketbuffer.cxx b/src/socketbuffer.cxx index 297c78d18..db71fb6ee 100644 --- a/src/socketbuffer.cxx +++ b/src/socketbuffer.cxx @@ -122,7 +122,7 @@ SocketBuffer::readInt() std::memcpy (&ret, buffer + pos, sizeof(ret)); ret = ntohl(ret); pos += sizeof(unsigned int); - + return ret; } @@ -239,7 +239,7 @@ void SocketBuffer::appendString(const tstring& str) { std::size_t const strlen = str.length(); - static std::size_t const sizeOfChar = sizeof (tchar) == 1 ? 1 : 2; + std::size_t const sizeOfChar = sizeof (tchar) == 1 ? 1 : 2; if((pos + sizeof(unsigned int) + strlen * sizeOfChar) > maxsize) { @@ -254,7 +254,7 @@ SocketBuffer::appendString(const tstring& str) pos += strlen; size = pos; #else - for(tstring::size_type i=0; i(str[i])); } #endif From 6e0cc94825070780b22246fe02649988529fb71a Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Sun, 9 Jul 2017 09:56:53 +0200 Subject: [PATCH 224/226] Handle SocketBuffer overflow by throwing an exception. Catch this exception in SocketAppender and throw away such message. --- src/socketappender.cxx | 12 ++++++++++-- src/socketbuffer.cxx | 28 ++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/socketappender.cxx b/src/socketappender.cxx index f16ad9fc6..7fafd3d16 100644 --- a/src/socketappender.cxx +++ b/src/socketappender.cxx @@ -19,6 +19,7 @@ // limitations under the License. #include +#include #include #include #include @@ -232,9 +233,16 @@ SocketAppender::append(const spi::InternalLoggingEvent& event) #endif helpers::SocketBuffer buffer(LOG4CPLUS_MAX_MESSAGE_SIZE - sizeof(unsigned int)); - convertToBuffer (buffer, event, serverName); - helpers::SocketBuffer msgBuffer(LOG4CPLUS_MAX_MESSAGE_SIZE); + try + { + convertToBuffer (buffer, event, serverName); + } + catch (std::runtime_error const & ex) + { + return; + } + helpers::SocketBuffer msgBuffer(LOG4CPLUS_MAX_MESSAGE_SIZE); msgBuffer.appendInt(static_cast(buffer.getSize())); msgBuffer.appendBuffer(buffer); diff --git a/src/socketbuffer.cxx b/src/socketbuffer.cxx index db71fb6ee..3ab80368e 100644 --- a/src/socketbuffer.cxx +++ b/src/socketbuffer.cxx @@ -192,8 +192,10 @@ void SocketBuffer::appendByte(unsigned char val) { if((pos + sizeof(unsigned char)) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendByte()- Attempt to write beyond end of buffer")); - return; + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendByte()-") + LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer"), + true); } buffer[pos] = static_cast(val); @@ -207,8 +209,10 @@ void SocketBuffer::appendShort(unsigned short val) { if((pos + sizeof(unsigned short)) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendShort()- Attempt to write beyond end of buffer")); - return; + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendShort()-") + LOG4CPLUS_TEXT("Attempt to write beyond end of buffer"), + true); } unsigned short s = htons(val); @@ -223,7 +227,10 @@ void SocketBuffer::appendInt(unsigned int val) { if((pos + sizeof(unsigned int)) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendInt()- Attempt to write beyond end of buffer")); + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendInt()-") + LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer"), + true); return; } @@ -243,8 +250,10 @@ SocketBuffer::appendString(const tstring& str) if((pos + sizeof(unsigned int) + strlen * sizeOfChar) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendString()-") - LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer")); + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendString()-") + LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer"), + true); return; } @@ -266,7 +275,10 @@ void SocketBuffer::appendBuffer(const SocketBuffer& buf) { if((pos + buf.getSize()) > maxsize) { - getLogLog().error(LOG4CPLUS_TEXT("SocketBuffer::appendBuffer()- Attempt to write beyond end of buffer")); + getLogLog().error( + LOG4CPLUS_TEXT("SocketBuffer::appendBuffer()-") + LOG4CPLUS_TEXT(" Attempt to write beyond end of buffer"), + true); return; } From 78ca687803b5ac07ca234f50b0d97889750d2908 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Tue, 11 Jul 2017 20:48:11 +0200 Subject: [PATCH 225/226] Bump revision. Regenerate configure script. --- configure | 6 +++--- configure.ac | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 1c1b847eb..50186b194 100755 --- a/configure +++ b/configure @@ -4225,7 +4225,7 @@ esac # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=11:4:2 +LT_VERSION=11:5:2 LT_RELEASE=1.1 @@ -9520,8 +9520,6 @@ esac ;; esac - if test \( "$target_os" != "darwin" -o "$target_cpu" != "arm" \) \ - -a "$target_os" != "cygwin"; then : @@ -9676,6 +9674,8 @@ fi fi + if test \( "$target_os" != "darwin" -o "$target_cpu" != "arm" \) \ + -a "$target_os" != "cygwin"; then : diff --git a/configure.ac b/configure.ac index 9235aee27..b22ec6149 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AM_PROG_AR # ? :+1 : ? == just some internal changes, nothing breaks but might work # better # CURRENT : REVISION : AGE -LT_VERSION=11:4:2 +LT_VERSION=11:5:2 LT_RELEASE=1.1 AC_SUBST([LT_VERSION]) AC_SUBST([LT_RELEASE]) From 010a0e3cf88ee5129e3204720988fd4f611b50e6 Mon Sep 17 00:00:00 2001 From: Vaclav Haisman Date: Tue, 11 Jul 2017 21:02:42 +0200 Subject: [PATCH 226/226] Update for 1.1.3-RC8. --- ChangeLog | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3fe95eac4..d786545e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +log4cplus 1.1.3-RC8 + +- Fixed GitHub issue #195. Check if queue thread pointer is not NULL and if + it is running before trying to join it. + +- Fixed GitHub issue #205. Fixed NULL pointer dereference of queue in + `AsyncAppender` code. + +- Fixed SF#333. `AsyncAppender`'s appenders need to be closed so that + accumulated logs get flushed onto disk. + +- Updated `android.toolchain.cmake` from OpenCV. + +- Fixed GitHub issue #215. Mark `~HierarchyLocker()` with `noexcept(false)` + to avoid unlikely but possible `terminate()` call and a warning message + during compilation. + +- Disabled TLS support for iOS. + +- Do not use language level thread-local storage on Cygwin. (GCC PR64697). + +- Allow filters cofiguration in `AsyncAppender`. (suggested in SF#297 by + Markus von Arx) + +- Handle `SocketBuffer` overflow by throwing exception. + + log4cplus 1.1.3-RC7 - Fixed SF#322. -- C++11 construct that should not be present.