@@ -53,6 +53,7 @@ fn do_ctest() {
53
53
t if t. contains ( "emscripten" ) => test_emscripten ( t) ,
54
54
t if t. contains ( "freebsd" ) => test_freebsd ( t) ,
55
55
t if t. contains ( "haiku" ) => test_haiku ( t) ,
56
+ t if t. contains ( "l4re" ) => test_linux ( t) ,
56
57
t if t. contains ( "linux" ) => test_linux ( t) ,
57
58
t if t. contains ( "netbsd" ) => test_netbsd ( t) ,
58
59
t if t. contains ( "openbsd" ) => test_openbsd ( t) ,
@@ -94,9 +95,10 @@ fn do_semver() {
94
95
// NOTE: Android doesn't include the unix file (or the Linux file) because
95
96
// there are some many definitions missing it's actually easier just to
96
97
// maintain a file for Android.
97
- // NOTE: AIX doesn't include the unix file because there are definitions
98
- // missing on AIX. It is easier to maintain a file for AIX.
99
- if family != os && !matches ! ( os. as_str( ) , "android" | "aix" ) {
98
+ // NOTE: AIX and L4Re do not include the unix file because there are
99
+ // definitions missing on these systems. It is easier to maintain separate
100
+ // files for them.
101
+ if family != os && !matches ! ( os. as_str( ) , "android" | "aix" | "l4re" ) {
100
102
process_semver_file ( & mut output, & mut semver_root, & family) ;
101
103
}
102
104
// We don't do semver for unknown targets.
@@ -3568,18 +3570,26 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) {
3568
3570
}
3569
3571
3570
3572
fn test_linux ( target : & str ) {
3571
- assert ! ( target. contains( "linux" ) ) ;
3573
+ assert ! ( target. contains( "linux" ) || target. contains( "l4re" ) ) ;
3574
+
3575
+ // target_os
3576
+ let linux = target. contains ( "linux" ) ;
3577
+ let l4re = target. contains ( "l4re" ) ;
3572
3578
3573
3579
// target_env
3574
3580
let gnu = target. contains ( "gnu" ) ;
3575
3581
let musl = target. contains ( "musl" ) || target. contains ( "ohos" ) ;
3576
3582
let uclibc = target. contains ( "uclibc" ) ;
3577
3583
3578
- match ( gnu, musl, uclibc) {
3579
- ( true , false , false ) => ( ) ,
3580
- ( false , true , false ) => ( ) ,
3581
- ( false , false , true ) => ( ) ,
3582
- ( _, _, _) => panic ! ( "linux target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}" ) ,
3584
+ match ( linux, gnu, musl, uclibc) {
3585
+ ( true , true , false , false ) => ( ) ,
3586
+ ( true , false , true , false ) => ( ) ,
3587
+ ( true , false , false , true ) => ( ) ,
3588
+ ( false , false , false , true ) => ( ) ,
3589
+ ( _, _, _, _) => panic ! (
3590
+ "{} target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}" ,
3591
+ if linux { "linux" } else { "l4re" }
3592
+ ) ,
3583
3593
}
3584
3594
3585
3595
let arm = target. contains ( "arm" ) ;
@@ -3613,6 +3623,9 @@ fn test_linux(target: &str) {
3613
3623
. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
3614
3624
3615
3625
config_gnu_bits ( target, & mut cfg) ;
3626
+ if l4re {
3627
+ cfg. flag ( "-Wno-unused-function" ) ;
3628
+ }
3616
3629
3617
3630
headers ! { cfg:
3618
3631
"ctype.h" ,
@@ -3631,11 +3644,12 @@ fn test_linux(target: &str) {
3631
3644
"libgen.h" ,
3632
3645
"limits.h" ,
3633
3646
"link.h" ,
3634
- "linux/sysctl.h" ,
3647
+ [ uclibc] : "linux/if_ether.h" ,
3648
+ [ !l4re] : "linux/sysctl.h" ,
3635
3649
"locale.h" ,
3636
3650
"malloc.h" ,
3637
3651
"mntent.h" ,
3638
- "mqueue.h" ,
3652
+ [ !l4re ] : "mqueue.h" ,
3639
3653
"net/ethernet.h" ,
3640
3654
"net/if.h" ,
3641
3655
"net/if_arp.h" ,
@@ -3645,6 +3659,7 @@ fn test_linux(target: &str) {
3645
3659
"netinet/ip.h" ,
3646
3660
"netinet/tcp.h" ,
3647
3661
"netinet/udp.h" ,
3662
+ [ l4re] : "netpacket/packet.h" ,
3648
3663
"poll.h" ,
3649
3664
"pthread.h" ,
3650
3665
"pty.h" ,
@@ -3655,43 +3670,44 @@ fn test_linux(target: &str) {
3655
3670
"semaphore.h" ,
3656
3671
"shadow.h" ,
3657
3672
"signal.h" ,
3658
- "spawn.h" ,
3659
- "stddef.h" ,
3673
+ [ !l4re ] : "spawn.h" ,
3674
+ [ !l4re ] : "stddef.h" ,
3660
3675
"stdint.h" ,
3661
3676
"stdio.h" ,
3662
3677
"stdlib.h" ,
3663
3678
"string.h" ,
3664
- "sys/epoll.h" ,
3665
- "sys/eventfd.h" ,
3679
+ [ l4re] : "sys/auxv.h" ,
3680
+ [ !l4re] : "sys/epoll.h" ,
3681
+ [ !l4re] : "sys/eventfd.h" ,
3666
3682
"sys/file.h" ,
3667
- "sys/fsuid.h" ,
3668
- "sys/klog.h" ,
3669
- "sys/inotify.h" ,
3683
+ [ !l4re ] : "sys/fsuid.h" ,
3684
+ [ !l4re ] : "sys/klog.h" ,
3685
+ [ !l4re ] : "sys/inotify.h" ,
3670
3686
"sys/ioctl.h" ,
3671
3687
"sys/ipc.h" ,
3672
3688
"sys/mman.h" ,
3673
3689
"sys/mount.h" ,
3674
- "sys/msg.h" ,
3675
- "sys/personality.h" ,
3690
+ [ !l4re ] : "sys/msg.h" ,
3691
+ [ !l4re ] : "sys/personality.h" ,
3676
3692
"sys/prctl.h" ,
3677
- "sys/ptrace.h" ,
3678
- "sys/quota.h" ,
3679
- "sys/random.h" ,
3680
- "sys/reboot.h" ,
3693
+ [ !l4re ] : "sys/ptrace.h" ,
3694
+ [ !l4re ] : "sys/quota.h" ,
3695
+ [ !l4re ] : "sys/random.h" ,
3696
+ [ !l4re ] : "sys/reboot.h" ,
3681
3697
"sys/resource.h" ,
3682
3698
"sys/sem.h" ,
3683
- "sys/sendfile.h" ,
3699
+ [ !l4re ] : "sys/sendfile.h" ,
3684
3700
"sys/shm.h" ,
3685
- "sys/signalfd.h" ,
3701
+ [ !l4re ] : "sys/signalfd.h" ,
3686
3702
"sys/socket.h" ,
3687
3703
"sys/stat.h" ,
3688
3704
"sys/statvfs.h" ,
3689
- "sys/swap.h" ,
3705
+ [ !l4re ] : "sys/swap.h" ,
3690
3706
"sys/syscall.h" ,
3691
3707
"sys/time.h" ,
3692
- "sys/timerfd.h" ,
3708
+ [ !l4re ] : "sys/timerfd.h" ,
3693
3709
"sys/times.h" ,
3694
- "sys/timex.h" ,
3710
+ [ !l4re ] : "sys/timex.h" ,
3695
3711
"sys/types.h" ,
3696
3712
"sys/uio.h" ,
3697
3713
"sys/un.h" ,
@@ -3713,12 +3729,12 @@ fn test_linux(target: &str) {
3713
3729
// ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162
3714
3730
// Also unavailable on gnueabihf with glibc 2.30.
3715
3731
// https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1
3716
- [ ( x86_64 || x86_32 || arm) && !gnueabihf] : "sys/io.h" ,
3732
+ [ ( x86_64 || x86_32 || arm) && !gnueabihf && !l4re ] : "sys/io.h" ,
3717
3733
// `sys/reg.h` is only available on x86 and x86_64
3718
- [ x86_64 || x86_32] : "sys/reg.h" ,
3734
+ [ ( x86_64 || x86_32) && !l4re ] : "sys/reg.h" ,
3719
3735
// sysctl system call is deprecated and not available on musl
3720
3736
// It is also unsupported in x32, deprecated since glibc 2.30:
3721
- [ !( x32 || musl || gnu) ] : "sys/sysctl.h" ,
3737
+ [ !( x32 || musl || gnu || l4re ) ] : "sys/sysctl.h" ,
3722
3738
// <execinfo.h> is not supported by musl:
3723
3739
// https://www.openwall.com/lists/musl/2015/04/09/3
3724
3740
// <execinfo.h> is not present on uclibc.
@@ -3728,11 +3744,11 @@ fn test_linux(target: &str) {
3728
3744
// Include linux headers at the end:
3729
3745
headers ! {
3730
3746
cfg:
3731
- [ loongarch64 || riscv64] : "asm/hwcap.h" ,
3732
- "asm/mman.h" ,
3747
+ [ ( loongarch64 || riscv64) && !l4re ] : "asm/hwcap.h" ,
3748
+ [ !l4re ] : "asm/mman.h" ,
3733
3749
}
3734
3750
3735
- if !wasm32 {
3751
+ if !wasm32 && !l4re {
3736
3752
headers ! { cfg:
3737
3753
[ gnu] : "linux/aio_abi.h" ,
3738
3754
"linux/can.h" ,
@@ -3750,7 +3766,6 @@ fn test_linux(target: &str) {
3750
3766
"linux/if.h" ,
3751
3767
"linux/if_addr.h" ,
3752
3768
"linux/if_alg.h" ,
3753
- "linux/if_ether.h" ,
3754
3769
"linux/if_packet.h" ,
3755
3770
"linux/if_tun.h" ,
3756
3771
"linux/if_xdp.h" ,
@@ -3797,7 +3812,6 @@ fn test_linux(target: &str) {
3797
3812
"linux/wait.h" ,
3798
3813
"linux/wireless.h" ,
3799
3814
"sys/fanotify.h" ,
3800
- // <sys/auxv.h> is not present on uclibc
3801
3815
[ !uclibc] : "sys/auxv.h" ,
3802
3816
[ gnu || musl] : "linux/close_range.h" ,
3803
3817
}
@@ -3806,7 +3820,7 @@ fn test_linux(target: &str) {
3806
3820
// note: aio.h must be included before sys/mount.h
3807
3821
headers ! {
3808
3822
cfg:
3809
- "sys/xattr.h" ,
3823
+ [ !l4re ] : "sys/xattr.h" ,
3810
3824
"sys/sysinfo.h" ,
3811
3825
// AIO is not supported by uclibc:
3812
3826
[ !uclibc] : "aio.h" ,
@@ -3836,10 +3850,11 @@ fn test_linux(target: &str) {
3836
3850
3837
3851
cfg. rename_type ( move |ty| {
3838
3852
match ty {
3839
- "Ioctl" if gnu => Some ( "unsigned long" . to_string ( ) ) ,
3853
+ "Ioctl" if gnu || uclibc => Some ( "unsigned long" . to_string ( ) ) ,
3840
3854
"Ioctl" => Some ( "int" . to_string ( ) ) ,
3841
3855
// LFS64 types have been removed in musl 1.2.4+
3842
3856
"off64_t" if musl => Some ( "off_t" . to_string ( ) ) ,
3857
+ "fsword_t" if uclibc => Some ( "__SWORD_TYPE" . to_string ( ) ) ,
3843
3858
_ => None ,
3844
3859
}
3845
3860
} ) ;
@@ -4095,6 +4110,13 @@ fn test_linux(target: &str) {
4095
4110
4096
4111
cfg. skip_const ( move |constant| {
4097
4112
let name = constant. ident ( ) ;
4113
+
4114
+ // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but
4115
+ // somewhere in the core libraries. uClibc wants 16k, but that's not enough.
4116
+ if l4re && name == "PTHREAD_STACK_MIN" {
4117
+ return true ;
4118
+ }
4119
+
4098
4120
if !gnu {
4099
4121
// Skip definitions from the kernel on non-glibc Linux targets.
4100
4122
// They're libc-independent, so we only need to check them on one
@@ -4274,7 +4296,7 @@ fn test_linux(target: &str) {
4274
4296
4275
4297
// FIXME(musl): on musl the pthread types are defined a little differently
4276
4298
// - these constants are used by the glibc implementation.
4277
- n if musl && n. contains ( "__SIZEOF_PTHREAD" ) => true ,
4299
+ n if ( musl || uclibc ) && n. contains ( "__SIZEOF_PTHREAD" ) => true ,
4278
4300
4279
4301
// FIXME(linux): It was extended to 4096 since glibc 2.31 (Linux 5.4).
4280
4302
// We should do so after a while.
@@ -4861,7 +4883,9 @@ fn test_linux(target: &str) {
4861
4883
4862
4884
ctest:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
4863
4885
4864
- test_linux_like_apis ( target) ;
4886
+ if !l4re {
4887
+ test_linux_like_apis ( target) ;
4888
+ }
4865
4889
}
4866
4890
4867
4891
// This function tests APIs that are incompatible to test when other APIs
0 commit comments