@@ -11,7 +11,7 @@ use bincode;
11
11
use fnv:: FnvHasher ;
12
12
use libc:: { self , MAP_FAILED , MAP_SHARED , PROT_READ , PROT_WRITE , SOCK_SEQPACKET , SOL_SOCKET } ;
13
13
use libc:: { SO_LINGER , S_IFMT , S_IFSOCK , c_char, c_int, c_void, getsockopt} ;
14
- use libc:: { iovec, mode_t, msghdr, off_t , recvmsg, sendmsg} ;
14
+ use libc:: { iovec, mode_t, msghdr, recvmsg, sendmsg} ;
15
15
use libc:: { setsockopt, size_t, sockaddr, sockaddr_un, socketpair, socklen_t, sa_family_t} ;
16
16
use std:: cell:: Cell ;
17
17
use std:: cmp;
@@ -31,6 +31,7 @@ use std::time::UNIX_EPOCH;
31
31
use std:: thread;
32
32
use mio:: unix:: EventedFd ;
33
33
use mio:: { Poll , Token , Events , Ready , PollOpt } ;
34
+ use shmemfdrs:: create_shmem;
34
35
35
36
const MAX_FDS_IN_CMSG : u32 = 64 ;
36
37
@@ -945,31 +946,6 @@ fn recv(fd: c_int, blocking_mode: BlockingMode)
945
946
Ok ( ( main_data_buffer, channels, shared_memory_regions) )
946
947
}
947
948
948
- #[ cfg( not( all( target_os="linux" , feature="memfd" ) ) ) ]
949
- fn create_shmem ( name : CString , length : usize ) -> c_int {
950
- unsafe {
951
- // NB: the FreeBSD man page for shm_unlink states that it requires
952
- // write permissions, but testing shows that read-write is required.
953
- let fd = libc:: shm_open ( name. as_ptr ( ) ,
954
- libc:: O_CREAT | libc:: O_RDWR | libc:: O_EXCL ,
955
- 0o600 ) ;
956
- assert ! ( fd >= 0 ) ;
957
- assert ! ( libc:: shm_unlink( name. as_ptr( ) ) == 0 ) ;
958
- assert ! ( libc:: ftruncate( fd, length as off_t) == 0 ) ;
959
- fd
960
- }
961
- }
962
-
963
- #[ cfg( all( feature="memfd" , target_os="linux" ) ) ]
964
- fn create_shmem ( name : CString , length : usize ) -> c_int {
965
- unsafe {
966
- let fd = memfd_create ( name. as_ptr ( ) , 0 ) ;
967
- assert ! ( fd >= 0 ) ;
968
- assert ! ( libc:: ftruncate( fd, length as off_t) == 0 ) ;
969
- fd
970
- }
971
- }
972
-
973
949
struct UnixCmsg {
974
950
cmsg_buffer : * mut cmsghdr ,
975
951
msghdr : msghdr ,
@@ -1045,11 +1021,6 @@ fn is_socket(fd: c_int) -> bool {
1045
1021
1046
1022
// FFI stuff follows:
1047
1023
1048
- #[ cfg( all( feature="memfd" , target_os="linux" ) ) ]
1049
- unsafe fn memfd_create ( name : * const c_char , flags : usize ) -> c_int {
1050
- syscall ! ( MEMFD_CREATE , name, flags) as c_int
1051
- }
1052
-
1053
1024
#[ allow( non_snake_case) ]
1054
1025
fn CMSG_LEN ( length : size_t ) -> size_t {
1055
1026
CMSG_ALIGN ( mem:: size_of :: < cmsghdr > ( ) ) + length
0 commit comments