Author: carnold
Date: Tue Feb 12 15:52:02 2008
New Revision: 627188

URL: http://svn.apache.org/viewvc?rev=627188&view=rev
Log:
LOGCXX-75: Detect missing fwide for cygwin and stub AsyncAppender when 
!APR_HAS_THREADS

Modified:
    logging/log4cxx/trunk/configure.in
    logging/log4cxx/trunk/src/main/cpp/asyncappender.cpp
    logging/log4cxx/trunk/src/main/cpp/condition.cpp
    logging/log4cxx/trunk/src/main/cpp/systemerrwriter.cpp
    logging/log4cxx/trunk/src/main/cpp/systemoutwriter.cpp
    logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in
    logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw

Modified: logging/log4cxx/trunk/configure.in
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/configure.in?rev=627188&r1=627187&r2=627188&view=diff
==============================================================================
--- logging/log4cxx/trunk/configure.in (original)
+++ logging/log4cxx/trunk/configure.in Tue Feb 12 15:52:02 2008
@@ -191,6 +191,14 @@
  AC_SUBST(HAS_WCHAR_T, 0)
 fi
 
+AC_CHECK_FUNCS(fwide, [have_fwide=yes], [have_fwide=no])
+if test "$have_fwide" = "yes"
+then
+ AC_SUBST(HAS_FWIDE, 1)
+else
+ AC_SUBST(HAS_FWIDE, 0)
+fi
+
 
 # Checks for libraries
 # ----------------------------------------------------------------------------

Modified: logging/log4cxx/trunk/src/main/cpp/asyncappender.cpp
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/asyncappender.cpp?rev=627188&r1=627187&r2=627188&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/asyncappender.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/asyncappender.cpp Tue Feb 12 15:52:02 
2008
@@ -38,8 +38,6 @@
 using namespace log4cxx::helpers;
 using namespace log4cxx::spi;
 
-#if APR_HAS_THREADS
-
 
 IMPLEMENT_LOG4CXX_OBJECT(AsyncAppender)
 
@@ -56,7 +54,9 @@
   dispatcher(),
   locationInfo(false),
   blocking(true) {
+#if APR_HAS_THREADS
   dispatcher.run(dispatch, this);
+#endif
 }
 
 AsyncAppender::~AsyncAppender()
@@ -97,7 +97,8 @@
 
 
 void AsyncAppender::append(const spi::LoggingEventPtr& event, Pool& p) {
-        //
+#if APR_HAS_THREADS
+       //
         //   if dispatcher has died then
         //      append subsequent events synchronously
         //
@@ -168,6 +169,10 @@
                 }
             }
         }
+#else
+        synchronized sync(appenders->getMutex());
+        appenders->appendLoopOnAppenders(event, p);
+#endif
   }
   
 
@@ -179,12 +184,14 @@
         bufferNotFull.signalAll();
     }
     
