r294332 - Revert "Basic: match GCC behaviour for SuS macro"

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 7 11:00:06 PST 2017


Author: compnerd
Date: Tue Feb  7 13:00:06 2017
New Revision: 294332

URL: http://llvm.org/viewvc/llvm-project?rev=294332&view=rev
Log:
Revert "Basic: match GCC behaviour for SuS macro"

This reverts commit SVN r294148.  Seems that it was mistaken, and GCC
does still define `__unix` and `unix` when in GNU mode.

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/test/Driver/le32-unknown-nacl.cpp
    cfe/trunk/test/Driver/le64-unknown-unknown.cpp
    cfe/trunk/test/Driver/mipsel-nacl-defines.cpp
    cfe/trunk/test/Driver/x86_64-nacl-defines.cpp
    cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294332&r1=294331&r2=294332&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Feb  7 13:00:06 2017
@@ -303,10 +303,10 @@ protected:
     // DragonFly defines; list based off of gcc output
     Builder.defineMacro("__DragonFly__");
     Builder.defineMacro("__DragonFly_cc_version", "100001");
-    Builder.defineMacro("__unix__");
     Builder.defineMacro("__ELF__");
     Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
     Builder.defineMacro("__tune_i386__");
+    DefineStd(Builder, "unix", Opts);
   }
 public:
   DragonFlyBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
@@ -343,7 +343,7 @@ protected:
     Builder.defineMacro("__FreeBSD__", Twine(Release));
     Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
     Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     Builder.defineMacro("__ELF__");
 
     // On FreeBSD, wchar_t contains the number of the code point as
@@ -388,9 +388,9 @@ protected:
                     MacroBuilder &Builder) const override {
     // GNU/kFreeBSD defines; list based off of gcc output
 
+    DefineStd(Builder, "unix", Opts);
     Builder.defineMacro("__FreeBSD_kernel__");
     Builder.defineMacro("__GLIBC__");
-    Builder.defineMacro("__unix__");
     Builder.defineMacro("__ELF__");
     if (Opts.POSIXThreads)
       Builder.defineMacro("_REENTRANT");
@@ -410,8 +410,8 @@ protected:
                     MacroBuilder &Builder) const override {
     // Haiku defines; list based off of gcc output
     Builder.defineMacro("__HAIKU__");
-    Builder.defineMacro("__unix__");
     Builder.defineMacro("__ELF__");
+    DefineStd(Builder, "unix", Opts);
   }
 public:
   HaikuTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
@@ -440,8 +440,8 @@ protected:
     Builder.defineMacro("_EM_LSIZE", "4");
     Builder.defineMacro("_EM_FSIZE", "4");
     Builder.defineMacro("_EM_DSIZE", "8");
-    Builder.defineMacro("__unix__");
     Builder.defineMacro("__ELF__");
+    DefineStd(Builder, "unix", Opts);
   }
 public:
   MinixTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
@@ -455,7 +455,7 @@ protected:
   void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
                     MacroBuilder &Builder) const override {
     // Linux defines; list based off of gcc output
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     DefineStd(Builder, "linux", Opts);
     Builder.defineMacro("__gnu_linux__");
     Builder.defineMacro("__ELF__");
@@ -541,7 +541,7 @@ protected:
     // OpenBSD defines; list based off of gcc output
 
     Builder.defineMacro("__OpenBSD__");
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     Builder.defineMacro("__ELF__");
     if (Opts.POSIXThreads)
       Builder.defineMacro("_REENTRANT");
@@ -578,7 +578,7 @@ protected:
     // Bitrig defines; list based off of gcc output
 
     Builder.defineMacro("__Bitrig__");
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     Builder.defineMacro("__ELF__");
     if (Opts.POSIXThreads)
       Builder.defineMacro("_REENTRANT");
@@ -652,7 +652,7 @@ protected:
     Builder.defineMacro("__FreeBSD__", "9");
     Builder.defineMacro("__FreeBSD_cc_version", "900001");
     Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     Builder.defineMacro("__ELF__");
     Builder.defineMacro("__ORBIS__");
   }
@@ -683,8 +683,8 @@ class SolarisTargetInfo : public OSTarge
 protected:
   void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
                     MacroBuilder &Builder) const override {
-    Builder.defineMacro("__unix__");
     DefineStd(Builder, "sun", Opts);
+    DefineStd(Builder, "unix", Opts);
     Builder.defineMacro("__ELF__");
     Builder.defineMacro("__svr4__");
     Builder.defineMacro("__SVR4");
@@ -786,7 +786,7 @@ protected:
     if (Opts.CPlusPlus)
       Builder.defineMacro("_GNU_SOURCE");
 
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     Builder.defineMacro("__ELF__");
     Builder.defineMacro("__native_client__");
   }
@@ -4455,7 +4455,7 @@ public:
     Builder.defineMacro("__CYGWIN__");
     Builder.defineMacro("__CYGWIN32__");
     addCygMingDefines(Opts, Builder);
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     if (Opts.CPlusPlus)
       Builder.defineMacro("_GNU_SOURCE");
   }
@@ -4750,7 +4750,7 @@ public:
     Builder.defineMacro("__CYGWIN__");
     Builder.defineMacro("__CYGWIN64__");
     addCygMingDefines(Opts, Builder);
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     if (Opts.CPlusPlus)
       Builder.defineMacro("_GNU_SOURCE");
 
