Merge into master from pull request #29:
portability improvements, tabs replaced with spaces (https://github.com/floodlight/loxigen/pull/29)
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index b9a5560..6395022 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -757,7 +757,21 @@
  ****************************************************************/
 
 #ifdef __GNUC__
+#ifdef __linux__
+/* glibc */
 #include <features.h>
+#else
+/* NetBSD etc */
+#include <sys/cdefs.h>
+#ifdef __GNUC_PREREQ__
+#define __GNUC_PREREQ __GNUC_PREREQ__
+#endif
+#endif
+
+#ifndef __GNUC_PREREQ
+/* fallback */
+#define __GNUC_PREREQ(maj, min) 0
+#endif
 
 #if __GNUC_PREREQ(4,4)
 #pragma GCC optimize ("s")
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index fe7a41d..74aef8a 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -54,7 +54,7 @@
 Verify that the members all have the appropriate value
 
 Through out, checking the consistency of memory and memory operations
-is done with mcheck (not supported on Mac OS X).
+is done with mcheck (if available).
 
 """
 
@@ -401,10 +401,11 @@
 #include <locitest/unittest.h>
 #include <locitest/test_common.h>
 
-#if !defined(__APPLE__)
+/* mcheck is a glibc extension */
+#if defined(__linux__)
 #include <mcheck.h>
 #define MCHECK_INIT mcheck(NULL)
-#else /* mcheck not available under OS X */
+#else
 #define MCHECK_INIT do { } while (0)
 #endif
 
diff --git a/c_gen/templates/locitest/main.c b/c_gen/templates/locitest/main.c
index df80f9f..3b24035 100644
--- a/c_gen/templates/locitest/main.c
+++ b/c_gen/templates/locitest/main.c
@@ -9,10 +9,11 @@
 #include <locitest/unittest.h>
 #include <locitest/test_common.h>
 
-#if !defined(__APPLE__)
+/* mcheck is a glibc extension */
+#if defined(__linux__)
 #include <mcheck.h>
 #define MCHECK_INIT mcheck(NULL)
-#else /* mcheck not available under OS X */
+#else
 #define MCHECK_INIT do { } while (0)
 #endif
 
diff --git a/c_gen/templates/locitest/test_setup_from_add.c b/c_gen/templates/locitest/test_setup_from_add.c
index d8911f3..0b07076 100644
--- a/c_gen/templates/locitest/test_setup_from_add.c
+++ b/c_gen/templates/locitest/test_setup_from_add.c
@@ -33,10 +33,11 @@
 
 #include <locitest/test_common.h>
 
-#if !defined(__APPLE__)
+/* mcheck is a glibc extension */
+#if defined(__linux__)
 #include <mcheck.h>
 #define MCHECK_INIT mcheck(NULL)
-#else /* mcheck not available under OS X */
+#else
 #define MCHECK_INIT do { } while (0)
 #endif