revert to int atomics
This commit is contained in:
parent
224f66bb63
commit
42d509b1c3
@ -1101,7 +1101,7 @@ namespace google {
|
||||
|
||||
#if @ac_cv_cxx11_atomic@ && __cplusplus >= 201103L
|
||||
#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
|
||||
static std::atomic<unsigned> LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \
|
||||
static std::atomic<int> LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \
|
||||
GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \
|
||||
GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES_MOD_N, sizeof(int), "")); \
|
||||
++LOG_OCCURRENCES; \
|
||||
@ -1112,7 +1112,7 @@ namespace google {
|
||||
&what_to_do).stream()
|
||||
|
||||
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
|
||||
static std::atomic<unsigned> LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \
|
||||
static std::atomic<int> LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \
|
||||
GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \
|
||||
GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES_MOD_N, sizeof(int), "")); \
|
||||
++LOG_OCCURRENCES; \
|
||||
@ -1123,7 +1123,7 @@ namespace google {
|
||||
&what_to_do).stream()
|
||||
|
||||
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
|
||||
static std::atomic<unsigned> LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \
|
||||
static std::atomic<int> LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \
|
||||
GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \
|
||||
GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES_MOD_N, sizeof(int), "")); \
|
||||
++LOG_OCCURRENCES; \
|
||||
@ -1134,7 +1134,7 @@ namespace google {
|
||||
&what_to_do).stream()
|
||||
|
||||
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
|
||||
static std::atomic<unsigned> LOG_OCCURRENCES(0); \
|
||||
static std::atomic<int> LOG_OCCURRENCES(0); \
|
||||
GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \
|
||||
if (LOG_OCCURRENCES <= n) \
|
||||
++LOG_OCCURRENCES; \
|
||||
@ -1191,7 +1191,7 @@ namespace google {
|
||||
#else
|
||||
|
||||
#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
|
||||
static unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
|
||||
static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
|
||||
__sync_add_and_fetch(&LOG_OCCURRENCES, 1); \
|
||||
if (__sync_add_and_fetch(&LOG_OCCURRENCES_MOD_N, 1) > n) \
|
||||
__sync_sub_and_fetch(&LOG_OCCURRENCES_MOD_N, n); \
|
||||
@ -1201,7 +1201,7 @@ namespace google {
|
||||
&what_to_do).stream()
|
||||
|
||||
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
|
||||
static unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
|
||||
static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
|
||||
__sync_add_and_fetch(&LOG_OCCURRENCES, 1); \
|
||||
if ((condition) && \
|
||||
(__sync_add_and_fetch(&LOG_OCCURRENCES_MOD_N, 1) || true) && \
|
||||
@ -1212,7 +1212,7 @@ namespace google {
|
||||
&what_to_do).stream()
|
||||
|
||||
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
|
||||
static unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
|
||||
static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
|
||||
__sync_add_and_fetch(&LOG_OCCURRENCES, 1); \
|
||||
if (__sync_add_and_fetch(&LOG_OCCURRENCES_MOD_N, 1) > n) \
|
||||
__sync_sub_and_fetch(&LOG_OCCURRENCES_MOD_N, n); \
|
||||
@ -1222,7 +1222,7 @@ namespace google {
|
||||
&what_to_do).stream()
|
||||
|
||||
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
|
||||
static unsigned LOG_OCCURRENCES = 0; \
|
||||
static int LOG_OCCURRENCES = 0; \
|
||||
if (LOG_OCCURRENCES <= n) \
|
||||
__sync_add_and_fetch(&LOG_OCCURRENCES, 1); \
|
||||
if (LOG_OCCURRENCES <= n) \
|
||||
@ -1466,7 +1466,7 @@ GLOG_MSVC_PUSH_DISABLE_WARNING(4275)
|
||||
class GOOGLE_GLOG_DLL_DECL LogStream : public std::ostream {
|
||||
GLOG_MSVC_POP_WARNING()
|
||||
public:
|
||||
LogStream(char *buf, int len, uint64 ctr)
|
||||
LogStream(char *buf, int len, int64 ctr)
|
||||
: std::ostream(NULL),
|
||||
streambuf_(buf, len),
|
||||
ctr_(ctr),
|
||||
@ -1474,8 +1474,8 @@ GLOG_MSVC_POP_WARNING()
|
||||
rdbuf(&streambuf_);
|
||||
}
|
||||
|
||||
uint64 ctr() const { return ctr_; }
|
||||
void set_ctr(uint64 ctr) { ctr_ = ctr; }
|
||||
int64 ctr() const { return ctr_; }
|
||||
void set_ctr(int64 ctr) { ctr_ = ctr; }
|
||||
LogStream* self() const { return self_; }
|
||||
|
||||
// Legacy std::streambuf methods.
|
||||
@ -1487,7 +1487,7 @@ GLOG_MSVC_POP_WARNING()
|
||||
LogStream(const LogStream&);
|
||||
LogStream& operator=(const LogStream&);
|
||||
base_logging::LogStreamBuf streambuf_;
|
||||
uint64 ctr_; // Counter hack (for the LOG_EVERY_X() macro)
|
||||
int64 ctr_; // Counter hack (for the LOG_EVERY_X() macro)
|
||||
LogStream *self_; // Consistency check hack
|
||||
};
|
||||
|
||||
@ -1495,7 +1495,7 @@ public:
|
||||
// icc 8 requires this typedef to avoid an internal compiler error.
|
||||
typedef void (LogMessage::*SendMethod)();
|
||||
|
||||
LogMessage(const char* file, int line, LogSeverity severity, uint64 ctr,
|
||||
LogMessage(const char* file, int line, LogSeverity severity, int64 ctr,
|
||||
SendMethod send_method);
|
||||
|
||||
// Two special constructors that generate reduced amounts of code at
|
||||
@ -1668,8 +1668,7 @@ GOOGLE_GLOG_DLL_DECL std::ostream& operator<<(std::ostream &os,
|
||||
// Derived class for PLOG*() above.
|
||||
class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage {
|
||||
public:
|
||||
|
||||
ErrnoLogMessage(const char* file, int line, LogSeverity severity, uint64 ctr,
|
||||
ErrnoLogMessage(const char* file, int line, LogSeverity severity, int64 ctr,
|
||||
void (LogMessage::*send_method)());
|
||||
|
||||
// Postpends ": strerror(errno) [errno]".
|
||||
|
||||
@ -1507,7 +1507,7 @@ LogMessage::LogMessageData::LogMessageData()
|
||||
}
|
||||
|
||||
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
|
||||
uint64 ctr, void (LogMessage::*send_method)())
|
||||
int64 ctr, void (LogMessage::*send_method)())
|
||||
: allocated_(NULL) {
|
||||
Init(file, line, severity, send_method);
|
||||
data_->stream_.set_ctr(ctr);
|
||||
@ -1987,10 +1987,9 @@ ostream& operator<<(ostream &os, const PRIVATE_Counter&) {
|
||||
}
|
||||
|
||||
ErrnoLogMessage::ErrnoLogMessage(const char* file, int line,
|
||||
LogSeverity severity, uint64 ctr,
|
||||
LogSeverity severity, int64 ctr,
|
||||
void (LogMessage::*send_method)())
|
||||
: LogMessage(file, line, severity, ctr, send_method) {
|
||||
}
|
||||
: LogMessage(file, line, severity, ctr, send_method) {}
|
||||
|
||||
ErrnoLogMessage::~ErrnoLogMessage() {
|
||||
// Don't access errno directly because it may have been altered
|
||||
|
||||
Loading…
Reference in New Issue
Block a user