Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Provide explicit LC_C_LOCALE accessor and drop the various N...
details: https://anonhg.NetBSD.org/src/rev/5abb17566c0e
branches: trunk
changeset: 786875:5abb17566c0e
user: joerg <joerg%NetBSD.org@localhost>
date: Fri May 17 12:55:56 2013 +0000
description:
Provide explicit LC_C_LOCALE accessor and drop the various NULL checks.
Provide LC_GLOBAL_LOCALE in a way that works with all locale functions.
Merge constant data used by the initial global locale and the C locale.
Drop function call layer for _current_locale() and directly return the
locale reference, not a pointer to it. Use protected access for global
variables, so that libc references can avoid the GOT overhead.
diffstat:
common/lib/libc/stdlib/_strtol.h | 6 +-
common/lib/libc/stdlib/_strtoul.h | 6 +-
include/locale.h | 16 ++-
lib/libc/gdtoa/strtod.c | 6 +-
lib/libc/gdtoa/strtof.c | 6 +-
lib/libc/gdtoa/strtof_vaxf.c | 6 +-
lib/libc/gdtoa/strtold_subr.c | 8 +-
lib/libc/gen/isctype.c | 10 +-
lib/libc/locale/Makefile.inc | 4 +-
lib/libc/locale/_wcstod.h | 6 +-
lib/libc/locale/_wcstol.h | 6 +-
lib/libc/locale/_wcstoul.h | 6 +-
lib/libc/locale/c_locale.c | 176 --------------------------------------
lib/libc/locale/current_locale.c | 49 ----------
lib/libc/locale/freelocale.c | 8 +-
lib/libc/locale/global_locale.c | 55 ++++++++++-
lib/libc/locale/iswctype_mb.c | 39 +------
lib/libc/locale/localeconv.c | 6 +-
lib/libc/locale/multibyte_amd1.c | 46 ++-------
lib/libc/locale/multibyte_c90.c | 29 +----
lib/libc/locale/nb_lc_template.h | 4 +-
lib/libc/locale/newlocale.c | 6 +-
lib/libc/locale/setlocale.c | 6 +-
lib/libc/locale/setlocale_local.h | 17 ++-
lib/libc/locale/wcscoll.c | 8 +-
lib/libc/locale/wcsxfrm.c | 8 +-
lib/libc/stdio/vasprintf.c | 6 +-
lib/libc/stdio/vdprintf.c | 6 +-
lib/libc/stdio/vfscanf.c | 6 +-
lib/libc/stdio/vfwprintf.c | 9 +-
lib/libc/stdio/vfwscanf.c | 9 +-
lib/libc/stdio/vsnprintf.c | 6 +-
lib/libc/stdio/vsprintf.c | 6 +-
lib/libc/stdio/vsscanf.c | 6 +-
lib/libc/stdio/vswprintf.c | 6 +-
lib/libc/stdio/vswscanf.c | 6 +-
lib/libc/string/strcoll.c | 9 +-
lib/libc/string/strxfrm.c | 8 +-
lib/libc/string/wcscasecmp.c | 9 +-
lib/libc/string/wcsncasecmp.c | 9 +-
lib/libc/time/strftime.c | 9 +-
lib/libc/time/strptime.c | 9 +-
42 files changed, 188 insertions(+), 474 deletions(-)
diffs (truncated from 1838 to 300 lines):
diff -r ab8958ac6858 -r 5abb17566c0e common/lib/libc/stdlib/_strtol.h
--- a/common/lib/libc/stdlib/_strtol.h Fri May 17 10:48:54 2013 +0000
+++ b/common/lib/libc/stdlib/_strtol.h Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtol.h,v 1.6 2013/04/26 21:20:48 joerg Exp $ */
+/* $NetBSD: _strtol.h,v 1.7 2013/05/17 12:55:56 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -192,14 +192,12 @@
__INT
_FUNCNAME(const char *nptr, char **endptr, int base)
{
- return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, *_current_locale());
+ return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, _current_locale());
}
__INT
INT_FUNCNAME(, _FUNCNAME, _l)(const char *nptr, char **endptr, int base, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc);
}
#endif
diff -r ab8958ac6858 -r 5abb17566c0e common/lib/libc/stdlib/_strtoul.h
--- a/common/lib/libc/stdlib/_strtoul.h Fri May 17 10:48:54 2013 +0000
+++ b/common/lib/libc/stdlib/_strtoul.h Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoul.h,v 1.6 2013/04/26 21:20:48 joerg Exp $ */
+/* $NetBSD: _strtoul.h,v 1.7 2013/05/17 12:55:56 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -152,14 +152,12 @@
__UINT
_FUNCNAME(const char *nptr, char **endptr, int base)
{
- return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, *_current_locale());
+ return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, _current_locale());
}
__UINT
INT_FUNCNAME(, _FUNCNAME, _l)(const char *nptr, char **endptr, int base, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc);
}
#endif
diff -r ab8958ac6858 -r 5abb17566c0e include/locale.h
--- a/include/locale.h Fri May 17 10:48:54 2013 +0000
+++ b/include/locale.h Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locale.h,v 1.21 2013/04/30 00:45:04 joerg Exp $ */
+/* $NetBSD: locale.h,v 1.22 2013/05/17 12:55:57 joerg Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -85,10 +85,6 @@
# endif
#endif
-#ifdef __SETLOCALE_SOURCE__
-#define _LC_GLOBAL_LOCALE ((locale_t)-1)
-#endif
-
__BEGIN_DECLS
struct lconv *localeconv(void);
char *setlocale(int, const char *) __RENAME(__setlocale50);
@@ -109,6 +105,16 @@
void freelocale(locale_t);
struct lconv *localeconv_l(locale_t);
locale_t newlocale(int, const char *, locale_t);
+
+#ifndef _LIBC
+extern struct _locale _lc_global_locale;
+extern const struct _locale _lc_C_locale;
+#else
+extern __dso_protected struct _locale _lc_global_locale;
+extern __dso_protected const struct _locale _lc_C_locale;
+#endif
+#define LC_GLOBAL_LOCALE (&_lc_global_locale)
+#define LC_C_LOCALE ((locale_t)__UNCONST(&_lc_C_locale))
#endif
__END_DECLS
diff -r ab8958ac6858 -r 5abb17566c0e lib/libc/gdtoa/strtod.c
--- a/lib/libc/gdtoa/strtod.c Fri May 17 10:48:54 2013 +0000
+++ b/lib/libc/gdtoa/strtod.c Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.13 2013/04/19 10:41:53 joerg Exp $ */
+/* $NetBSD: strtod.c,v 1.14 2013/05/17 12:55:57 joerg Exp $ */
/****************************************************************
@@ -1103,7 +1103,7 @@
double
strtod(CONST char *s, char **sp)
{
- return _int_strtod_l(s, sp, *_current_locale());
+ return _int_strtod_l(s, sp, _current_locale());
}
#ifdef __weak_alias
@@ -1113,7 +1113,5 @@
double
strtod_l(CONST char *s, char **sp, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return _int_strtod_l(s, sp, loc);
}
diff -r ab8958ac6858 -r 5abb17566c0e lib/libc/gdtoa/strtof.c
--- a/lib/libc/gdtoa/strtof.c Fri May 17 10:48:54 2013 +0000
+++ b/lib/libc/gdtoa/strtof.c Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtof.c,v 1.6 2013/04/18 21:54:11 joerg Exp $ */
+/* $NetBSD: strtof.c,v 1.7 2013/05/17 12:55:57 joerg Exp $ */
/****************************************************************
@@ -96,13 +96,11 @@
float
strtof(CONST char *s, char **sp)
{
- return _int_strtof_l(s, sp, *_current_locale());
+ return _int_strtof_l(s, sp, _current_locale());
}
float
strtof_l(CONST char *s, char **sp, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return _int_strtof_l(s, sp, loc);
}
diff -r ab8958ac6858 -r 5abb17566c0e lib/libc/gdtoa/strtof_vaxf.c
--- a/lib/libc/gdtoa/strtof_vaxf.c Fri May 17 10:48:54 2013 +0000
+++ b/lib/libc/gdtoa/strtof_vaxf.c Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtof_vaxf.c,v 1.7 2013/04/18 21:54:11 joerg Exp $ */
+/* $NetBSD: strtof_vaxf.c,v 1.8 2013/05/17 12:55:57 joerg Exp $ */
/****************************************************************
@@ -83,13 +83,11 @@
float
strtof(CONST char *s, char **sp)
{
- return _int_strtof_l(s, sp, *_current_locale());
+ return _int_strtof_l(s, sp, _current_locale());
}
float
strtof_l(CONST char *s, char **sp, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return _int_strtof_l(s, sp, loc);
}
diff -r ab8958ac6858 -r 5abb17566c0e lib/libc/gdtoa/strtold_subr.c
--- a/lib/libc/gdtoa/strtold_subr.c Fri May 17 10:48:54 2013 +0000
+++ b/lib/libc/gdtoa/strtold_subr.c Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtold_subr.c,v 1.2 2013/04/18 21:54:11 joerg Exp $ */
+/* $NetBSD: strtold_subr.c,v 1.3 2013/05/17 12:55:57 joerg Exp $ */
/*
* Written by Klaus Klein <kleink%NetBSD.org@localhost>, November 16, 2005.
@@ -15,7 +15,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strtold_subr.c,v 1.2 2013/04/18 21:54:11 joerg Exp $");
+__RCSID("$NetBSD: strtold_subr.c,v 1.3 2013/05/17 12:55:57 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -53,13 +53,11 @@
long double
strtold(CONST char *s, char **sp)
{
- return _int_strtold_l(s, sp, *_current_locale());
+ return _int_strtold_l(s, sp, _current_locale());
}
long double
strtold_l(CONST char *s, char **sp, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return _int_strtold_l(s, sp, loc);
}
diff -r ab8958ac6858 -r 5abb17566c0e lib/libc/gen/isctype.c
--- a/lib/libc/gen/isctype.c Fri May 17 10:48:54 2013 +0000
+++ b/lib/libc/gen/isctype.c Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isctype.c,v 1.23 2013/04/16 11:29:13 joerg Exp $ */
+/* $NetBSD: isctype.c,v 1.24 2013/05/17 12:55:57 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: isctype.c,v 1.23 2013/04/16 11:29:13 joerg Exp $");
+__RCSID("$NetBSD: isctype.c,v 1.24 2013/05/17 12:55:57 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -57,8 +57,6 @@
int \
is##name ## _l(int c, locale_t loc) \
{ \
- if (loc == NULL) \
- loc = _C_locale; \
return (int)(((loc->cache->ctype_tab + 1)[c]) & (bit)); \
}
@@ -84,8 +82,6 @@
int
toupper_l(int c, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return (int)(((loc->cache->toupper_tab + 1)[c]));
}
@@ -98,8 +94,6 @@
int
tolower_l(int c, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return (int)(((loc->cache->tolower_tab + 1)[c]));
}
diff -r ab8958ac6858 -r 5abb17566c0e lib/libc/locale/Makefile.inc
--- a/lib/libc/locale/Makefile.inc Fri May 17 10:48:54 2013 +0000
+++ b/lib/libc/locale/Makefile.inc Fri May 17 12:55:56 2013 +0000
@@ -1,12 +1,12 @@
# from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91
-# $NetBSD: Makefile.inc,v 1.62 2013/04/30 00:45:05 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.63 2013/05/17 12:55:57 joerg Exp $
# locale sources
.PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
SRCS+= _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
setlocale.c __mb_cur_max.c \
- current_locale.c c_locale.c duplocale.c global_locale.c fix_grouping.c \
+ duplocale.c global_locale.c fix_grouping.c \
freelocale.c localeconv.c newlocale.c nl_langinfo.c \
generic_lc_all.c dummy_lc_collate.c \
wcstol.c wcstoll.c wcstoimax.c wcstoul.c wcstoull.c wcstoumax.c \
diff -r ab8958ac6858 -r 5abb17566c0e lib/libc/locale/_wcstod.h
--- a/lib/libc/locale/_wcstod.h Fri May 17 10:48:54 2013 +0000
+++ b/lib/libc/locale/_wcstod.h Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _wcstod.h,v 1.3 2013/04/18 22:23:17 joerg Exp $ */
+/* $NetBSD: _wcstod.h,v 1.4 2013/05/17 12:55:57 joerg Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
@@ -134,15 +134,13 @@
INT_NAME(, _FUNCNAME, )(const wchar_t * __restrict nptr,
wchar_t ** __restrict endptr)
{
- return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, *_current_locale());
+ return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, _current_locale());
}
_RETURN_TYPE
INT_NAME(, _FUNCNAME, _l)(const wchar_t * __restrict nptr,
wchar_t ** __restrict endptr, locale_t loc)
{
- if (loc == NULL)
- loc = _C_locale;
return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, loc);
}
#endif /*__WCSTOD_H_*/
diff -r ab8958ac6858 -r 5abb17566c0e lib/libc/locale/_wcstol.h
--- a/lib/libc/locale/_wcstol.h Fri May 17 10:48:54 2013 +0000
+++ b/lib/libc/locale/_wcstol.h Fri May 17 12:55:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _wcstol.h,v 1.5 2013/04/16 16:52:13 joerg Exp $ */
+/* $NetBSD: _wcstol.h,v 1.6 2013/05/17 12:55:57 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -150,14 +150,12 @@
_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
{
return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base,
- *_current_locale());
+ _current_locale());
}
Home |
Main Index |
Thread Index |
Old Index