Linux Modules
 help / color / mirror / Atom feed
From: John Spencer <maillist-kmod@barfooze.de>
To: linux-modules <linux-modules@vger.kernel.org>
Cc: John Spencer <maillist-kmod@barfooze.de>
Subject: [PATCH] make kmod compatible with GCC < 4.6
Date: Wed, 11 Sep 2013 03:17:36 +0200	[thread overview]
Message-ID: <522FC4B0.8090704@barfooze.de> (raw)

[-- 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)		\

             reply	other threads:[~2013-09-11  1:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11  1:17 John Spencer [this message]
2013-09-11  1:32 ` [PATCH] make kmod compatible with GCC < 4.6 Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=522FC4B0.8090704@barfooze.de \
    --to=maillist-kmod@barfooze.de \
    --cc=linux-modules@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox