@@ -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
use super :: incrementor:: Incrementor ;
36
37
@@ -947,31 +948,6 @@ fn recv(fd: c_int, blocking_mode: BlockingMode)
947
948
Ok ( ( main_data_buffer, channels, shared_memory_regions) )
948
949
}
949
950
950
- #[ cfg( not( all( target_os="linux" , feature="memfd" ) ) ) ]
951
- fn create_shmem ( name : CString , length : usize ) -> c_int {
952
- unsafe {
953
- // NB: the FreeBSD man page for shm_unlink states that it requires
954
- // write permissions, but testing shows that read-write is required.
955
- let fd = libc:: shm_open ( name. as_ptr ( ) ,
956
- libc:: O_CREAT | libc:: O_RDWR | libc:: O_EXCL ,
957
- 0o600 ) ;
958
- assert ! ( fd >= 0 ) ;
959
- assert ! ( libc:: shm_unlink( name. as_ptr( ) ) == 0 ) ;
960
- assert ! ( libc:: ftruncate( fd, length as off_t) == 0 ) ;
961
- fd
962
- }
963
- }
964
-
965
- #[ cfg( all( feature="memfd" , target_os="linux" ) ) ]
966
- fn create_shmem ( name : CString , length : usize ) -> c_int {
967
- unsafe {
968
- let fd = memfd_create ( name. as_ptr ( ) , 0 ) ;
969
- assert ! ( fd >= 0 ) ;
970
- assert ! ( libc:: ftruncate( fd, length as off_t) == 0 ) ;
971
- fd
972
- }
973
- }
974
-
975
951
struct UnixCmsg {
976
952
cmsg_buffer : * mut cmsghdr ,
977
953
msghdr : msghdr ,
@@ -1047,11 +1023,6 @@ fn is_socket(fd: c_int) -> bool {
1047
1023
1048
1024
// FFI stuff follows:
1049
1025
1050
- #[ cfg( all( feature="memfd" , target_os="linux" ) ) ]
1051
- unsafe fn memfd_create ( name : * const c_char , flags : usize ) -> c_int {
1052
- syscall ! ( MEMFD_CREATE , name, flags) as c_int
1053
- }
1054
-
1055
1026
#[ allow( non_snake_case) ]
1056
1027
fn CMSG_LEN ( length : size_t ) -> size_t {
1057
1028
CMSG_ALIGN ( mem:: size_of :: < cmsghdr > ( ) ) + length
0 commit comments