{"thread":{"id":"34444","subject":"[RFC/PATCH] Add the NO_SENTINEL build variable","startedAt":"2013-07-15T17:38:22Z","lastAt":"2013-07-20T17:51:28Z","messageCount":7,"participants":["Ramsay Jones","Jonathan Nieder","Junio C Hamano","Andreas Schwab"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"223461","messageId":"51E4338E.4090003@ramsay1.demon.co.uk","threadId":"34444","inReplyTo":null,"subject":"[RFC/PATCH] Add the NO_SENTINEL build variable","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-07-15T17:38:22Z","receivedAt":"2013-07-15T17:38:22Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nHi Jeff,\n\nOne of the three gcc compilers that I use does not understand the\nsentinel function attribute. (so, it spews 108 warning messages)\n\nIs this, or something like it, too ugly for you to squash into\nyour patch? :-D\n\nATB,\nRamsay Jones\n\n\n Makefile          | 6 ++++++\n argv-array.h      | 2 +-\n builtin/revert.c  | 4 ++--\n exec_cmd.h        | 2 +-\n git-compat-util.h | 6 ++++++\n run-command.h     | 2 +-\n 6 files changed, 17 insertions(+), 5 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 9c0da06..63b539c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -224,6 +224,9 @@ all::\n # Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,\n # as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)\n #\n+# Define NO_SENTINEL if you have a compiler which does not understand the\n+# sentinel function attribute.\n+#\n # Define USE_NSEC below if you want git to care about sub-second file mtimes\n # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and\n # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely\n@@ -1232,6 +1235,9 @@ endif\n ifdef NO_NORETURN\n \tBASIC_CFLAGS += -DNO_NORETURN\n endif\n+ifdef NO_SENTINEL\n+\tBASIC_CFLAGS += -DNO_SENTINEL\n+endif\n ifdef NO_NSEC\n \tBASIC_CFLAGS += -DNO_NSEC\n endif\ndiff --git a/argv-array.h b/argv-array.h\nindex e805748..31bc492 100644\n--- a/argv-array.h\n+++ b/argv-array.h\n@@ -15,7 +15,7 @@ void argv_array_init(struct argv_array *);\n void argv_array_push(struct argv_array *, const char *);\n __attribute__((format (printf,2,3)))\n void argv_array_pushf(struct argv_array *, const char *fmt, ...);\n-__attribute__((sentinel))\n+SENTINEL(0)\n void argv_array_pushl(struct argv_array *, ...);\n void argv_array_pop(struct argv_array *);\n void argv_array_clear(struct argv_array *);\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex b8b5174..6aedc18 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -54,7 +54,7 @@ static int option_parse_x(const struct option *opt,\n \treturn 0;\n }\n \n-__attribute__((sentinel))\n+SENTINEL(0)\n static void verify_opt_compatible(const char *me, const char *base_opt, ...)\n {\n \tconst char *this_opt;\n@@ -71,7 +71,7 @@ static void verify_opt_compatible(const char *me, const char *base_opt, ...)\n \t\tdie(_(\"%s: %s cannot be used with %s\"), me, this_opt, base_opt);\n }\n \n-__attribute__((sentinel))\n+SENTINEL(0)\n static void verify_opt_mutually_compatible(const char *me, ...)\n {\n \tconst char *opt1, *opt2 = NULL;\ndiff --git a/exec_cmd.h b/exec_cmd.h\nindex 307b55c..75c0a82 100644\n--- a/exec_cmd.h\n+++ b/exec_cmd.h\n@@ -7,7 +7,7 @@ extern const char *git_exec_path(void);\n extern void setup_path(void);\n extern const char **prepare_git_cmd(const char **argv);\n extern int execv_git_cmd(const char **argv); /* NULL terminated */\n-__attribute__((sentinel))\n+SENTINEL(0)\n extern int execl_git_cmd(const char *cmd, ...);\n extern const char *system_path(const char *path);\n \ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 9f1eaca..e846e01 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -300,6 +300,12 @@ extern char *gitbasename(char *);\n #endif\n #endif\n \n+#if defined(__GNUC__) && !defined(NO_SENTINEL)\n+#define SENTINEL(n) __attribute__((sentinel(n)))\n+#else\n+#define SENTINEL(n)\n+#endif\n+\n #include \"compat/bswap.h\"\n \n #ifdef USE_WILDMATCH\ndiff --git a/run-command.h b/run-command.h\nindex 0a47679..8e75671 100644\n--- a/run-command.h\n+++ b/run-command.h\n@@ -46,7 +46,7 @@ int finish_command(struct child_process *);\n int run_command(struct child_process *);\n \n extern char *find_hook(const char *name);\n-__attribute__((sentinel))\n+SENTINEL(0)\n extern int run_hook(const char *index_file, const char *name, ...);\n \n #define RUN_COMMAND_NO_STDIN 1\n-- \n1.8.3\n"},{"id":"223472","messageId":"20130715181357.GF14690@google.com","threadId":"34444","inReplyTo":"51E4338E.4090003@ramsay1.demon.co.uk","subject":"Re: [RFC/PATCH] Add the NO_SENTINEL build variable","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-07-15T18:13:57Z","receivedAt":"2013-07-15T18:13:57Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Ramsay Jones wrote:\n\n> One of the three gcc compilers that I use does not understand the\n> sentinel function attribute. (so, it spews 108 warning messages)\n\nDo you know what version of gcc introduced the sentinel attribute?\nWould it make sense for the ifdef in git-compat-util.h to be keyed on \n__GNUC__ and __GNUC_MINOR__ instead of a new makefile flag?\n\nThanks,\nJonathan\n"},{"id":"223587","messageId":"7v38rd8925.fsf@alter.siamese.dyndns.org","threadId":"34444","inReplyTo":"51E4338E.4090003@ramsay1.demon.co.uk","subject":"Re: [RFC/PATCH] Add the NO_SENTINEL build variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-17T16:06:58Z","receivedAt":"2013-07-17T16:06:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 9f1eaca..e846e01 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -300,6 +300,12 @@ extern char *gitbasename(char *);\n>  #endif\n>  #endif\n>  \n> +#if defined(__GNUC__) && !defined(NO_SENTINEL)\n> +#define SENTINEL(n) __attribute__((sentinel(n)))\n> +#else\n> +#define SENTINEL(n)\n> +#endif\n\nAllowing callers to use __attribute__((sentinel(1)), while it may be\na good enhancement, does not belong to \"some versions of GCC do not\nknow what to do with the sentinel attribute\".  Making this change in\na separate patch on top would be cleaner.\n\nAlso do we know what version of GCC started supporting this\nattribute?  http://gcc.gnu.org/gcc-4.0/changes.html mentions it in\n\"New Languages and Language specific improvements\" section, but the\npage also says \"The latest release in the 4.0 release series is GCC\n4.0.4\", so it is not clear if 4.0 had it, or it was added somewhere\nbetween 4.0 and 4.0.4 to me.\n"},{"id":"223592","messageId":"87sizd3z4f.fsf@igel.home","threadId":"34444","inReplyTo":"7v38rd8925.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] Add the NO_SENTINEL build variable","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2013-07-17T16:55:12Z","receivedAt":"2013-07-17T16:55:12Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Also do we know what version of GCC started supporting this\n> attribute?  http://gcc.gnu.org/gcc-4.0/changes.html mentions it in\n> \"New Languages and Language specific improvements\" section, but the\n> page also says \"The latest release in the 4.0 release series is GCC\n> 4.0.4\", so it is not clear if 4.0 had it, or it was added somewhere\n> between 4.0 and 4.0.4 to me.\n\nGenerally, gcc doesn't get new features added within the same minor\nversion, only bug fixes.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"223688","messageId":"51E82582.1030204@ramsay1.demon.co.uk","threadId":"34444","inReplyTo":"20130715181357.GF14690@google.com","subject":"Re: [RFC/PATCH] Add the NO_SENTINEL build variable","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-07-18T17:27:30Z","receivedAt":"2013-07-18T17:27:30Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Jonathan Nieder wrote:\n> Ramsay Jones wrote:\n> \n>> One of the three gcc compilers that I use does not understand the\n>> sentinel function attribute. (so, it spews 108 warning messages)\n> \n> Do you know what version of gcc introduced the sentinel attribute?\n> Would it make sense for the ifdef in git-compat-util.h to be keyed on \n> __GNUC__ and __GNUC_MINOR__ instead of a new makefile flag?\n> \n\nI have on old (v4.2.1) gcc repo on Linux and looking at\n\n    ~/gcc-4.2.1/gcc/ChangeLog-2004\n\nI can see that the sentinel attribute was added on 2004-09-04 by\nKaveh R. Ghazi.\n\nAlso, I find \"bump version string to version 4.0.0\" was on 2004-09-09\nand \"bump version string to version 3.5.0\" was on 2004-01-16.\n\nSeveral of my system header files (on Linux) imply that the\nsentinel attribute is supported by __GNUC__ >= 4. (One of them,\nansidecl.h, states that gcc 3.5 supports it but ...)\n\nATB,\nRamsay Jones\n"},{"id":"223704","messageId":"7vli531ryh.fsf@alter.siamese.dyndns.org","threadId":"34444","inReplyTo":"51E82582.1030204@ramsay1.demon.co.uk","subject":"Re: [RFC/PATCH] Add the NO_SENTINEL build variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-18T21:25:10Z","receivedAt":"2013-07-18T21:25:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n\n> Jonathan Nieder wrote:\n>> Ramsay Jones wrote:\n>> \n>>> One of the three gcc compilers that I use does not understand the\n>>> sentinel function attribute. (so, it spews 108 warning messages)\n>> \n>> Do you know what version of gcc introduced the sentinel attribute?\n>> Would it make sense for the ifdef in git-compat-util.h to be keyed on \n>> __GNUC__ and __GNUC_MINOR__ instead of a new makefile flag?\n>> \n>\n> I have on old (v4.2.1) gcc repo on Linux and looking at\n>\n>     ~/gcc-4.2.1/gcc/ChangeLog-2004\n>\n> I can see that the sentinel attribute was added on 2004-09-04 by\n> Kaveh R. Ghazi.\n>\n> Also, I find \"bump version string to version 4.0.0\" was on 2004-09-09\n> and \"bump version string to version 3.5.0\" was on 2004-01-16.\n>\n> Several of my system header files (on Linux) imply that the\n> sentinel attribute is supported by __GNUC__ >= 4. (One of them,\n> ansidecl.h, states that gcc 3.5 supports it but ...)\n\nPerhaps a message from yesterday would have helped?\n\n http://article.gmane.org/gmane.comp.version-control.git/230633\n\nseems to indicate that checking for version 4 is sufficient.\n\nAlso I asked you to split the __attribute__((sentinel(n)) support\ninto a separate patch.  We currently do not pass anything but 0\n(meaning, the sentinel is always at the end), and SENTINEL in all\ncapital is easy enough to grep for when somebody _does_ want to have\nsuch a support, so I'd prefer not to see __attribute__((sentinel(n))\nuntil it becomes necessary.\n\nThanks.\n"},{"id":"223878","messageId":"51EACE20.6030909@ramsay1.demon.co.uk","threadId":"34444","inReplyTo":"7vli531ryh.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] Add the NO_SENTINEL build variable","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-07-20T17:51:28Z","receivedAt":"2013-07-20T17:51:28Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n> \n>> Jonathan Nieder wrote:\n>>> Ramsay Jones wrote:\n>>>\n>>>> One of the three gcc compilers that I use does not understand the\n>>>> sentinel function attribute. (so, it spews 108 warning messages)\n>>>\n>>> Do you know what version of gcc introduced the sentinel attribute?\n>>> Would it make sense for the ifdef in git-compat-util.h to be keyed on \n>>> __GNUC__ and __GNUC_MINOR__ instead of a new makefile flag?\n>>>\n>>\n>> I have on old (v4.2.1) gcc repo on Linux and looking at\n>>\n>>     ~/gcc-4.2.1/gcc/ChangeLog-2004\n>>\n>> I can see that the sentinel attribute was added on 2004-09-04 by\n>> Kaveh R. Ghazi.\n>>\n>> Also, I find \"bump version string to version 4.0.0\" was on 2004-09-09\n>> and \"bump version string to version 3.5.0\" was on 2004-01-16.\n>>\n>> Several of my system header files (on Linux) imply that the\n>> sentinel attribute is supported by __GNUC__ >= 4. (One of them,\n>> ansidecl.h, states that gcc 3.5 supports it but ...)\n> \n> Perhaps a message from yesterday would have helped?\n> \n>  http://article.gmane.org/gmane.comp.version-control.git/230633\n> \n> seems to indicate that checking for version 4 is sufficient.\n> \n> Also I asked you to split the __attribute__((sentinel(n)) support\n> into a separate patch.  We currently do not pass anything but 0\n> (meaning, the sentinel is always at the end), and SENTINEL in all\n> capital is easy enough to grep for when somebody _does_ want to have\n> such a support, so I'd prefer not to see __attribute__((sentinel(n))\n> until it becomes necessary.\n\nSorry, but I didn't see any of these emails before sending this\nand the subsequent patch email. :(\n\nI can sometimes be away from email for several days at a time (and\nthen spend days trying to read the backlog - I'm on *far* too many\nmailing lists!).\n\n[The internet went black on me last night; I couldn't see anything\noutside of my ISP's servers (and not all of those). I also couldn't\nget any answer at the support phone number, so I probably wasn't the\nonly one ...]\n\nATB,\nRamsay Jones\n"}]}