File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ extern crate libcc2rs;
2+ use libcc2rs:: * ;
3+ use std:: cell:: RefCell ;
4+ use std:: collections:: BTreeMap ;
5+ use std:: io:: prelude:: * ;
6+ use std:: io:: { Read , Seek , Write } ;
7+ use std:: os:: fd:: AsFd ;
8+ use std:: rc:: { Rc , Weak } ;
9+ pub fn main ( ) {
10+ std:: process:: exit ( main_0 ( ) ) ;
11+ }
12+ fn main_0 ( ) -> i32 {
13+ assert ! ( ( ( ( libc:: SOCK_STREAM == 1 ) as i32 ) != 0 ) ) ;
14+ assert ! ( ( ( ( libc:: SOCK_DGRAM == 2 ) as i32 ) != 0 ) ) ;
15+ assert ! ( ( ( ( libc:: SOCK_RAW == 3 ) as i32 ) != 0 ) ) ;
16+ assert ! ( ( ( ( libc:: SOCK_RDM == 4 ) as i32 ) != 0 ) ) ;
17+ assert ! ( ( ( ( libc:: SOCK_SEQPACKET == 5 ) as i32 ) != 0 ) ) ;
18+ assert ! ( ( ( ( libc:: SOCK_DCCP == 6 ) as i32 ) != 0 ) ) ;
19+ assert ! ( ( ( ( libc:: SOCK_PACKET == 10 ) as i32 ) != 0 ) ) ;
20+ let x: Value < i32 > = Rc :: new ( RefCell :: new ( ( libc:: SOCK_STREAM | libc:: SOCK_CLOEXEC ) ) ) ;
21+ assert ! ( ( ( ( ( ( * x. borrow( ) ) & libc:: SOCK_STREAM ) == libc:: SOCK_STREAM ) as i32 ) != 0 ) ) ;
22+ assert ! ( ( ( ( ( ( * x. borrow( ) ) & libc:: SOCK_CLOEXEC ) == libc:: SOCK_CLOEXEC ) as i32 ) != 0 ) ) ;
23+ let y: Value < i32 > = Rc :: new ( RefCell :: new ( ( libc:: SOCK_DGRAM | libc:: SOCK_NONBLOCK ) ) ) ;
24+ assert ! ( ( ( ( ( ( * y. borrow( ) ) & libc:: SOCK_DGRAM ) == libc:: SOCK_DGRAM ) as i32 ) != 0 ) ) ;
25+ assert ! ( ( ( ( ( ( * y. borrow( ) ) & libc:: SOCK_NONBLOCK ) == libc:: SOCK_NONBLOCK ) as i32 ) != 0 ) ) ;
26+ return 0 ;
27+ }
Original file line number Diff line number Diff line change 1+ extern crate libc;
2+ use libc:: * ;
3+ extern crate libcc2rs;
4+ use libcc2rs:: * ;
5+ use std:: collections:: BTreeMap ;
6+ use std:: io:: { Read , Seek , Write } ;
7+ use std:: os:: fd:: { AsFd , FromRawFd , IntoRawFd } ;
8+ use std:: rc:: Rc ;
9+ pub fn main ( ) {
10+ unsafe {
11+ std:: process:: exit ( main_0 ( ) as i32 ) ;
12+ }
13+ }
14+ unsafe fn main_0 ( ) -> i32 {
15+ assert ! ( ( ( ( ( libc:: SOCK_STREAM ) == ( 1 ) ) as i32 ) != 0 ) ) ;
16+ assert ! ( ( ( ( ( libc:: SOCK_DGRAM ) == ( 2 ) ) as i32 ) != 0 ) ) ;
17+ assert ! ( ( ( ( ( libc:: SOCK_RAW ) == ( 3 ) ) as i32 ) != 0 ) ) ;
18+ assert ! ( ( ( ( ( libc:: SOCK_RDM ) == ( 4 ) ) as i32 ) != 0 ) ) ;
19+ assert ! ( ( ( ( ( libc:: SOCK_SEQPACKET ) == ( 5 ) ) as i32 ) != 0 ) ) ;
20+ assert ! ( ( ( ( ( libc:: SOCK_DCCP ) == ( 6 ) ) as i32 ) != 0 ) ) ;
21+ assert ! ( ( ( ( ( libc:: SOCK_PACKET ) == ( 10 ) ) as i32 ) != 0 ) ) ;
22+ let mut x: i32 = ( ( libc:: SOCK_STREAM ) | ( libc:: SOCK_CLOEXEC ) ) ;
23+ assert ! ( ( ( ( ( ( x) & ( libc:: SOCK_STREAM ) ) == ( libc:: SOCK_STREAM ) ) as i32 ) != 0 ) ) ;
24+ assert ! ( ( ( ( ( ( x) & ( libc:: SOCK_CLOEXEC ) ) == ( libc:: SOCK_CLOEXEC ) ) as i32 ) != 0 ) ) ;
25+ let mut y: i32 = ( ( libc:: SOCK_DGRAM ) | ( libc:: SOCK_NONBLOCK ) ) ;
26+ assert ! ( ( ( ( ( ( y) & ( libc:: SOCK_DGRAM ) ) == ( libc:: SOCK_DGRAM ) ) as i32 ) != 0 ) ) ;
27+ assert ! ( ( ( ( ( ( y) & ( libc:: SOCK_NONBLOCK ) ) == ( libc:: SOCK_NONBLOCK ) ) as i32 ) != 0 ) ) ;
28+ return 0 ;
29+ }
Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+ #include <sys/socket.h>
3+ #include <sys/types.h>
4+
5+ int main () {
6+ assert (SOCK_STREAM == 1 );
7+ assert (SOCK_DGRAM == 2 );
8+ assert (SOCK_RAW == 3 );
9+ assert (SOCK_RDM == 4 );
10+ assert (SOCK_SEQPACKET == 5 );
11+ assert (SOCK_DCCP == 6 );
12+ assert (SOCK_PACKET == 10 );
13+
14+ int x = SOCK_STREAM | SOCK_CLOEXEC ;
15+ assert ((x & SOCK_STREAM ) == SOCK_STREAM );
16+ assert ((x & SOCK_CLOEXEC ) == SOCK_CLOEXEC );
17+
18+ int y = SOCK_DGRAM | SOCK_NONBLOCK ;
19+ assert ((y & SOCK_DGRAM ) == SOCK_DGRAM );
20+ assert ((y & SOCK_NONBLOCK ) == SOCK_NONBLOCK );
21+
22+ return 0 ;
23+ }
You can’t perform that action at this time.
0 commit comments