git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Lars Schneider <larsxschneider@gmail.com>, git@vger.kernel.org
Subject: [PATCH] list: avoid incompatibility with *BSD sys/queue.h
Date: Sun, 17 Jul 2016 00:25:34 +0000	[thread overview]
Message-ID: <20160717002533.GA14200@whir> (raw)
In-Reply-To: <20160716210454.GA7849@starla>

Eric Wong <e@80x24.org> wrote:
> Lars Schneider <larsxschneider@gmail.com> wrote:
> > It looks like as if this topic breaks the OS X build because 
> > it defines LIST_HEAD. LIST_HEAD is already defined in 
> > /usr/include/sys/queue.h. 
> 
> Oops, I suppose GIT_LIST_HEAD is an acceptable name?
> (looks a bit like a refname, though...).
> 
> Or maybe CDS_LIST_HEAD (since I originally took it from the cds
> namespace under urcu)

Naming things is hard; I think it's better to just undef an
existing LIST_HEAD, instead, since it's unlikely we'd ever use
sys/queue.h from *BSD.  (sys/queue.h is branchier, and IMHO
sys/queue.h macros are uglier than list_entry (container_of))

> I also wonder where we use sys/queue.h, since I use
> LIST_HEAD from ccan/list/list.h in a different project
> without conflicts...

Still wondering... Checking sys/mman.h in an old FreeBSD source
tree I had lying around reveals "#include <sys/queue.h>" is
guarded by "#if defined(_KERNEL)", so it mman.h wouldn't pull
it in for userspace builds...

-----8<------
Subject: [PATCH] list: avoid incompatibility with *BSD sys/queue.h

Somehow, the OS X build pulls in sys/queue.h and causes
conflicts with the LIST_HEAD macro, here.

ref: http://mid.gmane.org/FB76544F-16F7-45CA-9649-FD62EE44B0DE@gmail.com

Reported-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Eric Wong <e@80x24.org>
---
 list.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/list.h b/list.h
index f65edce..a226a87 100644
--- a/list.h
+++ b/list.h
@@ -36,6 +36,8 @@ struct list_head {
 	struct list_head *next, *prev;
 };
 
+/* avoid conflicts with BSD-only sys/queue.h */
+#undef LIST_HEAD
 /* Define a variable with the head and tail of the list. */
 #define LIST_HEAD(name) \
 	struct list_head name = { &(name), &(name) }
-- 
EW

  parent reply	other threads:[~2016-07-17  0:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13 16:56 What's cooking in git.git (Jul 2016, #05; Wed, 13) Junio C Hamano
2016-07-13 17:27 ` Stefan Beller
2016-07-13 17:32   ` Junio C Hamano
2016-07-13 17:52     ` Stefan Beller
2016-07-13 17:55       ` Junio C Hamano
2016-07-13 22:41       ` Junio C Hamano
2016-07-13 22:42         ` Jeff King
2016-07-13 17:40 ` Duy Nguyen
2016-07-13 17:46   ` Junio C Hamano
2016-07-14 12:59 ` Johannes Schindelin
2016-07-14 13:15 ` Johannes Schindelin
2016-07-14 15:45   ` Junio C Hamano
2016-07-14 13:46 ` Johannes Schindelin
2016-07-14 15:48   ` Junio C Hamano
2016-07-16 20:54 ` Lars Schneider
2016-07-16 21:04   ` Eric Wong
2016-07-16 22:04     ` Lars Schneider
2016-07-17  0:25     ` Eric Wong [this message]
2016-07-17  5:58       ` [PATCH] list: avoid incompatibility with *BSD sys/queue.h Eric Sunshine
2016-07-17 23:07         ` Eric Wong
2016-07-18 16:08       ` Lars Schneider

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=20160717002533.GA14200@whir \
    --to=e@80x24.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=larsxschneider@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).