buildrootschalter/package/uclibc/0.9.33.2/uclibc-0015-add-posix_madvise.c.patch
Peter Korsgaard 055f1c02d3 uclibc: add upstream 0.9.33 fixes
Upstream has a large number of patches lined up for the next 0.9.33.x bugfix
release;

http://git.uclibc.org/uClibc/log/?h=0.9.33

Add them here, as atleast some of them are quite critical (E.G. the eventfd
issue gets triggered by recent glib versions).

I've skipped the microblaze and xtensa fixes as we don't currently support
those with 0.9.33.2.

Drop uclibc-0002-Add-definition-of-MSG_WAITFORONE-and-MSG_CMSG_CMSG_CLOEXE.patch
as that is a subset of uclibc-0035-socket.h-pull-socket_type.h-from-eglibc.patch

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2013-09-06 15:28:51 +02:00

62 lines
3.5 KiB
Diff

From 93b8ce8886e30986be31c1403b606b6367dc258a Mon Sep 17 00:00:00 2001
From: "Peter S. Mazinger" <ps.m@gmx.net>
Date: Tue, 26 Apr 2011 23:03:44 +0200
Subject: [PATCH] add posix_madvise.c
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
libc/sysdeps/linux/common/Makefile.in | 2 +-
libc/sysdeps/linux/common/posix_madvise.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 libc/sysdeps/linux/common/posix_madvise.c
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index 3b5763c..b39082b 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -81,7 +81,7 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_getres.c clock_gettime.c clock_settime.c \
sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \
sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c
# clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
-CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c
+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c
CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
diff --git a/libc/sysdeps/linux/common/posix_madvise.c b/libc/sysdeps/linux/common/posix_madvise.c
new file mode 100644
index 0000000..2f95bcb
--- /dev/null
+++ b/libc/sysdeps/linux/common/posix_madvise.c
@@ -0,0 +1,25 @@
+/* vi: set sw=4 ts=4: */
+/* Licensed under the LGPL v2.1, see the file LICENSE in this tarball. */
+
+#include <sys/mman.h>
+#include <sys/syscall.h>
+
+#if defined __NR_madvise && defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
+int posix_madvise(void *addr, size_t len, int advice)
+{
+ int result;
+ /* We have one problem: the kernel's MADV_DONTNEED does not
+ * correspond to POSIX's POSIX_MADV_DONTNEED. The former simply
+ * discards changes made to the memory without writing it back to
+ * disk, if this would be necessary. The POSIX behaviour does not
+ * allow this. There is no functionality mapping for the POSIX
+ * behaviour so far so we ignore that advice for now. */
+ if (advice == POSIX_MADV_DONTNEED)
+ return 0;
+
+ /* this part might use madvise function */
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (madvise, err, 3, addr, len, advice);
+ return INTERNAL_SYSCALL_ERRNO (result, err);
+}
+#endif
--
1.7.10.4