From: Junio C Hamano <gitster@pobox.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
git@vger.kernel.org, git-packagers@googlegroups.com,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: Re: Git v2.21.0-rc0 broken on *BSD, maybe others
Date: Tue, 12 Feb 2019 10:42:10 -0800 [thread overview]
Message-ID: <xmqqr2ccdf25.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <xmqqlg2ldjg4.fsf@gitster-ct.c.googlers.com> (Junio C. Hamano's message of "Tue, 12 Feb 2019 09:07:23 -0800")
Junio C Hamano <gitster@pobox.com> writes:
> If I find time later in the day, I may forge your sign-off and
> fabricate log messages for both patches, but unfortunately I need to
> run a long errand today during the day, so it may not happen.
And here is the other one. I have the s/is/if/ typofix already in there.
-- >8 --
From: Duy Nguyen <pclouds@gmail.com>
Date: Tue, 12 Feb 2019 21:14:41 +0700
Subject: [PATCH] git-compat-util: work around fileno(fp) that is a macro
On various BSD's, fileno(fp) is implemented as a macro that directly
accesses the fields in the FILE * object, which breaks a function that
accepts a "void *fp" parameter and calls fileno(fp) and expect it to
work.
Work it around by adding a compile-time knob FILENO_IS_A_MACRO that
inserts a real helper function in the middle of the callchain.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Makefile | 7 +++++++
compat/fileno.c | 7 +++++++
config.mak.uname | 2 ++
git-compat-util.h | 8 ++++++++
4 files changed, 24 insertions(+)
create mode 100644 compat/fileno.c
diff --git a/Makefile b/Makefile
index 1a44c811aa..08d9961425 100644
--- a/Makefile
+++ b/Makefile
@@ -427,6 +427,8 @@ all::
#
# Define HAVE_GETDELIM if your system has the getdelim() function.
#
+# Define FILENO_IS_A_MACRO if fileno() is a macro, not a real function.
+#
# Define PAGER_ENV to a SP separated VAR=VAL pairs to define
# default environment variables to be passed when a pager is spawned, e.g.
#
@@ -1773,6 +1775,11 @@ ifdef HAVE_WPGMPTR
BASIC_CFLAGS += -DHAVE_WPGMPTR
endif
+ifdef FILENO_IS_A_MACRO
+ COMPAT_CFLAGS += -DFILENO_IS_A_MACRO
+ COMPAT_OBJS += compat/fileno.o
+endif
+
ifeq ($(TCLTK_PATH),)
NO_TCLTK = NoThanks
endif
diff --git a/compat/fileno.c b/compat/fileno.c
new file mode 100644
index 0000000000..7b105f4cd7
--- /dev/null
+++ b/compat/fileno.c
@@ -0,0 +1,7 @@
+#define COMPAT_CODE
+#include "../git-compat-util.h"
+
+int git_fileno(FILE *stream)
+{
+ return fileno(stream);
+}
diff --git a/config.mak.uname b/config.mak.uname
index 3ee7da0e23..23eac5ac9d 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -221,6 +221,7 @@ ifeq ($(uname_S),FreeBSD)
HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
PAGER_ENV = LESS=FRX LV=-c MORE=FRX
FREAD_READS_DIRECTORIES = UnfortunatelyYes
+ FILENO_IS_A_MACRO = UnfortunatelyYes
endif
ifeq ($(uname_S),OpenBSD)
NO_STRCASESTR = YesPlease
@@ -233,6 +234,7 @@ ifeq ($(uname_S),OpenBSD)
HAVE_BSD_SYSCTL = YesPlease
HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
PROCFS_EXECUTABLE_PATH = /proc/curproc/file
+ FILENO_IS_A_MACRO = UnfortunatelyYes
endif
ifeq ($(uname_S),MirBSD)
NO_STRCASESTR = YesPlease
diff --git a/git-compat-util.h b/git-compat-util.h
index 09b0102cae..7899f42f5e 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1220,6 +1220,14 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
#define getc_unlocked(fh) getc(fh)
#endif
+#ifdef FILENO_IS_A_MACRO
+int git_fileno(FILE *stream);
+# ifndef COMPAT_CODE
+# undef fileno
+# define fileno(p) git_fileno(p)
+# endif
+#endif
+
/*
* Our code often opens a path to an optional file, to work on its
* contents when we can successfully open it. We can ignore a failure
--
2.21.0-rc0-36-ge9bd4aa026
next prev parent reply other threads:[~2019-02-12 18:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 7:28 [ANNOUNCE] Git v2.21.0-rc0 Junio C Hamano
2019-02-07 12:39 ` Christian Couder
2019-02-07 19:47 ` Johannes Schindelin
2019-02-07 19:50 ` Johannes Schindelin
2019-02-07 20:34 ` Junio C Hamano
2019-02-07 20:56 ` Junio C Hamano
2019-02-12 12:13 ` Git v2.21.0-rc0 broken on *BSD, maybe others Ævar Arnfjörð Bjarmason
2019-02-12 12:43 ` Duy Nguyen
2019-02-12 12:45 ` Duy Nguyen
2019-02-12 13:14 ` Ævar Arnfjörð Bjarmason
2019-02-12 13:16 ` Ævar Arnfjörð Bjarmason
2019-02-12 13:30 ` SZEDER Gábor
2019-02-13 14:56 ` Johannes Schindelin
2019-02-12 17:07 ` Junio C Hamano
2019-02-12 18:41 ` Junio C Hamano
2019-02-12 18:42 ` Junio C Hamano [this message]
2019-02-12 17:52 ` Junio C Hamano
2019-02-12 17:56 ` Junio C Hamano
2019-02-12 12:44 ` SZEDER Gábor
2019-02-12 13:07 ` Ævar Arnfjörð Bjarmason
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr2ccdf25.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=git-packagers@googlegroups.com \
--cc=git@vger.kernel.org \
--cc=pclouds@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).