Merge branch 'nd/fileno-may-be-macro'
authorJunio C Hamano <gitster@pobox.com>
Thu, 14 Feb 2019 02:18:41 +0000 (18:18 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Feb 2019 02:18:41 +0000 (18:18 -0800)
* nd/fileno-may-be-macro:
git-compat-util: work around fileno(fp) that is a macro

Makefile
compat/fileno.c [new file with mode: 0644]
config.mak.uname
git-compat-util.h
index 0e13a5b4698a02e93c9f2c95e06b4193fe229567..af7e809ced694635d1281dbcf3f0ab234ce3c137 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -433,6 +433,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.
 #
@@ -1800,6 +1802,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 (file)
index 0000000..7b105f4
--- /dev/null
@@ -0,0 +1,7 @@
+#define COMPAT_CODE
+#include "../git-compat-util.h"
+
+int git_fileno(FILE *stream)
+{
+       return fileno(stream);
+}
index 281c547e2f6ef617029821a617d518ea5e133915..bd55e828cabd2a4b17ebf8a8735027c5c8d950f7 100644 (file)
@@ -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
@@ -234,6 +235,7 @@ ifeq ($(uname_S),OpenBSD)
        HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
        PROCFS_EXECUTABLE_PATH = /proc/curproc/file
        FREAD_READS_DIRECTORIES = UnfortunatelyYes
+       FILENO_IS_A_MACRO = UnfortunatelyYes
 endif
 ifeq ($(uname_S),MirBSD)
        NO_STRCASESTR = YesPlease
index 29a19902aaa00b90176e253c90c2384fca65857c..6573808ebd991b52eca7cc644af4c9611b9c3747 100644 (file)
@@ -1234,6 +1234,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