Skip to content

Commit

Permalink
couple of fixes for MSVC compiler errors. Frankly, glog is a frickin'…
Browse files Browse the repository at this point in the history
… mess as far as I am concerned. It was already messy, but it's gotten worse. Moving to spdlog anyway as that one has the speed, organization and feature set I'm looking for; whatever glog has that spdlog hasn't, we can introruce there without the chaos this has...
  • Loading branch information
GerHobbelt committed Mar 15, 2024
1 parent a01a2d5 commit 85301f7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
8 changes: 0 additions & 8 deletions src/glog/log_severity.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@
#ifndef BASE_LOG_SEVERITY_H__
#define BASE_LOG_SEVERITY_H__

#ifndef GLOG_LOGGING_H
#error "Include glog/logging.h instead of log_severity.h"
#endif

#if !defined(GOOGLE_GLOG_DLL_DECL)
# error <glog/log_severity.h> was not included correctly. See the documentation for how to consume the library.
#endif

namespace google {

// The recommended semantics of the log levels are as follows:
Expand Down
2 changes: 1 addition & 1 deletion src/glog/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ GOOGLE_GLOG_DLL_DECL bool IsFailureSignalHandlerInstalled();
// is the size of the message. You should not expect the data is
// terminated with '\0'.
GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
size_t size));
void (*writer)(const char* data, size_t size));

// Dump stack trace as a string.
GOOGLE_GLOG_DLL_DECL std::string GetStackTrace();
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#define _GNU_SOURCE 1

#include "config.h"
#include "utilities.h"

#include <atomic>
Expand All @@ -40,7 +41,6 @@
#include <cstdlib>

#include "base/googleinit.h"
#include "config.h"
#include "glog/flags.h"
#include "glog/logging.h"
#include "stacktrace.h"
Expand Down
30 changes: 24 additions & 6 deletions src/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@

#include "config.h"
#include "glog/platform.h"
#if defined(GLOG_OS_WINDOWS)
# include <windows.h>
#endif
#if defined(GLOG_USE_WINDOWS_PORT)
# include "port.h"
#endif
#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined(HAVE_IO_H)
# include <io.h>
#endif
#if !defined(HAVE_SSIZE_T)
# if defined(GLOG_OS_WINDOWS)
# include <basetsd.h>
Expand Down Expand Up @@ -213,20 +219,32 @@ class GLOG_NO_EXPORT FileDescriptor final {

constexpr int get() const noexcept { return fd_; }

int release() noexcept { return std::exchange(fd_, InvalidHandle); }
void reset(std::nullptr_t) noexcept { safe_close(); }
void reset() noexcept { reset(nullptr); }
int release() noexcept {
return std::exchange(fd_, InvalidHandle);
}
void reset(std::nullptr_t) noexcept {
safe_close();
}
void reset() noexcept {
reset(nullptr);
}
void reset(int fd) noexcept {
reset();
fd_ = fd;
}

int close() noexcept { return unsafe_close(); }
int close() noexcept {
return unsafe_close();
}

~FileDescriptor() { safe_close(); }
~FileDescriptor() {
safe_close();
}

private:
int unsafe_close() noexcept { return ::close(release()); }
int unsafe_close() noexcept {
return ::close(release());
}
void safe_close() noexcept {
if (*this) {
unsafe_close();
Expand Down

0 comments on commit 85301f7

Please sign in to comment.