Skip to content

Commit e1a95b7

Browse files
peffgitster
authored andcommitted
git-compat-util: undefine system names before redeclaring them
When we define a macro to point a system function (e.g., flockfile) to our custom wrapper, we should make sure that the system did not already define it as a macro. This is rarely a problem, but can cause compilation failures if both of these are true: - we decide to define our own wrapper even though the system provides the function; we know this happens at least with uclibc, which may declare flockfile, etc, without _POSIX_THREAD_SAFE_FUNCTIONS - the system version is declared as a macro; we know this happens at least with uclibc's version of getc_unlocked() So just handling getc_unlocked() would be sufficient to deal with the real-world case we've seen. But since it's easy to do, we may as well be defensive about the other macro wrappers added in the previous patch. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e0c08a4 commit e1a95b7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

git-compat-util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ static inline int git_setitimer(int which,
279279
struct itimerval *newvalue) {
280280
return 0; /* pretend success */
281281
}
282+
#undef setitimer
282283
#define setitimer(which,value,ovalue) git_setitimer(which,value,ovalue)
283284
#endif
284285

@@ -1323,6 +1324,9 @@ static inline void git_funlockfile(FILE *fh)
13231324
{
13241325
; /* nothing */
13251326
}
1327+
#undef flockfile
1328+
#undef funlockfile
1329+
#undef getc_unlocked
13261330
#define flockfile(fh) git_flockfile(fh)
13271331
#define funlockfile(fh) git_funlockfile(fh)
13281332
#define getc_unlocked(fh) getc(fh)

0 commit comments

Comments
 (0)