File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88#undef htonl
99#undef htons
1010
11+ #ifdef __cplusplus
12+ extern "C" {
13+ #endif
1114uint32_t cpp2rust_ntohl (uint32_t x );
1215uint16_t cpp2rust_ntohs (uint16_t x );
1316uint32_t cpp2rust_htonl (uint32_t x );
1417uint16_t cpp2rust_htons (uint16_t x );
18+ #ifdef __cplusplus
19+ }
20+ #endif
1521
1622#define ntohl (x ) cpp2rust_ntohl(x)
1723#define ntohs (x ) cpp2rust_ntohs(x)
Original file line number Diff line number Diff line change 55
66#undef errno
77
8+ #ifdef __cplusplus
9+ extern "C" {
10+ #endif
811int * cpp2rust_errno (void );
12+ #ifdef __cplusplus
13+ }
14+ #endif
915
1016#define errno (*cpp2rust_errno())
Original file line number Diff line number Diff line change 88#undef FD_ISSET
99#undef FD_ZERO
1010
11+ #ifdef __cplusplus
12+ extern "C" {
13+ #endif
1114void cpp2rust_fd_set (int fd , fd_set * set );
1215void cpp2rust_fd_clr (int fd , fd_set * set );
1316int cpp2rust_fd_isset (int fd , const fd_set * set );
1417void cpp2rust_fd_zero (fd_set * set );
18+ #ifdef __cplusplus
19+ }
20+ #endif
1521
1622#define FD_SET (fd , set ) cpp2rust_fd_set(fd, set)
1723#define FD_CLR (fd , set ) cpp2rust_fd_clr(fd, set)
Original file line number Diff line number Diff line change @@ -208,6 +208,19 @@ fn main_0() -> i32 {
208208 ( ( sizes. as_pointer ( ) as Ptr < usize > ) . to_end ( ) ) . reinterpret_cast :: < usize > ( ) ;
209209 assert ! ( ( ( ( sizes_end) . clone( ) - ( sizes. as_pointer( ) as Ptr :: <usize >) ) as i64 == 4_i64 ) ) ;
210210 assert ! ( ( ( ( sizes_end. offset( -( ( 1 ) as isize ) ) ) . read( ) ) == 4_usize ) ) ;
211+ let set: Value < CFdSet > = Rc :: new ( RefCell :: new ( Default :: default ( ) ) ) ;
212+ ( set. as_pointer ( ) ) . with_mut ( |__s| __s. zero ( ) ) ;
213+ ( set. as_pointer ( ) ) . with_mut ( |__s| __s. set ( 3 ) ) ;
214+ assert ! (
215+ ( if ( set. as_pointer( ) ) . with( |__s| __s. isset( 3 ) ) {
216+ 1
217+ } else {
218+ 0
219+ } != 0 )
220+ ) ;
221+ libcc2rs:: cpp2rust_errno ( ) . write ( 42 ) ;
222+ assert ! ( ( ( libcc2rs:: cpp2rust_errno( ) . read( ) ) == 42 ) ) ;
223+ assert ! ( ( u32 :: from_be( u32 :: to_be( 7_u32 ) ) == 7_u32 ) ) ;
211224 return 0 ;
212225}
213226pub fn __cpp2rust_init_globals ( ) { }
Original file line number Diff line number Diff line change @@ -197,6 +197,13 @@ unsafe fn main_0() -> i32 {
197197 == ( 4_i64 ) )
198198 ) ;
199199 assert ! ( ( ( * ( sizes_end. offset( -( ( 1 ) as isize ) ) ) ) == ( 4_usize ) ) ) ;
200+ let mut set: :: libc:: fd_set = std:: mem:: zeroed :: < :: libc:: fd_set > ( ) ;
201+ libc:: FD_ZERO ( ( & mut set as * mut :: libc:: fd_set ) ) ;
202+ libc:: FD_SET ( 3 , ( & mut set as * mut :: libc:: fd_set ) ) ;
203+ assert ! ( ( libc:: FD_ISSET ( 3 , ( & mut set as * mut :: libc:: fd_set) . cast_const( ) ) as i32 != 0 ) ) ;
204+ ( * libcc2rs:: cpp2rust_errno_unsafe ( ) ) = 42 ;
205+ assert ! ( ( ( * libcc2rs:: cpp2rust_errno_unsafe( ) ) == ( 42 ) ) ) ;
206+ assert ! ( ( ( u32 :: from_be( u32 :: to_be( 7_u32 ) ) ) == ( 7_u32 ) ) ) ;
200207 return 0 ;
201208}
202209pub unsafe fn __cpp2rust_init_globals ( ) { }
Original file line number Diff line number Diff line change 11#include < algorithm>
2+ #include < arpa/inet.h>
23#include < cassert>
34#include < cstddef>
45#include < cstdint>
6+ #include < errno.h>
57#include < iterator>
8+ #include < sys/select.h>
69#include < sys/types.h>
710#include < utility>
811
@@ -113,5 +116,15 @@ int main() {
113116 const size_t *sizes_end = std::end (sizes);
114117 assert (sizes_end - sizes == 4 );
115118 assert (*(sizes_end - 1 ) == 4 );
119+
120+ fd_set set;
121+ FD_ZERO (&set);
122+ FD_SET (3 , &set);
123+ assert (FD_ISSET (3 , &set));
124+
125+ errno = 42 ;
126+ assert (errno == 42 );
127+
128+ assert (ntohl (htonl (7 )) == 7 );
116129 return 0 ;
117130}
You can’t perform that action at this time.
0 commit comments