summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base/mutex.h4
-rw-r--r--src/config.h.cmake.in181
-rw-r--r--src/config.h.in9
-rw-r--r--src/demangle.h2
-rw-r--r--src/demangle_unittest.cc5
-rw-r--r--src/glog/logging.h.in25
-rw-r--r--src/googletest.h2
-rw-r--r--src/logging.cc2
-rw-r--r--src/logging_unittest.cc1
-rw-r--r--src/mock-log.h3
-rw-r--r--src/signalhandler_unittest.cc5
-rw-r--r--src/stl_logging_unittest.cc9
-rw-r--r--src/symbolize_unittest.cc5
-rw-r--r--src/utilities_unittest.cc6
-rw-r--r--src/vlog_is_on.cc38
-rwxr-xr-xsrc/windows/port.cc2
-rwxr-xr-xsrc/windows/port.h8
17 files changed, 271 insertions, 36 deletions
diff --git a/src/base/mutex.h b/src/base/mutex.h
index 37527d5..ced2b99 100644
--- a/src/base/mutex.h
+++ b/src/base/mutex.h
@@ -134,7 +134,9 @@
// *does* cause problems for FreeBSD, or MacOSX, but isn't needed
// for locking there.)
# ifdef __linux__
-# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
+# ifndef _XOPEN_SOURCE // Some other header might have already set it for us.
+# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
+# endif
# endif
# include <pthread.h>
typedef pthread_rwlock_t MutexType;
diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in
new file mode 100644
index 0000000..0094a09
--- /dev/null
+++ b/src/config.h.cmake.in
@@ -0,0 +1,181 @@
+/* define if glog doesn't use RTTI */
+#cmakedefine DISABLE_RTTI
+
+/* Namespace for Google classes */
+#cmakedefine GOOGLE_NAMESPACE ${GOOGLE_NAMESPACE}
+
+/* Define if you have the `dladdr' function */
+#cmakedefine HAVE_DLADDR
+
+/* Define if you have the `snprintf' function */
+#cmakedefine HAVE_SNPRINTF
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#cmakedefine HAVE_DLFCN_H
+
+/* Define to 1 if you have the <execinfo.h> header file. */
+#cmakedefine HAVE_EXECINFO_H
+
+/* Define if you have the `fcntl' function */
+#cmakedefine HAVE_FCNTL
+
+/* Define to 1 if you have the <glob.h> header file. */
+#cmakedefine HAVE_GLOB_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#cmakedefine HAVE_LIBPTHREAD
+
+/* Define to 1 if you have the <libunwind.h> header file. */
+#cmakedefine HAVE_LIBUNWIND_H
+
+/* define if you have google gflags library */
+#cmakedefine HAVE_LIB_GFLAGS
+
+/* define if you have google gmock library */
+#cmakedefine HAVE_LIB_GMOCK
+
+/* define if you have google gtest library */
+#cmakedefine HAVE_LIB_GTEST
+
+/* define if you have libunwind */
+#cmakedefine HAVE_LIB_UNWIND
+
+/* Define to 1 if you have the <memory.h> header file. */
+#cmakedefine HAVE_MEMORY_H
+
+/* define if the compiler implements namespaces */
+#cmakedefine HAVE_NAMESPACES
+
+/* Define if you have the 'pread' function */
+#cmakedefine HAVE_PREAD
+
+/* Define if you have POSIX threads libraries and header files. */
+#cmakedefine HAVE_PTHREAD
+
+/* Define to 1 if you have the <pwd.h> header file. */
+#cmakedefine HAVE_PWD_H
+
+/* Define if you have the 'pwrite' function */
+#cmakedefine HAVE_PWRITE
+
+/* define if the compiler implements pthread_rwlock_* */
+#cmakedefine HAVE_RWLOCK
+
+/* Define if you have the 'sigaction' function */
+#cmakedefine HAVE_SIGACTION
+
+/* Define if you have the `sigaltstack' function */
+#cmakedefine HAVE_SIGALTSTACK
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#cmakedefine HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#cmakedefine HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#cmakedefine HAVE_STRING_H
+
+/* Define to 1 if you have the <syscall.h> header file. */
+#cmakedefine HAVE_SYSCALL_H
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#cmakedefine HAVE_SYSLOG_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/syscall.h> header file. */
+#cmakedefine HAVE_SYS_SYSCALL_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#cmakedefine HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H}
+
+/* Define to 1 if you have the <sys/ucontext.h> header file. */
+#cmakedefine HAVE_SYS_UCONTEXT_H
+
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+#cmakedefine HAVE_SYS_UTSNAME_H
+
+/* Define to 1 if you have the <ucontext.h> header file. */
+#cmakedefine HAVE_UCONTEXT_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
+
+/* Define to 1 if you have the <unwind.h> header file. */
+#cmakedefine HAVE_UNWIND_H ${HAVE_UNWIND_H}
+
+/* define if the compiler supports using expression for operator */
+#cmakedefine HAVE_USING_OPERATOR
+
+/* define if your compiler has __attribute__ */
+#cmakedefine HAVE___ATTRIBUTE__
+
+/* define if your compiler has __builtin_expect */
+#cmakedefine HAVE___BUILTIN_EXPECT ${HAVE___BUILTIN_EXPECT}
+
+/* define if your compiler has __sync_val_compare_and_swap */
+#cmakedefine HAVE___SYNC_VAL_COMPARE_AND_SWAP
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#cmakedefine LT_OBJDIR
+
+/* Name of package */
+#cmakedefine PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#cmakedefine PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#cmakedefine PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#cmakedefine PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#cmakedefine PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#cmakedefine PACKAGE_URL
+
+/* Define to the version of this package. */
+#cmakedefine PACKAGE_VERSION
+
+/* How to access the PC from a struct ucontext */
+#cmakedefine PC_FROM_UCONTEXT
+
+/* Define to necessary symbol if this constant uses a non-standard name on
+ your system. */
+#cmakedefine PTHREAD_CREATE_JOINABLE
+
+/* The size of `void *', as computed by sizeof. */
+#cmakedefine SIZEOF_VOID_P ${SIZEOF_VOID_P}
+
+/* Define to 1 if you have the ANSI C header files. */
+#cmakedefine STDC_HEADERS
+
+/* the namespace where STL code like vector<> is defined */
+#cmakedefine STL_NAMESPACE ${STL_NAMESPACE}
+
+/* location of source code */
+#cmakedefine TEST_SRC_DIR ${TEST_SRC_DIR}
+
+/* Version number of package */
+#cmakedefine VERSION
+
+/* Stops putting the code inside the Google namespace */
+#cmakedefine _END_GOOGLE_NAMESPACE_ ${_END_GOOGLE_NAMESPACE_}
+
+/* Puts following code inside the Google namespace */
+#cmakedefine _START_GOOGLE_NAMESPACE_ ${_START_GOOGLE_NAMESPACE_}
diff --git a/src/config.h.in b/src/config.h.in
index 8190f23..e41635a 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -178,3 +178,12 @@
/* Puts following code inside the Google namespace */
#undef _START_GOOGLE_NAMESPACE_
+
+// Annoying stuff for windows -- makes sure clients can import these functions
+#ifndef GOOGLE_GLOG_DLL_DECL
+# if defined(_WIN32) && !defined(__CYGWIN__)
+# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
+# else
+# define GOOGLE_GLOG_DLL_DECL
+# endif
+#endif
diff --git a/src/demangle.h b/src/demangle.h
index 9c75915..2653029 100644
--- a/src/demangle.h
+++ b/src/demangle.h
@@ -77,7 +77,7 @@ _START_GOOGLE_NAMESPACE_
// Demangle "mangled". On success, return true and write the
// demangled symbol name to "out". Otherwise, return false.
// "out" is modified even if demangling is unsuccessful.
-bool Demangle(const char *mangled, char *out, int out_size);
+bool GOOGLE_GLOG_DLL_DECL Demangle(const char *mangled, char *out, int out_size);
_END_GOOGLE_NAMESPACE_
diff --git a/src/demangle_unittest.cc b/src/demangle_unittest.cc
index 9d219e6..32f3221 100644
--- a/src/demangle_unittest.cc
+++ b/src/demangle_unittest.cc
@@ -41,6 +41,11 @@
#include "googletest.h"
#include "config.h"
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
+#endif
+
GLOG_DEFINE_bool(demangle_filter, false,
"Run demangle_unittest in filter mode");
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index 70bf88b..455bd28 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -48,14 +48,6 @@
#endif
#include <vector>
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
-# else
-# define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
#if defined(_MSC_VER)
#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
__pragma(warning(disable:n))
@@ -65,6 +57,15 @@
#define GLOG_MSVC_POP_WARNING()
#endif
+// Annoying stuff for windows -- makes sure clients can import these functions
+#ifndef GOOGLE_GLOG_DLL_DECL
+# if defined(_WIN32) && !defined(__CYGWIN__)
+# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
+# else
+# define GOOGLE_GLOG_DLL_DECL
+# endif
+#endif
+
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
@@ -1167,6 +1168,8 @@ public:
char* str() const { return pbase(); }
private:
+ LogStream(const LogStream&);
+ LogStream& operator=(const LogStream&);
base_logging::LogStreamBuf streambuf_;
int ctr_; // Counter hack (for the LOG_EVERY_X() macro)
LogStream *self_; // Consistency check hack
@@ -1234,7 +1237,7 @@ public:
void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs
// Call abort() or similar to perform LOG(FATAL) crash.
- static void Fail() @ac_cv___attribute___noreturn@;
+ static void @ac_cv___attribute___noreturn@ Fail();
std::ostream& stream();
@@ -1282,7 +1285,7 @@ class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
public:
LogMessageFatal(const char* file, int line);
LogMessageFatal(const char* file, int line, const CheckOpString& result);
- ~LogMessageFatal() @ac_cv___attribute___noreturn@;
+ @ac_cv___attribute___noreturn@ ~LogMessageFatal();
};
// A non-macro interface to the log facility; (useful
@@ -1586,7 +1589,7 @@ class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
NullStreamFatal() { }
NullStreamFatal(const char* file, int line, const CheckOpString& result) :
NullStream(file, line, result) { }
- @ac_cv___attribute___noreturn@ ~NullStreamFatal() { _exit(1); }
+ @ac_cv___attribute___noreturn@ ~NullStreamFatal() throw () { _exit(1); }
};
// Install a signal handler that will dump signal information and a stack
diff --git a/src/googletest.h b/src/googletest.h
index 2525bc3..b4677b2 100644
--- a/src/googletest.h
+++ b/src/googletest.h
@@ -81,7 +81,7 @@ static inline string GetTempDir() {
#endif
}
-#if defined(OS_WINDOWS) && defined(_MSC_VER)
+#if defined(OS_WINDOWS) && defined(_MSC_VER) && !defined(TEST_SRC_DIR)
// The test will run in glog/vsproject/<project name>
// (e.g., glog/vsproject/logging_unittest).
static const char TEST_SRC_DIR[] = "../..";
diff --git a/src/logging.cc b/src/logging.cc
index 12bc849..b7c2f4c 100644
--- a/src/logging.cc
+++ b/src/logging.cc
@@ -819,6 +819,8 @@ void LogDestination::DeleteLogDestinations() {
delete log_destinations_[severity];
log_destinations_[severity] = NULL;
}
+ MutexLock l(&sink_mutex_);
+ delete sinks_;
}
namespace {
diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc
index fa6afce..e180567 100644
--- a/src/logging_unittest.cc
+++ b/src/logging_unittest.cc
@@ -61,6 +61,7 @@ DECLARE_string(log_backtrace_at); // logging.cc
#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
#endif
#ifdef HAVE_LIB_GMOCK
diff --git a/src/mock-log.h b/src/mock-log.h
index 5b21811..30a0f74 100644
--- a/src/mock-log.h
+++ b/src/mock-log.h
@@ -115,7 +115,8 @@ class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink {
// WaitTillSent() and Log() are executed in the same thread.
virtual void send(GOOGLE_NAMESPACE::LogSeverity severity,
const char* full_filename,
- const char* base_filename, int line, const tm* tm_time,
+ const char* /*base_filename*/, int /*line*/,
+ const tm* /*tm_time*/,
const char* message, size_t message_len) {
// We are only interested in the log severity, full file name, and
// log message.
diff --git a/src/signalhandler_unittest.cc b/src/signalhandler_unittest.cc
index 1cd0fa0..8dae5f5 100644
--- a/src/signalhandler_unittest.cc
+++ b/src/signalhandler_unittest.cc
@@ -41,6 +41,11 @@
#include <string>
#include "glog/logging.h"
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace gflags;
+#endif
+
using namespace GOOGLE_NAMESPACE;
void* DieInThread(void*) {
diff --git a/src/stl_logging_unittest.cc b/src/stl_logging_unittest.cc
index 20f23b3..89fd6a1 100644
--- a/src/stl_logging_unittest.cc
+++ b/src/stl_logging_unittest.cc
@@ -31,6 +31,7 @@
#ifdef HAVE_USING_OPERATOR
+#include <functional>
#include <iostream>
#include <map>
#include <ostream>
@@ -41,11 +42,19 @@
// C++0x isn't enabled by default in GCC and libc++ does not have
// non-standard ext/* and tr1/unordered_*.
# if defined(_LIBCPP_VERSION)
+# ifndef GLOG_STL_LOGGING_FOR_UNORDERED
# define GLOG_STL_LOGGING_FOR_UNORDERED
+# endif
# else
+# ifndef GLOG_STL_LOGGING_FOR_EXT_HASH
# define GLOG_STL_LOGGING_FOR_EXT_HASH
+# endif
+# ifndef GLOG_STL_LOGGING_FOR_EXT_SLIST
# define GLOG_STL_LOGGING_FOR_EXT_SLIST
+# endif
+# ifndef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
# define GLOG_STL_LOGGING_FOR_TR1_UNORDERED
+# endif
# endif
#endif
diff --git a/src/symbolize_unittest.cc b/src/symbolize_unittest.cc
index f25909d..05cb8a1 100644
--- a/src/symbolize_unittest.cc
+++ b/src/symbolize_unittest.cc
@@ -41,6 +41,11 @@
#include "googletest.h"
#include "config.h"
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
+#endif
+
using namespace std;
using namespace GOOGLE_NAMESPACE;
diff --git a/src/utilities_unittest.cc b/src/utilities_unittest.cc
index 7b79619..38e847d 100644
--- a/src/utilities_unittest.cc
+++ b/src/utilities_unittest.cc
@@ -28,11 +28,15 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Shinichiro Hamaji
-
#include "utilities.h"
#include "googletest.h"
#include "glog/logging.h"
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
+#endif
+
using namespace GOOGLE_NAMESPACE;
TEST(utilities, sync_val_compare_and_swap) {
diff --git a/src/vlog_is_on.cc b/src/vlog_is_on.cc
index 8a79df5..4c95583 100644
--- a/src/vlog_is_on.cc
+++ b/src/vlog_is_on.cc
@@ -162,30 +162,32 @@ int SetVLOGLevel(const char* module_pattern, int log_level) {
int result = FLAGS_v;
int const pattern_len = strlen(module_pattern);
bool found = false;
- MutexLock l(&vmodule_lock); // protect whole read-modify-write
- for (const VModuleInfo* info = vmodule_list;
- info != NULL; info = info->next) {
- if (info->module_pattern == module_pattern) {
- if (!found) {
+ {
+ MutexLock l(&vmodule_lock); // protect whole read-modify-write
+ for (const VModuleInfo* info = vmodule_list;
+ info != NULL; info = info->next) {
+ if (info->module_pattern == module_pattern) {
+ if (!found) {
+ result = info->vlog_level;
+ found = true;
+ }
+ info->vlog_level = log_level;
+ } else if (!found &&
+ SafeFNMatch_(info->module_pattern.c_str(),
+ info->module_pattern.size(),
+ module_pattern, pattern_len)) {
result = info->vlog_level;
found = true;
}
+ }
+ if (!found) {
+ VModuleInfo* info = new VModuleInfo;
+ info->module_pattern = module_pattern;
info->vlog_level = log_level;
- } else if (!found &&
- SafeFNMatch_(info->module_pattern.c_str(),
- info->module_pattern.size(),
- module_pattern, pattern_len)) {
- result = info->vlog_level;
- found = true;
+ info->next = vmodule_list;
+ vmodule_list = info;
}
}
- if (!found) {
- VModuleInfo* info = new VModuleInfo;
- info->module_pattern = module_pattern;
- info->vlog_level = log_level;
- info->next = vmodule_list;
- vmodule_list = info;
- }
RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
return result;
}
diff --git a/src/windows/port.cc b/src/windows/port.cc
index bfa6e70..d994325 100755
--- a/src/windows/port.cc
+++ b/src/windows/port.cc
@@ -55,6 +55,7 @@ int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
return _vsnprintf(str, size-1, format, ap);
}
+#ifndef HAVE_SNPRINTF
int snprintf(char *str, size_t size, const char *format, ...) {
va_list ap;
va_start(ap, format);
@@ -62,3 +63,4 @@ int snprintf(char *str, size_t size, const char *format, ...) {
va_end(ap);
return r;
}
+#endif
diff --git a/src/windows/port.h b/src/windows/port.h
index 24d7677..d78a185 100755
--- a/src/windows/port.h
+++ b/src/windows/port.h
@@ -111,12 +111,16 @@ enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 };
* because they don't always NUL-terminate. :-( We also can't use the
* name vsnprintf, since windows defines that (but not snprintf (!)).
*/
-extern int snprintf(char *str, size_t size,
+#ifndef HAVE_SNPRINTF
+extern int GOOGLE_GLOG_DLL_DECL snprintf(char *str, size_t size,
const char *format, ...);
-extern int safe_vsnprintf(char *str, size_t size,
+#endif
+extern int GOOGLE_GLOG_DLL_DECL safe_vsnprintf(char *str, size_t size,
const char *format, va_list ap);
#define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap)
+#ifndef va_copy
#define va_copy(dst, src) (dst) = (src)
+#endif
/* Windows doesn't support specifying the number of buckets as a
* hash_map constructor arg, so we leave this blank.