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 {
459459 self . target_cfg ( ) . endian == Endian :: Big
460460 }
461461
462+ pub fn is_little_endian ( & self ) -> bool {
463+ self . target_cfg ( ) . endian == Endian :: Little
464+ }
465+
462466 pub fn get_pointer_width ( & self ) -> u32 {
463467 * & self . target_cfg ( ) . pointer_width
464468 }
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
5858 "ignore-elf" ,
5959 "ignore-emscripten" ,
6060 "ignore-endian-big" ,
61+ "ignore-endian-little" ,
6162 "ignore-enzyme" ,
6263 "ignore-freebsd" ,
6364 "ignore-fuchsia" ,
Original file line number Diff line number Diff line change @@ -205,6 +205,11 @@ fn parse_cfg_name_directive<'a>(
205205 condition: config. is_big_endian( ) ,
206206 message: "on big-endian targets" ,
207207 }
208+ condition ! {
209+ name: "endian-little" ,
210+ condition: config. is_little_endian( ) ,
211+ message: "on little-endian targets" ,
212+ }
208213 condition ! {
209214 name: format!( "stage{}" , config. stage) . as_str( ) ,
210215 allowed_names: & [ "stage0" , "stage1" , "stage2" ] ,
Original file line number Diff line number Diff line change @@ -689,6 +689,22 @@ fn is_big_endian() {
689689 }
690690}
691691
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+
692708#[ test]
693709fn pointer_width ( ) {
694710 let widths = [
You can’t perform that action at this time.
0 commit comments