@@ -398,6 +398,8 @@ mod linux {
398
398
399
399
use libc:: { iovec, ssize_t, syscall, SYS_preadv2 } ;
400
400
401
+ // TODO: Replace this with libc::RWF_NOWAIT once they have it for musl
402
+ // targets
401
403
const RWF_NOWAIT : c_int = 0x00000008 ;
402
404
403
405
fn cvt_ssize ( t : ssize_t ) -> io:: Result < ssize_t > {
@@ -408,12 +410,14 @@ mod linux {
408
410
}
409
411
}
410
412
411
- unsafe fn preadv2 ( fd : c_int , iov : * const iovec , iovcnt : c_int , flags : c_int ) -> ssize_t {
413
+ unsafe fn preadv2 ( fd : c_int , iov : & iovec ) -> ssize_t {
414
+ let iovcnt: c_int = 1 ;
415
+
412
416
#[ cfg( all( target_arch = "x86_64" , target_pointer_width = "64" ) ) ]
413
- let res = syscall ( SYS_preadv2 , fd, iov, iovcnt, -1 , 0 , flags ) ;
417
+ let res = syscall ( SYS_preadv2 , fd, iov, iovcnt, -1 , 0 , RWF_NOWAIT ) ;
414
418
415
419
#[ cfg( all( target_arch = "x86_64" , target_pointer_width = "32" ) ) ]
416
- let res = syscall ( SYS_preadv2 , fd, iov, iovcnt, -1 , flags ) ;
420
+ let res = syscall ( SYS_preadv2 , fd, iov, iovcnt, -1 , RWF_NOWAIT ) ;
417
421
418
422
#[ cfg( not( target_arch = "x86_64" ) ) ]
419
423
let res = syscall (
@@ -423,7 +427,7 @@ mod linux {
423
427
iovcnt,
424
428
-1 as libc:: c_long ,
425
429
( ( -1 as u64 ) >> 32 ) as libc:: c_long ,
426
- flags ,
430
+ RWF_NOWAIT ,
427
431
) ;
428
432
429
433
res. try_into ( ) . unwrap ( )
@@ -443,8 +447,6 @@ mod linux {
443
447
iov_base : buf. as_ptr ( ) as * mut _ ,
444
448
iov_len : buf. len ( ) ,
445
449
} ,
446
- 1 ,
447
- RWF_NOWAIT ,
448
450
)
449
451
} ) {
450
452
Ok ( cnt) => Ok ( cnt. try_into ( ) . unwrap ( ) ) ,
0 commit comments