@@ -5865,7 +5865,7 @@ public:
     Builder.defineMacro("_ARM_");
     Builder.defineMacro("__CYGWIN__");
     Builder.defineMacro("__CYGWIN32__");
-    Builder.defineMacro("__unix__");
+    DefineStd(Builder, "unix", Opts);
     if (Opts.CPlusPlus)
       Builder.defineMacro("_GNU_SOURCE");
   }
@@ -8040,8 +8040,8 @@ public:
 
   void getTargetDefines(const LangOptions &Opts,
                         MacroBuilder &Builder) const override {
+    DefineStd(Builder, "unix", Opts);
     defineCPUMacros(Builder, "le64", /*Tuning=*/false);
-    Builder.defineMacro("__unix__");
     Builder.defineMacro("__ELF__");
   }
   ArrayRef<Builtin::Info> getTargetBuiltins() const override {

Modified: cfe/trunk/test/Driver/le32-unknown-nacl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/le32-unknown-nacl.cpp?rev=294332&r1=294331&r2=294332&view=diff
==============================================================================
--- cfe/trunk/test/Driver/le32-unknown-nacl.cpp (original)
+++ cfe/trunk/test/Driver/le32-unknown-nacl.cpp Tue Feb  7 13:00:06 2017
@@ -60,9 +60,9 @@ void __le32__defined() {}
 void __pnacl__defined() {}
 #endif
 
-// CHECK: __unix__defined
-#ifdef __unix__
-void __unix__defined() {}
+// CHECK: unixdefined
+#ifdef unix
+void unixdefined() {}
 #endif
 
 // CHECK: __ELF__defined

Modified: cfe/trunk/test/Driver/le64-unknown-unknown.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/le64-unknown-unknown.cpp?rev=294332&r1=294331&r2=294332&view=diff
==============================================================================
--- cfe/trunk/test/Driver/le64-unknown-unknown.cpp (original)
+++ cfe/trunk/test/Driver/le64-unknown-unknown.cpp Tue Feb  7 13:00:06 2017
@@ -54,6 +54,16 @@ void __le64defined() {}
 void __le64__defined() {}
 #endif
 
+// CHECK: unixdefined
+#ifdef unix
+void unixdefined() {}
+#endif
+
+// CHECK: __unixdefined
+#ifdef __unix
+void __unixdefined() {}
+#endif
+
 // CHECK: __unix__defined
 #ifdef __unix__
 void __unix__defined() {}

Modified: cfe/trunk/test/Driver/mipsel-nacl-defines.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mipsel-nacl-defines.cpp?rev=294332&r1=294331&r2=294332&view=diff
==============================================================================
--- cfe/trunk/test/Driver/mipsel-nacl-defines.cpp (original)
+++ cfe/trunk/test/Driver/mipsel-nacl-defines.cpp Tue Feb  7 13:00:06 2017
@@ -21,9 +21,9 @@ void _mipsdefined() {}
 void __native_client__defined() {}
 #endif
 
-// CHECK: __unix__defined
-#ifdef __unix__
-void __unix__defined() {}
+// CHECK: unixdefined
+#ifdef unix
+void unixdefined() {}
 #endif
 
 // CHECK: __ELF__defined

Modified: cfe/trunk/test/Driver/x86_64-nacl-defines.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86_64-nacl-defines.cpp?rev=294332&r1=294331&r2=294332&view=diff
==============================================================================
--- cfe/trunk/test/Driver/x86_64-nacl-defines.cpp (original)
+++ cfe/trunk/test/Driver/x86_64-nacl-defines.cpp Tue Feb  7 13:00:06 2017
@@ -21,9 +21,9 @@ void __native_client__defined() {}
 void __x86_64__defined() {}
 #endif
 
-// CHECK: __unix__defined
-#ifdef __unix__
-void __unix__defined() {}
+// CHECK: unixdefined
+#ifdef unix
+void unixdefined() {}
 #endif
 
 // CHECK: __ELF__defined

Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=294332&r1=294331&r2=294332&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Feb  7 13:00:06 2017
@@ -8462,6 +8462,7 @@
 // PS4:#define __WINT_WIDTH__ 32
 // PS4:#define __amd64 1
 // PS4:#define __amd64__ 1
+// PS4:#define __unix 1
 // PS4:#define __unix__ 1
 // PS4:#define __x86_64 1
 // PS4:#define __x86_64__ 1
@@ -8859,6 +8860,7 @@
 // WEBASSEMBLY32-NOT:#define __wasm_simd128__
 // WEBASSEMBLY32-NOT:#define __wasm_simd256__
 // WEBASSEMBLY32-NOT:#define __wasm_simd512__
+// WEBASSEMBLY32-NOT:#define __unix
 // WEBASSEMBLY32-NOT:#define __unix__
 // WEBASSEMBLY32-NEXT:#define __wasm 1
 // WEBASSEMBLY32-NEXT:#define __wasm32 1
@@ -9174,6 +9176,7 @@
 // WEBASSEMBLY64-NOT:#define __wasm_simd128__
 // WEBASSEMBLY64-NOT:#define __wasm_simd256__
 // WEBASSEMBLY64-NOT:#define __wasm_simd512__
+// WEBASSEMBLY64-NOT:#define __unix
 // WEBASSEMBLY64-NOT:#define __unix__
 // WEBASSEMBLY64-NEXT:#define __wasm 1
 // WEBASSEMBLY64-NOT:#define __wasm32




More information about the cfe-commits mailing list