|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 418bcb0ce3b704ea26ee1b4a68706abca536f65a Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Fri, 22 Aug 2014 14:38:28 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] shared: drop UNIQUE()
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
The UNIQUE() macro works fine if used in un-stacked macros. However, once
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
you stack them like:
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
MAX(MIN(a, b),
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
CLAMP(MAX(c, d), e, f))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
you will get warnings due to shadowing other variables. gcc uses the last
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
line of a macro expansion as value for __LINE__, therefore, we cannot even
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
avoid this by splitting the expressions across lines.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Remove the only user of UNIQUE() so we introduce a new helper in
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
follow-ups.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/macro.h | 4 +---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 1 insertion(+), 3 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/macro.h b/src/shared/macro.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 43fa3e556f..2807bc74e8 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/macro.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/macro.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -79,8 +79,6 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define XCONCATENATE(x, y) x ## y
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define CONCATENATE(x, y) XCONCATENATE(x, y)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-#define UNIQUE(prefix) CONCATENATE(prefix, __LINE__)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* Rounds up */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define ALIGN4(l) (((l) + 3) & ~3)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -219,7 +217,7 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#else
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define assert_cc(expr) \
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
DISABLE_WARNING_DECLARATION_AFTER_STATEMENT; \
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- struct UNIQUE(_assert_struct_) { \
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ struct CONCATENATE(_assert_struct_, __LINE__) { \
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char x[(expr) ? 0 : -1]; \
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}; \
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
REENABLE_WARNING
|