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.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@209795 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2014-05-29 05:02:22 +00:00
parent 4f3368e269
commit fcafd80ace
3 changed files with 14 additions and 3 deletions

View File

@@ -56,7 +56,9 @@ __iostream_category::message(int ev) const
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");

View File

@@ -68,6 +68,9 @@ __generic_error_category::message(int ev) const
#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) const
#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_condition(int ev) const _NOEXCEPT
#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());
}