[cfe-commits] r101989 - in /cfe/trunk/lib: Basic/Targets.cpp Frontend/InitPreprocessor.cpp

Douglas Gregor dgregor at apple.com
Tue Apr 20 22:52:38 PDT 2010


Author: dgregor
Date: Wed Apr 21 00:52:38 2010
New Revision: 101989

URL: http://llvm.org/viewvc/llvm-project?rev=101989&view=rev
Log:
Sink the _GNU_SOURCE definition down into the target configuration,
and only define it where we know we need it---Linux and Cygwin. Thanks
to Chris for the prodding.

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=101989&r1=101988&r2=101989&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Apr 21 00:52:38 2010
@@ -219,6 +219,8 @@
     Builder.defineMacro("__ELF__");
     if (Opts.POSIXThreads)
       Builder.defineMacro("_REENTRANT");
+    if (Opts.CPlusPlus)
+      Builder.defineMacro("_GNU_SOURCE");
   }
 public:
   LinuxTargetInfo(const std::string& triple)
@@ -1221,6 +1223,8 @@
     Builder.defineMacro("__CYGWIN__");
     Builder.defineMacro("__CYGWIN32__");
     DefineStd(Builder, "unix", Opts);
+    if (Opts.CPlusPlus)
+      Builder.defineMacro("_GNU_SOURCE");
   }
 };
 } // end anonymous namespace

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=101989&r1=101988&r2=101989&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Apr 21 00:52:38 2010
@@ -294,30 +294,6 @@
       //   C++ translation unit.
       Builder.defineMacro("__cplusplus", "199711L");
     Builder.defineMacro("__private_extern__", "extern");
-
-    // Define _GNU_SOURCE on platforms where we expect to use glibc.
-    switch (TI.getTriple().getOS()) {
-    case llvm::Triple::Cygwin:
-    case llvm::Triple::MinGW64:
-    case llvm::Triple::MinGW32:
-    case llvm::Triple::Linux:
-    case llvm::Triple::Solaris:
-    case llvm::Triple::AuroraUX:
-      Builder.defineMacro("_GNU_SOURCE");
-      break;
-
-    case llvm::Triple::Darwin:
-    case llvm::Triple::DragonFly:
-    case llvm::Triple::FreeBSD:
-    case llvm::Triple::UnknownOS:
-    case llvm::Triple::Lv2:
-    case llvm::Triple::NetBSD:
-    case llvm::Triple::OpenBSD:
-    case llvm::Triple::Psp:
-    case llvm::Triple::Win32:
-    case llvm::Triple::Haiku:
-      break;
-    }
   }
 
   if (LangOpts.Microsoft) {





More information about the cfe-commits mailing list