[1/3] Remove direct locale references from stdlib

Message ID 20180216184628.8013-1-info@jasoon.nl
State New
Headers show
Series
  • [1/3] Remove direct locale references from stdlib
Related show

Commit Message

Jaap de Wolff Feb. 16, 2018, 6:46 p.m.
---
 newlib/libc/locale/setlocale.h    |  7 +++++++
 newlib/libc/stdlib/gdtoa-gethex.c |  3 +--
 newlib/libc/stdlib/local.h        |  4 ----
 newlib/libc/stdlib/strtod.c       | 11 +++++------
 newlib/libc/stdlib/strtoimax.c    |  4 ++--
 newlib/libc/stdlib/strtol.c       |  4 ++--
 newlib/libc/stdlib/strtold.c      |  8 ++++----
 newlib/libc/stdlib/strtoll.c      |  4 ++--
 newlib/libc/stdlib/strtoul.c      |  4 ++--
 newlib/libc/stdlib/strtoull.c     |  4 ++--
 newlib/libc/stdlib/strtoumax.c    |  4 ++--
 newlib/libc/stdlib/wcsnrtombs.c   |  6 +++---
 newlib/libc/stdlib/wcstod.c       | 12 ++++++------
 newlib/libc/stdlib/wcstoimax.c    |  4 ++--
 newlib/libc/stdlib/wcstol.c       |  4 ++--
 newlib/libc/stdlib/wcstold.c      |  8 ++++----
 newlib/libc/stdlib/wcstoll.c      |  4 ++--
 newlib/libc/stdlib/wcstoul.c      |  4 ++--
 newlib/libc/stdlib/wcstoull.c     |  4 ++--
 newlib/libc/stdlib/wcstoumax.c    |  4 ++--
 20 files changed, 54 insertions(+), 53 deletions(-)

-- 
2.11.0

Patch

diff --git a/newlib/libc/locale/setlocale.h b/newlib/libc/locale/setlocale.h
index 85a38d586..fe212c1ec 100644
--- a/newlib/libc/locale/setlocale.h
+++ b/newlib/libc/locale/setlocale.h
@@ -439,6 +439,13 @@  extern void __set_charset_from_locale (const char *locale, char *charset);
 extern char *__set_locale_from_locale_alias (const char *, char *);
 #endif
 
+#define _locale_decimalpoint(loc) (__localeconv_l(loc))->decimal_point
+#define _locale_wctomb(loc,r,buff,wc,ps) (loc)->wctomb(r,buff,wc,ps)
+#define _locale_mbtowc(loc,r,buff,wc,ps) (loc)->mbtowc(r,buff,wc,ps)
+#define __WCTOMB (__get_current_locale ()->wctomb)
+#define __MBTOWC (__get_current_locale ()->mbtowc)
+
+#define __CURRENT_LOCALE  __get_current_locale()
 __END_DECLS
 
 #endif /* !_SETLOCALE_H_ */
