Skip to content

Commit 1db999c

Browse files
committed
Merge branch 'nd/fileno-may-be-macro'
* nd/fileno-may-be-macro: git-compat-util: work around fileno(fp) that is a macro
2 parents c73472a + 18a4f6b commit 1db999c

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ all::
433433
#
434434
# Define HAVE_GETDELIM if your system has the getdelim() function.
435435
#
436+
# Define FILENO_IS_A_MACRO if fileno() is a macro, not a real function.
437+
#
436438
# Define PAGER_ENV to a SP separated VAR=VAL pairs to define
437439
# default environment variables to be passed when a pager is spawned, e.g.
438440
#
@@ -1800,6 +1802,11 @@ ifdef HAVE_WPGMPTR
18001802
BASIC_CFLAGS += -DHAVE_WPGMPTR
18011803
endif
18021804

1805+
ifdef FILENO_IS_A_MACRO
1806+
COMPAT_CFLAGS += -DFILENO_IS_A_MACRO
1807+
COMPAT_OBJS += compat/fileno.o
1808+
endif
1809+
18031810
ifeq ($(TCLTK_PATH),)
18041811
NO_TCLTK = NoThanks
18051812
endif

compat/fileno.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#define COMPAT_CODE
2+
#include "../git-compat-util.h"
3+
4+
int git_fileno(FILE *stream)
5+
{
6+
return fileno(stream);
7+
}

config.mak.uname

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ ifeq ($(uname_S),FreeBSD)
221221
HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
222222
PAGER_ENV = LESS=FRX LV=-c MORE=FRX
223223
FREAD_READS_DIRECTORIES = UnfortunatelyYes
224+
FILENO_IS_A_MACRO = UnfortunatelyYes
224225
endif
225226
ifeq ($(uname_S),OpenBSD)
226227
NO_STRCASESTR = YesPlease
@@ -234,6 +235,7 @@ ifeq ($(uname_S),OpenBSD)
234235
HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
235236
PROCFS_EXECUTABLE_PATH = /proc/curproc/file
236237
FREAD_READS_DIRECTORIES = UnfortunatelyYes
238+
FILENO_IS_A_MACRO = UnfortunatelyYes
237239
endif
238240
ifeq ($(uname_S),MirBSD)
239241
NO_STRCASESTR = YesPlease

git-compat-util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,14 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
12341234
#define getc_unlocked(fh) getc(fh)
12351235
#endif
12361236

1237+
#ifdef FILENO_IS_A_MACRO
1238+
int git_fileno(FILE *stream);
1239+
# ifndef COMPAT_CODE
1240+
# undef fileno
1241+
# define fileno(p) git_fileno(p)
1242+
# endif
1243+
#endif
1244+
12371245
/*
12381246
* Our code often opens a path to an optional file, to work on its
12391247
* contents when we can successfully open it. We can ignore a failure

0 commit comments

Comments
 (0)