Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export OS_* defines (fixes #715) #716

Merged
merged 1 commit into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/*.cmake
/*.filters
/*.sln
/*.vcxproj
autom4te.cache
*.orig
/build*/
bazel-*
CMakeCache.txt
CMakeFiles/
config.h
glog-*.tar.gz
packages/debian-*
packages/rpm-unknown
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ set (GLOG_PUBLIC_H
${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h
${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h
src/glog/log_severity.h
src/glog/platform.h
)

set (GLOG_SRCS
Expand Down
6 changes: 5 additions & 1 deletion bazel/glog.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
}),
hdrs = [
"src/glog/log_severity.h",
"src/glog/platform.h",
":logging_h",
":raw_logging_h",
":stl_logging_h",
Expand All @@ -149,7 +150,10 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
defines = select({
# GOOGLE_GLOG_DLL_DECL is normally set by export.h, but that's not
# generated for Bazel.
"@bazel_tools//src/conditions:windows": ["GOOGLE_GLOG_DLL_DECL=__declspec(dllexport)"],
"@bazel_tools//src/conditions:windows": [
"GOOGLE_GLOG_DLL_DECL=__declspec(dllexport)",
"GLOG_NO_ABBREVIATED_SEVERITIES",
],
"//conditions:default": [],
}),
copts =
Expand Down
2 changes: 1 addition & 1 deletion src/base/commandlineflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

#else

#include "glog/logging.h"
#include <glog/logging.h>

#define DECLARE_VARIABLE(type, shorttype, name, tn) \
namespace fL##shorttype { \
Expand Down
6 changes: 3 additions & 3 deletions src/demangle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
#include "demangle.h"
#include "utilities.h"

#if defined(OS_WINDOWS)
#if defined(GLOG_OS_WINDOWS)
#include <dbghelp.h>
#endif

_START_GOOGLE_NAMESPACE_

#if !defined(OS_WINDOWS)
#if !defined(GLOG_OS_WINDOWS)
typedef struct {
const char *abbrev;
const char *real_name;
Expand Down Expand Up @@ -1324,7 +1324,7 @@ static bool ParseTopLevelMangledName(State *state) {

// The demangler entry point.
bool Demangle(const char *mangled, char *out, size_t out_size) {
#if defined(OS_WINDOWS)
#if defined(GLOG_OS_WINDOWS)
// When built with incremental linking, the Windows debugger
// library provides a more complicated `Symbol->Name` with the
// Incremental Linking Table offset, which looks like
Expand Down
2 changes: 1 addition & 1 deletion src/demangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#define BASE_DEMANGLE_H_

#include "config.h"
#include "glog/logging.h"
#include <glog/logging.h>

_START_GOOGLE_NAMESPACE_

Expand Down
4 changes: 2 additions & 2 deletions src/demangle_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <iostream>
#include <fstream>
#include <string>
#include "glog/logging.h"
#include <glog/logging.h>
#include "demangle.h"
#include "googletest.h"
#include "config.h"
Expand All @@ -62,7 +62,7 @@ static const char *DemangleIt(const char * const mangled) {
}
}

#if defined(OS_WINDOWS)
#if defined(GLOG_OS_WINDOWS)

TEST(Demangle, Windows) {
EXPECT_STREQ(
Expand Down
14 changes: 8 additions & 6 deletions src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
#define GLOG_MSVC_POP_WARNING()
#endif

#include <glog/platform.h>

#if @ac_cv_have_glog_export@
#include "glog/export.h"
#include <glog/export.h>
#endif

// Annoying stuff for windows -- makes sure clients can import these functions
Expand Down Expand Up @@ -106,7 +108,7 @@

#if @ac_cv_cxx11_atomic@ && __cplusplus >= 201103L
#include <atomic>
#elif defined(OS_WINDOWS)
#elif defined(GLOG_OS_WINDOWS)
#include <Windows.h>
#endif

Expand Down Expand Up @@ -586,8 +588,8 @@ DECLARE_bool(log_utc_time);
@ac_google_start_namespace@

// They need the definitions of integer types.
#include "glog/log_severity.h"
#include "glog/vlog_is_on.h"
#include <glog/log_severity.h>
#include <glog/vlog_is_on.h>

// Initialize google's logging library. You will see the program name
// specified by argv0 in log outputs.
Expand Down Expand Up @@ -1055,7 +1057,7 @@ namespace google {
LOG_PREVIOUS_TIME_RAW.store(std::chrono::duration_cast<std::chrono::nanoseconds>(LOG_CURRENT_TIME).count(), std::memory_order_relaxed); \
if (LOG_TIME_DELTA > LOG_TIME_PERIOD) @ac_google_namespace@::LogMessage( \
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity).stream()
#elif defined(OS_WINDOWS)
#elif defined(GLOG_OS_WINDOWS)
#define SOME_KIND_OF_LOG_EVERY_T(severity, seconds) \
GLOG_CONSTEXPR LONGLONG LOG_TIME_PERIOD = (seconds) * LONGLONG(1000000000); \
static LARGE_INTEGER LOG_PREVIOUS_TIME; \
Expand Down Expand Up @@ -1131,7 +1133,7 @@ namespace google {
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()

#elif defined(OS_WINDOWS)
#elif defined(GLOG_OS_WINDOWS)

#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
static volatile unsigned LOG_OCCURRENCES = 0; \
Expand Down
58 changes: 58 additions & 0 deletions src/glog/platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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: Shinichiro Hamaji
//
// Detect supported platforms.

#ifndef GLOG_PLATFORM_H
#define GLOG_PLATFORM_H

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
#define GLOG_OS_WINDOWS
#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
#define GLOG_OS_CYGWIN
#elif defined(linux) || defined(__linux) || defined(__linux__)
#ifndef GLOG_OS_LINUX
#define GLOG_OS_LINUX
#endif
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
#define GLOG_OS_MACOSX
#elif defined(__FreeBSD__)
#define GLOG_OS_FREEBSD
#elif defined(__NetBSD__)
#define GLOG_OS_NETBSD
#elif defined(__OpenBSD__)
#define GLOG_OS_OPENBSD
#else
// TODO(hamaji): Add other platforms.
#error Platform not supported by glog. Please consider to contribute platform information by submitting a pull request on Github.
#endif

#endif // GLOG_PLATFORM_H
6 changes: 3 additions & 3 deletions src/glog/raw_logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

@ac_google_start_namespace@

#include "glog/log_severity.h"
#include "glog/logging.h"
#include "glog/vlog_is_on.h"
#include <glog/log_severity.h>
#include <glog/logging.h>
#include <glog/vlog_is_on.h>

// Annoying stuff for windows -- makes sure clients can import these functions
#ifndef GOOGLE_GLOG_DLL_DECL
Expand Down
2 changes: 1 addition & 1 deletion src/glog/vlog_is_on.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#ifndef BASE_VLOG_IS_ON_H_
#define BASE_VLOG_IS_ON_H_

#include "glog/log_severity.h"
#include <glog/log_severity.h>

// Annoying stuff for windows -- makes sure clients can import these functions
#ifndef GOOGLE_GLOG_DLL_DECL
Expand Down
14 changes: 7 additions & 7 deletions src/googletest.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ _END_GOOGLE_NAMESPACE_
#define GOOGLE_GLOG_DLL_DECL

static inline string GetTempDir() {
#ifndef OS_WINDOWS
#ifndef GLOG_OS_WINDOWS
return "/tmp";
#else
char tmp[MAX_PATH];
Expand All @@ -85,7 +85,7 @@ static inline string GetTempDir() {
#endif
}

#if defined(OS_WINDOWS) && defined(_MSC_VER) && !defined(TEST_SRC_DIR)
#if defined(GLOG_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[] = "../..";
Expand Down Expand Up @@ -220,7 +220,7 @@ static inline void CalledAbort() {
longjmp(g_jmp_buf, 1);
}

#ifdef OS_WINDOWS
#ifdef GLOG_OS_WINDOWS
// TODO(hamaji): Death test somehow doesn't work in Windows.
#define ASSERT_DEATH(fn, msg)
#else
Expand Down Expand Up @@ -510,7 +510,7 @@ static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
WriteToFile(golden, munged_golden);
string munged_captured = cap->filename() + ".munged";
WriteToFile(captured, munged_captured);
#ifdef OS_WINDOWS
#ifdef GLOG_OS_WINDOWS
string diffcmd("fc " + munged_golden + " " + munged_captured);
#else
string diffcmd("diff -u " + munged_golden + " " + munged_captured);
Expand Down Expand Up @@ -552,7 +552,7 @@ class Thread {
virtual ~Thread() {}

void SetJoinable(bool) {}
#if defined(OS_WINDOWS) && !defined(OS_CYGWIN)
#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN)
void Start() {
handle_ = CreateThread(NULL,
0,
Expand Down Expand Up @@ -585,7 +585,7 @@ class Thread {
return NULL;
}

#if defined(OS_WINDOWS) && !defined(OS_CYGWIN)
#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN)
static DWORD InvokeThreadW(void* self) {
InvokeThread(self);
return 0;
Expand All @@ -598,7 +598,7 @@ class Thread {
};

static inline void SleepForMilliseconds(unsigned t) {
#ifndef OS_WINDOWS
#ifndef GLOG_OS_WINDOWS
# if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L
const struct timespec req = {0, t * 1000 * 1000};
nanosleep(&req, NULL);
Expand Down
Loading