diff --git a/newlib/libc/stdlib/gdtoa-gethex.c b/newlib/libc/stdlib/gdtoa-gethex.c
index 939e0dd8d..ff5de2258 100644
--- a/newlib/libc/stdlib/gdtoa-gethex.c
+++ b/newlib/libc/stdlib/gdtoa-gethex.c
@@ -150,8 +150,7 @@  gethex (struct _reent *ptr, const char **sp, const FPI *fpi,
 	int esign, havedig, irv, k, n, nbits, up, zret;
 	__ULong L, lostbits, *x;
 	Long e, e1;
-	unsigned char *decimalpoint = (unsigned char *)
-				      __localeconv_l (loc)->decimal_point;
+	unsigned char *decimalpoint = (unsigned char *)_locale_decimalpoint(loc);
 	size_t decp_len = strlen ((const char *) decimalpoint);
 	unsigned char decp_end = decimalpoint[decp_len - 1];
 
diff --git a/newlib/libc/stdlib/local.h b/newlib/libc/stdlib/local.h
index a96ed2cc4..36e458c85 100644
--- a/newlib/libc/stdlib/local.h
+++ b/newlib/libc/stdlib/local.h
@@ -29,8 +29,6 @@  wctomb_f __big5_wctomb;
 #endif
 #endif
 
-#define __WCTOMB (__get_current_locale ()->wctomb)
-
 typedef int mbtowc_f (struct _reent *, wchar_t *, const char *, size_t,
 		      mbstate_t *);
 typedef mbtowc_f *mbtowc_p;
@@ -50,8 +48,6 @@  mbtowc_f __big5_mbtowc;
 #endif
 #endif
 
-#define __MBTOWC (__get_current_locale ()->mbtowc)
-
 extern wchar_t __iso_8859_conv[14][0x60];
 int __iso_8859_val_index (int);
 int __iso_8859_index (const char *);
diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c
index 402510cdf..359caf98e 100644
--- a/newlib/libc/stdlib/strtod.c
+++ b/newlib/libc/stdlib/strtod.c
@@ -256,8 +256,7 @@  _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se,
 #ifdef Honor_FLT_ROUNDS
 	int rounding;
 #endif
-	struct lconv *lconv = __localeconv_l (loc);
-	int dec_len = strlen (lconv->decimal_point);
+	int dec_len = strlen (_locale_decimalpoint(loc));
 
 	delta = bs = bd = NULL;
 	sign = nz0 = nz = decpt = 0;
@@ -337,7 +336,7 @@  _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se,
 		else
 			z = 10*z + c - '0';
 	nd0 = nd;
-	if (strncmp (s, lconv->decimal_point, dec_len) == 0)
+	if (strncmp (s, _locale_decimalpoint(loc), dec_len) == 0)
 		{
 		decpt = 1;
 		c = *(s += dec_len);
@@ -1254,7 +1253,7 @@  _strtod_r (struct _reent *ptr,
 	const char *__restrict s00,
 	char **__restrict se)
 {
-  return _strtod_l (ptr, s00, se, __get_current_locale ());
+  return _strtod_l (ptr, s00, se, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -1268,7 +1267,7 @@  strtod_l (const char *__restrict s00, char **__restrict se, locale_t loc)
 double
 strtod (const char *__restrict s00, char **__restrict se)
 {
-  return _strtod_l (_REENT, s00, se, __get_current_locale ());
+  return _strtod_l (_REENT, s00, se, __CURRENT_LOCALE);
 }
 
 float
@@ -1289,7 +1288,7 @@  float
 strtof (const char *__restrict s00,
 	char **__restrict se)
 {
-  double val = _strtod_l (_REENT, s00, se, __get_current_locale ());
+  double val = _strtod_l (_REENT, s00, se, __CURRENT_LOCALE);
   if (isnan (val))
     return nanf (NULL);
   float retval = (float) val;
diff --git a/newlib/libc/stdlib/strtoimax.c b/newlib/libc/stdlib/strtoimax.c
index b0efa3e51..d483ac7ce 100644
--- a/newlib/libc/stdlib/strtoimax.c
+++ b/newlib/libc/stdlib/strtoimax.c
@@ -148,7 +148,7 @@  intmax_t
 _strtoimax_r(struct _reent *rptr, const char *__restrict nptr,
 	     char **__restrict endptr, int base)
 {
-	return _strtoimax_l(rptr, nptr, endptr, base, __get_current_locale());
+	return _strtoimax_l(rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -163,7 +163,7 @@  strtoimax_l(const char * __restrict nptr, char ** __restrict endptr, int base,
 intmax_t
 strtoimax(const char* __restrict nptr, char** __restrict endptr, int base)
 {
-	return _strtoimax_l(_REENT, nptr, endptr, base, __get_current_locale());
+	return _strtoimax_l(_REENT, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/strtol.c b/newlib/libc/stdlib/strtol.c
index f7572b169..42441646a 100644
--- a/newlib/libc/stdlib/strtol.c
+++ b/newlib/libc/stdlib/strtol.c
@@ -217,7 +217,7 @@  _strtol_r (struct _reent *rptr,
 	char **__restrict endptr,
 	int base)
 {
-	return _strtol_l (rptr, nptr, endptr, base, __get_current_locale ());
+	return _strtol_l (rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -234,7 +234,7 @@  strtol (const char *__restrict s,
 	char **__restrict ptr,
 	int base)
 {
-	return _strtol_l (_REENT, s, ptr, base, __get_current_locale ());
+	return _strtol_l (_REENT, s, ptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/strtold.c b/newlib/libc/stdlib/strtold.c
index 6bd1c2cbb..0b4b77a7a 100644
--- a/newlib/libc/stdlib/strtold.c
+++ b/newlib/libc/stdlib/strtold.c
@@ -64,11 +64,11 @@  _strtold_r (struct _reent *ptr, const char *__restrict s00,
 {
 #ifdef _LDBL_EQ_DBL
   /* On platforms where long double is as wide as double.  */
-  return _strtod_l (ptr, s00, se, __get_current_locale ());
+  return _strtod_l (ptr, s00, se, __CURRENT_LOCALE);
 #else
   long double result;
 
-  _strtorx_l (ptr, s00, se, FLT_ROUNDS, &result, __get_current_locale ());
+  _strtorx_l (ptr, s00, se, FLT_ROUNDS, &result, __CURRENT_LOCALE);
   return result;
 #endif
 }
@@ -92,11 +92,11 @@  strtold (const char *__restrict s00, char **__restrict se)
 {
 #ifdef _LDBL_EQ_DBL
   /* On platforms where long double is as wide as double.  */
-  return _strtod_l (_REENT, s00, se, __get_current_locale ());
+  return _strtod_l (_REENT, s00, se, __CURRENT_LOCALE);
 #else
   long double result;
 
-  _strtorx_l (_REENT, s00, se, FLT_ROUNDS, &result, __get_current_locale ());
+  _strtorx_l (_REENT, s00, se, FLT_ROUNDS, &result, __CURRENT_LOCALE);
   return result;
 #endif
 }
diff --git a/newlib/libc/stdlib/strtoll.c b/newlib/libc/stdlib/strtoll.c
index 295886e8f..b52183e29 100644
--- a/newlib/libc/stdlib/strtoll.c
+++ b/newlib/libc/stdlib/strtoll.c
@@ -219,7 +219,7 @@  _strtoll_r (struct _reent *rptr,
 	char **__restrict endptr,
 	int base)
 {
-	return _strtoll_l (rptr, nptr, endptr, base, __get_current_locale ());
+	return _strtoll_l (rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -236,7 +236,7 @@  strtoll (const char *__restrict s,
 	char **__restrict ptr,
 	int base)
 {
-	return _strtoll_l (_REENT, s, ptr, base, __get_current_locale ());
+	return _strtoll_l (_REENT, s, ptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/strtoul.c b/newlib/libc/stdlib/strtoul.c
index f2fba37f2..b5121d01f 100644
--- a/newlib/libc/stdlib/strtoul.c
+++ b/newlib/libc/stdlib/strtoul.c
@@ -196,7 +196,7 @@  _strtoul_r (struct _reent *rptr,
 	char **__restrict endptr,
 	int base)
 {
-  return _strtoul_l (rptr, nptr, endptr, base, __get_current_locale ());
+  return _strtoul_l (rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -213,7 +213,7 @@  strtoul (const char *__restrict s,
 	char **__restrict ptr,
 	int base)
 {
-	return _strtoul_l (_REENT, s, ptr, base, __get_current_locale ());
+	return _strtoul_l (_REENT, s, ptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/strtoull.c b/newlib/libc/stdlib/strtoull.c
index ce4de6e7e..a4024a2c3 100644
--- a/newlib/libc/stdlib/strtoull.c
+++ b/newlib/libc/stdlib/strtoull.c
@@ -194,7 +194,7 @@  _strtoull_r (struct _reent *rptr,
 	char **__restrict endptr,
 	int base)
 {
-	return _strtoull_l (rptr, nptr, endptr, base, __get_current_locale ());
+	return _strtoull_l (rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -211,7 +211,7 @@  strtoull (const char *__restrict s,
 	char **__restrict ptr,
 	int base)
 {
-	return _strtoull_l (_REENT, s, ptr, base, __get_current_locale ());
+	return _strtoull_l (_REENT, s, ptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/strtoumax.c b/newlib/libc/stdlib/strtoumax.c
index aa4a0ac42..e078ba127 100644
--- a/newlib/libc/stdlib/strtoumax.c
+++ b/newlib/libc/stdlib/strtoumax.c
@@ -130,7 +130,7 @@  uintmax_t
 _strtoumax_r(struct _reent *rptr, const char *__restrict nptr,
 	     char **__restrict endptr, int base)
 {
-	return _strtoumax_l(rptr, nptr, endptr, base, __get_current_locale());
+	return _strtoumax_l(rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -145,7 +145,7 @@  strtoumax_l(const char * __restrict nptr, char ** __restrict endptr, int base,
 uintmax_t
 strtoumax(const char* __restrict nptr, char** __restrict endptr, int base)
 {
-	return _strtoumax_l(_REENT, nptr, endptr, base, __get_current_locale());
+	return _strtoumax_l(_REENT, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/wcsnrtombs.c b/newlib/libc/stdlib/wcsnrtombs.c
index 43dd2f3e6..33263f5fe 100644
--- a/newlib/libc/stdlib/wcsnrtombs.c
+++ b/newlib/libc/stdlib/wcsnrtombs.c
@@ -101,7 +101,7 @@  _wcsnrtombs_l (struct _reent *r, char *dst, const wchar_t **src, size_t nwc,
     {
       int count = ps->__count;
       wint_t wch = ps->__value.__wch;
-      int bytes = loc->wctomb (r, buff, *pwcs, ps);
+      int bytes = _locale_wctomb(loc, r, buff, *pwcs, ps);
       if (bytes == -1)
 	{
 	  r->_errno = EILSEQ;
@@ -146,7 +146,7 @@  _wcsnrtombs_r (struct _reent *r,
 	mbstate_t *ps)
 {
   return _wcsnrtombs_l (_REENT, dst, src, nwc, len, ps,
-			__get_current_locale ());
+			__CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -158,6 +158,6 @@  wcsnrtombs (char *__restrict dst,
 	mbstate_t *__restrict ps)
 {
   return _wcsnrtombs_l (_REENT, dst, src, nwc, len, ps,
-			__get_current_locale ());
+			__CURRENT_LOCALE);
 }
 #endif /* !_REENT_ONLY */
diff --git a/newlib/libc/stdlib/wcstod.c b/newlib/libc/stdlib/wcstod.c
index 9e0d563ef..96242a685 100644
--- a/newlib/libc/stdlib/wcstod.c
+++ b/newlib/libc/stdlib/wcstod.c
@@ -198,10 +198,10 @@  _wcstod_l (struct _reent *ptr, const wchar_t *nptr, wchar_t **endptr,
 		   just one byte long.  The resulting difference (end - buf)
 		   is then equivalent to the number of valid wide characters
 		   in the input string. */
-		len = strlen (__localeconv_l (loc)->decimal_point);
+		len = strlen (_locale_decimalpoint(loc));
 		if (len > 1) {
 			char *d = strstr (buf,
-					  __localeconv_l (loc)->decimal_point);
+					  _locale_decimalpoint(loc));
 			if (d && d < end)
 				end -= len - 1;
 		}
@@ -218,7 +218,7 @@  _wcstod_r (struct _reent *ptr,
 	const wchar_t *nptr,
 	wchar_t **endptr)
 {
-  return _wcstod_l (ptr, nptr, endptr, __get_current_locale ());
+  return _wcstod_l (ptr, nptr, endptr, __CURRENT_LOCALE);
 }
 
 float
@@ -226,7 +226,7 @@  _wcstof_r (struct _reent *ptr,
 	const wchar_t *nptr,
 	wchar_t **endptr)
 {
-  double retval = _wcstod_l (ptr, nptr, endptr, __get_current_locale ());
+  double retval = _wcstod_l (ptr, nptr, endptr, __CURRENT_LOCALE);
   if (isnan (retval))
     return nanf (NULL);
   return (float)retval;
@@ -244,7 +244,7 @@  wcstod_l (const wchar_t *__restrict nptr, wchar_t **__restrict endptr,
 double
 wcstod (const wchar_t *__restrict nptr, wchar_t **__restrict endptr)
 {
-  return _wcstod_l (_REENT, nptr, endptr, __get_current_locale ());
+  return _wcstod_l (_REENT, nptr, endptr, __CURRENT_LOCALE);
 }
 
 float
@@ -266,7 +266,7 @@  float
 wcstof (const wchar_t *__restrict nptr,
 	wchar_t **__restrict endptr)
 {
-  double val = _wcstod_l (_REENT, nptr, endptr, __get_current_locale ());
+  double val = _wcstod_l (_REENT, nptr, endptr, __CURRENT_LOCALE);
   if (isnan (val))
     return nanf (NULL);
   float retval = (float) val;
diff --git a/newlib/libc/stdlib/wcstoimax.c b/newlib/libc/stdlib/wcstoimax.c
index 02ab1c1f4..9be117e73 100644
--- a/newlib/libc/stdlib/wcstoimax.c
+++ b/newlib/libc/stdlib/wcstoimax.c
@@ -137,7 +137,7 @@  intmax_t
 _wcstoimax_r(struct _reent *rptr, const wchar_t *__restrict nptr,
 	     wchar_t **__restrict endptr, int base)
 {
-	return _wcstoimax_l(rptr, nptr, endptr, base, __get_current_locale());
+	return _wcstoimax_l(rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -152,7 +152,7 @@  wcstoimax_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
 intmax_t
 wcstoimax(const wchar_t* __restrict nptr, wchar_t** __restrict endptr, int base)
 {
-	return _wcstoimax_l(_REENT, nptr, endptr, base, __get_current_locale());
+	return _wcstoimax_l(_REENT, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/wcstol.c b/newlib/libc/stdlib/wcstol.c
index 023a9c45e..c69a61d66 100644
--- a/newlib/libc/stdlib/wcstol.c
+++ b/newlib/libc/stdlib/wcstol.c
@@ -218,7 +218,7 @@  _wcstol_r (struct _reent *rptr,
 	wchar_t **endptr,
 	int base)
 {
-	return _wcstol_l (rptr, nptr, endptr, base, __get_current_locale ());
+	return _wcstol_l (rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -235,7 +235,7 @@  wcstol (const wchar_t *__restrict s,
 	wchar_t **__restrict ptr,
 	int base)
 {
-	return _wcstol_l (_REENT, s, ptr, base, __get_current_locale ());
+	return _wcstol_l (_REENT, s, ptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/wcstold.c b/newlib/libc/stdlib/wcstold.c
index 4876e119b..9aa0744c4 100644
--- a/newlib/libc/stdlib/wcstold.c
+++ b/newlib/libc/stdlib/wcstold.c
@@ -93,10 +93,10 @@  wcstold_l (const wchar_t *__restrict nptr, wchar_t **__restrict endptr,
 	 just one byte long.  The resulting difference (end - buf)
 	 is then equivalent to the number of valid wide characters
 	 in the input string.  */
-      len = strlen (__localeconv_l (loc)->decimal_point);
+      len = strlen (_locale_decimalpoint (loc));
       if (len > 1)
 	{
-	  char *d = strstr (buf, __localeconv_l (loc)->decimal_point);
+	  char *d = strstr (buf, _locale_decimalpoint (loc));
 
 	  if (d && d < end)
 	    end -= len - 1;
@@ -116,8 +116,8 @@  wcstold (const wchar_t *__restrict nptr, wchar_t **__restrict endptr)
 {
 #ifdef _LDBL_EQ_DBL
 /* On platforms where long double is as wide as double.  */
-  return wcstod_l(nptr, endptr, __get_current_locale ());
+  return wcstod_l(nptr, endptr, __CURRENT_LOCALE);
 #else
-  return wcstold_l(nptr, endptr, __get_current_locale ());
+  return wcstold_l(nptr, endptr, __CURRENT_LOCALE);
 #endif
 }
diff --git a/newlib/libc/stdlib/wcstoll.c b/newlib/libc/stdlib/wcstoll.c
index 5fe0b2976..f42b7ebc3 100644
--- a/newlib/libc/stdlib/wcstoll.c
+++ b/newlib/libc/stdlib/wcstoll.c
@@ -218,7 +218,7 @@  _wcstoll_r (struct _reent *rptr,
 	wchar_t **endptr,
 	int base)
 {
-	return _wcstoll_l (rptr, nptr, endptr, base, __get_current_locale ());
+	return _wcstoll_l (rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -235,7 +235,7 @@  wcstoll (const wchar_t *__restrict s,
 	wchar_t **__restrict ptr,
 	int base)
 {
-	return _wcstoll_l (_REENT, s, ptr, base, __get_current_locale ());
+	return _wcstoll_l (_REENT, s, ptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/wcstoul.c b/newlib/libc/stdlib/wcstoul.c
index 8e2796587..ad781a6ed 100644
--- a/newlib/libc/stdlib/wcstoul.c
+++ b/newlib/libc/stdlib/wcstoul.c
@@ -197,7 +197,7 @@  _wcstoul_r (struct _reent *rptr,
 	wchar_t **endptr,
 	int base)
 {
-	return _wcstoul_l (rptr, nptr, endptr, base, __get_current_locale ());
+	return _wcstoul_l (rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -214,7 +214,7 @@  wcstoul (const wchar_t *__restrict s,
 	wchar_t **__restrict ptr,
 	int base)
 {
-	return _wcstoul_l (_REENT, s, ptr, base, __get_current_locale ());
+	return _wcstoul_l (_REENT, s, ptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/wcstoull.c b/newlib/libc/stdlib/wcstoull.c
index 5a37473e0..f6d269145 100644
--- a/newlib/libc/stdlib/wcstoull.c
+++ b/newlib/libc/stdlib/wcstoull.c
@@ -213,7 +213,7 @@  _wcstoull_r (struct _reent *rptr,
 	wchar_t **endptr,
 	int base)
 {
-	return _wcstoull_l (rptr, nptr, endptr, base, __get_current_locale ());
+	return _wcstoull_l (rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -230,7 +230,7 @@  wcstoull (const wchar_t *__restrict s,
 	wchar_t **__restrict ptr,
 	int base)
 {
-	return _wcstoull_l (_REENT, s, ptr, base, __get_current_locale ());
+	return _wcstoull_l (_REENT, s, ptr, base, __CURRENT_LOCALE);
 }
 
 #endif
diff --git a/newlib/libc/stdlib/wcstoumax.c b/newlib/libc/stdlib/wcstoumax.c
index 17b5275fa..3fea6b853 100644
--- a/newlib/libc/stdlib/wcstoumax.c
+++ b/newlib/libc/stdlib/wcstoumax.c
@@ -136,7 +136,7 @@  uintmax_t
 _wcstoumax_r(struct _reent *rptr, const wchar_t *__restrict nptr,
 	     wchar_t **__restrict endptr, int base)
 {
-	return _wcstoumax_l(rptr, nptr, endptr, base, __get_current_locale());
+	return _wcstoumax_l(rptr, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #ifndef _REENT_ONLY
@@ -151,7 +151,7 @@  wcstoumax_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
 uintmax_t
 wcstoumax(const wchar_t* __restrict nptr, wchar_t** __restrict endptr, int base)
 {
-	return _wcstoumax_l(_REENT, nptr, endptr, base, __get_current_locale());
+	return _wcstoumax_l(_REENT, nptr, endptr, base, __CURRENT_LOCALE);
 }
 
 #endif