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
main
sdong 9 years ago
parent 9eb4f95967
commit edf1cd497f
  1. 14
      util/concurrent_arena.h

@ -17,6 +17,14 @@
#include "util/mutexlock.h" #include "util/mutexlock.h"
#include "util/thread_local.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 { namespace rocksdb {
class Logger; class Logger;
@ -78,7 +86,7 @@ class ConcurrentArena : public Allocator {
private: private:
struct Shard { struct Shard {
char padding[40] __attribute__((__unused__)); char padding[40] ROCKSDB_FIELD_UNUSED;
mutable SpinMutex mutex; mutable SpinMutex mutex;
char* free_begin_; char* free_begin_;
std::atomic<size_t> allocated_and_unused_; std::atomic<size_t> allocated_and_unused_;
@ -92,7 +100,7 @@ class ConcurrentArena : public Allocator {
enum ZeroFirstEnum : uint32_t { tls_cpuid = 0 }; enum ZeroFirstEnum : uint32_t { tls_cpuid = 0 };
#endif #endif
char padding0[56] __attribute__((__unused__)); char padding0[56] ROCKSDB_FIELD_UNUSED;
size_t shard_block_size_; size_t shard_block_size_;
@ -106,7 +114,7 @@ class ConcurrentArena : public Allocator {
std::atomic<size_t> memory_allocated_bytes_; std::atomic<size_t> memory_allocated_bytes_;
std::atomic<size_t> irregular_block_num_; std::atomic<size_t> irregular_block_num_;
char padding1[56] __attribute__((__unused__)); char padding1[56] ROCKSDB_FIELD_UNUSED;
Shard* Repick(); Shard* Repick();

Loading…
Cancel
Save