diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-02-02 22:04:02 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-02-07 21:49:45 +0100 |
| commit | 949a29adb9f400ebdc15aed2dd874c17ffa839cb (patch) | |
| tree | dfefa274a44ba25f08eb6013a6611a0be5b48c95 /cgcc | |
| parent | e6e60e370f4309431de9d488f6dc1fe96a976879 (diff) | |
| download | sparse-dev-949a29adb9f400ebdc15aed2dd874c17ffa839cb.tar.gz | |
predefs: add arch-specific predefines
Predefined macros like '__x86_64__', '__arm__', ... are used
in systems headers (and surely at other places too).
So, when appropriate, define the following symbols which seems
to be somehow needed by glibc:
m68k: __m68k__
mips: __mpis64, __mips
ppc: __ppc64__, __powerpc, __ppc__
riscv: __riscv__, __riscv_xlen__
s390: __zarch__
sparc: __sparc_v9__, __sparcv9
x86-64: __x86_64__, __x86_64
Also, the following symbols, which were previously only defined
in cgcc, are now defined in Sparse itself:
i386 __i386, __i386__
sparc __sparc, __sparc__, __arch64__, __sparc64__, __sparcv9__
s390 __s390__, __s390x__
ppc __PPC__, __powerpc__, __PPC64__, __powerpc64__
arm __arm__
arm64 __aarch64__
Note: these are only tested on i386, x86-64, arm, arm64,
mips64 (ABI O32), ppc, ppc64 (power7), ppc64el (power8)
and sparc64, most of them on a not-so-new OS version.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'cgcc')
| -rwxr-xr-x | cgcc | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -287,16 +287,16 @@ sub add_specs { " -D'__fastcall=__attribute__((__fastcall__))'" . " -D'__declspec(x)=__attribute__((x))'"; } elsif ($spec eq 'i386') { - return (' -D__i386=1 -D__i386__=1' . + return ( &float_types (1, 1, 21, [24,8], [53,11], [64,15])); } elsif ($spec eq 'sparc') { - return (' -D__sparc=1 -D__sparc__=1' . + return ( &integer_types (8, 16, 32, $m64 ? 64 : 32, 64) . &float_types (1, 1, 33, [24,8], [53,11], [113,15]) . &define_size_t ($m64 ? "long unsigned int" : "unsigned int") . ' -D__SIZEOF_POINTER__=' . ($m64 ? '8' : '4')); } elsif ($spec eq 'sparc64') { - return (' -D__sparc=1 -D__sparc__=1 -D__sparcv9__=1 -D__sparc64__=1 -D__arch64__=1 -D__LP64__=1' . + return ( &integer_types (8, 16, 32, 64, 64, 128) . &float_types (1, 1, 33, [24,8], [53,11], [113,15]) . &define_size_t ("long unsigned int") . @@ -304,25 +304,23 @@ sub add_specs { } elsif ($spec eq 'x86_64') { return &float_types (1, 1, 33, [24,8], [53,11], [113,15]); } elsif ($spec eq 'ppc') { - return (' -D__powerpc__=1 -D_BIG_ENDIAN -D_STRING_ARCH_unaligned=1' . + return (' -D_BIG_ENDIAN -D_STRING_ARCH_unaligned=1' . &integer_types (8, 16, 32, $m64 ? 64 : 32, 64) . &float_types (1, 1, 21, [24,8], [53,11], [113,15]) . &define_size_t ($m64 ? "long unsigned int" : "unsigned int") . ' -D__SIZEOF_POINTER__=' . ($m64 ? '8' : '4')); } elsif ($spec eq 'ppc64') { - return (' -D__powerpc__=1 -D__PPC__=1 -D_STRING_ARCH_unaligned=1' . - ' -D__powerpc64__=1 -D__PPC64__=1' . - ' -m64' . + return (' -D_STRING_ARCH_unaligned=1 -m64' . &float_types (1, 1, 21, [24,8], [53,11], [113,15])); } elsif ($spec eq 's390x') { - return (' -D__s390x__ -D__s390__ -D_BIG_ENDIAN' . + return (' -D_BIG_ENDIAN' . &integer_types (8, 16, 32, $m64 ? 64 : 32, 64) . &float_types (1, 1, 36, [24,8], [53,11], [113,15]) . &define_size_t ("long unsigned int") . ' -D__SIZEOF_POINTER__=' . ($m64 ? '8' : '4')); } elsif ($spec eq 'arm') { chomp (my $gccmachine = `$cc -dumpmachine`); - my $cppsymbols = ' -D__arm__=1 -m32'; + my $cppsymbols = ' -m32'; if ($gccmachine eq 'arm-linux-gnueabihf') { $cppsymbols .= ' -D__ARM_PCS_VFP=1'; @@ -331,7 +329,7 @@ sub add_specs { return ($cppsymbols . &float_types (1, 1, 36, [24,8], [53,11], [53, 11])); } elsif ($spec eq 'aarch64') { - return (' -D__aarch64__=1 -m64' . + return (' -m64' . &float_types (1, 1, 36, [24,8], [53,11], [113,15])); } elsif ($spec eq 'host_os_specs') { my $os = `uname -s`; |
