Skip to content

Commit

Permalink
Use NULL to indicate uninitialized VLOG_IS_ON site.
Browse files Browse the repository at this point in the history
  • Loading branch information
xulongwu4 committed Apr 27, 2020
1 parent 3ba8976 commit 4a82a85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
15 changes: 4 additions & 11 deletions src/glog/vlog_is_on.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@
// parsing of --vmodule flag and/or SetVLOGLevel calls.
#define VLOG_IS_ON(verboselevel) \
__extension__ \
({ static @ac_google_namespace@::int32* vlocal__ = &@ac_google_namespace@::kLogSiteUninitialized; \
({ static @ac_google_namespace@::int32* vlocal__ = NULL; \
@ac_google_namespace@::int32 verbose_level__ = (verboselevel); \
(*vlocal__ >= verbose_level__) && \
((vlocal__ != &@ac_google_namespace@::kLogSiteUninitialized) || \
(@ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \
__FILE__, verbose_level__))); })
(vlocal__ == NULL ? @ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \
__FILE__, verbose_level__) : *vlocal__ >= verbose_level__); \
})
#else
// GNU extensions not available, so we do not support --vmodule.
// Dynamic value of FLAGS_v always controls the logging level.
Expand All @@ -106,12 +105,6 @@ extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,

// Various declarations needed for VLOG_IS_ON above: =========================

// Special value used to indicate that a VLOG_IS_ON site has not been
// initialized. We make this a large value, so the common-case check
// of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
// passes in such cases and InitVLOG3__ is then triggered.
extern @ac_google_namespace@::int32 kLogSiteUninitialized;

// Helper routine which determines the logging info for a particalur VLOG site.
// site_flag is the address of the site-local pointer to the controlling
// verbosity level
Expand Down
2 changes: 0 additions & 2 deletions src/vlog_is_on.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,

using glog_internal_namespace_::SafeFNMatch_;

int32 kLogSiteUninitialized = 1000;

// List of per-module log levels from FLAGS_vmodule.
// Once created each element is never deleted/modified
// except for the vlog_level: other threads will read VModuleInfo blobs
Expand Down
15 changes: 4 additions & 11 deletions src/windows/glog/vlog_is_on.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@
// parsing of --vmodule flag and/or SetVLOGLevel calls.
#define VLOG_IS_ON(verboselevel) \
__extension__ \
({ static google::int32* vlocal__ = &google::kLogSiteUninitialized; \
({ static @ac_google_namespace@::int32* vlocal__ = NULL; \
google::int32 verbose_level__ = (verboselevel); \
(*vlocal__ >= verbose_level__) && \
((vlocal__ != &google::kLogSiteUninitialized) || \
(google::InitVLOG3__(&vlocal__, &FLAGS_v, \
__FILE__, verbose_level__))); })
(vlocal__ == NULL ? @ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \
__FILE__, verbose_level__) : *vlocal__ >= verbose_level__); \
})
#else
// GNU extensions not available, so we do not support --vmodule.
// Dynamic value of FLAGS_v always controls the logging level.
Expand All @@ -110,12 +109,6 @@ extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,

// Various declarations needed for VLOG_IS_ON above: =========================

// Special value used to indicate that a VLOG_IS_ON site has not been
// initialized. We make this a large value, so the common-case check
// of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
// passes in such cases and InitVLOG3__ is then triggered.
extern google::int32 kLogSiteUninitialized;

// Helper routine which determines the logging info for a particalur VLOG site.
// site_flag is the address of the site-local pointer to the controlling
// verbosity level
Expand Down

0 comments on commit 4a82a85

Please sign in to comment.