Skip to content

Commit a409d59

Browse files
committed
Newlib names ELAST differently than linux
llvm-svn: 216943
1 parent 3f7a24e commit a409d59

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

libcxx/include/__config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,17 @@ template <unsigned> struct __static_assert_check {};
635635
#define _LIBCPP_WCTYPE_IS_MASK
636636
#endif
637637

638+
#if defined(ELAST)
639+
#define _LIBCPP_ELAST ELAST
640+
#elif defined(__linux__)
641+
#define _LIBCPP_ELAST 4095
642+
#elif defined(_NEWLIB_VERSION)
643+
#define _LIBCPP_ELAST __ELASTERROR
644+
#else
645+
// Warn here so that the person doing the libcxx port has an easier time:
646+
#warning This platform's ELAST hasn't been ported yet
647+
#endif
648+
638649
#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
639650
# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1
640651
#endif

libcxx/src/ios.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10+
#include "__config"
1011
#include "ios"
1112
#include "streambuf"
1213
#include "istream"
@@ -52,11 +53,9 @@ string
5253
__iostream_category::message(int ev) const
5354
{
5455
if (ev != static_cast<int>(io_errc::stream)
55-
#ifdef ELAST
56-
&& ev <= ELAST
57-
#elif defined(__linux__)
58-
&& ev <= 4095
59-
#endif // ELAST
56+
#ifdef _LIBCPP_ELAST
57+
&& ev <= _LIBCPP_ELAST
58+
#endif // _LIBCPP_ELAST
6059
)
6160
return __do_message::message(ev);
6261
return string("unspecified iostream_category error");

libcxx/src/system_error.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//===----------------------------------------------------------------------===//
99

1010
#define _LIBCPP_BUILDING_SYSTEM_ERROR
11+
#include "__config"
1112
#include "system_error"
1213
#include "string"
1314
#include "cstring"
@@ -65,13 +66,10 @@ __generic_error_category::name() const _NOEXCEPT
6566
string
6667
__generic_error_category::message(int ev) const
6768
{
68-
#ifdef ELAST
69-
if (ev > ELAST)
69+
#ifdef _LIBCPP_ELAST
70+
if (ev > _LIBCPP_ELAST)
7071
return string("unspecified generic_category error");
71-
#elif defined(__linux__)
72-
if (ev > 4095)
73-
return string("unspecified generic_category error");
74-
#endif // ELAST
72+
#endif // _LIBCPP_ELAST
7573
return __do_message::message(ev);
7674
}
7775

@@ -100,26 +98,20 @@ __system_error_category::name() const _NOEXCEPT
10098
string
10199
__system_error_category::message(int ev) const
102100
{
103-
#ifdef ELAST
104-
if (ev > ELAST)
105-
return string("unspecified system_category error");
106-
#elif defined(__linux__)
107-
if (ev > 4095)
101+
#ifdef _LIBCPP_ELAST
102+
if (ev > _LIBCPP_ELAST)
108103
return string("unspecified system_category error");
109-
#endif // ELAST
104+
#endif // _LIBCPP_ELAST
110105
return __do_message::message(ev);
111106
}
112107

113108
error_condition
114109
__system_error_category::default_error_condition(int ev) const _NOEXCEPT
115110
{
116-
#ifdef ELAST
117-
if (ev > ELAST)
118-
return error_condition(ev, system_category());
119-
#elif defined(__linux__)
120-
if (ev > 4095)
111+
#ifdef _LIBCPP_ELAST
112+
if (ev > _LIBCPP_ELAST)
121113
return error_condition(ev, system_category());
122-
#endif // ELAST
114+
#endif // _LIBCPP_ELAST
123115
return error_condition(ev, generic_category());
124116
}
125117

0 commit comments

Comments
 (0)