27
27
import jnr .ffi .annotations .In ;
28
28
import jnr .ffi .annotations .Out ;
29
29
import jnr .ffi .annotations .Transient ;
30
+ import jnr .ffi .annotations .Variadic ;
30
31
import jnr .ffi .types .size_t ;
31
32
import jnr .ffi .types .ssize_t ;
32
33
import jnr .ffi .Platform ;
34
+ import jnr .ffi .types .u_int64_t ;
33
35
34
36
import java .io .IOException ;
35
37
import java .nio .ByteBuffer ;
@@ -46,7 +48,8 @@ public static interface LibC {
46
48
public @ ssize_t int read (int fd , @ Out byte [] data , @ size_t long size );
47
49
public @ ssize_t int write (int fd , @ In ByteBuffer data , @ size_t long size );
48
50
public @ ssize_t int write (int fd , @ In byte [] data , @ size_t long size );
49
- public int fcntl (int fd , int cmd , int data );
51
+ @ Variadic (fixedCount = 2 )
52
+ public int fcntl (int fd , int cmd , @ u_int64_t int data );
50
53
public int poll (@ In @ Out ByteBuffer pfds , int nfds , int timeout );
51
54
public int poll (@ In @ Out Pointer pfds , int nfds , int timeout );
52
55
public int kqueue ();
@@ -155,6 +158,12 @@ public static void setBlocking(int fd, boolean block) {
155
158
156
159
libc ().fcntl (fd , LibC .F_SETFL , flags );
157
160
}
161
+
162
+ public static boolean getBlocking (int fd ) {
163
+ int flags = libc ().fcntl (fd , LibC .F_GETFL , 0 );
164
+
165
+ return !((flags & LibC .O_NONBLOCK ) == LibC .O_NONBLOCK );
166
+ }
158
167
159
168
public static int shutdown (int fd , int how ) {
160
169
return libc ().shutdown (fd , how );
0 commit comments