You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by he...@apache.org on 2017/03/29 02:53:49 UTC
[08/14] incubator-impala git commit: IMPALA-4758: (1/2) Update gutil/
from Kudu@a1bfd7b
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/cpu.cc
----------------------------------------------------------------------
diff --git a/be/src/gutil/cpu.cc b/be/src/gutil/cpu.cc
new file mode 100644
index 0000000..f4c3885
--- /dev/null
+++ b/be/src/gutil/cpu.cc
@@ -0,0 +1,289 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "kudu/gutil/cpu.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <algorithm>
+
+#include "kudu/gutil/basictypes.h"
+#include "kudu/gutil/strings/stringpiece.h"
+
+#if defined(__x86_64__)
+#if defined(_MSC_VER)
+#include <intrin.h>
+#include <immintrin.h> // For _xgetbv()
+#endif
+#endif
+
+namespace base {
+
+CPU::CPU()
+ : signature_(0),
+ type_(0),
+ family_(0),
+ model_(0),
+ stepping_(0),
+ ext_model_(0),
+ ext_family_(0),
+ has_mmx_(false),
+ has_sse_(false),
+ has_sse2_(false),
+ has_sse3_(false),
+ has_ssse3_(false),
+ has_sse41_(false),
+ has_sse42_(false),
+ has_avx_(false),
+ has_avx2_(false),
+ has_aesni_(false),
+ has_non_stop_time_stamp_counter_(false),
+ has_broken_neon_(false),
+ cpu_vendor_("unknown") {
+ Initialize();
+}
+
+namespace {
+
+#if defined(__x86_64__)
+#ifndef _MSC_VER
+
+#if defined(__pic__) && defined(__i386__)
+
+void __cpuid(int cpu_info[4], int info_type) {
+ __asm__ volatile (
+ "mov %%ebx, %%edi\n"
+ "cpuid\n"
+ "xchg %%edi, %%ebx\n"
+ : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
+ : "a"(info_type)
+ );
+}
+
+#else
+
+void __cpuid(int cpu_info[4], int info_type) {
+ __asm__ volatile (
+ "cpuid\n"
+ : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
+ : "a"(info_type), "c"(0)
+ );
+}
+
+#endif
+
+// _xgetbv returns the value of an Intel Extended Control Register (XCR).
+// Currently only XCR0 is defined by Intel so |xcr| should always be zero.
+uint64 _xgetbv(uint32 xcr) {
+ uint32 eax, edx;
+
+ __asm__ volatile (
+ "xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr));
+ return (static_cast<uint64>(edx) << 32) | eax;
+}
+
+#endif // !_MSC_VER
+#endif // __x86_64__
+
+#if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX))
+class LazyCpuInfoValue {
+ public:
+ LazyCpuInfoValue() : has_broken_neon_(false) {
+ // This function finds the value from /proc/cpuinfo under the key "model
+ // name" or "Processor". "model name" is used in Linux 3.8 and later (3.7
+ // and later for arm64) and is shown once per CPU. "Processor" is used in
+ // earler versions and is shown only once at the top of /proc/cpuinfo
+ // regardless of the number CPUs.
+ const char kModelNamePrefix[] = "model name\t: ";
+ const char kProcessorPrefix[] = "Processor\t: ";
+
+ // This function also calculates whether we believe that this CPU has a
+ // broken NEON unit based on these fields from cpuinfo:
+ unsigned implementer = 0, architecture = 0, variant = 0, part = 0,
+ revision = 0;
+ const struct {
+ const char key[17];
+ unsigned int* result;
+ } kUnsignedValues[] = {
+ {"CPU implementer", &implementer},
+ {"CPU architecture", &architecture},
+ {"CPU variant", &variant},
+ {"CPU part", &part},
+ {"CPU revision", &revision},
+ };
+
+ std::string contents;
+ ReadFileToString(FilePath("/proc/cpuinfo"), &contents);
+ DCHECK(!contents.empty());
+ if (contents.empty()) {
+ return;
+ }
+
+ std::istringstream iss(contents);
+ std::string line;
+ while (std::getline(iss, line)) {
+ if (brand_.empty() &&
+ (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0 ||
+ line.compare(0, strlen(kProcessorPrefix), kProcessorPrefix) == 0)) {
+ brand_.assign(line.substr(strlen(kModelNamePrefix)));
+ }
+
+ for (size_t i = 0; i < arraysize(kUnsignedValues); i++) {
+ const char *key = kUnsignedValues[i].key;
+ const size_t len = strlen(key);
+
+ if (line.compare(0, len, key) == 0 &&
+ line.size() >= len + 1 &&
+ (line[len] == '\t' || line[len] == ' ' || line[len] == ':')) {
+ size_t colon_pos = line.find(':', len);
+ if (colon_pos == std::string::npos) {
+ continue;
+ }
+
+ const StringPiece line_sp(line);
+ StringPiece value_sp = line_sp.substr(colon_pos + 1);
+ while (!value_sp.empty() &&
+ (value_sp[0] == ' ' || value_sp[0] == '\t')) {
+ value_sp = value_sp.substr(1);
+ }
+
+ // The string may have leading "0x" or not, so we use strtoul to
+ // handle that.
+ char* endptr;
+ std::string value(value_sp.as_string());
+ unsigned long int result = strtoul(value.c_str(), &endptr, 0);
+ if (*endptr == 0 && result <= UINT_MAX) {
+ *kUnsignedValues[i].result = result;
+ }
+ }
+ }
+ }
+
+ has_broken_neon_ =
+ implementer == 0x51 &&
+ architecture == 7 &&
+ variant == 1 &&
+ part == 0x4d &&
+ revision == 0;
+ }
+
+ const std::string& brand() const { return brand_; }
+ bool has_broken_neon() const { return has_broken_neon_; }
+
+ private:
+ std::string brand_;
+ bool has_broken_neon_;
+ DISALLOW_COPY_AND_ASSIGN(LazyCpuInfoValue);
+};
+
+base::LazyInstance<LazyCpuInfoValue>::Leaky g_lazy_cpuinfo =
+ LAZY_INSTANCE_INITIALIZER;
+
+#endif // defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) ||
+ // defined(OS_LINUX))
+
+} // anonymous namespace
+
+void CPU::Initialize() {
+#if defined(__x86_64__)
+ int cpu_info[4] = {-1};
+ char cpu_string[48];
+
+ // __cpuid with an InfoType argument of 0 returns the number of
+ // valid Ids in CPUInfo[0] and the CPU identification string in
+ // the other three array elements. The CPU identification string is
+ // not in linear order. The code below arranges the information
+ // in a human readable form. The human readable order is CPUInfo[1] |
+ // CPUInfo[3] | CPUInfo[2]. CPUInfo[2] and CPUInfo[3] are swapped
+ // before using memcpy to copy these three array elements to cpu_string.
+ __cpuid(cpu_info, 0);
+ int num_ids = cpu_info[0];
+ std::swap(cpu_info[2], cpu_info[3]);
+ memcpy(cpu_string, &cpu_info[1], 3 * sizeof(cpu_info[1]));
+ cpu_vendor_.assign(cpu_string, 3 * sizeof(cpu_info[1]));
+
+ // Interpret CPU feature information.
+ if (num_ids > 0) {
+ int cpu_info7[4] = {0};
+ __cpuid(cpu_info, 1);
+ if (num_ids >= 7) {
+ __cpuid(cpu_info7, 7);
+ }
+ signature_ = cpu_info[0];
+ stepping_ = cpu_info[0] & 0xf;
+ model_ = ((cpu_info[0] >> 4) & 0xf) + ((cpu_info[0] >> 12) & 0xf0);
+ family_ = (cpu_info[0] >> 8) & 0xf;
+ type_ = (cpu_info[0] >> 12) & 0x3;
+ ext_model_ = (cpu_info[0] >> 16) & 0xf;
+ ext_family_ = (cpu_info[0] >> 20) & 0xff;
+ has_mmx_ = (cpu_info[3] & 0x00800000) != 0;
+ has_sse_ = (cpu_info[3] & 0x02000000) != 0;
+ has_sse2_ = (cpu_info[3] & 0x04000000) != 0;
+ has_sse3_ = (cpu_info[2] & 0x00000001) != 0;
+ has_ssse3_ = (cpu_info[2] & 0x00000200) != 0;
+ has_sse41_ = (cpu_info[2] & 0x00080000) != 0;
+ has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
+ // AVX instructions will generate an illegal instruction exception unless
+ // a) they are supported by the CPU,
+ // b) XSAVE is supported by the CPU and
+ // c) XSAVE is enabled by the kernel.
+ // See http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled
+ //
+ // In addition, we have observed some crashes with the xgetbv instruction
+ // even after following Intel's example code. (See crbug.com/375968.)
+ // Because of that, we also test the XSAVE bit because its description in
+ // the CPUID documentation suggests that it signals xgetbv support.
+ has_avx_ =
+ (cpu_info[2] & 0x10000000) != 0 &&
+ (cpu_info[2] & 0x04000000) != 0 /* XSAVE */ &&
+ (cpu_info[2] & 0x08000000) != 0 /* OSXSAVE */ &&
+ (_xgetbv(0) & 6) == 6 /* XSAVE enabled by kernel */;
+ has_aesni_ = (cpu_info[2] & 0x02000000) != 0;
+ has_avx2_ = has_avx_ && (cpu_info7[1] & 0x00000020) != 0;
+ }
+
+ // Get the brand string of the cpu.
+ __cpuid(cpu_info, 0x80000000);
+ const int parameter_end = 0x80000004;
+ int max_parameter = cpu_info[0];
+
+ if (cpu_info[0] >= parameter_end) {
+ char* cpu_string_ptr = cpu_string;
+
+ for (int parameter = 0x80000002; parameter <= parameter_end &&
+ cpu_string_ptr < &cpu_string[sizeof(cpu_string)]; parameter++) {
+ __cpuid(cpu_info, parameter);
+ memcpy(cpu_string_ptr, cpu_info, sizeof(cpu_info));
+ cpu_string_ptr += sizeof(cpu_info);
+ }
+ cpu_brand_.assign(cpu_string, cpu_string_ptr - cpu_string);
+ }
+
+ const int parameter_containing_non_stop_time_stamp_counter = 0x80000007;
+ if (max_parameter >= parameter_containing_non_stop_time_stamp_counter) {
+ __cpuid(cpu_info, parameter_containing_non_stop_time_stamp_counter);
+ has_non_stop_time_stamp_counter_ = (cpu_info[3] & (1 << 8)) != 0;
+ }
+#elif defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX))
+ cpu_brand_.assign(g_lazy_cpuinfo.Get().brand());
+ has_broken_neon_ = g_lazy_cpuinfo.Get().has_broken_neon();
+#else
+ #error unknown architecture
+#endif
+}
+
+CPU::IntelMicroArchitecture CPU::GetIntelMicroArchitecture() const {
+ if (has_avx2()) return AVX2;
+ if (has_avx()) return AVX;
+ if (has_sse42()) return SSE42;
+ if (has_sse41()) return SSE41;
+ if (has_ssse3()) return SSSE3;
+ if (has_sse3()) return SSE3;
+ if (has_sse2()) return SSE2;
+ if (has_sse()) return SSE;
+ return PENTIUM;
+}
+
+} // namespace base
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/cpu.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/cpu.h b/be/src/gutil/cpu.h
new file mode 100644
index 0000000..6549814
--- /dev/null
+++ b/be/src/gutil/cpu.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_CPU_H_
+#define BASE_CPU_H_
+
+#include <string>
+
+namespace base {
+
+// Query information about the processor.
+class CPU {
+ public:
+ // Constructor
+ CPU();
+
+ enum IntelMicroArchitecture {
+ PENTIUM,
+ SSE,
+ SSE2,
+ SSE3,
+ SSSE3,
+ SSE41,
+ SSE42,
+ AVX,
+ AVX2,
+ MAX_INTEL_MICRO_ARCHITECTURE
+ };
+
+ // Accessors for CPU information.
+ const std::string& vendor_name() const { return cpu_vendor_; }
+ int signature() const { return signature_; }
+ int stepping() const { return stepping_; }
+ int model() const { return model_; }
+ int family() const { return family_; }
+ int type() const { return type_; }
+ int extended_model() const { return ext_model_; }
+ int extended_family() const { return ext_family_; }
+ bool has_mmx() const { return has_mmx_; }
+ bool has_sse() const { return has_sse_; }
+ bool has_sse2() const { return has_sse2_; }
+ bool has_sse3() const { return has_sse3_; }
+ bool has_ssse3() const { return has_ssse3_; }
+ bool has_sse41() const { return has_sse41_; }
+ bool has_sse42() const { return has_sse42_; }
+ bool has_avx() const { return has_avx_; }
+ bool has_avx2() const { return has_avx2_; }
+ bool has_aesni() const { return has_aesni_; }
+ bool has_non_stop_time_stamp_counter() const {
+ return has_non_stop_time_stamp_counter_;
+ }
+ // has_broken_neon is only valid on ARM chips. If true, it indicates that we
+ // believe that the NEON unit on the current CPU is flawed and cannot execute
+ // some code. See https://code.google.com/p/chromium/issues/detail?id=341598
+ bool has_broken_neon() const { return has_broken_neon_; }
+
+ IntelMicroArchitecture GetIntelMicroArchitecture() const;
+ const std::string& cpu_brand() const { return cpu_brand_; }
+
+ private:
+ // Query the processor for CPUID information.
+ void Initialize();
+
+ int signature_; // raw form of type, family, model, and stepping
+ int type_; // process type
+ int family_; // family of the processor
+ int model_; // model of processor
+ int stepping_; // processor revision number
+ int ext_model_;
+ int ext_family_;
+ bool has_mmx_;
+ bool has_sse_;
+ bool has_sse2_;
+ bool has_sse3_;
+ bool has_ssse3_;
+ bool has_sse41_;
+ bool has_sse42_;
+ bool has_avx_;
+ bool has_avx2_;
+ bool has_aesni_;
+ bool has_non_stop_time_stamp_counter_;
+ bool has_broken_neon_;
+ std::string cpu_vendor_;
+ std::string cpu_brand_;
+};
+
+} // namespace base
+
+#endif // BASE_CPU_H_
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/cycleclock-inl.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/cycleclock-inl.h b/be/src/gutil/cycleclock-inl.h
index f5a1333..7738592 100644
--- a/be/src/gutil/cycleclock-inl.h
+++ b/be/src/gutil/cycleclock-inl.h
@@ -1,16 +1,21 @@
// Copyright (C) 1999-2007 Google, Inc.
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
//
// All rights reserved.
// Extracted from base/timer.h by jrvb
@@ -26,13 +31,13 @@
// with modifications by m3b. See also
// https://setisvn.ssl.berkeley.edu/svn/lib/fftw-3.0.1/kernel/cycle.h
-#ifndef SUPERSONIC_OPENSOURCE_AUXILIARY_CYCLECLOCK_INL_H_
-#define SUPERSONIC_OPENSOURCE_AUXILIARY_CYCLECLOCK_INL_H_
+#ifndef GUTIL_CYCLECLOCK_INL_H_
+#define GUTIL_CYCLECLOCK_INL_H_
#include <sys/time.h>
-#include "gutil/port.h"
-#include "gutil/arm_instruction_set_select.h"
+#include "kudu/gutil/port.h"
+#include "kudu/gutil/arm_instruction_set_select.h"
// Please do not nest #if directives. Keep one section, and one #if per
// platform.
@@ -143,7 +148,7 @@ inline int64 CycleClock::Now() {
// ----------------------------------------------------------------
#elif defined(ARMV6) // V6 is the earliest arm that has a standard cyclecount
-#include "base/sysinfo.h"
+#include "kudu/gutil/sysinfo.h"
inline int64 CycleClock::Now() {
uint32 pmccntr;
uint32 pmuseren;
@@ -166,7 +171,7 @@ inline int64 CycleClock::Now() {
// ----------------------------------------------------------------
#elif defined(ARMV3)
-#include "base/sysinfo.h" // for CyclesPerSecond()
+#include "kudu/gutil/sysinfo.h" // for CyclesPerSecond()
inline int64 CycleClock::Now() {
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -176,7 +181,7 @@ inline int64 CycleClock::Now() {
// ----------------------------------------------------------------
#elif defined(__mips__)
-#include "base/sysinfo.h"
+#include "kudu/gutil/sysinfo.h"
inline int64 CycleClock::Now() {
// mips apparently only allows rdtsc for superusers, so we fall
// back to gettimeofday. It's possible clock_gettime would be better.
@@ -195,4 +200,4 @@ inline int64 CycleClock::Now() {
#error You need to define CycleTimer for your O/S and CPU
#endif
-#endif // SUPERSONIC_OPENSOURCE_AUXILIARY_CYCLECLOCK_INL_H_
+#endif // GUTIL_CYCLECLOCK_INL_H_
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/dynamic_annotations.c
----------------------------------------------------------------------
diff --git a/be/src/gutil/dynamic_annotations.c b/be/src/gutil/dynamic_annotations.c
new file mode 100644
index 0000000..32c032b
--- /dev/null
+++ b/be/src/gutil/dynamic_annotations.c
@@ -0,0 +1,173 @@
+/* Copyright (c) 2008-2009, 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: Kostya Serebryany
+ */
+
+#ifdef __cplusplus
+# error "This file should be built as pure C to avoid name mangling"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "gutil/dynamic_annotations.h"
+
+#ifdef __GNUC__
+/* valgrind.h uses gcc extensions so it won't build with other compilers */
+#include "gutil/valgrind.h"
+#endif
+
+/* Compiler-based ThreadSanitizer defines
+ DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL = 1
+ and provides its own definitions of the functions. */
+
+#ifndef DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL
+# define DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL 0
+#endif
+
+/* Each function is empty and called (via a macro) only in debug mode.
+ The arguments are captured by dynamic tools at runtime. */
+
+#if DYNAMIC_ANNOTATIONS_ENABLED == 1 \
+ && DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0
+
+void AnnotateRWLockCreate(const char *file, int line,
+ const volatile void *lock){}
+void AnnotateRWLockDestroy(const char *file, int line,
+ const volatile void *lock){}
+void AnnotateRWLockAcquired(const char *file, int line,
+ const volatile void *lock, long is_w){}
+void AnnotateRWLockReleased(const char *file, int line,
+ const volatile void *lock, long is_w){}
+void AnnotateBarrierInit(const char *file, int line,
+ const volatile void *barrier, long count,
+ long reinitialization_allowed) {}
+void AnnotateBarrierWaitBefore(const char *file, int line,
+ const volatile void *barrier) {}
+void AnnotateBarrierWaitAfter(const char *file, int line,
+ const volatile void *barrier) {}
+void AnnotateBarrierDestroy(const char *file, int line,
+ const volatile void *barrier) {}
+
+void AnnotateCondVarWait(const char *file, int line,
+ const volatile void *cv,
+ const volatile void *lock){}
+void AnnotateCondVarSignal(const char *file, int line,
+ const volatile void *cv){}
+void AnnotateCondVarSignalAll(const char *file, int line,
+ const volatile void *cv){}
+void AnnotatePublishMemoryRange(const char *file, int line,
+ const volatile void *address,
+ long size){}
+void AnnotateUnpublishMemoryRange(const char *file, int line,
+ const volatile void *address,
+ long size){}
+void AnnotatePCQCreate(const char *file, int line,
+ const volatile void *pcq){}
+void AnnotatePCQDestroy(const char *file, int line,
+ const volatile void *pcq){}
+void AnnotatePCQPut(const char *file, int line,
+ const volatile void *pcq){}
+void AnnotatePCQGet(const char *file, int line,
+ const volatile void *pcq){}
+void AnnotateNewMemory(const char *file, int line,
+ const volatile void *mem,
+ long size){}
+void AnnotateExpectRace(const char *file, int line,
+ const volatile void *mem,
+ const char *description){}
+void AnnotateBenignRace(const char *file, int line,
+ const volatile void *mem,
+ const char *description){}
+void AnnotateBenignRaceSized(const char *file, int line,
+ const volatile void *mem,
+ long size,
+ const char *description) {}
+void AnnotateMutexIsUsedAsCondVar(const char *file, int line,
+ const volatile void *mu){}
+void AnnotateTraceMemory(const char *file, int line,
+ const volatile void *arg){}
+void AnnotateThreadName(const char *file, int line,
+ const char *name){}
+void AnnotateIgnoreReadsBegin(const char *file, int line){}
+void AnnotateIgnoreReadsEnd(const char *file, int line){}
+void AnnotateIgnoreWritesBegin(const char *file, int line){}
+void AnnotateIgnoreWritesEnd(const char *file, int line){}
+void AnnotateEnableRaceDetection(const char *file, int line, int enable){}
+void AnnotateNoOp(const char *file, int line,
+ const volatile void *arg){}
+void AnnotateFlushState(const char *file, int line){}
+
+#endif /* DYNAMIC_ANNOTATIONS_ENABLED == 1
+ && DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 */
+
+#if DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0
+
+static int GetRunningOnValgrind(void) {
+#ifdef RUNNING_ON_VALGRIND
+ if (RUNNING_ON_VALGRIND) return 1;
+#endif
+ char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND");
+ if (running_on_valgrind_str) {
+ return strcmp(running_on_valgrind_str, "0") != 0;
+ }
+ return 0;
+}
+
+/* See the comments in dynamic_annotations.h */
+int RunningOnValgrind(void) {
+ static volatile int running_on_valgrind = -1;
+ int local_running_on_valgrind = running_on_valgrind;
+ /* C doesn't have thread-safe initialization of statics, and we
+ don't want to depend on pthread_once here, so hack it. */
+ ANNOTATE_BENIGN_RACE(&running_on_valgrind, "safe hack");
+ if (local_running_on_valgrind == -1)
+ running_on_valgrind = local_running_on_valgrind = GetRunningOnValgrind();
+ return local_running_on_valgrind;
+}
+
+/* See the comments in dynamic_annotations.h */
+double ValgrindSlowdown(void) {
+ /* Same initialization hack as in RunningOnValgrind(). */
+ static volatile double slowdown = 0.0;
+ double local_slowdown = slowdown;
+ ANNOTATE_BENIGN_RACE(&slowdown, "safe hack");
+ if (RunningOnValgrind() == 0) {
+ return 1.0;
+ }
+ if (local_slowdown == 0.0) {
+ char *env = getenv("VALGRIND_SLOWDOWN");
+ slowdown = local_slowdown = env ? atof(env) : 50.0;
+ }
+ return local_slowdown;
+}
+
+#endif /* DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 */
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/dynamic_annotations.cc
----------------------------------------------------------------------
diff --git a/be/src/gutil/dynamic_annotations.cc b/be/src/gutil/dynamic_annotations.cc
deleted file mode 100644
index 5743674..0000000
--- a/be/src/gutil/dynamic_annotations.cc
+++ /dev/null
@@ -1,173 +0,0 @@
-/* Copyright (c) 2008-2009, 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: Kostya Serebryany
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "dynamic_annotations.h"
-
-#ifdef __GNUC__
-/* valgrind.h uses gcc extensions so it won't build with other compilers */
-#include "gutil/valgrind.h"
-#endif
-
-// Impala modification: made this file C++ and use extern "C" (IMPALA-3183).
-extern "C" {
-
-/* Compiler-based ThreadSanitizer defines
- DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL = 1
- and provides its own definitions of the functions. */
-
-#ifndef DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL
-# define DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL 0
-#endif
-
-/* Each function is empty and called (via a macro) only in debug mode.
- The arguments are captured by dynamic tools at runtime. */
-
-#if DYNAMIC_ANNOTATIONS_ENABLED == 1 \
- && DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0
-
-void AnnotateRWLockCreate(const char *file, int line,
- const volatile void *lock){}
-void AnnotateRWLockDestroy(const char *file, int line,
- const volatile void *lock){}
-void AnnotateRWLockAcquired(const char *file, int line,
- const volatile void *lock, long is_w){}
-void AnnotateRWLockReleased(const char *file, int line,
- const volatile void *lock, long is_w){}
-void AnnotateBarrierInit(const char *file, int line,
- const volatile void *barrier, long count,
- long reinitialization_allowed) {}
-void AnnotateBarrierWaitBefore(const char *file, int line,
- const volatile void *barrier) {}
-void AnnotateBarrierWaitAfter(const char *file, int line,
- const volatile void *barrier) {}
-void AnnotateBarrierDestroy(const char *file, int line,
- const volatile void *barrier) {}
-
-void AnnotateCondVarWait(const char *file, int line,
- const volatile void *cv,
- const volatile void *lock){}
-void AnnotateCondVarSignal(const char *file, int line,
- const volatile void *cv){}
-void AnnotateCondVarSignalAll(const char *file, int line,
- const volatile void *cv){}
-void AnnotatePublishMemoryRange(const char *file, int line,
- const volatile void *address,
- long size){}
-void AnnotateUnpublishMemoryRange(const char *file, int line,
- const volatile void *address,
- long size){}
-void AnnotatePCQCreate(const char *file, int line,
- const volatile void *pcq){}
-void AnnotatePCQDestroy(const char *file, int line,
- const volatile void *pcq){}
-void AnnotatePCQPut(const char *file, int line,
- const volatile void *pcq){}
-void AnnotatePCQGet(const char *file, int line,
- const volatile void *pcq){}
-void AnnotateNewMemory(const char *file, int line,
- const volatile void *mem,
- long size){}
-void AnnotateExpectRace(const char *file, int line,
- const volatile void *mem,
- const char *description){}
-void AnnotateBenignRace(const char *file, int line,
- const volatile void *mem,
- const char *description){}
-void AnnotateBenignRaceSized(const char *file, int line,
- const volatile void *mem,
- long size,
- const char *description) {}
-void AnnotateMutexIsUsedAsCondVar(const char *file, int line,
- const volatile void *mu){}
-void AnnotateTraceMemory(const char *file, int line,
- const volatile void *arg){}
-void AnnotateThreadName(const char *file, int line,
- const char *name){}
-void AnnotateIgnoreReadsBegin(const char *file, int line){}
-void AnnotateIgnoreReadsEnd(const char *file, int line){}
-void AnnotateIgnoreWritesBegin(const char *file, int line){}
-void AnnotateIgnoreWritesEnd(const char *file, int line){}
-void AnnotateEnableRaceDetection(const char *file, int line, int enable){}
-void AnnotateNoOp(const char *file, int line,
- const volatile void *arg){}
-void AnnotateFlushState(const char *file, int line){}
-
-#endif /* DYNAMIC_ANNOTATIONS_ENABLED == 1
- && DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 */
-
-#if DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0
-
-static int GetRunningOnValgrind(void) {
-#ifdef RUNNING_ON_VALGRIND
- if (RUNNING_ON_VALGRIND) return 1;
-#endif
- char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND");
- if (running_on_valgrind_str) {
- return strcmp(running_on_valgrind_str, "0") != 0;
- }
- return 0;
-}
-
-/* See the comments in dynamic_annotations.h */
-int RunningOnValgrind(void) {
- static volatile int running_on_valgrind = -1;
- int local_running_on_valgrind = running_on_valgrind;
- /* C doesn't have thread-safe initialization of statics, and we
- don't want to depend on pthread_once here, so hack it. */
- ANNOTATE_BENIGN_RACE(&running_on_valgrind, "safe hack");
- if (local_running_on_valgrind == -1)
- running_on_valgrind = local_running_on_valgrind = GetRunningOnValgrind();
- return local_running_on_valgrind;
-}
-
-/* See the comments in dynamic_annotations.h */
-double ValgrindSlowdown(void) {
- /* Same initialization hack as in RunningOnValgrind(). */
- static volatile double slowdown = 0.0;
- double local_slowdown = slowdown;
- ANNOTATE_BENIGN_RACE(&slowdown, "safe hack");
- if (RunningOnValgrind() == 0) {
- return 1.0;
- }
- if (local_slowdown == 0.0) {
- char *env = getenv("VALGRIND_SLOWDOWN");
- slowdown = local_slowdown = env ? atof(env) : 50.0;
- }
- return local_slowdown;
-}
-
-#endif /* DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 */
-}
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/dynamic_annotations.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/dynamic_annotations.h b/be/src/gutil/dynamic_annotations.h
index 53e6c31..ce68d89 100644
--- a/be/src/gutil/dynamic_annotations.h
+++ b/be/src/gutil/dynamic_annotations.h
@@ -246,6 +246,15 @@
ANNOTATE_IGNORE_READS_END();\
}while(0)\
+ /* Start ignoring all synchronization until ANNOTATE_IGNORE_SYNC_END
+ is called. */
+ #define ANNOTATE_IGNORE_SYNC_BEGIN() \
+ AnnotateIgnoreSyncBegin(__FILE__, __LINE__)
+
+ /* Stop ignoring all synchronization. */
+ #define ANNOTATE_IGNORE_SYNC_END() \
+ AnnotateIgnoreSyncEnd(__FILE__, __LINE__)
+
/* Enable (enable!=0) or disable (enable==0) race detection for all threads.
This annotation could be useful if you want to skip expensive race analysis
during some period of program execution, e.g. during initialization. */
@@ -374,6 +383,8 @@
#define ANNOTATE_IGNORE_WRITES_END() /* empty */
#define ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() /* empty */
#define ANNOTATE_IGNORE_READS_AND_WRITES_END() /* empty */
+ #define ANNOTATE_IGNORE_SYNC_BEGIN() /* empty */
+ #define ANNOTATE_IGNORE_SYNC_END() /* empty */
#define ANNOTATE_ENABLE_RACE_DETECTION(enable) /* empty */
#define ANNOTATE_NO_OP(arg) /* empty */
#define ANNOTATE_FLUSH_STATE() /* empty */
@@ -396,7 +407,7 @@
#if defined(__GNUC__) && (!defined(SWIG)) && (!defined(__clang__))
-#if DYNAMIC_ANNOTATIONS_ENABLED == 0 && LLVM_ENABLE_THREADS == 0
+#if DYNAMIC_ANNOTATIONS_ENABLED == 0
#define ANNOTALYSIS_ONLY 1
#undef ANNOTALYSIS_STATIC_INLINE
#define ANNOTALYSIS_STATIC_INLINE static inline
@@ -524,6 +535,8 @@ void AnnotateIgnoreWritesBegin(const char *file, int line)
ANNOTALYSIS_STATIC_INLINE
void AnnotateIgnoreWritesEnd(const char *file, int line)
ANNOTALYSIS_IGNORE_WRITES_END ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY
+void AnnotateIgnoreSyncBegin(const char *file, int line);
+void AnnotateIgnoreSyncEnd(const char *file, int line);
void AnnotateEnableRaceDetection(const char *file, int line, int enable);
void AnnotateNoOp(const char *file, int line,
const volatile void *arg);
@@ -559,6 +572,53 @@ int RunningOnValgrind(void);
*/
double ValgrindSlowdown(void);
+
+/* AddressSanitizer annotations from LLVM asan_interface.h */
+
+
+#if defined(__SANITIZE_ADDRESS__) || defined(ADDRESS_SANITIZER)
+// Marks memory region [addr, addr+size) as unaddressable.
+// This memory must be previously allocated by the user program. Accessing
+// addresses in this region from instrumented code is forbidden until
+// this region is unpoisoned. This function is not guaranteed to poison
+// the whole region - it may poison only subregion of [addr, addr+size) due
+// to ASan alignment restrictions.
+// Method is NOT thread-safe in the sense that no two threads can
+// (un)poison memory in the same memory region simultaneously.
+void __asan_poison_memory_region(void const volatile *addr, size_t size);
+// Marks memory region [addr, addr+size) as addressable.
+// This memory must be previously allocated by the user program. Accessing
+// addresses in this region is allowed until this region is poisoned again.
+// This function may unpoison a superregion of [addr, addr+size) due to
+// ASan alignment restrictions.
+// Method is NOT thread-safe in the sense that no two threads can
+// (un)poison memory in the same memory region simultaneously.
+void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
+
+// User code should use macros instead of functions.
+#define ASAN_POISON_MEMORY_REGION(addr, size) \
+ __asan_poison_memory_region((addr), (size))
+#define ASAN_UNPOISON_MEMORY_REGION(addr, size) \
+ __asan_unpoison_memory_region((addr), (size))
+#else
+#define ASAN_POISON_MEMORY_REGION(addr, size) \
+ ((void)(addr), (void)(size))
+#define ASAN_UNPOISON_MEMORY_REGION(addr, size) \
+ ((void)(addr), (void)(size))
+#endif
+
+// Sets the callback to be called right before death on error.
+// Passing 0 will unset the callback.
+void __asan_set_death_callback(void (*callback)(void));
+
+#if defined(__SANITIZE_ADDRESS__) || defined(ADDRESS_SANITIZER)
+#define ASAN_SET_DEATH_CALLBACK(cb) \
+ __asan_set_death_callback((cb))
+#else
+#define ASAN_SET_DEATH_CALLBACK(cb) \
+ ((void)(cb))
+#endif
+
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/endian.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/endian.h b/be/src/gutil/endian.h
index fe8cf85..5ed8f38 100644
--- a/be/src/gutil/endian.h
+++ b/be/src/gutil/endian.h
@@ -1,16 +1,21 @@
// Copyright 2005 Google Inc.
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
//
// ---
//
@@ -27,9 +32,9 @@
#include <assert.h>
-#include "gutil/int128.h"
-#include "gutil/integral_types.h"
-#include "gutil/port.h"
+#include "kudu/gutil/int128.h"
+#include "kudu/gutil/integral_types.h"
+#include "kudu/gutil/port.h"
inline uint64 gbswap_64(uint64 host_int) {
#if defined(__GNUC__) && defined(__x86_64__) && !defined(__APPLE__)
@@ -74,15 +79,17 @@ inline uint64 ghtonll(uint64 x) { return x; }
#error "Unsupported bytesex: Either IS_BIG_ENDIAN or IS_LITTLE_ENDIAN must be defined" // NOLINT
#endif // bytesex
-// This one is safe to take as it's an extension
-#define htonll(x) ghtonll(x)
// ntoh* and hton* are the same thing for any size and bytesex,
// since the function is an involution, i.e., its own inverse.
#define gntohl(x) ghtonl(x)
#define gntohs(x) ghtons(x)
#define gntohll(x) ghtonll(x)
+#if !defined(__APPLE__)
+// This one is safe to take as it's an extension
+#define htonll(x) ghtonll(x)
#define ntohll(x) htonll(x)
+#endif
// Utilities to convert numbers between the current hosts's native byte
// order and little-endian byte order
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/fixedarray.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/fixedarray.h b/be/src/gutil/fixedarray.h
index d201df9..3e9e072 100644
--- a/be/src/gutil/fixedarray.h
+++ b/be/src/gutil/fixedarray.h
@@ -1,16 +1,21 @@
// Copyright 2005 Google Inc.
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
//
// ---
//
@@ -19,10 +24,12 @@
#define UTIL_GTL_FIXEDARRAY_H__
#include <stddef.h>
+
#include <glog/logging.h>
-#include "gutil/logging-inl.h"
-#include "gutil/macros.h"
-#include "gutil/manual_constructor.h"
+
+#include "kudu/gutil/logging-inl.h"
+#include "kudu/gutil/macros.h"
+#include "kudu/gutil/manual_constructor.h"
// A FixedArray<T> represents a non-resizable array of T where the
// length of the array does not need to be a compile time constant.
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/gscoped_ptr.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/gscoped_ptr.h b/be/src/gutil/gscoped_ptr.h
index 4232b97..eee1ec7 100644
--- a/be/src/gutil/gscoped_ptr.h
+++ b/be/src/gutil/gscoped_ptr.h
@@ -50,15 +50,15 @@
// return gscoped_ptr<Foo>(new Foo("new"));
// }
// gscoped_ptr<Foo> PassThru(gscoped_ptr<Foo> arg) {
-// return arg.Pass();
+// return std::move(arg);
// }
//
// {
// gscoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay").
-// TakesOwnership(ptr.Pass()); // ptr no longer owns Foo("yay").
+// TakesOwnership(std::move(ptr)); // ptr no longer owns Foo("yay").
// gscoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo.
// gscoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2.
-// PassThru(ptr2.Pass()); // ptr2 is correspondingly NULL.
+// PassThru(std::move(ptr2)); // ptr2 is correspondingly NULL.
// }
//
// Notice that if you do not call Pass() when returning from PassThru(), or
@@ -72,7 +72,7 @@
// gscoped_ptr<Child> to gscoped_ptr<Parent>:
//
// gscoped_ptr<Foo> foo(new Foo());
-// gscoped_ptr<FooParent> parent = foo.Pass();
+// gscoped_ptr<FooParent> parent = std::move(foo);
//
// PassAs<>() should be used to upcast return value in return statement:
//
@@ -91,8 +91,8 @@
// some of the older compilers we have to support.
// -------------------------------------------------------------------------
-#ifndef BASE_MEMORY_SCOPED_PTR_H_
-#define BASE_MEMORY_SCOPED_PTR_H_
+#ifndef KUDU_GUTIL_GSCOPED_PTR_H_
+#define KUDU_GUTIL_GSCOPED_PTR_H_
// This is an implementation designed to match the anticipated future TR2
// implementation of the scoped_ptr class, and its closely-related brethren,
@@ -104,12 +104,12 @@
#include <algorithm> // For std::swap().
-#include "gutil/basictypes.h"
-#include "gutil/template_util.h"
-#include "gutil/type_traits.h"
-#include "gutil/move.h"
+#include "kudu/gutil/basictypes.h"
+#include "kudu/gutil/template_util.h"
+#include "kudu/gutil/type_traits.h"
+#include "kudu/gutil/move.h"
-namespace base {
+namespace kudu {
namespace subtle {
class RefCountedBase;
@@ -174,7 +174,7 @@ struct DefaultDeleter<T[n]> {
// Function object which invokes 'free' on its parameter, which must be
// a pointer. Can be used to store malloc-allocated pointers in gscoped_ptr:
//
-// gscoped_ptr<int, base::FreeDeleter> foo_ptr(
+// gscoped_ptr<int, kudu::FreeDeleter> foo_ptr(
// static_cast<int*>(malloc(sizeof(int))));
struct FreeDeleter {
inline void operator()(void* ptr) const {
@@ -186,8 +186,8 @@ namespace internal {
template <typename T> struct IsNotRefCounted {
enum {
- value = !base::is_convertible<T*, base::subtle::RefCountedBase*>::value &&
- !base::is_convertible<T*, base::subtle::RefCountedThreadSafeBase*>::
+ value = !base::is_convertible<T*, kudu::subtle::RefCountedBase*>::value &&
+ !base::is_convertible<T*, kudu::subtle::RefCountedThreadSafeBase*>::
value
};
};
@@ -285,7 +285,7 @@ class gscoped_ptr_impl {
// discussion of this technique.
struct Data : public D {
explicit Data(T* ptr_in) : ptr(ptr_in) {}
- Data(T* ptr_in, const D& other) : D(other), ptr(ptr_in) {}
+ Data(T* ptr_in, D other) : D(std::move(other)), ptr(ptr_in) {}
T* ptr;
};
@@ -296,7 +296,7 @@ class gscoped_ptr_impl {
} // namespace internal
-} // namespace base
+} // namespace kudu
// A gscoped_ptr<T> is like a T*, except that the destructor of gscoped_ptr<T>
// automatically deletes the pointer it holds (if any).
@@ -314,11 +314,11 @@ class gscoped_ptr_impl {
// unique_ptr<> features. Known deficiencies include not supporting move-only
// deleteres, function pointers as deleters, and deleters with reference
// types.
-template <class T, class D = base::DefaultDeleter<T> >
+template <class T, class D = kudu::DefaultDeleter<T> >
class gscoped_ptr {
MOVE_ONLY_TYPE_FOR_CPP_03(gscoped_ptr, RValue)
- COMPILE_ASSERT(base::internal::IsNotRefCounted<T>::value,
+ COMPILE_ASSERT(kudu::internal::IsNotRefCounted<T>::value,
T_is_refcounted_type_and_needs_scoped_refptr);
public:
@@ -393,7 +393,7 @@ class gscoped_ptr {
// Allow gscoped_ptr<element_type> to be used in boolean expressions, but not
// implicitly convertible to a real bool (which is dangerous).
private:
- typedef base::internal::gscoped_ptr_impl<element_type, deleter_type>
+ typedef kudu::internal::gscoped_ptr_impl<element_type, deleter_type>
gscoped_ptr::*Testable;
public:
@@ -433,7 +433,7 @@ class gscoped_ptr {
private:
// Needed to reach into |impl_| in the constructor.
template <typename U, typename V> friend class gscoped_ptr;
- base::internal::gscoped_ptr_impl<element_type, deleter_type> impl_;
+ kudu::internal::gscoped_ptr_impl<element_type, deleter_type> impl_;
// Forbid comparison of gscoped_ptr types. If U != T, it totally
// doesn't make sense, and if U == T, it still doesn't make sense
@@ -500,7 +500,7 @@ class gscoped_ptr<T[], D> {
// Allow gscoped_ptr<element_type> to be used in boolean expressions, but not
// implicitly convertible to a real bool (which is dangerous).
private:
- typedef base::internal::gscoped_ptr_impl<element_type, deleter_type>
+ typedef kudu::internal::gscoped_ptr_impl<element_type, deleter_type>
gscoped_ptr::*Testable;
public:
@@ -531,7 +531,7 @@ class gscoped_ptr<T[], D> {
enum { type_must_be_complete = sizeof(element_type) };
// Actually hold the data.
- base::internal::gscoped_ptr_impl<element_type, deleter_type> impl_;
+ kudu::internal::gscoped_ptr_impl<element_type, deleter_type> impl_;
// Disable initialization from any type other than element_type*, by
// providing a constructor that matches such an initialization, but is
@@ -691,12 +691,12 @@ bool operator!=(C* p1, const gscoped_array<C>& p2) {
return p1 != p2.get();
}
-// DEPRECATED: Use gscoped_ptr<C, base::FreeDeleter> instead.
+// DEPRECATED: Use gscoped_ptr<C, kudu::FreeDeleter> instead.
//
// gscoped_ptr_malloc<> is similar to gscoped_ptr<>, but it accepts a
// second template argument, the functor used to free the object.
-template<class C, class FreeProc = base::FreeDeleter>
+template<class C, class FreeProc = kudu::FreeDeleter>
class gscoped_ptr_malloc {
MOVE_ONLY_TYPE_FOR_CPP_03(gscoped_ptr_malloc, RValue)
@@ -827,4 +827,4 @@ gscoped_ptr<T> make_gscoped_ptr(T* ptr) {
return gscoped_ptr<T>(ptr);
}
-#endif // BASE_MEMORY_SCOPED_PTR_H_
+#endif // KUDU_GUTIL_GSCOPED_PTR_H_
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/builtin_type_hash.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/builtin_type_hash.h b/be/src/gutil/hash/builtin_type_hash.h
index 173839b..c979eb2 100644
--- a/be/src/gutil/hash/builtin_type_hash.h
+++ b/be/src/gutil/hash/builtin_type_hash.h
@@ -10,10 +10,10 @@
#include <stddef.h>
#include <stdint.h>
-#include "gutil/casts.h"
-#include "gutil/integral_types.h"
-#include "gutil/macros.h"
-#include "gutil/hash/jenkins_lookup2.h"
+#include "kudu/gutil/casts.h"
+#include "kudu/gutil/integral_types.h"
+#include "kudu/gutil/macros.h"
+#include "kudu/gutil/hash/jenkins_lookup2.h"
inline uint32 Hash32NumWithSeed(uint32 num, uint32 c) {
uint32 b = 0x9e3779b9UL; // the golden ratio; an arbitrary value
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/city.cc
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/city.cc b/be/src/gutil/hash/city.cc
index c35e70e..cc00ff7 100644
--- a/be/src/gutil/hash/city.cc
+++ b/be/src/gutil/hash/city.cc
@@ -14,7 +14,7 @@
// optimize the code here by writing a program that systematically explores
// more of the space of possible hash functions, or by using SIMD instructions.
-#include "gutil/hash/city.h"
+#include "kudu/gutil/hash/city.h"
#include <sys/types.h>
#include <algorithm>
@@ -28,12 +28,12 @@ using std::swap;
using std::make_pair;
using std::pair;
-#include "gutil/int128.h"
-#include "gutil/integral_types.h"
+#include "kudu/gutil/int128.h"
+#include "kudu/gutil/integral_types.h"
#include <glog/logging.h>
-#include "gutil/logging-inl.h"
-#include "gutil/hash/hash128to64.h"
-#include "gutil/endian.h"
+#include "kudu/gutil/logging-inl.h"
+#include "kudu/gutil/hash/hash128to64.h"
+#include "kudu/gutil/endian.h"
namespace util_hash {
@@ -305,7 +305,7 @@ uint128 CityHash128(const char *s, size_t len) {
uint128(LittleEndian::Load64(s) ^ k3,
LittleEndian::Load64(s + 8)));
} else if (len >= 8) {
- return CityHash128WithSeed(NULL,
+ return CityHash128WithSeed(nullptr,
0,
uint128(LittleEndian::Load64(s) ^ (len * k0),
LittleEndian::Load64(s + len - 8) ^ k1));
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/city.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/city.h b/be/src/gutil/hash/city.h
index d5925e5..e99202e 100644
--- a/be/src/gutil/hash/city.h
+++ b/be/src/gutil/hash/city.h
@@ -23,8 +23,8 @@
#include <stddef.h> // for size_t.
-#include "gutil/int128.h"
-#include "gutil/integral_types.h"
+#include "kudu/gutil/int128.h"
+#include "kudu/gutil/integral_types.h"
namespace util_hash {
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/hash.cc
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/hash.cc b/be/src/gutil/hash/hash.cc
index 85c4663..92a8ca2 100644
--- a/be/src/gutil/hash/hash.cc
+++ b/be/src/gutil/hash/hash.cc
@@ -7,13 +7,13 @@
// To find the implementation of the core Bob Jenkins lookup2 hash, look in
// jenkins.cc.
-#include "gutil/hash/hash.h"
+#include "kudu/gutil/hash/hash.h"
-#include "gutil/integral_types.h"
+#include "kudu/gutil/integral_types.h"
#include <glog/logging.h>
-#include "gutil/logging-inl.h"
-#include "gutil/hash/jenkins.h"
-#include "gutil/hash/jenkins_lookup2.h"
+#include "kudu/gutil/logging-inl.h"
+#include "kudu/gutil/hash/jenkins.h"
+#include "kudu/gutil/hash/jenkins_lookup2.h"
// For components that ship code externally (notably the Google Search
// Appliance) we want to change the fingerprint function so that
@@ -36,10 +36,6 @@ static inline uint32 char2unsigned(char c) {
return static_cast<uint32>(static_cast<unsigned char>(c));
}
-static inline uint64 char2unsigned64(char c) {
- return static_cast<uint64>(static_cast<unsigned char>(c));
-}
-
uint64 FingerprintReferenceImplementation(const char *s, uint32 len) {
uint32 hi = Hash32StringWithSeed(s, len, kFingerprintSeed0);
uint32 lo = Hash32StringWithSeed(s, len, kFingerprintSeed1);
@@ -193,8 +189,8 @@ uint64 FingerprintInterleavedImplementation(const char *s, uint32 len) {
#include <ext/hash_set>
namespace __gnu_cxx {
-template class hash_set<string>;
-template class hash_map<string, string>;
+template class hash_set<std::string>;
+template class hash_map<std::string, std::string>;
} // namespace __gnu_cxx
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/hash.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/hash.h b/be/src/gutil/hash/hash.h
index 05116a7..3c14f80 100644
--- a/be/src/gutil/hash/hash.h
+++ b/be/src/gutil/hash/hash.h
@@ -77,12 +77,6 @@
#include <stdint.h> // for uintptr_t
#include <string.h>
#include <algorithm>
-using std::copy;
-using std::max;
-using std::min;
-using std::reverse;
-using std::sort;
-using std::swap;
#include <ext/hash_map>
using __gnu_cxx::hash;
using __gnu_cxx::hash_map; // hacky way to make sure we import standard hash<> fns
@@ -90,22 +84,19 @@ using __gnu_cxx::hash_map; // hacky way to make sure we import standard hash
using __gnu_cxx::hash;
using __gnu_cxx::hash_set;
#include <string>
-using std::string;
#include <utility>
-using std::make_pair;
-using std::pair;
-
-#include "gutil/casts.h"
-#include "gutil/int128.h"
-#include "gutil/integral_types.h"
-#include "gutil/macros.h"
-#include "gutil/port.h"
-#include "gutil/hash/city.h"
-#include "gutil/hash/hash128to64.h"
-#include "gutil/hash/jenkins.h"
-#include "gutil/hash/jenkins_lookup2.h"
-#include "gutil/hash/legacy_hash.h"
-#include "gutil/hash/string_hash.h"
+
+#include "kudu/gutil/casts.h"
+#include "kudu/gutil/int128.h"
+#include "kudu/gutil/integral_types.h"
+#include "kudu/gutil/macros.h"
+#include "kudu/gutil/port.h"
+#include "kudu/gutil/hash/city.h"
+#include "kudu/gutil/hash/hash128to64.h"
+#include "kudu/gutil/hash/jenkins.h"
+#include "kudu/gutil/hash/jenkins_lookup2.h"
+#include "kudu/gutil/hash/legacy_hash.h"
+#include "kudu/gutil/hash/string_hash.h"
#include <ext/hash_set>
namespace __gnu_cxx {
@@ -123,14 +114,6 @@ struct hash {
};
#endif // defined(_MSC_VER)
-template<> struct hash<int64> {
- size_t operator()(int64 x) const { return static_cast<size_t>(x); }
-};
-
-template<> struct hash<uint64> {
- size_t operator()(uint64 x) const { return static_cast<size_t>(x); }
-};
-
#endif // !defined(_STLP_LONG_LONG) && !(defined(_MSC_VER) && _MSC_VER >= 1600)
template<> struct hash<bool> {
@@ -186,10 +169,10 @@ inline uint64 CombineFingerprintHalves(uint32 hi, uint32 lo) {
return result;
}
-inline uint64 Fingerprint(const string& s) {
+inline uint64 Fingerprint(const std::string& s) {
return Fingerprint(s.data(), static_cast<uint32>(s.size()));
}
-inline uint64 Hash64StringWithSeed(const string& s, uint64 c) {
+inline uint64 Hash64StringWithSeed(const std::string& s, uint64 c) {
return Hash64StringWithSeed(s.data(), static_cast<uint32>(s.size()), c);
}
inline uint64 Fingerprint(schar c) {
@@ -283,8 +266,8 @@ struct hash<std::basic_string<_CharT, _Traits, _Alloc> > {
};
// they don't define a hash for const string at all
-template<> struct hash<const string> {
- size_t operator()(const string& k) const {
+template<> struct hash<const std::string> {
+ size_t operator()(const std::string& k) const {
return HashTo32(k.data(), static_cast<uint32>(k.length()));
}
};
@@ -306,12 +289,12 @@ template<> struct hash<char const*> {
// MSVC 10.0 and above have already defined this.
#if !defined(_MSC_VER) || _MSC_VER < 1600
-template<> struct hash<string> {
- size_t operator()(const string& k) const {
+template<> struct hash<std::string> {
+ size_t operator()(const std::string& k) const {
return HashTo32(k.data(), k.length());
}
// Less than operator:
- bool operator()(const string& a, const string& b) const {
+ bool operator()(const std::string& a, const std::string& b) const {
return a < b;
}
static const size_t bucket_size = 4; // These are required by MSVC
@@ -426,8 +409,8 @@ struct GoodFastHash<const std::basic_string<_CharT, _Traits, _Alloc> > {
#include <ext/hash_set>
namespace __gnu_cxx {
-extern template class hash_set<string>;
-extern template class hash_map<string, string>;
+extern template class hash_set<std::string>;
+extern template class hash_map<std::string, std::string>;
} // namespace __gnu_cxx
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/hash128to64.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/hash128to64.h b/be/src/gutil/hash/hash128to64.h
index af95662..481a010 100644
--- a/be/src/gutil/hash/hash128to64.h
+++ b/be/src/gutil/hash/hash128to64.h
@@ -4,8 +4,8 @@
#ifndef UTIL_HASH_HASH128TO64_H_
#define UTIL_HASH_HASH128TO64_H_
-#include "gutil/int128.h"
-#include "gutil/integral_types.h"
+#include "kudu/gutil/int128.h"
+#include "kudu/gutil/integral_types.h"
// Hash 128 input bits down to 64 bits of output.
// This is intended to be a reasonably good hash function.
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/jenkins.cc
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/jenkins.cc b/be/src/gutil/hash/jenkins.cc
index 7fd34bd..70a7e30 100644
--- a/be/src/gutil/hash/jenkins.cc
+++ b/be/src/gutil/hash/jenkins.cc
@@ -16,12 +16,12 @@
// to load words from memory a byte at a time. See gwshash.cc for an
// implementation that is compatible with Bob Jenkins' lookup2.c.
-#include "gutil/hash/jenkins.h"
+#include "kudu/gutil/hash/jenkins.h"
-#include "gutil/integral_types.h"
+#include "kudu/gutil/integral_types.h"
#include <glog/logging.h>
-#include "gutil/logging-inl.h"
-#include "gutil/hash/jenkins_lookup2.h"
+#include "kudu/gutil/logging-inl.h"
+#include "kudu/gutil/hash/jenkins_lookup2.h"
static inline uint32 char2unsigned(char c) {
return static_cast<uint32>(static_cast<unsigned char>(c));
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/jenkins.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/jenkins.h b/be/src/gutil/hash/jenkins.h
index 6837a66..90a47ed 100644
--- a/be/src/gutil/hash/jenkins.h
+++ b/be/src/gutil/hash/jenkins.h
@@ -10,7 +10,7 @@
#ifndef UTIL_HASH_JENKINS_H_
#define UTIL_HASH_JENKINS_H_
-#include "gutil/integral_types.h"
+#include "kudu/gutil/integral_types.h"
// ----------------------------------------------------------------------
// Hash32StringWithSeed()
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/jenkins_lookup2.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/jenkins_lookup2.h b/be/src/gutil/hash/jenkins_lookup2.h
index 6793809..e6ffa84 100644
--- a/be/src/gutil/hash/jenkins_lookup2.h
+++ b/be/src/gutil/hash/jenkins_lookup2.h
@@ -15,8 +15,8 @@
#ifndef UTIL_HASH_JENKINS_LOOKUP2_H_
#define UTIL_HASH_JENKINS_LOOKUP2_H_
-#include "gutil/integral_types.h"
-#include "gutil/port.h"
+#include "kudu/gutil/integral_types.h"
+#include "kudu/gutil/port.h"
// ----------------------------------------------------------------------
// mix()
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/legacy_hash.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/legacy_hash.h b/be/src/gutil/hash/legacy_hash.h
index 31029eb..3a69336 100644
--- a/be/src/gutil/hash/legacy_hash.h
+++ b/be/src/gutil/hash/legacy_hash.h
@@ -10,9 +10,9 @@
#ifndef UTIL_HASH_LEGACY_HASH_H_
#define UTIL_HASH_LEGACY_HASH_H_
-#include "gutil/integral_types.h"
-#include "gutil/hash/builtin_type_hash.h"
-#include "gutil/hash/string_hash.h"
+#include "kudu/gutil/integral_types.h"
+#include "kudu/gutil/hash/builtin_type_hash.h"
+#include "kudu/gutil/hash/string_hash.h"
// Hash8, Hash16 and Hash32 are for legacy use only.
typedef uint32 Hash32;
@@ -73,9 +73,6 @@ HASH_TO((uint32 c), Hash32NumWithSeed(static_cast<uint32>(c), MIX32))
HASH_TO((int32 c), Hash32NumWithSeed(static_cast<uint32>(c), MIX32))
HASH_TO((uint64 c), static_cast<uint32>(Hash64NumWithSeed(c, MIX64) >> 32))
HASH_TO((int64 c), static_cast<uint32>(Hash64NumWithSeed(c, MIX64) >> 32))
-#ifdef _LP64
-HASH_TO((intptr_t c), static_cast<uint32>(Hash64NumWithSeed(c, MIX64) >> 32))
-#endif
#undef HASH_TO // clean up the macro space
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/hash/string_hash.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/hash/string_hash.h b/be/src/gutil/hash/string_hash.h
index 4e39997..d8c20f3 100644
--- a/be/src/gutil/hash/string_hash.h
+++ b/be/src/gutil/hash/string_hash.h
@@ -13,11 +13,11 @@
#include <stddef.h>
-#include "gutil/port.h"
-#include "gutil/integral_types.h"
-#include "gutil/hash/city.h"
-#include "gutil/hash/jenkins.h"
-#include "gutil/hash/jenkins_lookup2.h"
+#include "kudu/gutil/port.h"
+#include "kudu/gutil/integral_types.h"
+#include "kudu/gutil/hash/city.h"
+#include "kudu/gutil/hash/jenkins.h"
+#include "kudu/gutil/hash/jenkins_lookup2.h"
namespace hash_internal {
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/int128.cc
----------------------------------------------------------------------
diff --git a/be/src/gutil/int128.cc b/be/src/gutil/int128.cc
index 9e2ab18..eeaee2f 100644
--- a/be/src/gutil/int128.cc
+++ b/be/src/gutil/int128.cc
@@ -6,8 +6,8 @@
#include <iostream>
using std::cout;
using std::endl;
-#include "gutil/int128.h"
-#include "gutil/integral_types.h"
+#include "kudu/gutil/int128.h"
+#include "kudu/gutil/integral_types.h"
const uint128_pod kuint128max = {
static_cast<uint64>(GG_LONGLONG(0xFFFFFFFFFFFFFFFF)),
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/int128.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/int128.h b/be/src/gutil/int128.h
index 72b87cd..2a19cca 100644
--- a/be/src/gutil/int128.h
+++ b/be/src/gutil/int128.h
@@ -7,7 +7,7 @@
#include <iosfwd>
using std::ostream;
-#include "gutil/integral_types.h"
+#include "kudu/gutil/integral_types.h"
struct uint128_pod;
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/integral_types.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/integral_types.h b/be/src/gutil/integral_types.h
index a57ef1e..cbcf917 100644
--- a/be/src/gutil/integral_types.h
+++ b/be/src/gutil/integral_types.h
@@ -10,6 +10,8 @@
#ifndef BASE_INTEGRAL_TYPES_H_
#define BASE_INTEGRAL_TYPES_H_
+#include <inttypes.h>
+
// These typedefs are also defined in base/google.swig. In the
// SWIG environment, we use those definitions and avoid duplicate
// definitions here with an ifdef. The definitions should be the
@@ -18,14 +20,14 @@
// Standard typedefs
// All Google2 code is compiled with -funsigned-char to make "char"
// unsigned. Google2 code therefore doesn't need a "uchar" type.
-typedef signed char schar;
-typedef signed char int8;
-typedef short int16;
-typedef int int32;
+typedef int8_t schar;
+typedef int8_t int8;
+typedef int16_t int16;
+typedef int32_t int32;
#ifdef _MSC_VER
typedef __int64 int64;
#else
-typedef long long int64;
+typedef int64_t int64;
#endif /* _MSC_VER */
// NOTE: unsigned types are DANGEROUS in loops and other arithmetical
@@ -34,13 +36,13 @@ typedef long long int64;
// use 'unsigned' to express "this value should always be positive";
// use assertions for this.
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
+typedef uint8_t uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
#ifdef _MSC_VER
typedef unsigned __int64 uint64;
#else
-typedef unsigned long long uint64;
+typedef uint64_t uint64;
#endif /* _MSC_VER */
// A type to represent a Unicode code-point value. As of Unicode 4.0,
@@ -72,16 +74,10 @@ typedef unsigned long uword_t;
#define GG_LONGLONG(x) x##I64
#define GG_ULONGLONG(x) x##UI64
-// Length modifier in printf format string for int64's (e.g. within %d)
-#define GG_LL_FORMAT "I64" // As in printf("%I64d", ...)
-#define GG_LL_FORMAT_W L"I64"
-
#else /* not Visual C++ */
#define GG_LONGLONG(x) x##LL
#define GG_ULONGLONG(x) x##ULL
-#define GG_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also.
-#define GG_LL_FORMAT_W L"ll"
#endif // _MSC_VER
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/linux_syscall_support.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/linux_syscall_support.h b/be/src/gutil/linux_syscall_support.h
index 59d1dcc..5476d0b 100644
--- a/be/src/gutil/linux_syscall_support.h
+++ b/be/src/gutil/linux_syscall_support.h
@@ -235,7 +235,7 @@ struct siginfo;
struct kernel_old_sigaction {
union {
void (*sa_handler_)(int);
- void (*sa_sigaction_)(int, int *, void *);
+ void (*sa_sigaction_)(int, struct siginfo *, void *);
};
unsigned long sa_mask;
unsigned long sa_flags;
@@ -272,13 +272,13 @@ struct kernel_sigaction {
unsigned long sa_flags;
union {
void (*sa_handler_)(int);
- void (*sa_sigaction_)(int, int *, void *);
+ void (*sa_sigaction_)(int, struct siginfo *, void *);
};
struct kernel_sigset_t sa_mask;
#else
union {
void (*sa_handler_)(int);
- void (*sa_sigaction_)(int, int *, void *);
+ void (*sa_sigaction_)(int, struct siginfo *, void *);
};
unsigned long sa_flags;
void (*sa_restorer)(void);
@@ -2603,15 +2603,15 @@ struct kernel_io_event {
/* check for fn == NULL
* and child_stack == NULL
*/
- "cmp"LSS_SIZE_S"i cr0, %6, 0\n\t"
- "cmp"LSS_SIZE_S"i cr1, %7, 0\n\t"
+ "cmp" LSS_SIZE_S "i cr0, %6, 0\n\t"
+ "cmp" LSS_SIZE_S "i cr1, %7, 0\n\t"
"cror cr0*4+eq, cr1*4+eq, cr0*4+eq\n\t"
"beq- cr0, 1f\n\t"
/* set up stack frame for child */
- "clrr"LSS_SIZE_S"i %7, %7, 4\n\t"
+ "clrr" LSS_SIZE_S "i %7, %7, 4\n\t"
"li 0, 0\n\t"
- "st"LSS_SIZE_S"u 0, %13(%7)\n\t"
+ "st" LSS_SIZE_S "u 0, %13(%7)\n\t"
/* fn, arg, child_stack are saved across the syscall: r27-29 */
"mr 28, %6\n\t"
@@ -2629,7 +2629,7 @@ struct kernel_io_event {
"sc\n\t"
/* Test if syscall was successful */
- "cmp"LSS_SIZE_S"i cr1, 3, 0\n\t"
+ "cmp" LSS_SIZE_S "i cr1, 3, 0\n\t"
"crandc cr1*4+eq, cr1*4+eq, cr0*4+so\n\t"
"bne- cr1, 1f\n\t"
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/logging-inl.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/logging-inl.h b/be/src/gutil/logging-inl.h
index 795c21a..409a99c 100644
--- a/be/src/gutil/logging-inl.h
+++ b/be/src/gutil/logging-inl.h
@@ -1,16 +1,21 @@
// Copyright 2012 Google Inc.
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
//
// All rights reserved.
//
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/macros.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/macros.h b/be/src/gutil/macros.h
index ca0daea..f271bd4 100644
--- a/be/src/gutil/macros.h
+++ b/be/src/gutil/macros.h
@@ -11,7 +11,7 @@
#define BASE_MACROS_H_
#include <stddef.h> // For size_t
-#include "gutil/port.h"
+#include "kudu/gutil/port.h"
// The swigged version of an abstract class must be concrete if any methods
// return objects of the abstract type. We keep it abstract in C++ and
@@ -39,10 +39,8 @@ template <bool>
struct CompileAssert {
};
-#ifndef COMPILE_ASSERT
#define COMPILE_ASSERT(expr, msg) \
- typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
-#endif
+ typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] ATTRIBUTE_UNUSED
// Implementation details of COMPILE_ASSERT:
//
@@ -95,21 +93,10 @@ struct CompileAssert {
// Note, that most uses of DISALLOW_ASSIGN and DISALLOW_COPY are broken
// semantically, one should either use disallow both or neither. Try to
// avoid these in new code.
-//
-// The LANG_CXX11 branch is a workaround for
-// http://gcc.gnu.org/PR51213 in gcc-4.7 / Crosstool v16.
-// TODO(user): Remove "&& !defined(__clang_)" when =delete is
-// gcc-4.7 before =delete is allowed, go back to the C++98 definition.
#ifndef DISALLOW_COPY_AND_ASSIGN
-#if LANG_CXX11 && !defined(__clang__)
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete
-#else
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&); \
- void operator=(const TypeName&)
-#endif
#endif
// An older, politically incorrect name for the above.
@@ -123,7 +110,7 @@ struct CompileAssert {
// that wants to prevent anyone from instantiating it. This is
// especially useful for classes containing only static methods.
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
- TypeName(); \
+ TypeName() = delete; \
DISALLOW_COPY_AND_ASSIGN(TypeName)
// The arraysize(arr) macro returns the # of elements in an array arr.
@@ -205,6 +192,14 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
#define AS_STRING(x) AS_STRING_INTERNAL(x)
#define AS_STRING_INTERNAL(x) #x
+// Macro that allows definition of a variable appended with the current line
+// number in the source file. Typically for use by other macros to allow the
+// user to declare multiple variables with the same "base" name inside the same
+// lexical block.
+#define VARNAME_LINENUM(varname) VARNAME_LINENUM_INTERNAL(varname ## _L, __LINE__)
+#define VARNAME_LINENUM_INTERNAL(v, line) VARNAME_LINENUM_INTERNAL2(v, line)
+#define VARNAME_LINENUM_INTERNAL2(v, line) v ## line
+
// The following enum should be used only as a constructor argument to indicate
// that the variable has static storage class, and that the constructor should
// do nothing to its state. It indicates to the reader that it is legal to
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/02f3e3fc/be/src/gutil/manual_constructor.h
----------------------------------------------------------------------
diff --git a/be/src/gutil/manual_constructor.h b/be/src/gutil/manual_constructor.h
index 1434f72..adcda07 100644
--- a/be/src/gutil/manual_constructor.h
+++ b/be/src/gutil/manual_constructor.h
@@ -45,7 +45,7 @@
#include <stddef.h>
-#include "gutil/port.h"
+#include "kudu/gutil/port.h"
namespace base {