summaryrefslogtreecommitdiff
path: root/compat/fileno.c
diff options
context:
space:
mode:
authorLibravatar Duy Nguyen <pclouds@gmail.com>2019-02-12 21:14:41 +0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-02-12 10:01:59 -0800
commit18a4f6be6b4cfc34de6f80c36ab3ef951a0f7164 (patch)
tree8ba3c3bc28c1eae9f19ce47e7fca682ee0e4a895 /compat/fileno.c
parentGit 2.20.1 (diff)
downloadtgif-18a4f6be6b4cfc34de6f80c36ab3ef951a0f7164.tar.xz
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>
Diffstat (limited to 'compat/fileno.c')
-rw-r--r--compat/fileno.c7
1 files changed, 7 insertions, 0 deletions
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);
+}