Linux Modules
 help / color / mirror / Atom feed
* [PATCH] make kmod compatible with GCC < 4.6
@ 2013-09-11  1:17 John Spencer
  2013-09-11  1:32 ` Lucas De Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: John Spencer @ 2013-09-11  1:17 UTC (permalink / raw)
  To: linux-modules; +Cc: John Spencer

[-- Attachment #1: Type: text/plain, Size: 226 bytes --]

hello list, find attached a patch that fixes compilation with 
non-bleeding-edge compilers (we use GCC 4.5.4 in production).

the missing C11 feature is emulated on compilers that feature a __LINE__ 
macro.

best regards
--JS

[-- Attachment #2: kmod-static-assert.patch --]
[-- Type: text/x-patch, Size: 782 bytes --]

[PATCH] make kmod compatible with GCC < 4.6

--- kmod-15.org/libkmod/macro.h
+++ kmod-15/libkmod/macro.h
@@ -21,8 +21,25 @@
 
 #include <stddef.h>
 
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ +0 >= 201112L) || \
+    (defined(__GNUC__) && (__GNUC__ +0) * 10 + (__GNUC_MINOR__ +0) >= 46)
+
 #define assert_cc(expr) \
 	_Static_assert((expr), #expr)
+
+#elif defined(__LINE__)
+
+#define PASTE2__(A, B) A ## B
+#define PASTE__(A, B) PASTE2__(A, B)
+#define STATIC_ASSERT__(COND) typedef char PASTE__(static_assertion, __LINE__) [(COND)?1:-1]
+#define assert_cc(expr) \
+	STATIC_ASSERT__((expr))
+
+#else
+#warning "compiler has no support for static assertions"
+#define assert_cc(expr) do {} while(0)
+
+#endif
 
 #if HAVE_TYPEOF
 #define check_types_match(expr1, expr2)		\

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] make kmod compatible with GCC < 4.6
  2013-09-11  1:17 [PATCH] make kmod compatible with GCC < 4.6 John Spencer
@ 2013-09-11  1:32 ` Lucas De Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Lucas De Marchi @ 2013-09-11  1:32 UTC (permalink / raw)
  To: John Spencer; +Cc: linux-modules

Hi John,

On Tue, Sep 10, 2013 at 10:17 PM, John Spencer
<maillist-kmod@barfooze.de> wrote:
> hello list, find attached a patch that fixes compilation with
> non-bleeding-edge compilers (we use GCC 4.5.4 in production).
>
> the missing C11 feature is emulated on compilers that feature a __LINE__
> macro.

there's a patch for this applied already, restoring our previous
behavior. Doesn't it work for you? See dc8ed09 (Add configure check
for _Static_assert())



Lucas De Marchi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-11  1:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11  1:17 [PATCH] make kmod compatible with GCC < 4.6 John Spencer
2013-09-11  1:32 ` Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox