From edf1cd497f2ed98b4d7cba5c3b4ae77992aa1c55 Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 28 Dec 2015 18:27:40 -0800 Subject: [PATCH] Not generating "__attribute__((__unused__))" for padding fields if it is not CLANG Summary: Adding "__attribute__((__unused__))" after padding fields will pass CLANG build but will fail gcc 4.8.1. Fix it by not generating it under GCC 4.8.1. Test Plan: Build under four combinations of USE_CLANG=0,1 and ROCKSDB_FBCODE_BUILD_WITH_481=0.1. Reviewers: yhchiang, rven, ngbronson, anthony, IslamAbdelRahman Reviewed By: anthony Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D52371 --- util/concurrent_arena.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/util/concurrent_arena.h b/util/concurrent_arena.h index 912c67da3..fb29c87a1 100644 --- a/util/concurrent_arena.h +++ b/util/concurrent_arena.h @@ -17,6 +17,14 @@ #include "util/mutexlock.h" #include "util/thread_local.h" +// Only generate field unused warning for padding array, or build under +// GCC 4.8.1 will fail. +#ifdef __clang__ +#define ROCKSDB_FIELD_UNUSED __attribute__((__unused__)) +#else +#define ROCKSDB_FIELD_UNUSED +#endif // __clang__ + namespace rocksdb { class Logger; @@ -78,7 +86,7 @@ class ConcurrentArena : public Allocator { private: struct Shard { - char padding[40] __attribute__((__unused__)); + char padding[40] ROCKSDB_FIELD_UNUSED; mutable SpinMutex mutex; char* free_begin_; std::atomic allocated_and_unused_; @@ -92,7 +100,7 @@ class ConcurrentArena : public Allocator { enum ZeroFirstEnum : uint32_t { tls_cpuid = 0 }; #endif - char padding0[56] __attribute__((__unused__)); + char padding0[56] ROCKSDB_FIELD_UNUSED; size_t shard_block_size_; @@ -106,7 +114,7 @@ class ConcurrentArena : public Allocator { std::atomic memory_allocated_bytes_; std::atomic irregular_block_num_; - char padding1[56] __attribute__((__unused__)); + char padding1[56] ROCKSDB_FIELD_UNUSED; Shard* Repick();