[PATCH] Properly handle glibc (that is, GNU environment) cases.
Thomas Schwinge
thomas at codesourcery.com
Mon Mar 25 09:04:21 PDT 2013
---
lib/Support/DynamicLibrary.cpp | 4 +--
lib/Target/TargetLibraryInfo.cpp | 69 +++++++++++++++++++++++++++++---------
2 files changed, 56 insertions(+), 17 deletions(-)
diff --git lib/Support/DynamicLibrary.cpp lib/Support/DynamicLibrary.cpp
index f14cb45..b398809 100644
--- lib/Support/DynamicLibrary.cpp
+++ lib/Support/DynamicLibrary.cpp
@@ -157,10 +157,10 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
#define EXPLICIT_SYMBOL(SYM) \
if (!strcmp(symbolName, #SYM)) return &SYM
-// On linux we have a weird situation. The stderr/out/in symbols are both
+// With glibc, the stderr/stdout/stdin symbols are both
// macros and global variables because of standards requirements. So, we
// boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
-#if defined(__linux__) and !defined(__ANDROID__)
+#ifdef __GLIBC__
{
EXPLICIT_SYMBOL(stderr);
EXPLICIT_SYMBOL(stdout);
diff --git lib/Target/TargetLibraryInfo.cpp lib/Target/TargetLibraryInfo.cpp
index ee88ce7..4fa6344 100644
--- lib/Target/TargetLibraryInfo.cpp
+++ lib/Target/TargetLibraryInfo.cpp
@@ -339,6 +339,8 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T,
llvm_unreachable("TargetLibraryInfo function names must be sorted");
}
#endif // !NDEBUG
+
+ bool available;
// memset_pattern16 is only available on iOS 3.0 and Mac OS/X 10.5 and later.
if (T.isMacOSX()) {
@@ -528,34 +530,71 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T,
}
// ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
- // Linux (GLIBC):
+ // systems using glibc:
// http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
// http://svn.freebsd.org/base/user/eri/pf45/head/lib/libc/string/ffsl.c
// http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
- switch (T.getOS()) {
- case Triple::Darwin:
- case Triple::MacOSX:
- case Triple::IOS:
- case Triple::FreeBSD:
- case Triple::Linux:
+ available = false;
+ switch (T.getEnvironment()) {
+ case Triple::GNU:
+ available = true;
break;
default:
- TLI.setUnavailable(LibFunc::ffsl);
+ switch (T.getOS()) {
+ case Triple::Darwin:
+ case Triple::MacOSX:
+ case Triple::IOS:
+ case Triple::FreeBSD:
+ case Triple::Linux:
+ available = true;
+ break;
+ default:
+ break;
+ }
+ break;
}
+ if (!available)
+ TLI.setUnavailable(LibFunc::ffsl);
- // ffsll is available on at least FreeBSD and Linux (GLIBC):
+ // ffsll is available on at least FreeBSD and systems using glibc:
// http://svn.freebsd.org/base/user/eri/pf45/head/lib/libc/string/ffsll.c
// http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
- switch (T.getOS()) {
- case Triple::FreeBSD:
- case Triple::Linux:
+ available = false;
+ switch (T.getEnvironment()) {
+ case Triple::GNU:
+ available = true;
break;
default:
- TLI.setUnavailable(LibFunc::ffsll);
+ switch (T.getOS()) {
+ case Triple::FreeBSD:
+ case Triple::Linux:
+ available = true;
+ break;
+ default:
+ break;
+ }
+ break;
}
+ if (!available)
+ TLI.setUnavailable(LibFunc::ffsll);
- // The following functions are available on at least Linux:
- if (T.getOS() != Triple::Linux) {
+ // The following functions are available on at least systems using glibc:
+ available = false;
+ switch (T.getEnvironment()) {
+ case Triple::GNU:
+ available = true;
+ break;
+ default:
+ switch (T.getOS()) {
+ case Triple::Linux:
+ available = true;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ if (!available) {
TLI.setUnavailable(LibFunc::dunder_strdup);
TLI.setUnavailable(LibFunc::dunder_strtok_r);
TLI.setUnavailable(LibFunc::dunder_isoc99_scanf);
--
1.7.9.5
More information about the llvm-commits
mailing list