Discussion:
[PATCH 1/2] Prevent zconf.gperf from throwing an error on OSX
Jason T. Masker
2014-10-16 16:27:09 UTC
Permalink
Updated zconf.gperf patch to be conditional.

The problem is when compiling with clang/LLVM, so not necessarily
specific to OS X. Offsetof is part of C99 and defined in stddef.h, but
is builtin with gcc. This code will check for a definition and try
including stddef.h if it is not found. As a last resort, offsetof will
be defined.


diff --git a/kconfig/zconf.gperf b/kconfig/zconf.gperf
index c9e690e..d758a2a 100644
--- a/kconfig/zconf.gperf
+++ b/kconfig/zconf.gperf
@@ -7,6 +7,15 @@
%pic
%struct-type

+%{
+# ifndef offsetof
+# include <stddef.h>
+# ifndef offsetof
+# define offsetof(st, m) ((size_t)(&((st *)0)->m))
+# endif
+# endif
+%}
+
struct kconf_id;

static struct kconf_id *kconf_id_lookup(register const char *str,
register unsigned int len);

--
For unsubscribe information see http://sourceware.org/lists.html#faq
Bryan Hundven
2014-10-16 16:30:51 UTC
Permalink
Jason,
Post by Jason T. Masker
Updated zconf.gperf patch to be conditional.
The problem is when compiling with clang/LLVM, so not necessarily
specific to OS X. Offsetof is part of C99 and defined in stddef.h, but
is builtin with gcc. This code will check for a definition and try
including stddef.h if it is not found. As a last resort, offsetof will
be defined.
diff --git a/kconfig/zconf.gperf b/kconfig/zconf.gperf
index c9e690e..d758a2a 100644
--- a/kconfig/zconf.gperf
+++ b/kconfig/zconf.gperf
@@ -7,6 +7,15 @@
%pic
%struct-type
+%{
+# ifndef offsetof
+# include <stddef.h>
+# ifndef offsetof
+# define offsetof(st, m) ((size_t)(&((st *)0)->m))
+# endif
+# endif
+%}
+
struct kconf_id;
static struct kconf_id *kconf_id_lookup(register const char *str,
register unsigned int len);
--
For unsubscribe information see http://sourceware.org/lists.html#faq
I 100% agree with this patch! A newer version of gperf does make the
issue go away, it is however a good goal to not have to install
homebrew to install a newer version of gperf (I've complained about
this in the past), so...

Signed-off-by: Bryan Hundven <***@gmail.com>

--
For unsubscribe information see http://sourceware.org/lists.html#faq
Gmail
2014-10-16 20:54:07 UTC
Permalink
+1

Sent from my iPhone
Post by Bryan Hundven
Jason,
Post by Jason T. Masker
Updated zconf.gperf patch to be conditional.
The problem is when compiling with clang/LLVM, so not necessarily
specific to OS X. Offsetof is part of C99 and defined in stddef.h, but
is builtin with gcc. This code will check for a definition and try
including stddef.h if it is not found. As a last resort, offsetof will
be defined.
diff --git a/kconfig/zconf.gperf b/kconfig/zconf.gperf
index c9e690e..d758a2a 100644
--- a/kconfig/zconf.gperf
+++ b/kconfig/zconf.gperf
@@ -7,6 +7,15 @@
%pic
%struct-type
+%{
+# ifndef offsetof
+# include <stddef.h>
+# ifndef offsetof
+# define offsetof(st, m) ((size_t)(&((st *)0)->m))
+# endif
+# endif
+%}
+
struct kconf_id;
static struct kconf_id *kconf_id_lookup(register const char *str,
register unsigned int len);
--
For unsubscribe information see http://sourceware.org/lists.html#faq
I 100% agree with this patch! A newer version of gperf does make the
issue go away, it is however a good goal to not have to install
homebrew to install a newer version of gperf (I've complained about
this in the past), so...
--
For unsubscribe information see http://sourceware.org/lists.html#faq
--
For unsubscribe information see http://sourceware.org/lists.html#faq
Bryan Hundven
2014-10-16 16:32:15 UTC
Permalink
Jason,
Post by Jason T. Masker
Updated zconf.gperf patch to be conditional.
The problem is when compiling with clang/LLVM, so not necessarily
specific to OS X. Offsetof is part of C99 and defined in stddef.h, but
is builtin with gcc. This code will check for a definition and try
including stddef.h if it is not found. As a last resort, offsetof will
be defined.
You also need to put your sign-off here, for Yann to accept the patch.
Post by Jason T. Masker
diff --git a/kconfig/zconf.gperf b/kconfig/zconf.gperf
index c9e690e..d758a2a 100644
--- a/kconfig/zconf.gperf
+++ b/kconfig/zconf.gperf
@@ -7,6 +7,15 @@
%pic
%struct-type
+%{
+# ifndef offsetof
+# include <stddef.h>
+# ifndef offsetof
+# define offsetof(st, m) ((size_t)(&((st *)0)->m))
+# endif
+# endif
+%}
+
struct kconf_id;
static struct kconf_id *kconf_id_lookup(register const char *str,
register unsigned int len);
--
For unsubscribe information see http://sourceware.org/lists.html#faq
-Bryan

--
For unsubscribe information see http://sourceware.org/lists.html#faq
Jason T. Masker
2014-10-16 16:45:27 UTC
Permalink
Post by Bryan Hundven
Jason,
Post by Jason T. Masker
Updated zconf.gperf patch to be conditional.
The problem is when compiling with clang/LLVM, so not necessarily
specific to OS X. Offsetof is part of C99 and defined in stddef.h, but
is builtin with gcc. This code will check for a definition and try
including stddef.h if it is not found. As a last resort, offsetof will
be defined.
You also need to put your sign-off here, for Yann to accept the patch.
Post by Jason T. Masker
diff --git a/kconfig/zconf.gperf b/kconfig/zconf.gperf
index c9e690e..d758a2a 100644
--- a/kconfig/zconf.gperf
+++ b/kconfig/zconf.gperf
@@ -7,6 +7,15 @@
%pic
%struct-type
+%{
+# ifndef offsetof
+# include <stddef.h>
+# ifndef offsetof
+# define offsetof(st, m) ((size_t)(&((st *)0)->m))
+# endif
+# endif
+%}
+
struct kconf_id;
static struct kconf_id *kconf_id_lookup(register const char *str,
register unsigned int len);
--
For unsubscribe information see http://sourceware.org/lists.html#faq
-Bryan
--
For unsubscribe information see http://sourceware.org/lists.html#faq
Loading...