src/java.base/unix/native/libnio/ch/IOUtil.c
changeset 49290 07779973cbe2
parent 47216 71c04702a3d5
child 49430 e376090dc07e
equal deleted inserted replaced
49289:148e29df1644 49290:07779973cbe2
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   102         }
   102         }
   103     }
   103     }
   104     return ((jlong) fd[0] << 32) | (jlong) fd[1];
   104     return ((jlong) fd[0] << 32) | (jlong) fd[1];
   105 }
   105 }
   106 
   106 
       
   107 
       
   108 JNIEXPORT jint JNICALL
       
   109 Java_sun_nio_ch_IOUtil_write1(JNIEnv *env, jclass cl, jint fd, jbyte b)
       
   110 {
       
   111     char c = (char)b;
       
   112     return convertReturnVal(env, write(fd, &c, 1), JNI_FALSE);
       
   113 }
       
   114 
       
   115 
   107 JNIEXPORT jboolean JNICALL
   116 JNIEXPORT jboolean JNICALL
   108 Java_sun_nio_ch_IOUtil_drain(JNIEnv *env, jclass cl, jint fd)
   117 Java_sun_nio_ch_IOUtil_drain(JNIEnv *env, jclass cl, jint fd)
   109 {
   118 {
   110     char buf[128];
   119     char buf[16];
   111     int tn = 0;
   120     int tn = 0;
   112 
   121 
   113     for (;;) {
   122     for (;;) {
   114         int n = read(fd, buf, sizeof(buf));
   123         int n = read(fd, buf, sizeof(buf));
   115         tn += n;
   124         tn += n;