Hello,

Since commit 52b50c15fa3b319bb162f0d47fbeb6582842c020, madvise() advice
macros are no longer available on noMMU architectures. However, the
madvise() function call is still available. Therefore the following
piece of code from madplay causes a build failure:

# if defined(HAVE_MADVISE)
  madvise(fdm, length, MADV_SEQUENTIAL);
# endif

Indeed, because madvise() exists in uClibc, HAVE_MADVISE is defined.
But MADV_SEQUENTIAL is no longer defined, causing a build failure.

Shouldn't madvise() be handled like posix_madvise(), i.e made not
available on noMMU systems?

Also, I see in <sys/mman.h> that the posix_madvise() prototype is still
visible on noMMU platforms. Is still really correct?

See the two attached patches (completely untested, not even build
tested) for what I mean.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
>From 1b70bcc8f98d28eb09d793b4380ce83b44f59911 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
Date: Wed, 7 Dec 2016 23:18:49 +0100
Subject: [PATCH 1/2] libc/sysdeps/linux/common/madvise.c: disable on noMMU
 architectures

Similar to what was done in commit
9945c6d21797553e78cbef8034f6dd16b3824df5 for posix_madvise().

Signed-off-by: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
---
 libc/sysdeps/linux/common/madvise.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libc/sysdeps/linux/common/madvise.c b/libc/sysdeps/linux/common/madvise.c
index e953d7b..bb486d2 100644
--- a/libc/sysdeps/linux/common/madvise.c
+++ b/libc/sysdeps/linux/common/madvise.c
@@ -9,6 +9,8 @@
 
 #include <sys/syscall.h>
 #include <sys/mman.h>
+#ifdef __ARCH_USE_MMU__
 #if defined __NR_madvise && defined __USE_BSD
 _syscall3(int, madvise, void *, __addr, size_t, __len, int, __advice)
+#endif /* __ARCH_USE_MMU__ */
 #endif
-- 
2.7.4

>From cbd4b00001bbe31c76fd0b05aa33de7898338482 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
Date: Wed, 7 Dec 2016 23:20:18 +0100
Subject: [PATCH 2/2] include/sys/mman.h: remove madvise/posix_madvise
 prototypes on noMMU

Signed-off-by: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
---
 include/sys/mman.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/sys/mman.h b/include/sys/mman.h
index 71d553a..fc8fce5 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -99,6 +99,7 @@ static __inline__ int msync (void *__addr, size_t __len, int __flags) { return 0
 
 #endif
 
+#ifdef __ARCH_USE_MMU__
 #if defined __USE_BSD && (defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__)
 /* Advise the system about particular usage patterns the program follows
    for the region starting at ADDR and extending LEN bytes.  */
@@ -108,6 +109,8 @@ extern int madvise (void *__addr, size_t __len, int __advice) __THROW;
 /* This is the POSIX name for this function.  */
 extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW;
 #endif
+#endif /* __ARCH_USE_MMU__ */
+
 
 #if defined __UCLIBC_HAS_REALTIME__
 # ifdef __ARCH_USE_MMU__
-- 
2.7.4

_______________________________________________
devel mailing list
devel@uclibc-ng.org
http://mailman.uclibc-ng.org/cgi-bin/mailman/listinfo/devel

Reply via email to