Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/java/io/io_util_md.h
32287 views
/*1* Copyright (c) 2003, 2013, 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);4142FD handleOpen(const char *path, int oflag, int mode);4344/*45* Macros to set/get fd from the java.io.FileDescriptor. These46* macros rely on having an appropriately defined 'this' object47* within the scope in which they're used.48* If GetObjectField returns null, SET_FD will stop and GET_FD49* will simply return -1 to avoid crashing VM.50*/5152#define SET_FD(this, fd, fid) \53if ((*env)->GetObjectField(env, (this), (fid)) != NULL) \54(*env)->SetIntField(env, (*env)->GetObjectField(env, (this), (fid)),IO_fd_fdID, (fd))5556#define GET_FD(this, fid) \57(*env)->GetObjectField(env, (this), (fid)) == NULL ? \58-1 : (*env)->GetIntField(env, (*env)->GetObjectField(env, (this), (fid)), IO_fd_fdID)5960/*61* Macros to set/get fd when inside java.io.FileDescriptor62*/63#define THIS_FD(obj) (*env)->GetIntField(env, obj, IO_fd_fdID)6465/*66* Route the routines67*/68#define IO_Sync fsync69#define IO_Read handleRead70#define IO_Write handleWrite71#define IO_Append handleWrite72#define IO_Available handleAvailable73#define IO_SetLength handleSetLength7475#ifdef _ALLBSD_SOURCE76#define open64 open77#define fstat64 fstat78#define stat64 stat79#define lseek64 lseek80#define ftruncate64 ftruncate81#define IO_Lseek lseek82#else83#define IO_Lseek lseek6484#endif8586/*87* On Solaris, the handle field is unused88*/89#define SET_HANDLE(fd) return (jlong)-19091/*92* Retry the operation if it is interrupted93*/94#define RESTARTABLE(_cmd, _result) do { \95do { \96_result = _cmd; \97} while((_result == -1) && (errno == EINTR)); \98} while(0)99100/*101* IO helper function(s)102*/103void fileClose(JNIEnv *env, jobject this, jfieldID fid);104105#ifdef MACOSX106jstring newStringPlatform(JNIEnv *env, const char* str);107#endif108109110