On Mar 27, 2006, at 5:42 AM, Michael Barker wrote:
Hi,Another punt at the Non-blocking IO and Scatter/Gather stuff. This patch also adds scatter/gather support to the FileChannelImpl. ChangeLog: 2006-03-19 Michael Barker <[EMAIL PROTECTED]> * vm/reference/gnu/java/nio/VMChannel.java: Added, supports setting non-blocking and scatter-gather io operations. * gnu/java/nio/PipeImpl.java: Retrofitted to use VMChannel * gnu/java/nio/SelectorImpl.java (register) Added condition for gnu.java.nio.SocketChannelSelectionKeyImpl * gnu/java/nio/SocketChannelSelectionKeyImpl.java Added. * gnu/java/nio/channels/FileChannelImpl.java: Retrofitted to use VMChannel * java/nio/FileChannel.java (read (ByteBuffer)) Changed to call abstract method. (write (ByteBuffer)) Changed to call abstract method. * include/gnu_java_nio_VMChannel.h: Added. * native/jni/java-nio/gnu_java_nio_VMChannel.c: Added.
Hi Michael.I (finally!) took a look at this patch, and it looks fine to me; any bugs with it are worth the risk to have a real implementation of scatter/gather IO, in my opinion.
One nit is that gnu_java_nio_VMChannel.c doesn't compile with -Werror for me (Darwin/x86, gcc 4.0.1), due to some unused variables and missing prototypes. I'll attach a patch that fixes these warnings.
Thanks,
--- native/jni/java-nio/gnu_java_nio_VMChannel.c 2006-05-05
23:15:51.000000000 -0700
+++ native/jni/java-nio/gnu_java_nio_VMChannel.c.mine 2006-04-18
14:52:45.000000000 -0700
@@ -66,6 +66,24 @@
{
#endif
+enum JCL_buffer_type { DIRECT, ARRAY, UNKNOWN };
+
+struct JCL_buffer
+{
+ enum JCL_buffer_type type;
+ jbyte *ptr;
+ jint offset;
+ jint position;
+ jint limit;
+ jint count;
+};
+
+jmethodID get_method_id(JNIEnv *, jclass, const char *, const char *);
+void JCL_print_buffer(JNIEnv *, struct JCL_buffer *);
+int JCL_init_buffer(JNIEnv *, struct JCL_buffer *, jobject);
+void JCL_release_buffer(JNIEnv *, struct JCL_buffer *, jobject, jint);
+void JCL_cleanup_buffers(JNIEnv *, struct JCL_buffer *, jint, jobjectArray,
jint, jlong);
+
static jfieldID address_fid;
static jmethodID get_position_mid;
static jmethodID set_position_mid;
@@ -89,20 +107,8 @@
return mid;
}
-enum JCL_buffer_type { DIRECT, ARRAY, UNKNOWN };
-
-struct JCL_buffer
-{
- enum JCL_buffer_type type;
- jbyte *ptr;
- jint offset;
- jint position;
- jint limit;
- jint count;
-};
-
void
-JCL_print_buffer(JNIEnv *env, struct JCL_buffer *buf)
+JCL_print_buffer(JNIEnv *env __attribute__((__unused__)), struct JCL_buffer
*buf)
{
fprintf(stdout, "Buffer - type: %d, ptr: %d\n", buf->type, (int)buf->ptr);
fflush(stdout);
@@ -378,8 +384,8 @@
jint length)
{
jint i;
- jboolean is_error = JNI_FALSE;
- char *error_msg;
+/* jboolean is_error = JNI_FALSE; */
+/* char *error_msg; */
struct iovec buffers[JCL_IOV_MAX];
struct JCL_buffer bi_list[JCL_IOV_MAX];
ssize_t result;
@@ -454,8 +460,8 @@
jint length)
{
int i;
- jboolean is_error = JNI_FALSE;
- char *error_msg;
+/* jboolean is_error = JNI_FALSE; */
+/* char *error_msg; */
struct iovec buffers[JCL_IOV_MAX];
struct JCL_buffer bi_list[JCL_IOV_MAX];
ssize_t result;
PGP.sig
Description: This is a digitally signed message part
