[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] Use posix_madvise instead of madvise in kdelibs
From: Michael Pyne <mpyne () purinchu ! net>
Date: 2009-06-07 17:14:37
Message-ID: 200906071314.42175.mpyne () purinchu ! net
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
Hi all,
I've attached a patch to use the posix_madvise function instead of madvise in
kdelibs. There are currently two places where madvise is used, in
kdecore/sycoca/ksycoca.cpp and kdeui/util/kpixmapcache.cpp. This is related
to bug 195262 https://bugs.kde.org/show_bug.cgi?id=195262 (compilation errors
on Solaris using madvise).
The problem on Solaris is that even for recent OpenSolaris releases the
madvise function accepts a char* for the memory address instead of void*.
posix_madvise standardized it to void*, which *is* supported by Solaris. So
the net effect is to remove some conditional compilation code.
I've also had to change the ConfigureChecks.cmake file. I'm using
check_symbol_exists instead of the check_function_exists because using
posix_madvise requires including sys/mman.h.
The void* cast in ksycoca.cpp is still required due to sycoca declaring the
pointer as const void*.
Please let me know if there are any objections (especially relating to BSDs,
since I don't run those).
Regards,
- Michael Pyne
["kdelibs-use-posix_madvise.patch" (text/x-patch)]
Index: ConfigureChecks.cmake
===================================================================
--- ConfigureChecks.cmake (revision 978435)
+++ ConfigureChecks.cmake (working copy)
@@ -99,15 +99,15 @@
check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL) # kioslave
check_symbol_exists(S_ISSOCK "sys/stat.h" HAVE_S_ISSOCK) # config.h
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF) # config.h
+check_symbol_exists(posix_madvise "sys/mman.h" HAVE_MADVISE) # kdecore, kdeui
-
check_function_exists(posix_fadvise HAVE_FADVISE) # kioslave
check_function_exists(backtrace HAVE_BACKTRACE) # kdecore, kio
check_function_exists(getpagesize HAVE_GETPAGESIZE) # khtml
check_function_exists(getpeereid HAVE_GETPEEREID) # kdesu
check_function_exists(fdatasync HAVE_FDATASYNC) # kdecore
-check_function_exists(madvise HAVE_MADVISE) # kdecore
-check_function_exists(mmap HAVE_MMAP) # kdecore, khtml
+check_function_exists(mmap HAVE_MMAP) # kdecore, khtml
+
if(NOT WIN32)
# we don't have it on windows but need to export it to be backward compatible
# can be removed when 4.1 is out
Index: kdecore/sycoca/ksycoca.cpp
===================================================================
--- kdecore/sycoca/ksycoca.cpp (revision 978435)
+++ kdecore/sycoca/ksycoca.cpp (working copy)
@@ -62,14 +62,10 @@
*/
#define KSYCOCA_FILENAME "ksycoca4"
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
+#if HAVE_MADVISE
+#include <sys/mman.h> // This #include was checked when looking for posix_madvise
#endif
-#ifdef Q_OS_SOLARIS
-extern "C" int madvise(caddr_t, size_t, int);
-#endif
-
#ifndef MAP_FAILED
#define MAP_FAILED ((void *) -1)
#endif
@@ -142,7 +138,7 @@
return false;
} else {
#ifdef HAVE_MADVISE
- (void) madvise((char*)sycoca_mmap, sycoca_size, MADV_WILLNEED);
+ (void) posix_madvise((void*)sycoca_mmap, sycoca_size, MADV_WILLNEED);
#endif // HAVE_MADVISE
return true;
}
Index: kdeui/util/kpixmapcache.cpp
===================================================================
--- kdeui/util/kpixmapcache.cpp (revision 978435)
+++ kdeui/util/kpixmapcache.cpp (working copy)
@@ -50,7 +50,7 @@
#include <sys/types.h>
#include <string.h>
-#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MADVISE)
+#if defined(HAVE_MADVISE)
#include <sys/mman.h>
#endif
@@ -472,7 +472,7 @@
}
info->indexHeader = reinterpret_cast<KPixmapCacheIndexHeader *>(indexMem);
#ifdef HAVE_MADVISE
- madvise(indexMem, info->size, MADV_WILLNEED);
+ posix_madvise(indexMem, info->size, MADV_WILLNEED);
#endif
info->file->close();
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic