All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] ewah/bitmap: silence warning about MASK macro redefinition
Date: Tue, 02 Jun 2015 15:15:09 -0700	[thread overview]
Message-ID: <xmqqegltzriq.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1433281675-24893-1-git-send-email-sunshine@sunshineco.com> (Eric Sunshine's message of "Tue, 2 Jun 2015 17:47:55 -0400")

Eric Sunshine <sunshine@sunshineco.com> writes:

> On PowerPC Mac OS X (10.5.8 "Leopard" with Xcode 3.1), system header
> /usr/include/ppc/param.h[1] pollutes the preprocessor namespace with a
> macro generically named MASK. This conflicts with the same-named macro
> in ewah/bitmap.c.
>
> [1]: Included indirectly via:
>      git-compat-util.h ->
>      sys/sysctl.h ->
>      sys/ucred.h ->
>      sys/param.h ->
>      machine/param.h ->
>      ppc/param.h
>
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
>
> The alternative is to rename MASK in ewah/bitmap.c to something less
> generic, resulting in a slightly more noisy patch. I chose the #undef
> approach since it's a relatively common idiom to #undef a macro before
> #defining it in order to avoid exactly this sort of redefinition
> problem.

I agree that there is nothing controversial against this use of
#undef; I however wonder if we are stomping on _their_ use of MASK
and breaking whatever Mac OS X wants to express with that macro,
though (in which case, hiding collision like this may not be
sufficient and we have to live with the poor implementation choice
made by the header file and change the macro _we_ use).

Will queue.  Thanks.

>  ewah/bitmap.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/ewah/bitmap.c b/ewah/bitmap.c
> index 710e58c..b31cf75 100644
> --- a/ewah/bitmap.c
> +++ b/ewah/bitmap.c
> @@ -20,6 +20,8 @@
>  #include "git-compat-util.h"
>  #include "ewok.h"
>  
> +#undef MASK
> +#undef BLOCK
>  #define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD))
>  #define BLOCK(x) (x / BITS_IN_WORD)

  reply	other threads:[~2015-06-02 22:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 21:47 [PATCH] ewah/bitmap: silence warning about MASK macro redefinition Eric Sunshine
2015-06-02 22:15 ` Junio C Hamano [this message]
2015-06-03  4:51   ` Jeff King
2015-06-03  6:28     ` Eric Sunshine
2015-06-03  6:38       ` Jeff King
2015-06-03  6:39         ` [PATCH 1/2] " Jeff King
2015-06-03  6:46           ` Eric Sunshine
2015-06-03  6:39         ` [PATCH 2/2] ewah: use less generic macro name Jeff King
2015-06-03  6:51           ` Eric Sunshine
2015-06-03  6:50       ` [PATCH] ewah/bitmap: silence warning about MASK macro redefinition Junio C Hamano

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=xmqqegltzriq.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.