Commit 406c98b2 by Andreas Tobler Committed by Andreas Tobler

natFileChannelPosix.cc: Implement munmap_adaptor and msync_adaptor for older POSIX_C_SOURCES specs.

2004-03-14  Andreas Tobler <a.tobler@schweiz.ch>

	* gnu/java/nio/channels/natFileChannelPosix.cc: Implement
	munmap_adaptor and msync_adaptor for older POSIX_C_SOURCES specs.
	(MappedByteBufferImpl::unmapImpl): Use munmap_adaptor.
	(MappedByteBufferImpl::forceImpl): Use msync_adptor.

From-SVN: r79462
parent 7db956db
2004-03-14 Andreas Tobler <a.tobler@schweiz.ch>
* gnu/java/nio/channels/natFileChannelPosix.cc: Implement
munmap_adaptor and msync_adaptor for older POSIX_C_SOURCES specs.
(MappedByteBufferImpl::unmapImpl): Use munmap_adaptor.
(MappedByteBufferImpl::forceImpl): Use msync_adptor.
2004-03-12 Michael Koch <konqueror@gmx.de> 2004-03-12 Michael Koch <konqueror@gmx.de>
* java/text/DateFormatSymbols.java: Fixed file name in copyright. * java/text/DateFormatSymbols.java: Fixed file name in copyright.
......
...@@ -56,6 +56,26 @@ details. */ ...@@ -56,6 +56,26 @@ details. */
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
#include <sys/mman.h> #include <sys/mman.h>
// Use overload resolution to find out the argument types.
// E.g. Solaris 2.6 uses different argument types for munmap and msync.
// This is in case _POSIX_C_SOURCES is smaller than 3.
template <typename T_implPtr, typename T_implLen>
static inline int
munmap_adaptor(int (*munmap)(T_implPtr caddr, T_implLen sizet),
void* caddr, size_t sizet)
{
return munmap ((T_implPtr) caddr, (T_implLen) sizet);
}
template <typename T_implPtr, typename T_implLen, typename T_msync>
static inline int
msync_adaptor(int (*msync)(T_implPtr caddr, T_implLen sizet, T_msync msynct),
void* caddr, size_t sizet, int msynct)
{
return msync ((T_implPtr) caddr, (T_implLen) sizet, (T_msync) msynct);
}
#endif #endif
using gnu::gcj::RawData; using gnu::gcj::RawData;
...@@ -498,7 +518,7 @@ void ...@@ -498,7 +518,7 @@ void
MappedByteBufferImpl::unmapImpl () MappedByteBufferImpl::unmapImpl ()
{ {
#if defined(HAVE_MMAP) #if defined(HAVE_MMAP)
munmap((void*) implPtr, implLen); munmap_adaptor(munmap, implPtr, implLen);
#endif #endif
} }
...@@ -517,6 +537,6 @@ void ...@@ -517,6 +537,6 @@ void
MappedByteBufferImpl::forceImpl () MappedByteBufferImpl::forceImpl ()
{ {
#if defined(HAVE_MMAP) #if defined(HAVE_MMAP)
::msync((void*) implPtr, implLen, MS_SYNC); ::msync_adaptor(msync, implPtr, implLen, MS_SYNC);
#endif #endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment