@@ -947,11 +947,9 @@ fn recv(fd: c_int, blocking_mode: BlockingMode)
947
947
Ok ( ( main_data_buffer, channels, shared_memory_regions) )
948
948
}
949
949
950
- #[ cfg( not( all( target_os="linux" , feature="memfd" ) ) ) ]
950
+ #[ cfg( not( any ( target_os= "freebsd" , all( target_os="linux" , feature="memfd" ) ) ) ) ]
951
951
fn create_shmem ( name : CString , length : usize ) -> c_int {
952
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
953
let fd = libc:: shm_open ( name. as_ptr ( ) ,
956
954
libc:: O_CREAT | libc:: O_RDWR | libc:: O_EXCL ,
957
955
0o600 ) ;
@@ -962,6 +960,20 @@ fn create_shmem(name: CString, length: usize) -> c_int {
962
960
}
963
961
}
964
962
963
+ #[ cfg( target_os="freebsd" ) ]
964
+ fn create_shmem ( _name : CString , length : usize ) -> c_int {
965
+ unsafe {
966
+ // NB: the FreeBSD man page for shm_unlink states that it requires
967
+ // write permissions, but testing shows that read-write is required.
968
+ let fd = libc:: shm_open ( 1 as * mut i8 , // SHM_ANON
969
+ libc:: O_CREAT | libc:: O_RDWR | libc:: O_EXCL ,
970
+ 0o600 ) ;
971
+ assert ! ( fd >= 0 ) ;
972
+ assert ! ( libc:: ftruncate( fd, length as off_t) == 0 ) ;
973
+ fd
974
+ }
975
+ }
976
+
965
977
#[ cfg( all( feature="memfd" , target_os="linux" ) ) ]
966
978
fn create_shmem ( name : CString , length : usize ) -> c_int {
967
979
unsafe {
0 commit comments