[libcxx] r209795 - Linux: Correctly identify valid error codes
David Majnemer
david.majnemer at gmail.com
Wed May 28 22:02:23 PDT 2014
Author: majnemer
Date: Thu May 29 00:02:22 2014
New Revision: 209795
URL: http://llvm.org/viewvc/llvm-project?rev=209795&view=rev
Log:
Linux: Correctly identify valid error codes
[syserr.errcat.objects]p4 specifies that
system_category().default_error_condition(ev) map to
error_condition(posv, generic_category()) if ev could map to a POSIX
errno.
Linux reserves up to and including 4095 for errno values, use this as a
bound.
This fixes syserr.errcat.objects/system_category.pass.cpp on Linux.
Modified:
libcxx/trunk/src/ios.cpp
libcxx/trunk/src/system_error.cpp
libcxx/trunk/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
Modified: libcxx/trunk/src/ios.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/ios.cpp?rev=209795&r1=209794&r2=209795&view=diff
==============================================================================
--- libcxx/trunk/src/ios.cpp (original)
+++ libcxx/trunk/src/ios.cpp Thu May 29 00:02:22 2014
@@ -56,7 +56,9 @@ __iostream_category::message(int ev) con
if (ev != static_cast<int>(io_errc::stream)
#ifdef ELAST
&& ev <= ELAST
-#endif
+#elif defined(__linux__)
+ && ev <= 4095
+#endif // ELAST
)
return __do_message::message(ev);
return string("unspecified iostream_category error");
Modified: libcxx/trunk/src/system_error.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/system_error.cpp?rev=209795&r1=209794&r2=209795&view=diff
==============================================================================
--- libcxx/trunk/src/system_error.cpp (original)
+++ libcxx/trunk/src/system_error.cpp Thu May 29 00:02:22 2014
@@ -68,6 +68,9 @@ __generic_error_category::message(int ev
#ifdef ELAST
if (ev > ELAST)
return string("unspecified generic_category error");
+#elif defined(__linux__)
+ if (ev > 4095)
+ return string("unspecified generic_category error");
#endif // ELAST
return __do_message::message(ev);
}
@@ -100,6 +103,9 @@ __system_error_category::message(int ev)
#ifdef ELAST
if (ev > ELAST)
return string("unspecified system_category error");
+#elif defined(__linux__)
+ if (ev > 4095)
+ return string("unspecified system_category error");
#endif // ELAST
return __do_message::message(ev);
}
@@ -110,6 +116,9 @@ __system_error_category::default_error_c
#ifdef ELAST
if (ev > ELAST)
return error_condition(ev, system_category());
+#elif defined(__linux__)
+ if (ev > 4095)
+ return error_condition(ev, system_category());
#endif // ELAST
return error_condition(ev, generic_category());
}
Modified: libcxx/trunk/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp?rev=209795&r1=209794&r2=209795&view=diff
==============================================================================
--- libcxx/trunk/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp (original)
+++ libcxx/trunk/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp Thu May 29 00:02:22 2014
@@ -23,7 +23,7 @@ int main()
std::error_condition e_cond = e_cat1.default_error_condition(5);
assert(e_cond.value() == 5);
assert(e_cond.category() == std::generic_category());
- e_cond = e_cat1.default_error_condition(500);
- assert(e_cond.value() == 500);
+ e_cond = e_cat1.default_error_condition(5000);
+ assert(e_cond.value() == 5000);
assert(e_cond.category() == std::system_category());
}
More information about the cfe-commits
mailing list