@@ -7,8 +7,11 @@ use std::env;
7
7
8
8
fn do_cc ( ) {
9
9
let target = env:: var ( "TARGET" ) . unwrap ( ) ;
10
- if cfg ! ( unix) && !target. contains ( "wasi" ) {
11
- cc:: Build :: new ( ) . file ( "src/cmsg.c" ) . compile ( "cmsg" ) ;
10
+ if cfg ! ( unix) {
11
+ let exclude = [ "wasi" , "solaris" , "illumos" ] ;
12
+ if !exclude. iter ( ) . any ( |x| target. contains ( x) ) {
13
+ cc:: Build :: new ( ) . file ( "src/cmsg.c" ) . compile ( "cmsg" ) ;
14
+ }
12
15
}
13
16
if target. contains ( "android" ) || target. contains ( "linux" ) {
14
17
cc:: Build :: new ( ) . file ( "src/errqueue.c" ) . compile ( "errqueue" ) ;
@@ -27,7 +30,8 @@ fn do_ctest() {
27
30
t if t. contains ( "netbsd" ) => return test_netbsd ( t) ,
28
31
t if t. contains ( "openbsd" ) => return test_openbsd ( t) ,
29
32
t if t. contains ( "redox" ) => return test_redox ( t) ,
30
- t if t. contains ( "solaris" ) => return test_solaris ( t) ,
33
+ t if t. contains ( "solaris" ) => return test_solarish ( t) ,
34
+ t if t. contains ( "illumos" ) => return test_solarish ( t) ,
31
35
t if t. contains ( "wasi" ) => return test_wasi ( t) ,
32
36
t if t. contains ( "windows" ) => return test_windows ( t) ,
33
37
t if t. contains ( "vxworks" ) => return test_vxworks ( t) ,
@@ -649,9 +653,13 @@ fn test_cloudabi(target: &str) {
649
653
cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
650
654
}
651
655
652
- fn test_solaris ( target : & str ) {
653
- assert ! ( target. contains( "solaris" ) ) ;
656
+ fn test_solarish ( target : & str ) {
657
+ let is_solaris = target. contains ( "solaris" ) ;
658
+ let is_illumos = target. contains ( "illumos" ) ;
659
+ assert ! ( is_solaris || is_illumos) ;
654
660
661
+ // ctest generates arguments supported only by clang, so make sure to run with CC=clang.
662
+ // While debugging, "CFLAGS=-ferror-limit=<large num>" is useful to get more error output.
655
663
let mut cfg = ctest_cfg ( ) ;
656
664
cfg. flag ( "-Wno-deprecated-declarations" ) ;
657
665
@@ -664,6 +672,7 @@ fn test_solaris(target: &str) {
664
672
"ctype.h" ,
665
673
"dirent.h" ,
666
674
"dlfcn.h" ,
675
+ "door.h" ,
667
676
"errno.h" ,
668
677
"execinfo.h" ,
669
678
"fcntl.h" ,
@@ -673,6 +682,7 @@ fn test_solaris(target: &str) {
673
682
"langinfo.h" ,
674
683
"limits.h" ,
675
684
"locale.h" ,
685
+ "mqueue.h" ,
676
686
"net/if.h" ,
677
687
"net/if_arp.h" ,
678
688
"net/route.h" ,
@@ -705,6 +715,7 @@ fn test_solaris(target: &str) {
705
715
"sys/socket.h" ,
706
716
"sys/stat.h" ,
707
717
"sys/statvfs.h" ,
718
+ "sys/shm.h" ,
708
719
"sys/time.h" ,
709
720
"sys/times.h" ,
710
721
"sys/timex.h" ,
@@ -723,15 +734,100 @@ fn test_solaris(target: &str) {
723
734
"wchar.h" ,
724
735
}
725
736
737
+ cfg. skip_type ( move |ty| {
738
+ match ty {
739
+ // sighandler_t is not present here
740
+ "sighandler_t" => true ,
741
+ _ => false ,
742
+ }
743
+ } ) ;
744
+
745
+ cfg. type_name ( move |ty, is_struct, is_union| {
746
+ match ty {
747
+ "FILE" => "__FILE" . to_string ( ) ,
748
+ "DIR" | "Dl_info" => ty. to_string ( ) ,
749
+ t if t. ends_with ( "_t" ) => t. to_string ( ) ,
750
+ t if is_struct => format ! ( "struct {}" , t) ,
751
+ t if is_union => format ! ( "union {}" , t) ,
752
+ t => t. to_string ( ) ,
753
+ }
754
+ } ) ;
755
+
756
+ cfg. field_name ( move |struct_, field| {
757
+ match struct_ {
758
+ // rust struct uses raw u64, rather than union
759
+ "epoll_event" if field == "u64" => "data.u64" . to_string ( ) ,
760
+ // rust struct was committed with typo for Solaris
761
+ "door_arg_t" if field == "dec_num" => "desc_num" . to_string ( ) ,
762
+ "stat" if field. ends_with ( "_nsec" ) => {
763
+ // expose stat.Xtim.tv_nsec fields
764
+ field. trim_end_matches ( "e_nsec" ) . to_string ( ) + ".tv_nsec"
765
+ } ,
766
+ _ => field. to_string ( )
767
+ }
768
+ } ) ;
769
+
726
770
cfg. skip_const ( move |name| match name {
727
771
"DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
728
772
| "DT_SOCK" | "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => {
729
773
true
730
774
}
731
775
776
+ // skip sighandler_t assignments
777
+ "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true ,
778
+
779
+ "DT_UNKNOWN" => true ,
780
+
781
+ "_UTX_LINESIZE" | "_UTX_USERSIZE" |
782
+ "_UTX_PADSIZE" | "_UTX_IDSIZE" | "_UTX_HOSTSIZE" => true ,
783
+
784
+ "EADI" | "EXTPROC" | "IPC_SEAT" => true ,
785
+
786
+ // This evaluates to a sysconf() call rather than a constant
787
+ "PTHREAD_STACK_MIN" => true ,
788
+
732
789
_ => false ,
733
790
} ) ;
734
791
792
+
793
+
794
+ cfg. skip_struct ( move |ty| {
795
+ // the union handling is a mess
796
+ if ty. contains ( "door_desc_t_" ) {
797
+ return true
798
+ }
799
+ match ty {
800
+ // union, not a struct
801
+ "sigval" => true ,
802
+ // a bunch of solaris-only fields
803
+ "utmpx" if is_illumos => true ,
804
+ _ => false ,
805
+ }
806
+ } ) ;
807
+
808
+ cfg. skip_field ( move |s, field| {
809
+ match s {
810
+ // C99 sizing on this is tough
811
+ "dirent" if field == "d_name" => true ,
812
+ // the union/macro makes this rough
813
+ "sigaction" if field == "sa_sigaction" => true ,
814
+ // Missing in illumos
815
+ "sigevent" if field == "ss_sp" => true ,
816
+ // Avoid sigval union issues
817
+ "sigevent" if field == "sigev_value" => true ,
818
+ // const issues
819
+ "sigevent" if field == "sigev_notify_attributes" => true ,
820
+
821
+ // Avoid const and union issues
822
+ "door_arg" if field == "desc_ptr" => true ,
823
+ "door_desc_t" if field == "d_data" => true ,
824
+ "door_arg_t" if field. ends_with ( "_ptr" ) => true ,
825
+ "door_arg_t" if field. ends_with ( "rbuf" ) => true ,
826
+
827
+ _ => false
828
+ }
829
+ } ) ;
830
+
735
831
cfg. skip_fn ( move |name| {
736
832
// skip those that are manually verified
737
833
match name {
@@ -746,13 +842,19 @@ fn test_solaris(target: &str) {
746
842
// FIXME: unskip these for next major release
747
843
"setpriority" | "personality" => true ,
748
844
749
- // signal is defined with sighandler_t, so ignore
845
+ // signal is defined in terms of sighandler_t, so ignore
750
846
"signal" => true ,
751
847
848
+ // Currently missing
752
849
"cfmakeraw" | "cfsetspeed" => true ,
753
850
754
- // FIXME: mincore is defined with caddr_t on Solaris.
755
- "mincore" => true ,
851
+ // const-ness issues
852
+ "execv" | "execve" | "execvp" | "settimeofday" | "sethostname" => true ,
853
+
854
+ // Solaris-different
855
+ "getpwent_r" | "getgrent_r" | "updwtmpx" if is_illumos => true ,
856
+ "madvise" | "mprotect" if is_illumos => true ,
857
+ "door_call" | "door_return" | "door_create" if is_illumos => true ,
756
858
757
859
_ => false ,
758
860
}
0 commit comments