From 21effa23799fe52594ef73baffd3f2c8a6e8b43f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 13 Aug 2013 09:31:45 -0700 Subject: [PATCH] folly: attribute-aligned-arg must now be constant (not enum) Summary: With gcc-4.8.[01], the argument to __attribute__((__aligned__(...))) must be a literal; using an enum member evokes this: ./folly/MPMCQueue.h:341:63: error: requested alignment is not an \ integer constant size_t capacity_ FOLLY_ON_NEXT_CACHE_LINE; Changing the enum member to this made no difference: static constexpr size_t kFalseSharingRange = 64; Test Plan: compile tao and run test suite Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D926221 @override-unit-failures --- folly/MPMCQueue.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/folly/MPMCQueue.h b/folly/MPMCQueue.h index b4cdee18..fef1730e 100644 --- a/folly/MPMCQueue.h +++ b/folly/MPMCQueue.h @@ -335,7 +335,13 @@ class MPMCQueue : boost::noncopyable { (kFalseSharingRange - 1) / sizeof(detail::SingleElementQueue) }; -#define FOLLY_ON_NEXT_CACHE_LINE __attribute__((aligned(kFalseSharingRange))) + static_assert(kFalseSharingRange == 64, + "FOLLY_ON_NEXT_CACHE_LINE must track kFalseSharingRange"); + +// This literal "64' should be kFalseSharingRange, +// but gcc-4.8.0 and 4.8.1 reject it. +// FIXME: s/64/kFalseSharingRange/ if that ever changes. +#define FOLLY_ON_NEXT_CACHE_LINE __attribute__((aligned(64))) /// The maximum number of items in the queue at once size_t capacity_ FOLLY_ON_NEXT_CACHE_LINE; -- 2.34.1