seterrno_from_win_error (file, line, GetLastError ());
}
-extern char *_user_strerror _PARAMS ((int));
-
static char *
strerror_worker (int errnum)
{
return res;
}
-/* strerror: convert from errno values to error strings. Newlib's
- strerror_r returns "" for unknown values, so we override it to
- provide a nicer thread-safe result string and set errno. */
+/* Newlib requires this override for perror and friends to avoid
+ clobbering strerror() buffer, without having to differentiate
+ between strerror_r signatures. This function is intentionally not
+ exported, so that only newlib can use it. */
extern "C" char *
-strerror (int errnum)
+_strerror_r (struct _reent *, int errnum, int internal, int *errptr)
{
char *errstr = strerror_worker (errnum);
if (!errstr)
{
- __small_sprintf (errstr = _my_tls.locals.strerror_buf, "Unknown error %d",
- errnum);
- errno = _impure_ptr->_errno = EINVAL;
+ errstr = internal ? _my_tls.locals.strerror_r_buf
+ : _my_tls.locals.strerror_buf;
+ __small_sprintf (errstr, "Unknown error %d", errnum);
+ if (errptr)
+ *errptr = EINVAL;
}
return errstr;
}
+/* strerror: convert from errno values to error strings. Newlib's
+ strerror_r returns "" for unknown values, so we override it to
+ provide a nicer thread-safe result string and set errno. */
+extern "C" char *
+strerror (int errnum)
+{
+ int error = 0;
+ char *result = _strerror_r (NULL, errnum, 0, &error);
+ if (error)
+ set_errno (error);
+ return result;
+}
+
/* Newlib's <string.h> provides declarations for two strerror_r
variants, according to preprocessor feature macros. However, it
returns "" instead of "Unknown error ...", so we override both
extern "C" char *
strerror_r (int errnum, char *buf, size_t n)
{
- char *error = strerror (errnum);
- if (strlen (error) >= n)
- return error;
- return strcpy (buf, error);
+ int error = 0;
+ char *errstr = _strerror_r (NULL, errnum, 1, &error);
+ if (error)
+ set_errno (error);
+ if (strlen (errstr) >= n)
+ return errstr;
+ return strcpy (buf, errstr);
}
extern "C" int
//;# autogenerated: Do not edit.
-//; $tls::sizeof__cygtls = 3984;
+//; $tls::sizeof__cygtls = 4012;
//; $tls::func = -12700;
//; $tls::pfunc = 0;
//; $tls::saved_errno = -12696;
//; $tls::p__dontuse = 412;
//; $tls::locals = -11200;
//; $tls::plocals = 1500;
-//; $tls::_ctinfo = -9800;
-//; $tls::p_ctinfo = 2900;
-//; $tls::andreas = -9796;
-//; $tls::pandreas = 2904;
-//; $tls::wq = -9792;
-//; $tls::pwq = 2908;
-//; $tls::sig = -9764;
-//; $tls::psig = 2936;
-//; $tls::incyg = -9760;
-//; $tls::pincyg = 2940;
-//; $tls::spinning = -9756;
-//; $tls::pspinning = 2944;
-//; $tls::stacklock = -9752;
-//; $tls::pstacklock = 2948;
-//; $tls::stackptr = -9748;
-//; $tls::pstackptr = 2952;
-//; $tls::stack = -9744;
-//; $tls::pstack = 2956;
-//; $tls::initialized = -8720;
-//; $tls::pinitialized = 3980;
+//; $tls::_ctinfo = -9772;
+//; $tls::p_ctinfo = 2928;
+//; $tls::andreas = -9768;
+//; $tls::pandreas = 2932;
+//; $tls::wq = -9764;
+//; $tls::pwq = 2936;
+//; $tls::sig = -9736;
+//; $tls::psig = 2964;
+//; $tls::incyg = -9732;
+//; $tls::pincyg = 2968;
+//; $tls::spinning = -9728;
+//; $tls::pspinning = 2972;
+//; $tls::stacklock = -9724;
+//; $tls::pstacklock = 2976;
+//; $tls::stackptr = -9720;
+//; $tls::pstackptr = 2980;
+//; $tls::stack = -9716;
+//; $tls::pstack = 2984;
+//; $tls::initialized = -8692;
+//; $tls::pinitialized = 4008;
//; __DATA__
#define tls_func (-12700)
#define tls_p__dontuse (412)
#define tls_locals (-11200)
#define tls_plocals (1500)
-#define tls__ctinfo (-9800)
-#define tls_p_ctinfo (2900)
-#define tls_andreas (-9796)
-#define tls_pandreas (2904)
-#define tls_wq (-9792)
-#define tls_pwq (2908)
-#define tls_sig (-9764)
-#define tls_psig (2936)
-#define tls_incyg (-9760)
-#define tls_pincyg (2940)
-#define tls_spinning (-9756)
-#define tls_pspinning (2944)
-#define tls_stacklock (-9752)
-#define tls_pstacklock (2948)
-#define tls_stackptr (-9748)
-#define tls_pstackptr (2952)
-#define tls_stack (-9744)
-#define tls_pstack (2956)
-#define tls_initialized (-8720)
-#define tls_pinitialized (3980)
+#define tls__ctinfo (-9772)
+#define tls_p_ctinfo (2928)
+#define tls_andreas (-9768)
+#define tls_pandreas (2932)
+#define tls_wq (-9764)
+#define tls_pwq (2936)
+#define tls_sig (-9736)
+#define tls_psig (2964)
+#define tls_incyg (-9732)
+#define tls_pincyg (2968)
+#define tls_spinning (-9728)
+#define tls_pspinning (2972)
+#define tls_stacklock (-9724)
+#define tls_pstacklock (2976)
+#define tls_stackptr (-9720)
+#define tls_pstackptr (2980)
+#define tls_stack (-9716)
+#define tls_pstack (2984)
+#define tls_initialized (-8692)
+#define tls_pinitialized (4008)