]> granicus.if.org Git - clang/commitdiff
[OpenBSD] Add type sign information for OpenBSD
authorRenato Golin <renato.golin@linaro.org>
Thu, 22 Sep 2016 19:28:20 +0000 (19:28 +0000)
committerRenato Golin <renato.golin@linaro.org>
Thu, 22 Sep 2016 19:28:20 +0000 (19:28 +0000)
Like NetBSD, OpenBSD prefers having a consistent set of typedefs
across the architectures it supports over strictly following the ARM
ABIs.  The diff below makes sure that clang's view of those types
matches OpenBSD's system header files.  It also adds a test that
checks the relevant types on all OpenBSD platforms that clang works
on.  Hopefully we can add mips64 and powerpc to that list in the
future.

Patch by Mark Kettenis <mark.kettenis@xs4all.nl>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282184 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
test/Preprocessor/init.c

index 62ecd1e28ce6d029defbd128008956b89c3c4dcd..7843fde5c45626536b6e1899d1f5a368fb70b211 100644 (file)
@@ -4679,8 +4679,10 @@ class ARMTargetInfo : public TargetInfo {
     DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
     const llvm::Triple &T = getTriple();
 
-    // size_t is unsigned long on MachO-derived environments, NetBSD and Bitrig.
+    // size_t is unsigned long on MachO-derived environments, NetBSD,
+    // OpenBSD and Bitrig.
     if (T.isOSBinFormatMachO() || T.getOS() == llvm::Triple::NetBSD ||
+        T.getOS() == llvm::Triple::OpenBSD ||
         T.getOS() == llvm::Triple::Bitrig)
       SizeType = UnsignedLong;
     else
@@ -4688,6 +4690,7 @@ class ARMTargetInfo : public TargetInfo {
 
     switch (T.getOS()) {
     case llvm::Triple::NetBSD:
+    case llvm::Triple::OpenBSD:
       WCharType = SignedInt;
       break;
     case llvm::Triple::Win32:
@@ -4885,6 +4888,7 @@ public:
 
     switch (getTriple().getOS()) {
     case llvm::Triple::NetBSD:
+    case llvm::Triple::OpenBSD:
       PtrDiffType = SignedLong;
       break;
     default:
index 5a0b268d84721f6c55fcaad6e41eacb1cff53c3f..16342332b84702874d5a899e1decbe80c1ab65e0 100644 (file)
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=amd64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// OPENBSD:#define __ELF__ 1
+// OPENBSD:#define __INT16_TYPE__ short
+// OPENBSD:#define __INT32_TYPE__ int
+// OPENBSD:#define __INT64_TYPE__ long long int
+// OPENBSD:#define __INT8_TYPE__ signed char
+// OPENBSD:#define __INTMAX_TYPE__ long long int
+// OPENBSD:#define __INTPTR_TYPE__ long int
+// OPENBSD:#define __OpenBSD__ 1
+// OPENBSD:#define __PTRDIFF_TYPE__ long int
+// OPENBSD:#define __SIZE_TYPE__ long unsigned int
+// OPENBSD:#define __UINT16_TYPE__ unsigned short
+// OPENBSD:#define __UINT32_TYPE__ unsigned int
+// OPENBSD:#define __UINT64_TYPE__ long long unsigned int
+// OPENBSD:#define __UINT8_TYPE__ unsigned char
+// OPENBSD:#define __UINTMAX_TYPE__ long long unsigned int
+// OPENBSD:#define __UINTPTR_TYPE__ long unsigned int
+// OPENBSD:#define __WCHAR_TYPE__ int
+// OPENBSD:#define __WINT_TYPE__ int
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s
 // PPC64-FREEBSD-NOT: #define __LONG_DOUBLE_128__ 1
 //