* beneficial refactoring; use system.Endianness

* closes #18433
This commit is contained in:
Andreas Rumpf 2021-07-13 12:44:29 +02:00 • committed by GitHub
commit b3aca78e22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 6 deletions

View file

@ -592,8 +592,8 @@ proc isDefined*(conf: ConfigRef; symbol: string): bool =
result = conf.target.targetOS == osNintendoSwitch
of "freertos", "lwip":
result = conf.target.targetOS == osFreeRTOS
of "littleendian": result = CPU[conf.target.targetCPU].endian == platform.littleEndian
of "bigendian": result = CPU[conf.target.targetCPU].endian == platform.bigEndian
of "littleendian": result = CPU[conf.target.targetCPU].endian == littleEndian
of "bigendian": result = CPU[conf.target.targetCPU].endian == bigEndian
of "cpu8": result = CPU[conf.target.targetCPU].bit == 8
of "cpu16": result = CPU[conf.target.targetCPU].bit == 16
of "cpu32": result = CPU[conf.target.targetCPU].bit == 32

View file

@ -196,13 +196,11 @@ type
cpuSparc64, cpuMips64, cpuMips64el, cpuRiscV32, cpuRiscV64, cpuEsp, cpuWasm32
type
TEndian* = enum
littleEndian, bigEndian
TInfoCPU* = tuple[name: string, intSize: int, endian: TEndian,
TInfoCPU* = tuple[name: string, intSize: int, endian: Endianness,
floatSize, bit: int]
const
EndianToStr*: array[TEndian, string] = ["littleEndian", "bigEndian"]
EndianToStr*: array[Endianness, string] = ["littleEndian", "bigEndian"]
CPU*: array[succ(low(TSystemCPU))..high(TSystemCPU), TInfoCPU] = [
(name: "i386", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32),
(name: "m68k", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),