[cfe-commits] patch: NetBSD support in Targets.cpp
Krister Walfridsson
krister.walfridsson at gmail.com
Mon Jul 13 04:17:34 PDT 2009
The attached patch add NetBSD support for X86_64 and X86_32.
The NetBSD gcc has never defined "unix" and "__unix", so I have not
added them for clang either.
/Krister
-------------- next part --------------
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp (revision 75441)
+++ lib/Basic/Targets.cpp (working copy)
@@ -321,6 +321,24 @@
}
};
+// NetBSD Target
+template<typename Target>
+class NetBSDTargetInfo : public OSTargetInfo<Target> {
+protected:
+ virtual void getOSDefines(const LangOptions &Opts, const char *Triple,
+ std::vector<char> &Defs) const {
+ // NetBSD defines; list based off of gcc output
+ Define(Defs, "__NetBSD__", "1");
+ Define(Defs, "__unix__", "1");
+ Define(Defs, "__ELF__", "1");
+ }
+public:
+ NetBSDTargetInfo(const std::string &triple)
+ : OSTargetInfo<Target>(triple) {
+ this->UserLabelPrefix = "";
+ }
+};
+
// OpenBSD Target
template<typename Target>
class OpenBSDTargetInfo : public OSTargetInfo<Target> {
@@ -1372,6 +1390,7 @@
// Additions and corrections are welcome.
bool isDarwin = T.find("-darwin") != std::string::npos;
bool isDragonFly = T.find("-dragonfly") != std::string::npos;
+ bool isNetBSD = T.find("-netbsd") != std::string::npos;
bool isOpenBSD = T.find("-openbsd") != std::string::npos;
bool isFreeBSD = T.find("-freebsd") != std::string::npos;
bool isSolaris = T.find("-solaris") != std::string::npos;
@@ -1411,6 +1430,8 @@
return new DarwinX86_64TargetInfo(T);
if (isLinux)
return new LinuxTargetInfo<X86_64TargetInfo>(T);
+ if (isNetBSD)
+ return new NetBSDTargetInfo<X86_64TargetInfo>(T);
if (isOpenBSD)
return new OpenBSDX86_64TargetInfo(T);
if (isFreeBSD)
@@ -1433,6 +1454,8 @@
return new LinuxTargetInfo<X86_32TargetInfo>(T);
if (isDragonFly)
return new DragonFlyBSDTargetInfo<X86_32TargetInfo>(T);
+ if (isNetBSD)
+ return new NetBSDTargetInfo<X86_32TargetInfo>(T);
if (isOpenBSD)
return new OpenBSDI386TargetInfo(T);
if (isFreeBSD)
More information about the cfe-commits
mailing list