Skip to content

Commit

Permalink
use C++ headers
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Mar 30, 2021
1 parent 45fdc92 commit 3257e0f
Showing 22 changed files with 62 additions and 72 deletions.
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -87,8 +87,6 @@ check_include_file (inttypes.h HAVE_INTTYPES_H)
check_include_file (memory.h HAVE_MEMORY_H)
check_include_file (pwd.h HAVE_PWD_H)
check_include_file (stdint.h HAVE_STDINT_H)
check_include_file (stdlib.h HAVE_STDLIB_H)
check_include_file (string.h HAVE_STRING_H)
check_include_file (strings.h HAVE_STRINGS_H)
check_include_file (sys/stat.h HAVE_SYS_STAT_H)
check_include_file (sys/syscall.h HAVE_SYS_SYSCALL_H)
@@ -133,24 +131,24 @@ check_cxx_compiler_flag (-Wunnamed-type-template-args

# NOTE: Cannot use check_function_exists here since >=vc-14.0 can define
# snprintf as an inline function
check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF)
check_symbol_exists (snprintf cstdio HAVE_SNPRINTF)

check_library_exists (dbghelp UnDecorateSymbolName "" HAVE_DBGHELP)

check_c_source_compiles ("
#include <stdlib.h>
#include <cstdlib>
static void foo(void) __attribute__ ((unused));
int main(void) { return 0; }
" HAVE___ATTRIBUTE__)

check_c_source_compiles ("
#include <stdlib.h>
#include <cstdlib>
static void foo(void) __attribute__ ((visibility(\"default\")));
int main(void) { return 0; }
" HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)

check_c_source_compiles ("
#include <stdlib.h>
#include <cstdlib>
static void foo(void) __attribute__ ((visibility(\"hidden\")));
int main(void) { return 0; }
" HAVE___ATTRIBUTE__VISIBILITY_HIDDEN)
10 changes: 5 additions & 5 deletions src/base/commandlineflags.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// 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
@@ -14,7 +14,7 @@
// * 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
@@ -49,9 +49,9 @@
#define BASE_COMMANDLINEFLAGS_H__

#include "config.h"
#include <cstdlib> // for getenv
#include <cstring> // for memchr
#include <string>
#include <string.h> // for memchr
#include <stdlib.h> // for getenv

#ifdef HAVE_LIB_GFLAGS

4 changes: 2 additions & 2 deletions src/base/mutex.h
Original file line number Diff line number Diff line change
@@ -149,8 +149,8 @@

// We need to include these header files after defining _XOPEN_SOURCE
// as they may define the _XOPEN_SOURCE macro.
#include <assert.h>
#include <stdlib.h> // for abort()
#include <cassert>
#include <cstdlib> // for abort()

#define MUTEX_NAMESPACE glog_internal_namespace_

6 changes: 0 additions & 6 deletions src/config.h.cmake.in
Original file line number Diff line number Diff line change
@@ -79,15 +79,9 @@
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}

/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H

/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H

/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H

/* Define to 1 if you have the <syscall.h> header file. */
#cmakedefine HAVE_SYSCALL_H

2 changes: 1 addition & 1 deletion src/demangle.cc
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
//
// Note that we only have partial C++0x support yet.

#include <stdio.h> // for NULL
#include <cstdio> // for NULL
#include "utilities.h"
#include "demangle.h"

6 changes: 3 additions & 3 deletions src/glog/logging.h.in
Original file line number Diff line number Diff line change
@@ -36,9 +36,9 @@
#ifndef _LOGGING_H_
#define _LOGGING_H_

#include <errno.h>
#include <string.h>
#include <time.h>
#include <cerrno>
#include <cstring>
#include <ctime>
#include <iosfwd>
#include <ostream>
#include <sstream>
2 changes: 1 addition & 1 deletion src/glog/raw_logging.h.in
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@
#ifndef BASE_RAW_LOGGING_H_
#define BASE_RAW_LOGGING_H_

#include <time.h>
#include <ctime>

@ac_google_start_namespace@

2 changes: 1 addition & 1 deletion src/glog/vlog_is_on.h.in
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
// // that can't be accomplished e.g. via just VLOG(2) << ...;
// }
//
// The truth value that VLOG_IS_ON(level) returns is determined by
// The truth value that VLOG_IS_ON(level) returns is determined by
// the three verbosity level flags:
// --v=<n> Gives the default maximal active V-logging level;
// 0 is the default.
20 changes: 10 additions & 10 deletions src/logging.cc
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
#include "utilities.h"

#include <algorithm>
#include <assert.h>
#include <cassert>
#include <iomanip>
#include <string>
#ifdef HAVE_UNISTD_H
@@ -44,20 +44,20 @@
#ifdef HAVE_SYS_UTSNAME_H
# include <sys/utsname.h> // For uname.
#endif
#include <time.h>
#include <ctime>
#include <fcntl.h>
#include <cstdio>
#include <iostream>
#include <stdarg.h>
#include <stdlib.h>
#include <cstdarg>
#include <cstdlib>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_SYSLOG_H
# include <syslog.h>
#endif
#include <vector>
#include <errno.h> // for errno
#include <cerrno> // for errno
#include <sstream>
#ifdef OS_WINDOWS
#include "windows/dirent.h"
@@ -490,7 +490,7 @@ class LogCleaner {
const string& filename_extension) const;

bool IsLogLastModifiedOver(const string& filepath, int days) const;

bool enabled_;
int overdue_days_;
char dir_delim_; // filepath delimiter ('/' or '\\')
@@ -1230,7 +1230,7 @@ void LogFileObject::Write(bool force_flush,
file_length_ += header_len;
bytes_since_flush_ += header_len;
}

// Write to LOG file
if ( !stop_writing ) {
// fwrite() doesn't return an error when the disk is full, for
@@ -1660,7 +1660,7 @@ int AndroidLogLevel(const int severity) {
}
}
#endif // defined(__ANDROID__)
} // namespace
} // namespace

// Flush buffered message, called by the destructor, or any other function
// that needs to synchronize the log.
@@ -1696,13 +1696,13 @@ void LogMessage::Flush() {
++num_messages_[static_cast<int>(data_->severity_)];
}
LogDestination::WaitForSinks(data_);

#if defined(__ANDROID__)
const int level = AndroidLogLevel((int)data_->severity_);
const std::string text = std::string(data_->message_text_);
__android_log_write(level, "native", text.substr(0,data_->num_chars_to_log_).c_str());
#endif // defined(__ANDROID__)

if (append_newline) {
// Fix the ostrstream back how it was before we screwed with it.
// It's 99.44% certain that we don't need to worry about doing this.
2 changes: 1 addition & 1 deletion src/logging_striptest_main.cc
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@

// The common part of the striplog tests.

#include <stdio.h>
#include <cstdio>
#include <string>
#include <iosfwd>
#include "glog/logging.h"
7 changes: 3 additions & 4 deletions src/logging_unittest.cc
Original file line number Diff line number Diff line change
@@ -44,18 +44,17 @@
# include <sys/wait.h>
#endif

#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>

#include <stdio.h>
#include <stdlib.h>

#include "base/commandlineflags.h"
#include "glog/logging.h"
#include "glog/raw_logging.h"
6 changes: 3 additions & 3 deletions src/raw_logging.cc
Original file line number Diff line number Diff line change
@@ -34,13 +34,13 @@
#include "utilities.h"

#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
#include <cstdio>
#include <cerrno>
#ifdef HAVE_UNISTD_H
# include <unistd.h> // for close() and write()
#endif
#include <fcntl.h> // for open()
#include <time.h>
#include <ctime>
#include "config.h"
#include "glog/logging.h" // To pick up flag settings etc.
#include "glog/raw_logging.h"
4 changes: 2 additions & 2 deletions src/signalhandler.cc
Original file line number Diff line number Diff line change
@@ -36,8 +36,8 @@
#include "symbolize.h"
#include "glog/logging.h"

#include <signal.h>
#include <time.h>
#include <csignal>
#include <ctime>
#ifdef HAVE_UCONTEXT_H
# include <ucontext.h>
#endif
6 changes: 3 additions & 3 deletions src/signalhandler_unittest.cc
Original file line number Diff line number Diff line change
@@ -37,9 +37,9 @@
#if defined(HAVE_PTHREAD)
# include <pthread.h>
#endif
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <string>
#include "glog/logging.h"

2 changes: 1 addition & 1 deletion src/stacktrace_powerpc-inl.h
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
// http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK
// Linux has similar code: http://patchwork.ozlabs.org/linuxppc/patch?id=8882

#include <stdio.h>
#include <cstdio>
#include <stdint.h> // for uintptr_t
#include "stacktrace.h"

4 changes: 2 additions & 2 deletions src/stacktrace_unittest.cc
Original file line number Diff line number Diff line change
@@ -29,8 +29,8 @@

#include "utilities.h"

#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <cstdlib>
#include "config.h"
#include "base/commandlineflags.h"
#include "glog/logging.h"
2 changes: 1 addition & 1 deletion src/stacktrace_x86-inl.h
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
#include <sys/mman.h>
#endif

#include <stdio.h> // for NULL
#include <cstdio> // for NULL
#include "stacktrace.h"

_START_GOOGLE_NAMESPACE_
5 changes: 2 additions & 3 deletions src/stacktrace_x86_64-inl.h
Original file line number Diff line number Diff line change
@@ -31,10 +31,9 @@
//
// Produce stack trace using libgcc

extern "C" {
#include <stdlib.h> // for NULL
#include <cstdlib> // for NULL
#include <unwind.h> // ABI defined unwinder
}

#include "stacktrace.h"

_START_GOOGLE_NAMESPACE_
18 changes: 9 additions & 9 deletions src/symbolize.cc
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@

#if defined(HAVE_SYMBOLIZE)

#include <string.h>
#include <cstring>

#include <algorithm>
#include <limits>
@@ -118,14 +118,14 @@ _END_GOOGLE_NAMESPACE_
#else
#include <elf.h>
#endif
#include <errno.h>
#include <cerrno>
#include <climits>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@@ -849,7 +849,7 @@ _END_GOOGLE_NAMESPACE_
#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)

#include <dlfcn.h>
#include <string.h>
#include <cstring>

_START_GOOGLE_NAMESPACE_

@@ -951,7 +951,7 @@ _END_GOOGLE_NAMESPACE_

#else /* HAVE_SYMBOLIZE */

#include <assert.h>
#include <cassert>

#include "config.h"

2 changes: 1 addition & 1 deletion src/symbolize_unittest.cc
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@

#include "utilities.h"

#include <signal.h>
#include <csignal>
#include <iostream>

#include "glog/logging.h"
Loading

0 comments on commit 3257e0f

Please sign in to comment.