git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Junio C Hamano <gitster@pobox.com>,
	GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH] alloc.c: remove alloc_raw_commit_node() function
Date: Thu, 19 Jun 2014 05:19:24 -0400	[thread overview]
Message-ID: <20140619091924.GA29478@sigill.intra.peff.net> (raw)
In-Reply-To: <53A2131A.30900@ramsay1.demon.co.uk>

On Wed, Jun 18, 2014 at 11:30:50PM +0100, Ramsay Jones wrote:

> So, the patch below is a slight variation on the original patch.
> I'm still slightly concerned about portability, but given that it
> has been at least a decade since I last used a (pre-ANSI) compiler
> which had a problem with this ...

For a while some people were compiling git with pretty antique
compilers, but I do not know if that is the case any more (Junio noted
recently that we have had trailing commas on arrays and enums in
builtin/clean.c for the past year, and nobody has complained).

Maybe those systems have all died off, or maybe those people only
upgrade every few years, and we are due for an onslaught of portability
fixes soon. :)

> [I have several versions of the C standard that I can use to check
> up on the legalise, but I'm not sure I can be bothered! ;-) ]

It was actually pretty easy to find. I only have C99, but "empty macro
arguments" are listed as one of the changes since C89 in the foreward.

> diff --git a/alloc.c b/alloc.c
> index eb22a45..5392d13 100644
> --- a/alloc.c
> +++ b/alloc.c
> @@ -18,9 +18,12 @@
>  
>  #define BLOCKING 1024
>  
> -#define DEFINE_ALLOCATOR(name, type)				\
> +#define PUBLIC
> +#define PRIVATE static
> +
> +#define DEFINE_ALLOCATOR(scope, name, type)			\

I am not sure offhand whether this is more portable or not (it would
depend on order of macro expansion, and I am not brave enough to read
through the preprocessor section of the standard carefully). Quick
reading online suggests that it's OK, but that an extra level of macro
expansion would not be. And of course the Internet is never wrong. :)

I'm inclined to go with it, and deal with it later if we get a
portability complaint (at which point we are no worse off than we are
right now).

-Peff

  reply	other threads:[~2014-06-19  9:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 19:52 [PATCH] alloc.c: remove alloc_raw_commit_node() function Ramsay Jones
2014-06-18 20:08 ` Jeff King
2014-06-18 22:30   ` Ramsay Jones
2014-06-19  9:19     ` Jeff King [this message]
2014-06-19  9:55       ` Ramsay Jones
2014-06-19 20:32       ` 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=20140619091924.GA29478@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ramsay@ramsay1.demon.co.uk \
    /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).