summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcraig.schlenter@chromium.org <craig.schlenter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 16:12:36 +0000
committercraig.schlenter@chromium.org <craig.schlenter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 16:12:36 +0000
commit6e4bf0b7d06e7ce84581ec4af16aab420793d0e8 (patch)
tree982b59c48c5e8b0d6306ed65fdc7d25a1e5cb373
parentecfc0de82c7de7e5c17fd971826edeb65adcef33 (diff)
downloadchromium_src-6e4bf0b7d06e7ce84581ec4af16aab420793d0e8.zip
chromium_src-6e4bf0b7d06e7ce84581ec4af16aab420793d0e8.tar.gz
chromium_src-6e4bf0b7d06e7ce84581ec4af16aab420793d0e8.tar.bz2
A build fix for gcc 4.3 (and later).
Comparing a function with NULL has been prohibited since gcc 4.3 and produces a compilation error. This change encloses your code which compares a function with NULL with "#if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5" and "#endif". BUG=none TEST=build chromium with gcc 4.3 (and later) Review URL: http://codereview.chromium.org/206024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26449 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/debug_util_posix.cc60
1 files changed, 35 insertions, 25 deletions
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc
index 1768234..fe72c3c 100644
--- a/base/debug_util_posix.cc
+++ b/base/debug_util_posix.cc
@@ -13,6 +13,10 @@
#include <sys/types.h>
#include <unistd.h>
+#if defined(OS_MACOSX)
+#include <AvailabilityMacros.h>
+#endif
+
#include "base/basictypes.h"
#include "base/compat_execinfo.h"
#include "base/eintr_wrapper.h"
@@ -116,39 +120,45 @@ void DebugUtil::BreakDebugger() {
}
StackTrace::StackTrace() {
- if (backtrace == NULL) {
+#if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
+ if (!backtrace) {
count_ = 0;
- } else {
- // Though the backtrace API man page does not list any possible negative
- // return values, we take no chance.
- count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
+ return;
}
+#endif
+ // Though the backtrace API man page does not list any possible negative
+ // return values, we take no chance.
+ count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
}
void StackTrace::PrintBacktrace() {
- if (backtrace_symbols_fd != NULL) {
- fflush(stderr);
- backtrace_symbols_fd(trace_, count_, STDERR_FILENO);
- }
+#if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
+ if (!backtrace_symbols_fd)
+ return;
+#endif
+ fflush(stderr);
+ backtrace_symbols_fd(trace_, count_, STDERR_FILENO);
}
void StackTrace::OutputToStream(std::ostream* os) {
- if (backtrace_symbols != NULL) {
- scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace_, count_));
-
- // If we can't retrieve the symbols, print an error and just dump the raw
- // addresses.
- if (trace_symbols.get() == NULL) {
- (*os) << "Unable get symbols for backtrace (" << strerror(errno)
- << "). Dumping raw addresses in trace:\n";
- for (int i = 0; i < count_; ++i) {
- (*os) << "\t" << trace_[i] << "\n";
- }
- } else {
- (*os) << "Backtrace:\n";
- for (int i = 0; i < count_; ++i) {
- (*os) << "\t" << trace_symbols.get()[i] << "\n";
- }
+#if defined(OS_MACOSX) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
+ if (!backtrace_symbols)
+ return;
+#endif
+ scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace_, count_));
+
+ // If we can't retrieve the symbols, print an error and just dump the raw
+ // addresses.
+ if (trace_symbols.get() == NULL) {
+ (*os) << "Unable get symbols for backtrace (" << strerror(errno)
+ << "). Dumping raw addresses in trace:\n";
+ for (int i = 0; i < count_; ++i) {
+ (*os) << "\t" << trace_[i] << "\n";
+ }
+ } else {
+ (*os) << "Backtrace:\n";
+ for (int i = 0; i < count_; ++i) {
+ (*os) << "\t" << trace_symbols.get()[i] << "\n";
}
}
}