Skip to content

Commit eec7fd8

Browse files
Ramsay Jonesgitster
authored andcommitted
compat/nedmalloc: Fix compiler warnings on linux
On linux, when the build variable USE_NED_ALLOCATOR is set, gcc issues the following warnings: In file included from compat/nedmalloc/nedmalloc.c:63: .../malloc.c.h: In function 'mmap_resize': .../malloc.c.h:3762: warning: implicit declaration of function 'mremap' .../malloc.c.h: In function 'sys_trim': .../malloc.c.h:4195: warning: comparison between pointer and integer The warnings are caused by the <sys/mman.h> header not enabling the (conditional) declaration of the mremap() function. The declaration can be enabled by defining the _GNU_SOURCE symbol prior to including certain system header files. In particular, it may not be sufficient to simply define _GNU_SOURCE just prior to including the <sys/mman.h> header. (e.g. defining the symbol after including <sys/types.h> will be completely ineffective.) In order to suppress the warnings, we define the _GNU_SOURCE symbol at the start of the malloc.c.h header file. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 241c957 commit eec7fd8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compat/nedmalloc/malloc.c.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
484484
#define DLMALLOC_VERSION 20804
485485
#endif /* DLMALLOC_VERSION */
486486

487+
#if defined(linux)
488+
#define _GNU_SOURCE 1
489+
#endif
490+
487491
#ifndef WIN32
488492
#ifdef _WIN32
489493
#define WIN32 1

0 commit comments

Comments
 (0)