+#if APR_HAS_THREADS
     try {
         dispatcher.join();
-       } catch(InterruptedException& e) {
+   } catch(InterruptedException& e) {
         Thread::currentThreadInterrupt();
         LogLog::error(LOG4CXX_STR("Got an InterruptedException while waiting 
for the dispatcher to finish,"), e);
     }
+#endif
     
     {
         synchronized sync(appenders->getMutex());
@@ -305,7 +312,7 @@
 }
 
 
-
+#if APR_HAS_THREADS
 void* LOG4CXX_THREAD_FUNC AsyncAppender::dispatch(log4cxx_thread_t* thread, 
void* data) {
     AsyncAppender* pThis = (AsyncAppender*) data;
     bool isActive = true;
@@ -354,5 +361,4 @@
     }
     return 0;
 }
-                
-#endif
+#endif                

Modified: logging/log4cxx/trunk/src/main/cpp/condition.cpp
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/condition.cpp?rev=627188&r1=627187&r2=627188&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/condition.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/condition.cpp Tue Feb 12 15:52:02 2008
@@ -26,32 +26,39 @@
 using namespace log4cxx::helpers;
 using namespace log4cxx;
 
-#if APR_HAS_THREADS
-
 
 Condition::Condition(Pool& p)
 {
-        apr_pool_t* aprPool = (apr_pool_t*) p.getAPRPool();
+#if APR_HAS_THREADS
+       apr_pool_t* aprPool = (apr_pool_t*) p.getAPRPool();
         apr_thread_cond_t* aprCondition = NULL;
         apr_status_t stat = apr_thread_cond_create(&aprCondition, aprPool);
         if (stat != APR_SUCCESS) {
                 throw RuntimeException(stat);
         }
         condition = aprCondition;
+#endif
 }
 
 Condition::~Condition()
 {
+#if APR_HAS_THREADS
         apr_thread_cond_destroy((apr_thread_cond_t*) condition);
+#endif
 }
 
 log4cxx_status_t Condition::signalAll()
 {
+#if APR_HAS_THREADS
         return apr_thread_cond_broadcast((apr_thread_cond_t*) condition);
+#else
+      return APR_SUCCESS;
+#endif
 }
 
 void Condition::await(Mutex& mutex)
 {
+#if APR_HAS_THREADS
         if (Thread::interrupted()) {
              throw InterruptedException();
         }
@@ -61,6 +68,6 @@
         if (stat != APR_SUCCESS) {
                 throw InterruptedException(stat);
         }
+#endif
 }
 
-#endif

Modified: logging/log4cxx/trunk/src/main/cpp/systemerrwriter.cpp
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/systemerrwriter.cpp?rev=627188&r1=627187&r2=627188&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/systemerrwriter.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/systemerrwriter.cpp Tue Feb 12 15:52:02 
2008
@@ -48,20 +48,20 @@
 
 bool SystemErrWriter::isWide() {
 #if LOG4CXX_FORCE_WIDE_CONSOLE
-       return true;
-#elif LOG4CXX_FORCE_BYTE_CONSOLE
-       return false;
+   return true;
+#elif LOG4CXX_FORCE_BYTE_CONSOLE || !LOG4CXX_HAS_FWIDE
+   return false;
 #else
-       return fwide(stderr, 0) > 0;
+   return fwide(stderr, 0) > 0;
 #endif
 }
 
 void SystemErrWriter::write(const LogString& str) {
 #if LOG4CXX_WCHAR_T_API
     if (isWide()) {
-       LOG4CXX_ENCODE_WCHAR(msg, str);
+      LOG4CXX_ENCODE_WCHAR(msg, str);
         fputws(msg.c_str(), stderr);
-               return;
+      return;
     }
 #endif
     LOG4CXX_ENCODE_CHAR(msg, str);

Modified: logging/log4cxx/trunk/src/main/cpp/systemoutwriter.cpp
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/systemoutwriter.cpp?rev=627188&r1=627187&r2=627188&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/systemoutwriter.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/systemoutwriter.cpp Tue Feb 12 15:52:02 
2008
@@ -49,20 +49,20 @@
 
 bool SystemOutWriter::isWide() {
 #if LOG4CXX_FORCE_WIDE_CONSOLE
-       return true;
-#elif LOG4CXX_FORCE_BYTE_CONSOLE
-       return false;
+   return true;
+#elif LOG4CXX_FORCE_BYTE_CONSOLE || !LOG4CXX_HAS_FWIDE
+   return false;
 #else
-       return fwide(stdout, 0) > 0;
+   return fwide(stdout, 0) > 0;
 #endif
 }
 
 void SystemOutWriter::write(const LogString& str) {
 #if LOG4CXX_WCHAR_T_API
     if (isWide()) {
-       LOG4CXX_ENCODE_WCHAR(msg, str);
+      LOG4CXX_ENCODE_WCHAR(msg, str);
         fputws(msg.c_str(), stdout);
-               return;
+      return;
     }
 #endif
     LOG4CXX_ENCODE_CHAR(msg, str);

Modified: 
logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in?rev=627188&r1=627187&r2=627188&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in 
(original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.h.in 
Tue Feb 12 15:52:02 2008
@@ -39,6 +39,7 @@
 #define LOG4CXX_HAVE_ODBC @HAS_ODBC@
 #define LOG4CXX_HAS_MBSRTOWCS @HAS_MBSRTOWCS@
 #define LOG4CXX_HAS_WCSTOMBS @HAS_WCSTOMBS@
+#define LOG4CXX_HAS_FWIDE @HAS_FWIDE@
 
 #define LOG4CXX_CHARSET_UTF8 @CHARSET_UTF8@
 #define LOG4CXX_CHARSET_ISO88591 @CHARSET_ISO88591@

Modified: 
logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw?rev=627188&r1=627187&r2=627188&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw 
(original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/private/log4cxx_private.hw 
Tue Feb 12 15:52:02 2008
@@ -62,6 +62,7 @@
 #define LOG4CXX_HAS_MBSRTOWCS 0
 #endif
 
+#define LOG4CXX_HAS_FWIDE 1
 #define LOG4CXX_HAS_WCSTOMBS 1
 
 #define LOG4CXX_CHARSET_UTF8 0


Reply via email to