< prev index next >

src/java.base/unix/native/libnio/ch/FileChannelImpl.c

Print this page

        

@@ -274,5 +274,33 @@
 #else
     return IOS_UNSUPPORTED_CASE;
 #endif
 }
 
+JNIEXPORT jint JNICALL
+Java_sun_nio_ch_FileChannelImpl_setDirect0(JNIEnv *env, jobject this, jobject fObj)
+{
+    jint fd = fdval(env, fObj);
+    jint result;
+
+#ifdef O_DIRECT
+    result = fcntl(fd, F_SETFL, O_DIRECT);
+    if (result == -1) {
+        JNU_ThrowIOExceptionWithLastError(env, "DirectIO setup failed");
+    }
+    return result;
+#elif F_NOCACHE
+    result = fcntl(fd, F_NOCACHE, 1);
+    if (result == -1) {
+        JNU_ThrowIOExceptionWithLastError(env, "DirectIO setup failed");
+    }
+    return result;
+//#elif DIRECTIO_ON
+//    result = directio(fd, DIRECTIO_ON);
+//    if (result == -1) {
+//        JNU_ThrowIOExceptionWithLastError(env, "DirectIO setup failed");
+//    }
+    return result;
+#else
+    return -1;
+#endif
+}
< prev index next >