File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed
src/tools/compiletest/src Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -459,6 +459,10 @@ impl Config {
459
459
self . target_cfg ( ) . endian == Endian :: Big
460
460
}
461
461
462
+ pub fn is_little_endian ( & self ) -> bool {
463
+ self . target_cfg ( ) . endian == Endian :: Little
464
+ }
465
+
462
466
pub fn get_pointer_width ( & self ) -> u32 {
463
467
* & self . target_cfg ( ) . pointer_width
464
468
}
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
58
58
"ignore-elf" ,
59
59
"ignore-emscripten" ,
60
60
"ignore-endian-big" ,
61
+ "ignore-endian-little" ,
61
62
"ignore-enzyme" ,
62
63
"ignore-freebsd" ,
63
64
"ignore-fuchsia" ,
Original file line number Diff line number Diff line change @@ -205,6 +205,11 @@ fn parse_cfg_name_directive<'a>(
205
205
condition: config. is_big_endian( ) ,
206
206
message: "on big-endian targets" ,
207
207
}
208
+ condition ! {
209
+ name: "endian-little" ,
210
+ condition: config. is_little_endian( ) ,
211
+ message: "on little-endian targets" ,
212
+ }
208
213
condition ! {
209
214
name: format!( "stage{}" , config. stage) . as_str( ) ,
210
215
allowed_names: & [ "stage0" , "stage1" , "stage2" ] ,
Original file line number Diff line number Diff line change @@ -689,6 +689,22 @@ fn is_big_endian() {
689
689
}
690
690
}
691
691
692
+ #[ test]
693
+ fn is_little_endian ( ) {
694
+ let endians = [
695
+ ( "x86_64-unknown-linux-gnu" , true ) ,
696
+ ( "bpfeb-unknown-none" , false ) ,
697
+ ( "m68k-unknown-linux-gnu" , false ) ,
698
+ ( "aarch64_be-unknown-linux-gnu" , false ) ,
699
+ ( "powerpc64-unknown-linux-gnu" , false ) ,
700
+ ] ;
701
+ for ( target, is_little) in endians {
702
+ let config = cfg ( ) . target ( target) . build ( ) ;
703
+ assert_eq ! ( config. is_little_endian( ) , is_little, "{target} {is_little}" ) ;
704
+ assert_eq ! ( check_ignore( & config, "//@ ignore-endian-little" ) , is_little) ;
705
+ }
706
+ }
707
+
692
708
#[ test]
693
709
fn pointer_width ( ) {
694
710
let widths = [
You can’t perform that action at this time.
0 commit comments