diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f167682b..66d6f3108 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -653,8 +653,8 @@ if (gflags_FOUND) set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -lgflags") target_compile_definitions (glog PRIVATE - GFLAGS_DLL_DECLARE_FLAG=GOOGLE_GLOG_DLL_DECL - GFLAGS_DLL_DEFINE_FLAG=GOOGLE_GLOG_DLL_DECL + GFLAGS_DLL_DECLARE_FLAG=GLOG_EXPORT + GFLAGS_DLL_DEFINE_FLAG=GLOG_EXPORT ) endif (gflags_FOUND) @@ -702,7 +702,7 @@ target_compile_definitions (glogbase PUBLIC PRIVATE GOOGLE_GLOG_IS_A_DLL) generate_export_header (glog - EXPORT_MACRO_NAME GOOGLE_GLOG_DLL_DECL + EXPORT_MACRO_NAME GLOG_EXPORT EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/glog/export.h) string (STRIP "${glog_libraries_options_for_static_linking}" glog_libraries_options_for_static_linking) diff --git a/bazel/glog.bzl b/bazel/glog.bzl index 43a2637fc..dcf6f4152 100644 --- a/bazel/glog.bzl +++ b/bazel/glog.bzl @@ -78,10 +78,13 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): ] linux_or_darwin_copts = wasm_copts + [ + "-DGLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))", # For src/utilities.cc. "-DHAVE_SYS_SYSCALL_H", # For src/logging.cc to create symlinks. "-DHAVE_UNISTD_H", + "-fvisibility-inlines-hidden", + "-fvisibility=hidden", ] freebsd_only_copts = [ @@ -97,6 +100,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): ] windows_only_copts = [ + "-DGLOG_EXPORT=__declspec(dllexport)", "-DGLOG_NO_ABBREVIATED_SEVERITIES", "-DHAVE_SNPRINTF", "-I" + src_windows, @@ -150,15 +154,16 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): ], strip_include_prefix = "src", defines = select({ - # GOOGLE_GLOG_DLL_DECL is normally set by export.h, but that's not + # GLOG_EXPORT is normally set by export.h, but that's not # generated for Bazel. "@bazel_tools//src/conditions:windows": [ - "GOOGLE_GLOG_DLL_DECL=__declspec(dllexport)", + "GLOG_EXPORT=", "GLOG_DEPRECATED=__declspec(deprecated)", "GLOG_NO_ABBREVIATED_SEVERITIES", ], "//conditions:default": [ "GLOG_DEPRECATED=__attribute__((deprecated))", + "GLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))", ], }), copts = diff --git a/src/base/commandlineflags.h b/src/base/commandlineflags.h index 3784403bd..bcb12deac 100644 --- a/src/base/commandlineflags.h +++ b/src/base/commandlineflags.h @@ -61,16 +61,16 @@ #include -#define DECLARE_VARIABLE(type, shorttype, name, tn) \ - namespace fL##shorttype { \ - extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \ - } \ +#define DECLARE_VARIABLE(type, shorttype, name, tn) \ + namespace fL##shorttype { \ + extern GLOG_EXPORT type FLAGS_##name; \ + } \ using fL##shorttype::FLAGS_##name -#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \ - namespace fL##shorttype { \ - GOOGLE_GLOG_DLL_DECL type FLAGS_##name(value); \ - char FLAGS_no##name; \ - } \ +#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \ + namespace fL##shorttype { \ + GLOG_EXPORT type FLAGS_##name(value); \ + char FLAGS_no##name; \ + } \ using fL##shorttype::FLAGS_##name // bool specialization @@ -95,17 +95,17 @@ // Special case for string, because we have to specify the namespace // std::string, which doesn't play nicely with our FLAG__namespace hackery. -#define DECLARE_string(name) \ - namespace fLS { \ - extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name; \ - } \ +#define DECLARE_string(name) \ + namespace fLS { \ + extern GLOG_EXPORT std::string& FLAGS_##name; \ + } \ using fLS::FLAGS_##name -#define DEFINE_string(name, value, meaning) \ - namespace fLS { \ - std::string FLAGS_##name##_buf(value); \ - GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name = FLAGS_##name##_buf; \ - char FLAGS_no##name; \ - } \ +#define DEFINE_string(name, value, meaning) \ + namespace fLS { \ + std::string FLAGS_##name##_buf(value); \ + GLOG_EXPORT std::string& FLAGS_##name = FLAGS_##name##_buf; \ + char FLAGS_no##name; \ + } \ using fLS::FLAGS_##name #endif // HAVE_LIB_GFLAGS diff --git a/src/demangle.h b/src/demangle.h index 2ccb77335..f347b9814 100644 --- a/src/demangle.h +++ b/src/demangle.h @@ -78,7 +78,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 GOOGLE_GLOG_DLL_DECL Demangle(const char *mangled, char *out, size_t out_size); +bool GLOG_EXPORT Demangle(const char *mangled, char *out, size_t out_size); _END_GOOGLE_NAMESPACE_ diff --git a/src/glog/log_severity.h b/src/glog/log_severity.h index 987cc57da..aa48f5315 100644 --- a/src/glog/log_severity.h +++ b/src/glog/log_severity.h @@ -43,16 +43,7 @@ // whenever an ERROR occurs in production. // FATAL: // Use for undesired and unexpected events that the program cannot recover -// from. - -// 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 +// from. // Variables of type LogSeverity are widely taken to lie in the range // [0, NUM_SEVERITIES-1]. Be careful to preserve this assumption if @@ -76,7 +67,7 @@ const int INFO = GLOG_INFO, WARNING = GLOG_WARNING, #define DFATAL_LEVEL FATAL #endif -extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES]; +extern GLOG_EXPORT const char* const LogSeverityNames[NUM_SEVERITIES]; // NDEBUG usage helpers related to (RAW_)DCHECK: // diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in index 47a3d9a71..997bac4ac 100644 --- a/src/glog/logging.h.in +++ b/src/glog/logging.h.in @@ -69,15 +69,6 @@ #include #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. @@ -100,7 +91,7 @@ #undef GFLAGS_DLL_DECLARE_FLAG #endif // defined(GFLAGS_DLL_DECLARE_FLAG) -#define GFLAGS_DLL_DECLARE_FLAG GOOGLE_GLOG_DLL_DECL +#define GFLAGS_DLL_DECLARE_FLAG GLOG_EXPORT #if @ac_cv_have_libgflags@ #include @@ -135,7 +126,7 @@ typedef unsigned __int64 uint64; typedef double WallTime; -struct GOOGLE_GLOG_DLL_DECL LogMessageTime { +struct GLOG_EXPORT LogMessageTime { LogMessageTime(); LogMessageTime(std::tm t); LogMessageTime(std::time_t timestamp, WallTime now); @@ -390,7 +381,7 @@ typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, vo #define MUST_UNDEF_GFLAGS_DECLARE_MACROS #define DECLARE_VARIABLE(type, shorttype, name, tn) \ namespace fL##shorttype { \ - extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \ + extern GLOG_EXPORT type FLAGS_##name; \ } \ using fL##shorttype::FLAGS_##name @@ -412,7 +403,7 @@ typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, vo // std::string, which doesn't play nicely with our FLAG__namespace hackery. #define DECLARE_string(name) \ namespace fLS { \ - extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name; \ + extern GLOG_EXPORT std::string& FLAGS_##name; \ } \ using fLS::FLAGS_##name #endif @@ -613,19 +604,19 @@ DECLARE_bool(log_utc_time); // Initialize google's logging library. You will see the program name // specified by argv0 in log outputs. -GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0); +GLOG_EXPORT void InitGoogleLogging(const char* argv0); #ifdef GLOG_CUSTOM_PREFIX_SUPPORT -GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0, - CustomPrefixCallback prefix_callback, - void* prefix_callback_data = NULL); +GLOG_EXPORT void InitGoogleLogging(const char* argv0, + CustomPrefixCallback prefix_callback, + void* prefix_callback_data = NULL); #endif // Check if google's logging library has been initialized. -GOOGLE_GLOG_DLL_DECL bool IsGoogleLoggingInitialized(); +GLOG_EXPORT bool IsGoogleLoggingInitialized(); // Shutdown google's logging library. -GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging(); +GLOG_EXPORT void ShutdownGoogleLogging(); #if defined(__GNUC__) typedef void (*logging_fail_func_t)() __attribute__((noreturn)); @@ -634,12 +625,12 @@ typedef void (*logging_fail_func_t)(); #endif // Install a function which will be called after LOG(FATAL). -GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(logging_fail_func_t fail_func); +GLOG_EXPORT void InstallFailureFunction(logging_fail_func_t fail_func); // Enable/Disable old log cleaner. -GOOGLE_GLOG_DLL_DECL void EnableLogCleaner(unsigned int overdue_days); -GOOGLE_GLOG_DLL_DECL void DisableLogCleaner(); -GOOGLE_GLOG_DLL_DECL void SetApplicationFingerprint(const std::string& fingerprint); +GLOG_EXPORT void EnableLogCleaner(unsigned int overdue_days); +GLOG_EXPORT void DisableLogCleaner(); +GLOG_EXPORT void SetApplicationFingerprint(const std::string& fingerprint); class LogSink; // defined below @@ -763,17 +754,17 @@ inline void MakeCheckOpValueString(std::ostream* os, const T& v) { // Overrides for char types provide readable values for unprintable // characters. -template <> GOOGLE_GLOG_DLL_DECL +template <> GLOG_EXPORT void MakeCheckOpValueString(std::ostream* os, const char& v); -template <> GOOGLE_GLOG_DLL_DECL +template <> GLOG_EXPORT void MakeCheckOpValueString(std::ostream* os, const signed char& v); -template <> GOOGLE_GLOG_DLL_DECL +template <> GLOG_EXPORT void MakeCheckOpValueString(std::ostream* os, const unsigned char& v); // This is required because nullptr is only present in c++ 11 and later. #if @ac_cv_cxx11_nullptr_t@ && __cplusplus >= 201103L // Provide printable value for nullptr_t -template <> GOOGLE_GLOG_DLL_DECL +template <> GLOG_EXPORT void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& v); #endif @@ -798,7 +789,7 @@ LogSeverity NormalizeSeverity(LogSeverity s); // base::BuildCheckOpString(exprtext, base::Print, &v1, // base::Print, &v2), however this approach has complications // related to volatile arguments and function-pointer arguments). -class GOOGLE_GLOG_DLL_DECL CheckOpMessageBuilder { +class GLOG_EXPORT CheckOpMessageBuilder { public: // Inserts "exprtext" and " (" to the stream. explicit CheckOpMessageBuilder(const char *exprtext); @@ -931,7 +922,7 @@ typedef std::string _Check_string; // Helper functions for string comparisons. // To avoid bloat, the definitions are in logging.cc. #define DECLARE_CHECK_STROP_IMPL(func, expected) \ - GOOGLE_GLOG_DLL_DECL std::string* Check##func##expected##Impl( \ + GLOG_EXPORT std::string* Check##func##expected##Impl( \ const char* s1, const char* s2, const char* names); DECLARE_CHECK_STROP_IMPL(strcmp, true) DECLARE_CHECK_STROP_IMPL(strcmp, false) @@ -1249,7 +1240,7 @@ struct CrashReason; // Returns true if FailureSignalHandler is installed. // Needs to be exported since it's used by the signalhandler_unittest. -GOOGLE_GLOG_DLL_DECL bool IsFailureSignalHandlerInstalled(); +GLOG_EXPORT bool IsFailureSignalHandlerInstalled(); } // namespace glog_internal_namespace_ #define LOG_EVERY_N(severity, n) \ @@ -1427,7 +1418,7 @@ namespace base_logging { // LogMessage::LogStream is a std::ostream backed by this streambuf. // This class ignores overflow and leaves two bytes at the end of the // buffer to allow for a '\n' and '\0'. -class GOOGLE_GLOG_DLL_DECL LogStreamBuf : public std::streambuf { +class GLOG_EXPORT LogStreamBuf : public std::streambuf { public: // REQUIREMENTS: "len" must be >= 2 to account for the '\n' and '\0'. LogStreamBuf(char *buf, int len) { @@ -1455,7 +1446,7 @@ class GOOGLE_GLOG_DLL_DECL LogStreamBuf : public std::streambuf { // You shouldn't actually use LogMessage's constructor to log things, // though. You should use the LOG() macro (and variants thereof) // above. -class GOOGLE_GLOG_DLL_DECL LogMessage { +class GLOG_EXPORT LogMessage { public: enum { // Passing kNoLogPrefix for the line number disables the @@ -1473,7 +1464,7 @@ public: // http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx // Let's just ignore the warning. GLOG_MSVC_PUSH_DISABLE_WARNING(4275) - class GOOGLE_GLOG_DLL_DECL LogStream : public std::ostream { + class GLOG_EXPORT LogStream : public std::ostream { GLOG_MSVC_POP_WARNING() public: LogStream(char *buf, int len, int64 ctr) @@ -1610,7 +1601,7 @@ private: // This class happens to be thread-hostile because all instances share // a single data buffer, but since it can only be created just before // the process dies, we don't worry so much. -class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage { +class GLOG_EXPORT LogMessageFatal : public LogMessage { public: LogMessageFatal(const char* file, int line); LogMessageFatal(const char* file, int line, const CheckOpString& result); @@ -1671,12 +1662,12 @@ T* CheckNotNull(const char *file, int line, const char *names, T* t) { // Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This // only works if ostream is a LogStream. If the ostream is not a // LogStream you'll get an assert saying as much at runtime. -GOOGLE_GLOG_DLL_DECL std::ostream& operator<<(std::ostream &os, +GLOG_EXPORT std::ostream& operator<<(std::ostream &os, const PRIVATE_Counter&); // Derived class for PLOG*() above. -class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage { +class GLOG_EXPORT ErrnoLogMessage : public LogMessage { public: ErrnoLogMessage(const char* file, int line, LogSeverity severity, int64 ctr, void (LogMessage::*send_method)()); @@ -1694,7 +1685,7 @@ class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage { // logging macros. This avoids compiler warnings like "value computed // is not used" and "statement has no effect". -class GOOGLE_GLOG_DLL_DECL LogMessageVoidify { +class GLOG_EXPORT LogMessageVoidify { public: LogMessageVoidify() { } // This has to be an operator with a precedence lower than << but @@ -1705,19 +1696,19 @@ class GOOGLE_GLOG_DLL_DECL LogMessageVoidify { // Flushes all log files that contains messages that are at least of // the specified severity level. Thread-safe. -GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity); +GLOG_EXPORT void FlushLogFiles(LogSeverity min_severity); // Flushes all log files that contains messages that are at least of // the specified severity level. Thread-hostile because it ignores // locking -- used for catastrophic failures. -GOOGLE_GLOG_DLL_DECL void FlushLogFilesUnsafe(LogSeverity min_severity); +GLOG_EXPORT void FlushLogFilesUnsafe(LogSeverity min_severity); // // Set the destination to which a particular severity level of log // messages is sent. If base_filename is "", it means "don't log this // severity". Thread-safe. // -GOOGLE_GLOG_DLL_DECL void SetLogDestination(LogSeverity severity, +GLOG_EXPORT void SetLogDestination(LogSeverity severity, const char* base_filename); // @@ -1726,7 +1717,7 @@ GOOGLE_GLOG_DLL_DECL void SetLogDestination(LogSeverity severity, // you don't call this function, the symlink basename is the // invocation name of the program. Thread-safe. // -GOOGLE_GLOG_DLL_DECL void SetLogSymlink(LogSeverity severity, +GLOG_EXPORT void SetLogSymlink(LogSeverity severity, const char* symlink_basename); // @@ -1734,7 +1725,7 @@ GOOGLE_GLOG_DLL_DECL void SetLogSymlink(LogSeverity severity, // Users should subclass LogSink and override send to do whatever they want. // Implementations must be thread-safe because a shared instance will // be called from whichever thread ran the LOG(XXX) line. -class GOOGLE_GLOG_DLL_DECL LogSink { +class GLOG_EXPORT LogSink { public: virtual ~LogSink(); @@ -1774,8 +1765,8 @@ class GOOGLE_GLOG_DLL_DECL LogSink { }; // Add or remove a LogSink as a consumer of logging data. Thread-safe. -GOOGLE_GLOG_DLL_DECL void AddLogSink(LogSink *destination); -GOOGLE_GLOG_DLL_DECL void RemoveLogSink(LogSink *destination); +GLOG_EXPORT void AddLogSink(LogSink *destination); +GLOG_EXPORT void RemoveLogSink(LogSink *destination); // // Specify an "extension" added to the filename specified via @@ -1783,7 +1774,7 @@ GOOGLE_GLOG_DLL_DECL void RemoveLogSink(LogSink *destination); // often used to append the port we're listening on to the logfile // name. Thread-safe. // -GOOGLE_GLOG_DLL_DECL void SetLogFilenameExtension( +GLOG_EXPORT void SetLogFilenameExtension( const char* filename_extension); // @@ -1791,12 +1782,12 @@ GOOGLE_GLOG_DLL_DECL void SetLogFilenameExtension( // are logged to stderr (in addition to logging to the usual log // file(s)). Thread-safe. // -GOOGLE_GLOG_DLL_DECL void SetStderrLogging(LogSeverity min_severity); +GLOG_EXPORT void SetStderrLogging(LogSeverity min_severity); // // Make it so that all log messages go only to stderr. Thread-safe. // -GOOGLE_GLOG_DLL_DECL void LogToStderr(); +GLOG_EXPORT void LogToStderr(); // // Make it so that all log messages of at least a particular severity are @@ -1804,15 +1795,15 @@ GOOGLE_GLOG_DLL_DECL void LogToStderr(); // usual log file(s)). The list of addresses is just a string containing // the email addresses to send to (separated by spaces, say). Thread-safe. // -GOOGLE_GLOG_DLL_DECL void SetEmailLogging(LogSeverity min_severity, +GLOG_EXPORT void SetEmailLogging(LogSeverity min_severity, const char* addresses); // A simple function that sends email. dest is a commma-separated // list of addressess. Thread-safe. -GOOGLE_GLOG_DLL_DECL bool SendEmail(const char *dest, +GLOG_EXPORT bool SendEmail(const char *dest, const char *subject, const char *body); -GOOGLE_GLOG_DLL_DECL const std::vector& GetLoggingDirectories(); +GLOG_EXPORT const std::vector& GetLoggingDirectories(); // For tests only: Clear the internal [cached] list of logging directories to // force a refresh the next time GetLoggingDirectories is called. @@ -1822,13 +1813,13 @@ void TestOnly_ClearLoggingDirectoriesList(); // Returns a set of existing temporary directories, which will be a // subset of the directories returned by GetLogginDirectories(). // Thread-safe. -GOOGLE_GLOG_DLL_DECL void GetExistingTempDirectories( +GLOG_EXPORT void GetExistingTempDirectories( std::vector* list); // Print any fatal message again -- useful to call from signal handler // so that the last thing in the output is the fatal message. // Thread-hostile, but a race is unlikely. -GOOGLE_GLOG_DLL_DECL void ReprintFatalMessage(); +GLOG_EXPORT void ReprintFatalMessage(); // Truncate a log file that may be the append-only output of multiple // processes and hence can't simply be renamed/reopened (typically a @@ -1837,17 +1828,16 @@ GOOGLE_GLOG_DLL_DECL void ReprintFatalMessage(); // be racing with other writers, this approach has the potential to // lose very small amounts of data. For security, only follow symlinks // if the path is /proc/self/fd/* -GOOGLE_GLOG_DLL_DECL void TruncateLogFile(const char *path, - uint64 limit, uint64 keep); +GLOG_EXPORT void TruncateLogFile(const char* path, uint64 limit, uint64 keep); // Truncate stdout and stderr if they are over the value specified by // --max_log_size; keep the final 1MB. This function has the same // race condition as TruncateLogFile. -GOOGLE_GLOG_DLL_DECL void TruncateStdoutStderr(); +GLOG_EXPORT void TruncateStdoutStderr(); // Return the string representation of the provided LogSeverity level. // Thread-safe. -GOOGLE_GLOG_DLL_DECL const char* GetLogSeverityName(LogSeverity severity); +GLOG_EXPORT const char* GetLogSeverityName(LogSeverity severity); // --------------------------------------------------------------------- // Implementation details that are not useful to most clients @@ -1862,7 +1852,7 @@ GOOGLE_GLOG_DLL_DECL const char* GetLogSeverityName(LogSeverity severity); namespace base { -class GOOGLE_GLOG_DLL_DECL Logger { +class GLOG_EXPORT Logger { public: virtual ~Logger(); @@ -1891,12 +1881,12 @@ class GOOGLE_GLOG_DLL_DECL Logger { // Get the logger for the specified severity level. The logger // remains the property of the logging module and should not be // deleted by the caller. Thread-safe. -extern GOOGLE_GLOG_DLL_DECL Logger* GetLogger(LogSeverity level); +extern GLOG_EXPORT Logger* GetLogger(LogSeverity level); // Set the logger for the specified severity level. The logger // becomes the property of the logging module and should not // be deleted by the caller. Thread-safe. -extern GOOGLE_GLOG_DLL_DECL void SetLogger(LogSeverity level, Logger* logger); +extern GLOG_EXPORT void SetLogger(LogSeverity level, Logger* logger); } @@ -1911,14 +1901,14 @@ extern GOOGLE_GLOG_DLL_DECL void SetLogger(LogSeverity level, Logger* logger); // cases, you do not need to check the error code and you can directly // use the value of "buf". It will never have an undefined value. // DEPRECATED: Use StrError(int) instead. -GOOGLE_GLOG_DLL_DECL int posix_strerror_r(int err, char *buf, size_t len); +GLOG_EXPORT int posix_strerror_r(int err, char *buf, size_t len); // A thread-safe replacement for strerror(). Returns a string describing the // given POSIX error code. -GOOGLE_GLOG_DLL_DECL std::string StrError(int err); +GLOG_EXPORT std::string StrError(int err); // A class for which we define operator<<, which does nothing. -class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream { +class GLOG_EXPORT NullStream : public LogMessage::LogStream { public: // Initialize the LogStream so the messages can be written somewhere // (they'll never be actually displayed). This will be needed if a @@ -1947,7 +1937,7 @@ inline NullStream& operator<<(NullStream &str, const T &) { return str; } // Similar to NullStream, but aborts the program (without stack // trace), like LogMessageFatal. -class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream { +class GLOG_EXPORT NullStreamFatal : public NullStream { public: NullStreamFatal() { } NullStreamFatal(const char* file, int line, const CheckOpString& result) : @@ -1978,13 +1968,13 @@ class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream { // to use the failure signal handler for all threads. The stack trace // will be shown only for the thread that receives the signal. In other // words, stack traces of other threads won't be shown. -GOOGLE_GLOG_DLL_DECL void InstallFailureSignalHandler(); +GLOG_EXPORT void InstallFailureSignalHandler(); // Installs a function that is used for writing the failure dump. "data" // is the pointer to the beginning of a message to be written, and "size" // is the size of the message. You should not expect the data is // terminated with '\0'. -GOOGLE_GLOG_DLL_DECL void InstallFailureWriter( +GLOG_EXPORT void InstallFailureWriter( void (*writer)(const char* data, size_t size)); @ac_google_end_namespace@ diff --git a/src/glog/raw_logging.h.in b/src/glog/raw_logging.h.in index 4a7a1a222..b845f67a5 100644 --- a/src/glog/raw_logging.h.in +++ b/src/glog/raw_logging.h.in @@ -44,15 +44,6 @@ #include #include -// 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(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wvariadic-macros" @@ -179,11 +170,9 @@ static inline void RawLogStub__(int /* ignored */, ...) { // Logs format... at "severity" level, reporting it // as called from file:line. // This does not allocate memory or acquire locks. -GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity, - const char* file, - int line, - const char* format, ...) - @ac_cv___attribute___printf_4_5@; +GLOG_EXPORT void RawLog__(LogSeverity severity, const char* file, int line, + const char* format, ...) + @ac_cv___attribute___printf_4_5@; @ac_google_end_namespace@ diff --git a/src/glog/vlog_is_on.h.in b/src/glog/vlog_is_on.h.in index 5c9a7f457..7526fc346 100644 --- a/src/glog/vlog_is_on.h.in +++ b/src/glog/vlog_is_on.h.in @@ -63,15 +63,6 @@ #include -// 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(__GNUC__) // We emit an anonymous static int* variable at every VLOG_IS_ON(n) site. // (Normally) the first time every VLOG_IS_ON(n) site is hit, @@ -100,8 +91,7 @@ // one needs to supply the exact --vmodule pattern that applied to them. // (If no --vmodule pattern applied to them // the value of FLAGS_v will continue to control them.) -extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern, - int log_level); +extern GLOG_EXPORT int SetVLOGLevel(const char* module_pattern, int log_level); // Various declarations needed for VLOG_IS_ON above: ========================= @@ -120,10 +110,9 @@ struct SiteFlag { // verbose_level is the argument to VLOG_IS_ON // We will return the return value for VLOG_IS_ON // and if possible set *site_flag appropriately. -extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__( +extern GLOG_EXPORT bool InitVLOG3__( @ac_google_namespace@::SiteFlag* site_flag, - @ac_google_namespace@::int32* site_default, - const char* fname, + @ac_google_namespace@::int32* site_default, const char* fname, @ac_google_namespace@::int32 verbose_level); #endif // BASE_VLOG_IS_ON_H_ diff --git a/src/googletest.h b/src/googletest.h index 51e05dc71..5e9e7b8da 100644 --- a/src/googletest.h +++ b/src/googletest.h @@ -68,12 +68,12 @@ using std::vector; _START_GOOGLE_NAMESPACE_ -extern GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)(); +extern GLOG_EXPORT void (*g_logging_fail_func)(); _END_GOOGLE_NAMESPACE_ -#undef GOOGLE_GLOG_DLL_DECL -#define GOOGLE_GLOG_DLL_DECL +#undef GLOG_EXPORT +#define GLOG_EXPORT static inline string GetTempDir() { #ifndef GLOG_OS_WINDOWS diff --git a/src/logging.cc b/src/logging.cc index 5e002ecf4..463ad9ba3 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -1906,7 +1906,8 @@ void LogMessage::RecordCrashReason( #endif } -GOOGLE_GLOG_DLL_DECL logging_fail_func_t g_logging_fail_func = reinterpret_cast(&abort); +GLOG_EXPORT logging_fail_func_t g_logging_fail_func = + reinterpret_cast(&abort); void InstallFailureFunction(logging_fail_func_t fail_func) { g_logging_fail_func = fail_func; diff --git a/src/stacktrace.h b/src/stacktrace.h index f969b0c0c..55b98b2d4 100644 --- a/src/stacktrace.h +++ b/src/stacktrace.h @@ -54,7 +54,7 @@ _START_GOOGLE_NAMESPACE_ // .... ... // // "result" must not be NULL. -GOOGLE_GLOG_DLL_DECL int GetStackTrace(void** result, int max_depth, int skip_count); +GLOG_EXPORT int GetStackTrace(void** result, int max_depth, int skip_count); _END_GOOGLE_NAMESPACE_ diff --git a/src/symbolize.h b/src/symbolize.h index 2d7d1b82a..dcbb194c4 100644 --- a/src/symbolize.h +++ b/src/symbolize.h @@ -121,7 +121,7 @@ typedef int (*SymbolizeCallback)(int fd, char* out, size_t out_size, uint64_t relocation); -GOOGLE_GLOG_DLL_DECL +GLOG_EXPORT void InstallSymbolizeCallback(SymbolizeCallback callback); // Installs a callback function, which will be called instead of @@ -152,7 +152,7 @@ _START_GOOGLE_NAMESPACE_ // symbol name to "out". The symbol name is demangled if possible // (supports symbols generated by GCC 3.x or newer). Otherwise, // returns false. -GOOGLE_GLOG_DLL_DECL bool Symbolize(void *pc, char *out, size_t out_size); +GLOG_EXPORT bool Symbolize(void* pc, char* out, size_t out_size); _END_GOOGLE_NAMESPACE_ diff --git a/src/vlog_is_on.cc b/src/vlog_is_on.cc index 5c26957db..e478a3663 100644 --- a/src/vlog_is_on.cc +++ b/src/vlog_is_on.cc @@ -63,19 +63,15 @@ _START_GOOGLE_NAMESPACE_ namespace glog_internal_namespace_ { // Used by logging_unittests.cc so can't make it static here. -GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern, - size_t patt_len, - const char* str, - size_t str_len); +GLOG_EXPORT bool SafeFNMatch_(const char* pattern, size_t patt_len, + const char* str, size_t str_len); // Implementation of fnmatch that does not need 0-termination // of arguments and does not allocate any memory, // but we only support "*" and "?" wildcards, not the "[...]" patterns. // It's not a static function for the unittest. -GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern, - size_t patt_len, - const char* str, - size_t str_len) { +GLOG_EXPORT bool SafeFNMatch_(const char* pattern, size_t patt_len, + const char* str, size_t str_len) { size_t p = 0; size_t s = 0; while (1) { diff --git a/src/windows/port.h b/src/windows/port.h index beea5af21..a71979f83 100755 --- a/src/windows/port.h +++ b/src/windows/port.h @@ -122,11 +122,11 @@ enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 }; * name vsnprintf, since windows defines that (but not snprintf (!)). */ #ifndef HAVE_SNPRINTF -extern int GOOGLE_GLOG_DLL_DECL snprintf(char *str, size_t size, - const char *format, ...); +extern int GLOG_EXPORT snprintf(char* str, size_t size, const char* format, + ...); #endif -extern int GOOGLE_GLOG_DLL_DECL safe_vsnprintf(char *str, size_t size, - const char *format, va_list ap); +extern int GLOG_EXPORT 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) @@ -158,11 +158,12 @@ enum { PTHREAD_ONCE_INIT = 0 }; // important that this be 0! for SpinLock #endif // HAVE_PTHREAD #ifndef HAVE_LOCALTIME_R -extern GOOGLE_GLOG_DLL_DECL struct tm* localtime_r(const time_t* timep, struct tm* result); +extern GLOG_EXPORT struct tm* localtime_r(const time_t* timep, + struct tm* result); #endif // not HAVE_LOCALTIME_R #ifndef HAVE_GMTIME_R -extern GOOGLE_GLOG_DLL_DECL struct tm* gmtime_r(const time_t* timep, struct tm* result); +extern GLOG_EXPORT struct tm* gmtime_r(const time_t* timep, struct tm* result); #endif // not HAVE_GMTIME_R inline char* strerror_r(int errnum, char* buf, size_t buflen) { diff --git a/src/windows/preprocess.sh b/src/windows/preprocess.sh deleted file mode 100755 index c35e92913..000000000 --- a/src/windows/preprocess.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2008, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * 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. -# * Neither the name of Google Inc. 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 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER 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. - -# --- -# Author: Craig Silverstein -# Copied from google-perftools and modified by Shinichiro Hamaji -# -# This script is meant to be run at distribution-generation time, for -# instance by autogen.sh. It does some of the work configure would -# normally do, for windows systems. In particular, it expands all the -# @...@ variables found in .in files, and puts them here, in the windows -# directory. -# -# This script should be run before any new release. - -if [ -z "$1" ]; then - echo "USAGE: $0 " - exit 1 -fi - -DLLDEF_MACRO_NAME="GLOG_DLL_DECL" - -# The text we put in every .h files we create. As a courtesy, we'll -# include a helpful comment for windows users as to how to use -# GLOG_DLL_DECL. Apparently sed expands \n into a newline. Good! -DLLDEF_DEFINES="\ -// NOTE: if you are statically linking the template library into your binary\n\ -// (rather than using the template .dll), set '/D $DLLDEF_MACRO_NAME='\n\ -// as a compiler flag in your project file to turn off the dllimports.\n\ -#ifndef $DLLDEF_MACRO_NAME\n\ -# define $DLLDEF_MACRO_NAME __declspec(dllimport)\n\ -#endif" - -# Read all the windows config info into variables -# In order for the 'set' to take, this requires putting all in a subshell. -( - while read define varname value; do - [ "$define" != "#define" ] && continue - eval "$varname='$value'" - done - - # Process all the .in files in the "glog" subdirectory - mkdir -p "$1/windows/glog" - for file in `echo "$1"/glog/*.in`; do - echo "Processing $file" - outfile="$1/windows/glog/`basename $file .in`" - - echo "\ -// This file is automatically generated from $file -// using src/windows/preprocess.sh. -// DO NOT EDIT! -" > "$outfile" - # Besides replacing @...@, we also need to turn on dllimport - # We also need to replace hash by hash_compare (annoying we hard-code :-( ) - sed -e "s!@ac_windows_dllexport@!$DLLDEF_MACRO_NAME!g" \ - -e "s!@ac_windows_dllexport_defines@!$DLLDEF_DEFINES!g" \ - -e "s!@ac_cv_cxx_hash_map@!$HASH_MAP_H!g" \ - -e "s!@ac_cv_cxx_hash_namespace@!$HASH_NAMESPACE!g" \ - -e "s!@ac_cv_cxx_hash_set@!$HASH_SET_H!g" \ - -e "s!@ac_cv_have_stdint_h@!0!g" \ - -e "s!@ac_cv_have_systypes_h@!0!g" \ - -e "s!@ac_cv_have_inttypes_h@!0!g" \ - -e "s!@ac_cv_have_unistd_h@!0!g" \ - -e "s!@ac_cv_have_uint16_t@!0!g" \ - -e "s!@ac_cv_have_u_int16_t@!0!g" \ - -e "s!@ac_cv_have___uint16@!1!g" \ - -e "s!@ac_cv_have_libgflags@!0!g" \ - -e "s!@ac_cv_have___builtin_expect@!0!g" \ - -e "s!@ac_cv_cxx_using_operator@!1!g" \ - -e "s!@ac_cv___attribute___noreturn@!__declspec(noreturn)!g" \ - -e "s!@ac_cv___attribute___noinline@!!g" \ - -e "s!@ac_cv___attribute___printf_4_5@!!g" \ - -e "s!@ac_google_attribute@!${HAVE___ATTRIBUTE__:-0}!g" \ - -e "s!@ac_google_end_namespace@!$_END_GOOGLE_NAMESPACE_!g" \ - -e "s!@ac_google_namespace@!$GOOGLE_NAMESPACE!g" \ - -e "s!@ac_google_start_namespace@!$_START_GOOGLE_NAMESPACE_!g" \ - -e "s!@ac_htmlparser_namespace@!$HTMLPARSER_NAMESPACE!g" \ - -e "s!\\bhash\\b!hash_compare!g" \ - "$file" >> "$outfile" - done -) < "$1/windows/config.h" - -# log_severity.h isn't a .in file. -echo "\ -// This file is automatically generated from $1/glog/log_severity.h -// using src/windows/preprocess.sh. -// DO NOT EDIT! -" > "$1/windows/glog/log_severity.h" -cat "$1/glog/log_severity.h" >> "$1/windows/glog/log_severity.h" - -echo "DONE"