diff options
author | Marcus Comstedt <marcus@mc.pp.se> | 2019-09-15 12:30:03 +0200 |
---|---|---|
committer | Marcus Comstedt <marcus@mc.pp.se> | 2019-09-15 12:30:03 +0200 |
commit | 3d9ce8836c4c82fdb7f74ef3def1c4c85a0e1a1c (patch) | |
tree | ee399e4911036fcd7ce12c3427270e2f0aacd21a /bba | |
parent | dd40c41ffc42d487c54d14fb716f0464c05fece9 (diff) | |
download | nextpnr-3d9ce8836c4c82fdb7f74ef3def1c4c85a0e1a1c.tar.gz nextpnr-3d9ce8836c4c82fdb7f74ef3def1c4c85a0e1a1c.tar.bz2 nextpnr-3d9ce8836c4c82fdb7f74ef3def1c4c85a0e1a1c.zip |
bba: Require explicit endianness flag, and supply it
Signed-off-by: Marcus Comstedt <marcus@mc.pp.se>
Diffstat (limited to 'bba')
-rw-r--r-- | bba/bba.cmake | 8 | ||||
-rw-r--r-- | bba/main.cc | 12 |
2 files changed, 12 insertions, 8 deletions
diff --git a/bba/bba.cmake b/bba/bba.cmake index 3e094277..a6995ca3 100644 --- a/bba/bba.cmake +++ b/bba/bba.cmake @@ -11,3 +11,11 @@ ENDIF(NOT CMAKE_CROSSCOMPILING) IF(NOT CMAKE_CROSSCOMPILING) EXPORT(TARGETS bbasm FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake ) ENDIF(NOT CMAKE_CROSSCOMPILING) + +include(TestBigEndian) +TEST_BIG_ENDIAN(IS_BIG_ENDIAN) +if(IS_BIG_ENDIAN) + set(BBASM_ENDIAN_FLAG "--be") +else() + set(BBASM_ENDIAN_FLAG "--le") +endif() diff --git a/bba/main.cc b/bba/main.cc index b9cf6d8e..d4d16e12 100644 --- a/bba/main.cc +++ b/bba/main.cc @@ -66,12 +66,6 @@ const char *skipWhitespace(const char *p) return p; } -bool testBigEndian() -{ - int n = 1; - return !*(const char *)&n; -} - int main(int argc, char **argv) { bool debug = false; @@ -115,8 +109,10 @@ int main(int argc, char **argv) bigEndian = true; else if (vm.count("le")) bigEndian = false; - else - bigEndian = testBigEndian(); + else { + printf("Endian parameter is mandatory\n"); + exit(-1); + } if (vm.count("c")) writeC = true; |