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

GH-43796: [C++] Indent preprocessor directives #43798

Merged
merged 2 commits into from
Sep 6, 2024
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
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ BasedOnStyle: Google
ColumnLimit: 90
DerivePointerAlignment: false
IncludeBlocks: Preserve
IndentPPDirectives: AfterHash
16 changes: 8 additions & 8 deletions cpp/src/arrow/acero/aggregate_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ struct SumSentinelUnrolled : public Summer<T> {
static void Sum(const ArrayType& array, SumState<T>* state) {
SumState<T> local;

#define SUM_NOT_NULL(ITEM) \
do { \
local.total += values[i + ITEM] * Traits<T>::NotNull(values[i + ITEM]); \
local.valid_count++; \
} while (0)
# define SUM_NOT_NULL(ITEM) \
do { \
local.total += values[i + ITEM] * Traits<T>::NotNull(values[i + ITEM]); \
local.valid_count++; \
} while (0)

const auto values = array.raw_values();
const auto length = array.length();
Expand All @@ -185,7 +185,7 @@ struct SumSentinelUnrolled : public Summer<T> {
SUM_NOT_NULL(7);
}

#undef SUM_NOT_NULL
# undef SUM_NOT_NULL

for (int64_t i = length_rounded * 8; i < length; ++i) {
local.total += values[i] * Traits<T>::NotNull(values[i]);
Expand Down Expand Up @@ -256,7 +256,7 @@ struct SumBitmapVectorizeUnroll : public Summer<T> {
for (int64_t i = 0; i < length_rounded; i += 8) {
const uint8_t valid_byte = bitmap[i / 8];

#define SUM_SHIFT(ITEM) (values[i + ITEM] * ((valid_byte >> ITEM) & 1))
# define SUM_SHIFT(ITEM) (values[i + ITEM] * ((valid_byte >> ITEM) & 1))

if (valid_byte < 0xFF) {
// Some nulls
Expand All @@ -277,7 +277,7 @@ struct SumBitmapVectorizeUnroll : public Summer<T> {
}
}

#undef SUM_SHIFT
# undef SUM_SHIFT

for (int64_t i = length_rounded; i < length; ++i) {
if (bit_util::GetBit(bitmap, i)) {
Expand Down
22 changes: 11 additions & 11 deletions cpp/src/arrow/acero/asof_join_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
#include "arrow/acero/options.h"
#include "arrow/acero/unmaterialized_table_internal.h"
#ifndef NDEBUG
#include "arrow/acero/options_internal.h"
# include "arrow/acero/options_internal.h"
#endif
#include "arrow/acero/query_context.h"
#include "arrow/acero/schema_util.h"
#include "arrow/acero/util.h"
#include "arrow/array/builder_binary.h"
#include "arrow/array/builder_primitive.h"
#ifndef NDEBUG
#include "arrow/compute/function_internal.h"
# include "arrow/compute/function_internal.h"
#endif
#include "arrow/acero/time_series_util.h"
#include "arrow/compute/key_hash_internal.h"
Expand Down Expand Up @@ -207,16 +207,16 @@ class DebugSync {
std::unique_lock<std::mutex> debug_lock_;
};

#define DEBUG_SYNC(node, ...) DebugSync(node).insert(__VA_ARGS__)
#define DEBUG_MANIP(manip) \
DebugSync::Manip([](DebugSync& d) -> DebugSync& { return d << manip; })
#define NDEBUG_EXPLICIT
#define DEBUG_ADD(ndebug, ...) ndebug, __VA_ARGS__
# define DEBUG_SYNC(node, ...) DebugSync(node).insert(__VA_ARGS__)
# define DEBUG_MANIP(manip) \
DebugSync::Manip([](DebugSync& d) -> DebugSync& { return d << manip; })
# define NDEBUG_EXPLICIT
# define DEBUG_ADD(ndebug, ...) ndebug, __VA_ARGS__
#else
#define DEBUG_SYNC(...)
#define DEBUG_MANIP(...)
#define NDEBUG_EXPLICIT explicit
#define DEBUG_ADD(ndebug, ...) ndebug
# define DEBUG_SYNC(...)
# define DEBUG_MANIP(...)
# define NDEBUG_EXPLICIT explicit
# define DEBUG_ADD(ndebug, ...) ndebug
#endif

struct MemoStore {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/acero/asof_join_node_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#include "arrow/acero/exec_plan.h"
#include "arrow/testing/future_util.h"
#ifndef NDEBUG
#include <sstream>
# include <sstream>
#endif
#include <unordered_set>

#include "arrow/acero/options.h"
#ifndef NDEBUG
#include "arrow/acero/options_internal.h"
# include "arrow/acero/options_internal.h"
#endif
#include "arrow/acero/map_node.h"
#include "arrow/acero/query_context.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/acero/bloom_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#pragma once

#if defined(ARROW_HAVE_RUNTIME_AVX2)
#include <immintrin.h>
# include <immintrin.h>
#endif

#include <atomic>
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/acero/bloom_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ TEST(BloomFilter, Scaling) {
num_build.push_back(4000000);

std::vector<BloomFilterBuildStrategy> strategies;
#ifdef ARROW_ENABLE_THREADING
# ifdef ARROW_ENABLE_THREADING
strategies.push_back(BloomFilterBuildStrategy::PARALLEL);
#endif
# endif
strategies.push_back(BloomFilterBuildStrategy::SINGLE_THREADED);

for (const auto hardware_flags : HardwareFlagsForTesting()) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/acero/options_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#pragma once

#ifndef NDEBUG
#include <mutex>
#include <ostream>
# include <mutex>
# include <ostream>
#endif

namespace arrow {
Expand Down
42 changes: 21 additions & 21 deletions cpp/src/arrow/acero/visibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@
#pragma once

#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4251)
#else
#pragma GCC diagnostic ignored "-Wattributes"
#endif
# if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4251)
# else
# pragma GCC diagnostic ignored "-Wattributes"
# endif

#ifdef ARROW_ACERO_STATIC
#define ARROW_ACERO_EXPORT
#elif defined(ARROW_ACERO_EXPORTING)
#define ARROW_ACERO_EXPORT __declspec(dllexport)
#else
#define ARROW_ACERO_EXPORT __declspec(dllimport)
#endif
# ifdef ARROW_ACERO_STATIC
# define ARROW_ACERO_EXPORT
# elif defined(ARROW_ACERO_EXPORTING)
# define ARROW_ACERO_EXPORT __declspec(dllexport)
# else
# define ARROW_ACERO_EXPORT __declspec(dllimport)
# endif

#define ARROW_ACERO_NO_EXPORT
# define ARROW_ACERO_NO_EXPORT
#else // Not Windows
#ifndef ARROW_ACERO_EXPORT
#define ARROW_ACERO_EXPORT __attribute__((visibility("default")))
#endif
#ifndef ARROW_ACERO_NO_EXPORT
#define ARROW_ACERO_NO_EXPORT __attribute__((visibility("hidden")))
#endif
# ifndef ARROW_ACERO_EXPORT
# define ARROW_ACERO_EXPORT __attribute__((visibility("default")))
# endif
# ifndef ARROW_ACERO_NO_EXPORT
# define ARROW_ACERO_NO_EXPORT __attribute__((visibility("hidden")))
# endif
#endif // Not-Windows

#if defined(_MSC_VER)
#pragma warning(pop)
# pragma warning(pop)
#endif
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <vector>

#ifdef ARROW_ORC_NEED_TIME_ZONE_DATABASE_CHECK
#include <filesystem>
# include <filesystem>
#endif

#include "arrow/adapters/orc/util.h"
Expand Down
42 changes: 21 additions & 21 deletions cpp/src/arrow/c/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ extern "C" {
#endif

#ifndef ARROW_C_DATA_INTERFACE
#define ARROW_C_DATA_INTERFACE
# define ARROW_C_DATA_INTERFACE

#define ARROW_FLAG_DICTIONARY_ORDERED 1
#define ARROW_FLAG_NULLABLE 2
#define ARROW_FLAG_MAP_KEYS_SORTED 4
# define ARROW_FLAG_DICTIONARY_ORDERED 1
# define ARROW_FLAG_NULLABLE 2
# define ARROW_FLAG_MAP_KEYS_SORTED 4

struct ArrowSchema {
// Array type description
Expand Down Expand Up @@ -83,41 +83,41 @@ struct ArrowArray {
#endif // ARROW_C_DATA_INTERFACE

#ifndef ARROW_C_DEVICE_DATA_INTERFACE
#define ARROW_C_DEVICE_DATA_INTERFACE
# define ARROW_C_DEVICE_DATA_INTERFACE

// Spec and Documentation: https://arrow.apache.org/docs/format/CDeviceDataInterface.html

// DeviceType for the allocated memory
typedef int32_t ArrowDeviceType;

// CPU device, same as using ArrowArray directly
#define ARROW_DEVICE_CPU 1
# define ARROW_DEVICE_CPU 1
// CUDA GPU Device
#define ARROW_DEVICE_CUDA 2
# define ARROW_DEVICE_CUDA 2
// Pinned CUDA CPU memory by cudaMallocHost
#define ARROW_DEVICE_CUDA_HOST 3
# define ARROW_DEVICE_CUDA_HOST 3
// OpenCL Device
#define ARROW_DEVICE_OPENCL 4
# define ARROW_DEVICE_OPENCL 4
// Vulkan buffer for next-gen graphics
#define ARROW_DEVICE_VULKAN 7
# define ARROW_DEVICE_VULKAN 7
// Metal for Apple GPU
#define ARROW_DEVICE_METAL 8
# define ARROW_DEVICE_METAL 8
// Verilog simulator buffer
#define ARROW_DEVICE_VPI 9
# define ARROW_DEVICE_VPI 9
// ROCm GPUs for AMD GPUs
#define ARROW_DEVICE_ROCM 10
# define ARROW_DEVICE_ROCM 10
// Pinned ROCm CPU memory allocated by hipMallocHost
#define ARROW_DEVICE_ROCM_HOST 11
# define ARROW_DEVICE_ROCM_HOST 11
// Reserved for extension
#define ARROW_DEVICE_EXT_DEV 12
# define ARROW_DEVICE_EXT_DEV 12
// CUDA managed/unified memory allocated by cudaMallocManaged
#define ARROW_DEVICE_CUDA_MANAGED 13
# define ARROW_DEVICE_CUDA_MANAGED 13
// unified shared memory allocated on a oneAPI non-partitioned device.
#define ARROW_DEVICE_ONEAPI 14
# define ARROW_DEVICE_ONEAPI 14
// GPU support for next-gen WebGPU standard
#define ARROW_DEVICE_WEBGPU 15
# define ARROW_DEVICE_WEBGPU 15
// Qualcomm Hexagon DSP
#define ARROW_DEVICE_HEXAGON 16
# define ARROW_DEVICE_HEXAGON 16

struct ArrowDeviceArray {
// the Allocated Array
Expand All @@ -138,7 +138,7 @@ struct ArrowDeviceArray {
#endif // ARROW_C_DEVICE_DATA_INTERFACE

#ifndef ARROW_C_STREAM_INTERFACE
#define ARROW_C_STREAM_INTERFACE
# define ARROW_C_STREAM_INTERFACE

struct ArrowArrayStream {
// Callback to get the stream type
Expand Down Expand Up @@ -179,7 +179,7 @@ struct ArrowArrayStream {
#endif // ARROW_C_STREAM_INTERFACE

#ifndef ARROW_C_DEVICE_STREAM_INTERFACE
#define ARROW_C_DEVICE_STREAM_INTERFACE
# define ARROW_C_DEVICE_STREAM_INTERFACE

// Equivalent to ArrowArrayStream, but for ArrowDeviceArrays.
//
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/c/bridge_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// TODO(GH-37221): Remove these ifdef checks when compute dependency is removed
#ifdef ARROW_COMPUTE
#include "arrow/compute/api_vector.h"
# include "arrow/compute/api_vector.h"
#endif

namespace arrow {
Expand Down
16 changes: 8 additions & 8 deletions cpp/src/arrow/c/dlpack_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* \brief Compatibility with C++
*/
#ifdef __cplusplus
#define DLPACK_EXTERN_C extern "C"
# define DLPACK_EXTERN_C extern "C"
#else
#define DLPACK_EXTERN_C
# define DLPACK_EXTERN_C
#endif

/*! \brief The current major version of dlpack */
Expand All @@ -25,13 +25,13 @@

/*! \brief DLPACK_DLL prefix for windows */
#ifdef _WIN32
#ifdef DLPACK_EXPORTS
#define DLPACK_DLL __declspec(dllexport)
# ifdef DLPACK_EXPORTS
# define DLPACK_DLL __declspec(dllexport)
# else
# define DLPACK_DLL __declspec(dllimport)
# endif
#else
#define DLPACK_DLL __declspec(dllimport)
#endif
#else
#define DLPACK_DLL
# define DLPACK_DLL
#endif

#include <stddef.h>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// macOS defines PREALLOCATE as a preprocessor macro in the header sys/vnode.h.
// No other BSD seems to do so. The name is used as an identifier in MemAllocation enum.
#if defined(__APPLE__) && defined(PREALLOCATE)
#undef PREALLOCATE
# undef PREALLOCATE
#endif

namespace arrow {
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/compute/kernels/scalar_cast_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ struct TemporalToStringCastFunctor<O, TimestampType> {

#if defined(_MSC_VER)
// Silence warning: """'visitor': unreferenced local variable"""
#pragma warning(push)
#pragma warning(disable : 4101)
# pragma warning(push)
# pragma warning(disable : 4101)
#endif

struct Utf8Validator {
Expand Down Expand Up @@ -422,7 +422,7 @@ BinaryToBinaryCastExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* ou
}

#if defined(_MSC_VER)
#pragma warning(pop)
# pragma warning(pop)
#endif

// ----------------------------------------------------------------------
Expand Down
Loading
Loading