From 18a4f6be6b4cfc34de6f80c36ab3ef951a0f7164 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 12 Feb 2019 21:14:41 +0700 Subject: git-compat-util: work around fileno(fp) that is a macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- git-compat-util.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'git-compat-util.h') 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 -- cgit 1.2.3-korg