io/mmap.c: fix musl build on mips64
PATCH v2 1/1 io/mmap.c: fix musl build on mips64
musl undefines MAP_SYNC on some architectures such as mips64 since version 1.1.20 and
https://github.com/ifduyue/musl/commit/9b57db3f958d9adc3b1c7371b5c6723aaee448b7
resulting in the following build failure:
mmap.c: In function 'mmap_f':
mmap.c:196:33: error: 'MAP_SYNC' undeclared (first use in this function); did you mean 'MS_SYNC'?
196 | flags = MAP_SYNC | MAP_SHARED_VALIDATE;
| ^~~~~~~~
| MS_SYNCThis build failure is raised because header includes have been tangled up:
input.h -> libfrog/projects.h -> xfs.h -> linux.h.
As a result, linux.h will be included before sys/mman.h and the following piece of code from linux.h will be "overriden" on platforms without MAP_SYNC:
#ifndef HAVE_MAP_SYNC
#define MAP_SYNC 0
#define MAP_SHARED_VALIDATE 0
#else
#include <asm-generic/mman.h>
#include <asm-generic/mman-common.h>
#endif /* HAVE_MAP_SYNC */
To fix this build failure, include <sys/mman.h> before the other includes.
A more long-term solution would be to untangle the headers.
Fixes:
- http://autobuild.buildroot.org/results/3296194907baf7d3fe039f59bcbf595aa8107a28
---
Changes v1 -> v2 (after review of Dave Chinner):
- Update commit message
io/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io/mmap.c +1 -1
@@ -4,9 +4,9 @@* All Rights Reserved. */ +#include <sys/mman.h> #include "command.h" #include "input.h" -#include <sys/mman.h> #include <signal.h> #include "init.h" #include "io.h"
Signature · 1 line
2.35.1
Looks good:
(and another example of why the old rule of thumb to always include system headers before local ones is a good idea)
Quoted 31 lines · Fabrice Fontaine
musl undefines
MAP_SYNCon some architectures such as mips64 since version 1.1.20 and
https://github.com/ifduyue/musl/commit/9b57db3f958d9adc3b1c7371b5c6723aaee448b7
resulting in the following build failure:
mmap.c: In function 'mmap_f':
mmap.c:196:33: error: 'MAP_SYNC' undeclared (first use in this function); did you mean 'MS_SYNC'?196 | flags = MAP_SYNC | MAP_SHARED_VALIDATE; | ^~~~~~~~ | MS_SYNCThis build failure is raised because header includes have been tangled up:
input.h->libfrog/projects.h->xfs.h->linux.h.As a result,
linux.hwill be included beforesys/mman.hand the following piece of code fromlinux.hwill be "overriden" on platforms withoutMAP_SYNC:#ifndef
HAVE_MAP_SYNC
#defineMAP_SYNC0
#defineMAP_SHARED_VALIDATE0
#else
#include <asm-generic/mman.h>
#include <asm-generic/mman-common.h>
#endif /*HAVE_MAP_SYNC*/To fix this build failure, include <
sys/mman.h> before the other includes.
Quoted 6 lines
A more long-term solution would be to untangle the headers.
Fixes:
- http://autobuild.buildroot.org/results/3296194907baf7d3fe039f59bcbf595aa8107a28Signed-off-by Fabrice Fontaine <[email protected]>
LGTM,
--D
Quoted 25 lines
---
Changes v1 -> v2 (after review of Dave Chinner):
- Update commit messageio/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)io/mmap.c +1
-1@@ -4,9 +4,9 @@* All Rights Reserved. */ +#include <sys/mman.h> #include "command.h" #include "input.h" -#include <sys/mman.h> #include <signal.h> #include "init.h" #include "io.h" Signature · 1 line
2.35.1