/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "jni.h"
#include "jni_util.h"
#include "jvm.h"
#include "jvm_md.h"
#include "jlong.h"
#include <fcntl.h>
#include "sun_nio_ch_FileChannelImpl.h"
#include "java_lang_Integer.h"
#include "nio.h"
#include "nio_util.h"
#include <dlfcn.h>
#if defined(__linux__) || defined(__solaris__)
#include <sys/sendfile.h>
#elif defined(_ALLBSD_SOURCE)
#endif
{
return pageSize;
}
static jlong
{
if (rv >= 0)
return rv;
return IOS_INTERRUPTED;
return IOS_THROWN;
}
{
void *mapAddress = 0;
int protections = 0;
int flags = 0;
if (prot == sun_nio_ch_FileChannelImpl_MAP_RO) {
flags = MAP_SHARED;
} else if (prot == sun_nio_ch_FileChannelImpl_MAP_RW) {
flags = MAP_SHARED;
} else if (prot == sun_nio_ch_FileChannelImpl_MAP_PV) {
flags = MAP_PRIVATE;
}
mapAddress = mmap64(
0, /* Let OS decide location */
len, /* Number of bytes to map */
protections, /* File permissions */
flags, /* Changes are shared */
fd, /* File descriptor of mapped file */
off); /* Offset into file */
if (mapAddress == MAP_FAILED) {
return IOS_THROWN;
}
}
return ((jlong) (unsigned long) mapAddress);
}
{
void *a = (void *)jlong_to_ptr(address);
"Unmap failed");
}
{
if (offset < 0) {
} else {
}
}
{
if (fd != -1) {
if (result < 0) {
}
}
}
{
#if defined(__linux__)
if (n < 0) {
return IOS_UNAVAILABLE;
return IOS_UNSUPPORTED_CASE;
return IOS_INTERRUPTED;
}
return IOS_THROWN;
}
return n;
#elif defined (__solaris__)
/* Solaris sendfilev() will return -1 even if some bytes have been
* transferred, so we check numBytes first.
*/
if (numBytes > 0)
return numBytes;
if (result < 0) {
return IOS_UNAVAILABLE;
if (errno == EOPNOTSUPP)
return IOS_UNSUPPORTED_CASE;
return IOS_UNSUPPORTED_CASE;
return IOS_INTERRUPTED;
return IOS_THROWN;
}
return result;
int result;
#ifdef __APPLE__
#endif
if (numBytes > 0)
return numBytes;
if (result == -1) {
return IOS_UNAVAILABLE;
return IOS_UNSUPPORTED_CASE;
return IOS_UNSUPPORTED_CASE;
return IOS_INTERRUPTED;
return IOS_THROWN;
}
return result;
#else
return IOS_UNSUPPORTED_CASE;
#endif
}