Path: blob/master/src/java.base/unix/native/libjava/io_util_md.h
41119 views
/*1* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include "jni_util.h"2627/*28* Macros to use the right data type for file descriptors29*/30#define FD jint3132/*33* Prototypes for functions in io_util_md.c called from io_util.c,34* FileDescriptor.c, FileInputStream.c, FileOutputStream.c,35* UnixFileSystem_md.c36*/37ssize_t handleWrite(FD fd, const void *buf, jint len);38ssize_t handleRead(FD fd, void *buf, jint len);39jint handleAvailable(FD fd, jlong *pbytes);40jint handleSetLength(FD fd, jlong length);41jlong handleGetLength(FD fd);42FD handleOpen(const char *path, int oflag, int mode);4344/*45* Functions to get fd from the java.io.FileDescriptor field46* of an object. These functions rely on having an appropriately47* defined object with a FileDescriptor object at the fid offset.48* If the FD object is null, return -1 to avoid crashing VM.49*/50FD getFD(JNIEnv *env, jobject cur, jfieldID fid);5152/*53* Macros to set/get fd when inside java.io.FileDescriptor54*/55#define THIS_FD(obj) (*env)->GetIntField(env, obj, IO_fd_fdID)5657/*58* Route the routines59*/60#define IO_Sync fsync61#define IO_Read handleRead62#define IO_Write handleWrite63#define IO_Append handleWrite64#define IO_Available handleAvailable65#define IO_SetLength handleSetLength66#define IO_GetLength handleGetLength6768#ifdef _ALLBSD_SOURCE69#define open64 open70#define fstat64 fstat71#define stat64 stat72#define lseek64 lseek73#define ftruncate64 ftruncate74#define IO_Lseek lseek75#else76#define IO_Lseek lseek6477#endif7879/*80* On Solaris, the handle field is unused81*/82#define SET_HANDLE(fd) return (jlong)-18384/*85* Retry the operation if it is interrupted86*/87#define RESTARTABLE(_cmd, _result) \88do { \89_result = _cmd; \90} while ((_result == -1) && (errno == EINTR))9192void fileDescriptorClose(JNIEnv *env, jobject this);9394#ifdef MACOSX95jstring newStringPlatform(JNIEnv *env, const char* str);96#endif979899