@@ -11,7 +11,7 @@ use bincode;
1111use fnv:: FnvHasher ;
1212use libc:: { self , MAP_FAILED , MAP_SHARED , PROT_READ , PROT_WRITE , SOCK_SEQPACKET , SOL_SOCKET } ;
1313use 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} ;
1515use libc:: { setsockopt, size_t, sockaddr, sockaddr_un, socketpair, socklen_t, sa_family_t} ;
1616use std:: cell:: Cell ;
1717use std:: cmp;
@@ -31,6 +31,7 @@ use std::time::UNIX_EPOCH;
3131use std:: thread;
3232use mio:: unix:: EventedFd ;
3333use mio:: { Poll , Token , Events , Ready , PollOpt } ;
34+ use shmemfdrs:: create_shmem;
3435
3536const MAX_FDS_IN_CMSG : u32 = 64 ;
3637
@@ -945,31 +946,6 @@ fn recv(fd: c_int, blocking_mode: BlockingMode)
945946 Ok ( ( main_data_buffer, channels, shared_memory_regions) )
946947}
947948
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-
973949struct UnixCmsg {
974950 cmsg_buffer : * mut cmsghdr ,
975951 msghdr : msghdr ,
@@ -1045,11 +1021,6 @@ fn is_socket(fd: c_int) -> bool {
10451021
10461022// FFI stuff follows:
10471023
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-
10531024#[ allow( non_snake_case) ]
10541025fn CMSG_LEN ( length : size_t ) -> size_t {
10551026 CMSG_ALIGN ( mem:: size_of :: < cmsghdr > ( ) ) + length
0 commit comments