diff mbox

[1/2] Prevent zconf.gperf from throwing an error on OSX

Message ID CAEFQu-GPM_d5=Aa48WDFEHQrGXrOyAvu7pbZMMsnEegv8dBhWw@mail.gmail.com
State Not Applicable, archived
Headers show

Commit Message

Jason Masker Oct. 16, 2014, 4:27 p.m. UTC
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.


register unsigned int len);

--
For unsubscribe information see http://sourceware.org/lists.html#faq

Comments

Bryan Hundven Oct. 16, 2014, 4:30 p.m. UTC | #1
Jason,

On Thu, Oct 16, 2014 at 9:27 AM, Jason T. Masker <jason@masker.net> wrote:
> 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 <bryanhundven@gmail.com>

--
For unsubscribe information see http://sourceware.org/lists.html#faq
Bryan Hundven Oct. 16, 2014, 4:32 p.m. UTC | #2
Jason,

On Thu, Oct 16, 2014 at 9:27 AM, Jason T. Masker <jason@masker.net> wrote:
> 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.

>
> 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 Masker Oct. 16, 2014, 4:45 p.m. UTC | #3
Signed-off-by: Jason Masker <jason@masker.net>


On Thu, Oct 16, 2014 at 12:32 PM, Bryan Hundven <bryanhundven@gmail.com> wrote:
> Jason,
>
> On Thu, Oct 16, 2014 at 9:27 AM, Jason T. Masker <jason@masker.net> wrote:
>> 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.
>
>>
>> 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
Fernando Ortiz (e2k) Oct. 16, 2014, 8:54 p.m. UTC | #4
+1

Sent from my iPhone

> On Oct 16, 2014, at 11:30 AM, Bryan Hundven <bryanhundven@gmail.com> wrote:
> 
> Jason,
> 
>> On Thu, Oct 16, 2014 at 9:27 AM, Jason T. Masker <jason@masker.net> wrote:
>> 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 <bryanhundven@gmail.com>
> 
> --
> For unsubscribe information see http://sourceware.org/lists.html#faq
> 

--
For unsubscribe information see http://sourceware.org/lists.html#faq
diff mbox

Patch

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,