jdk/src/solaris/native/sun/nio/ch/IOUtil.c
changeset 12872 16fa902b1469
parent 7668 d4a77089c587
child 13024 ada1a7c54e84
equal deleted inserted replaced
12871:b583b4c82a82 12872:16fa902b1469
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 #include <sys/types.h>
    26 #include <sys/types.h>
    27 #include <string.h>
    27 #include <string.h>
       
    28 #include <sys/resource.h>
       
    29 
    28 #include "jni.h"
    30 #include "jni.h"
    29 #include "jni_util.h"
    31 #include "jni_util.h"
    30 #include "jvm.h"
    32 #include "jvm.h"
    31 #include "jlong.h"
    33 #include "jlong.h"
    32 #include "sun_nio_ch_IOUtil.h"
    34 #include "sun_nio_ch_IOUtil.h"
       
    35 #include "java_lang_Integer.h"
    33 #include "nio.h"
    36 #include "nio.h"
    34 #include "nio_util.h"
    37 #include "nio_util.h"
    35 
    38 
    36 static jfieldID fd_fdID;        /* for jint 'fd' in java.io.FileDescriptor */
    39 static jfieldID fd_fdID;        /* for jint 'fd' in java.io.FileDescriptor */
    37 
    40 
   116             continue;
   119             continue;
   117         return (tn > 0) ? JNI_TRUE : JNI_FALSE;
   120         return (tn > 0) ? JNI_TRUE : JNI_FALSE;
   118     }
   121     }
   119 }
   122 }
   120 
   123 
       
   124 JNIEXPORT jint JNICALL
       
   125 Java_sun_nio_ch_IOUtil_fdLimit(JNIEnv *env, jclass this)
       
   126 {
       
   127     struct rlimit rlp;
       
   128     if (getrlimit(RLIMIT_NOFILE, &rlp) < 0) {
       
   129         JNU_ThrowIOExceptionWithLastError(env, "getrlimit failed");
       
   130         return -1;
       
   131     }
       
   132     if (rlp.rlim_max < 0 || rlp.rlim_max > java_lang_Integer_MAX_VALUE) {
       
   133         return java_lang_Integer_MAX_VALUE;
       
   134     } else {
       
   135         return (jint)rlp.rlim_max;
       
   136     }
       
   137 }
   121 
   138 
   122 /* Declared in nio_util.h for use elsewhere in NIO */
   139 /* Declared in nio_util.h for use elsewhere in NIO */
   123 
   140 
   124 jint
   141 jint
   125 convertReturnVal(JNIEnv *env, jint n, jboolean reading)
   142 convertReturnVal(JNIEnv *env, jint n, jboolean reading)