@@ -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.
@@ -3563,18 +3565,26 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) {
3563
3565
}
3564
3566
3565
3567
fn test_linux ( target : & str ) {
3566
- assert ! ( target. contains( "linux" ) ) ;
3568
+ assert ! ( target. contains( "linux" ) || target. contains( "l4re" ) ) ;
3569
+
3570
+ // target_os
3571
+ let linux = target. contains ( "linux" ) ;
3572
+ let l4re = target. contains ( "l4re" ) ;
3567
3573
3568
3574
// target_env
3569
3575
let gnu = target. contains ( "gnu" ) ;
3570
3576
let musl = target. contains ( "musl" ) || target. contains ( "ohos" ) ;
3571
3577
let uclibc = target. contains ( "uclibc" ) ;
3572
3578
3573
- match ( gnu, musl, uclibc) {
3574
- ( true , false , false ) => ( ) ,
3575
- ( false , true , false ) => ( ) ,
3576
- ( false , false , true ) => ( ) ,
3577
- ( _, _, _) => panic ! ( "linux target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}" ) ,
3579
+ match ( linux, gnu, musl, uclibc) {
3580
+ ( true , true , false , false ) => ( ) ,
3581
+ ( true , false , true , false ) => ( ) ,
3582
+ ( true , false , false , true ) => ( ) ,
3583
+ ( false , false , false , true ) => ( ) ,
3584
+ ( _, _, _, _) => panic ! (
3585
+ "{} target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}" ,
3586
+ if linux { "linux" } else { "l4re" }
3587
+ ) ,
3578
3588
}
3579
3589
3580
3590
let arm = target. contains ( "arm" ) ;
@@ -3608,6 +3618,9 @@ fn test_linux(target: &str) {
3608
3618
. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
3609
3619
3610
3620
config_gnu_bits ( target, & mut cfg) ;
3621
+ if l4re {
3622
+ cfg. flag ( "-Wno-unused-function" ) ;
3623
+ }
3611
3624
3612
3625
headers ! { cfg:
3613
3626
"ctype.h" ,
@@ -3626,11 +3639,12 @@ fn test_linux(target: &str) {
3626
3639
"libgen.h" ,
3627
3640
"limits.h" ,
3628
3641
"link.h" ,
3629
- "linux/sysctl.h" ,
3642
+ [ uclibc] : "linux/if_ether.h" ,
3643
+ [ !l4re] : "linux/sysctl.h" ,
3630
3644
"locale.h" ,
3631
3645
"malloc.h" ,
3632
3646
"mntent.h" ,
3633
- "mqueue.h" ,
3647
+ [ !l4re ] : "mqueue.h" ,
3634
3648
"net/ethernet.h" ,
3635
3649
"net/if.h" ,
3636
3650
"net/if_arp.h" ,
@@ -3640,6 +3654,7 @@ fn test_linux(target: &str) {
3640
3654
"netinet/ip.h" ,
3641
3655
"netinet/tcp.h" ,
3642
3656
"netinet/udp.h" ,
3657
+ [ l4re] : "netpacket/packet.h" ,
3643
3658
"poll.h" ,
3644
3659
"pthread.h" ,
3645
3660
"pty.h" ,
@@ -3650,43 +3665,44 @@ fn test_linux(target: &str) {
3650
3665
"semaphore.h" ,
3651
3666
"shadow.h" ,
3652
3667
"signal.h" ,
3653
- "spawn.h" ,
3654
- "stddef.h" ,
3668
+ [ !l4re ] : "spawn.h" ,
3669
+ [ !l4re ] : "stddef.h" ,
3655
3670
"stdint.h" ,
3656
3671
"stdio.h" ,
3657
3672
"stdlib.h" ,
3658
3673
"string.h" ,
3659
- "sys/epoll.h" ,
3660
- "sys/eventfd.h" ,
3674
+ [ l4re] : "sys/auxv.h" ,
3675
+ [ !l4re] : "sys/epoll.h" ,
3676
+ [ !l4re] : "sys/eventfd.h" ,
3661
3677
"sys/file.h" ,
3662
- "sys/fsuid.h" ,
3663
- "sys/klog.h" ,
3664
- "sys/inotify.h" ,
3678
+ [ !l4re ] : "sys/fsuid.h" ,
3679
+ [ !l4re ] : "sys/klog.h" ,
3680
+ [ !l4re ] : "sys/inotify.h" ,
3665
3681
"sys/ioctl.h" ,
3666
3682
"sys/ipc.h" ,
3667
3683
"sys/mman.h" ,
3668
3684
"sys/mount.h" ,
3669
- "sys/msg.h" ,
3670
- "sys/personality.h" ,
3685
+ [ !l4re ] : "sys/msg.h" ,
3686
+ [ !l4re ] : "sys/personality.h" ,
3671
3687
"sys/prctl.h" ,
3672
- "sys/ptrace.h" ,
3673
- "sys/quota.h" ,
3674
- "sys/random.h" ,
3675
- "sys/reboot.h" ,
3688
+ [ !l4re ] : "sys/ptrace.h" ,
3689
+ [ !l4re ] : "sys/quota.h" ,
3690
+ [ !l4re ] : "sys/random.h" ,
3691
+ [ !l4re ] : "sys/reboot.h" ,
3676
3692
"sys/resource.h" ,
3677
3693
"sys/sem.h" ,
3678
- "sys/sendfile.h" ,
3694
+ [ !l4re ] : "sys/sendfile.h" ,
3679
3695
"sys/shm.h" ,
3680
- "sys/signalfd.h" ,
3696
+ [ !l4re ] : "sys/signalfd.h" ,
3681
3697
"sys/socket.h" ,
3682
3698
"sys/stat.h" ,
3683
3699
"sys/statvfs.h" ,
3684
- "sys/swap.h" ,
3700
+ [ !l4re ] : "sys/swap.h" ,
3685
3701
"sys/syscall.h" ,
3686
3702
"sys/time.h" ,
3687
- "sys/timerfd.h" ,
3703
+ [ !l4re ] : "sys/timerfd.h" ,
3688
3704
"sys/times.h" ,
3689
- "sys/timex.h" ,
3705
+ [ !l4re ] : "sys/timex.h" ,
3690
3706
"sys/types.h" ,
3691
3707
"sys/uio.h" ,
3692
3708
"sys/un.h" ,
@@ -3708,12 +3724,12 @@ fn test_linux(target: &str) {
3708
3724
// ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162
3709
3725
// Also unavailable on gnueabihf with glibc 2.30.
3710
3726
// https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1
3711
- [ ( x86_64 || x86_32 || arm) && !gnueabihf] : "sys/io.h" ,
3727
+ [ ( x86_64 || x86_32 || arm) && !gnueabihf && !l4re ] : "sys/io.h" ,
3712
3728
// `sys/reg.h` is only available on x86 and x86_64
3713
- [ x86_64 || x86_32] : "sys/reg.h" ,
3729
+ [ ( x86_64 || x86_32) && !l4re ] : "sys/reg.h" ,
3714
3730
// sysctl system call is deprecated and not available on musl
3715
3731
// It is also unsupported in x32, deprecated since glibc 2.30:
3716
- [ !( x32 || musl || gnu) ] : "sys/sysctl.h" ,
3732
+ [ !( x32 || musl || gnu || l4re ) ] : "sys/sysctl.h" ,
3717
3733
// <execinfo.h> is not supported by musl:
3718
3734
// https://www.openwall.com/lists/musl/2015/04/09/3
3719
3735
// <execinfo.h> is not present on uclibc.
@@ -3723,11 +3739,11 @@ fn test_linux(target: &str) {
3723
3739
// Include linux headers at the end:
3724
3740
headers ! {
3725
3741
cfg:
3726
- [ loongarch64 || riscv64] : "asm/hwcap.h" ,
3727
- "asm/mman.h" ,
3742
+ [ ( loongarch64 || riscv64) && !l4re ] : "asm/hwcap.h" ,
3743
+ [ !l4re ] : "asm/mman.h" ,
3728
3744
}
3729
3745
3730
- if !wasm32 {
3746
+ if !wasm32 && !l4re {
3731
3747
headers ! { cfg:
3732
3748
[ gnu] : "linux/aio_abi.h" ,
3733
3749
"linux/can.h" ,
@@ -3745,7 +3761,6 @@ fn test_linux(target: &str) {
3745
3761
"linux/if.h" ,
3746
3762
"linux/if_addr.h" ,
3747
3763
"linux/if_alg.h" ,
3748
- "linux/if_ether.h" ,
3749
3764
"linux/if_packet.h" ,
3750
3765
"linux/if_tun.h" ,
3751
3766
"linux/if_xdp.h" ,
@@ -3792,7 +3807,6 @@ fn test_linux(target: &str) {
3792
3807
"linux/wait.h" ,
3793
3808
"linux/wireless.h" ,
3794
3809
"sys/fanotify.h" ,
3795
- // <sys/auxv.h> is not present on uclibc
3796
3810
[ !uclibc] : "sys/auxv.h" ,
3797
3811
[ gnu || musl] : "linux/close_range.h" ,
3798
3812
}
@@ -3801,7 +3815,7 @@ fn test_linux(target: &str) {
3801
3815
// note: aio.h must be included before sys/mount.h
3802
3816
headers ! {
3803
3817
cfg:
3804
- "sys/xattr.h" ,
3818
+ [ !l4re ] : "sys/xattr.h" ,
3805
3819
"sys/sysinfo.h" ,
3806
3820
// AIO is not supported by uclibc:
3807
3821
[ !uclibc] : "aio.h" ,
@@ -3831,10 +3845,11 @@ fn test_linux(target: &str) {
3831
3845
3832
3846
cfg. rename_type ( move |ty| {
3833
3847
match ty {
3834
- "Ioctl" if gnu => Some ( "unsigned long" . to_string ( ) ) ,
3848
+ "Ioctl" if gnu || uclibc => Some ( "unsigned long" . to_string ( ) ) ,
3835
3849
"Ioctl" => Some ( "int" . to_string ( ) ) ,
3836
3850
// LFS64 types have been removed in musl 1.2.4+
3837
3851
"off64_t" if musl => Some ( "off_t" . to_string ( ) ) ,
3852
+ "fsword_t" if uclibc => Some ( "__SWORD_TYPE" . to_string ( ) ) ,
3838
3853
_ => None ,
3839
3854
}
3840
3855
} ) ;
@@ -4090,6 +4105,13 @@ fn test_linux(target: &str) {
4090
4105
4091
4106
cfg. skip_const ( move |constant| {
4092
4107
let name = constant. ident ( ) ;
4108
+
4109
+ // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but
4110
+ // somewhere in the core libraries. uClibc wants 16k, but that's not enough.
4111
+ if l4re && name == "PTHREAD_STACK_MIN" {
4112
+ return true ;
4113
+ }
4114
+
4093
4115
if !gnu {
4094
4116
// Skip definitions from the kernel on non-glibc Linux targets.
4095
4117
// They're libc-independent, so we only need to check them on one
@@ -4269,7 +4291,7 @@ fn test_linux(target: &str) {
4269
4291
4270
4292
// FIXME(musl): on musl the pthread types are defined a little differently
4271
4293
// - these constants are used by the glibc implementation.
4272
- n if musl && n. contains ( "__SIZEOF_PTHREAD" ) => true ,
4294
+ n if ( musl || uclibc ) && n. contains ( "__SIZEOF_PTHREAD" ) => true ,
4273
4295
4274
4296
// FIXME(linux): It was extended to 4096 since glibc 2.31 (Linux 5.4).
4275
4297
// We should do so after a while.
@@ -4856,7 +4878,9 @@ fn test_linux(target: &str) {
4856
4878
4857
4879
ctest:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
4858
4880
4859
- test_linux_like_apis ( target) ;
4881
+ if !l4re {
4882
+ test_linux_like_apis ( target) ;
4883
+ }
4860
4884
}
4861
4885
4862
4886
// This function tests APIs that are incompatible to test when other APIs
0 commit comments