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.
llvm-svn: 209795
diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp
index 00920ff..d5cb2d4 100644
--- a/libcxx/src/system_error.cpp
+++ b/libcxx/src/system_error.cpp
@@ -68,6 +68,9 @@
#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 @@
#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 @@
#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());
}