Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc make _locale_impl_t.cache as pointer to maintain ea...



details:   https://anonhg.NetBSD.org/src/rev/7487729e2e15
branches:  trunk
changeset: 755090:7487729e2e15
user:      tnozaki <tnozaki%NetBSD.org@localhost>
date:      Sat May 22 13:15:59 2010 +0000

description:
make _locale_impl_t.cache as pointer to maintain easily binary compatibility in future.
no ABI change was made.

diffstat:

 lib/libc/gen/isctype.c            |   7 +++----
 lib/libc/locale/global_locale.c   |  25 +++++++++++++------------
 lib/libc/locale/localeconv.c      |   9 +++------
 lib/libc/locale/nb_lc_template.h  |   4 ++--
 lib/libc/locale/nl_langinfo.c     |  11 ++++-------
 lib/libc/locale/setlocale_local.h |  10 ++++++++--
 6 files changed, 33 insertions(+), 33 deletions(-)

diffs (183 lines):

diff -r 1ebb68451b98 -r 7487729e2e15 lib/libc/gen/isctype.c
--- a/lib/libc/gen/isctype.c    Sat May 22 11:20:18 2010 +0000
+++ b/lib/libc/gen/isctype.c    Sat May 22 13:15:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isctype.c,v 1.18 2009/01/11 02:46:27 christos Exp $ */
+/* $NetBSD: isctype.c,v 1.19 2010/05/22 13:15:59 tnozaki 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.18 2009/01/11 02:46:27 christos Exp $");
+__RCSID("$NetBSD: isctype.c,v 1.19 2010/05/22 13:15:59 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -44,8 +44,7 @@
 
 #include "setlocale_local.h"
 
-#define _CTYPE_TAB(table, i) \
-    (((*_current_locale())->cache.table + 1)[i])
+#define _CTYPE_TAB(table, i)   ((_current_cache()->table + 1)[i])
 
 #undef isalnum
 #undef isalpha
diff -r 1ebb68451b98 -r 7487729e2e15 lib/libc/locale/global_locale.c
--- a/lib/libc/locale/global_locale.c   Sat May 22 11:20:18 2010 +0000
+++ b/lib/libc/locale/global_locale.c   Sat May 22 13:15:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: global_locale.c,v 1.7 2010/05/22 07:18:43 tnozaki Exp $ */
+/* $NetBSD: global_locale.c,v 1.8 2010/05/22 13:15:59 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: global_locale.c,v 1.7 2010/05/22 07:18:43 tnozaki Exp $");
+__RCSID("$NetBSD: global_locale.c,v 1.8 2010/05/22 13:15:59 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -134,16 +134,17 @@
        [(size_t)ALT_DIGITS ] = NULL,
 };
 
-struct _locale_impl_t _global_locale =
-{
-    .cache = {
-        .ctype_tab   = (const unsigned char *)&_C_ctype_[0],
-        .tolower_tab = (const short *)&_C_tolower_[0],
-        .toupper_tab = (const short *)&_C_toupper_[0],
-        .mb_cur_max = (size_t)1,
-        .ldata = &_global_ldata,
-        .items = &_global_items[0],
-    },
+static struct _locale_cache_t _global_cache = {
+    .ctype_tab   = (const unsigned char *)&_C_ctype_[0],
+    .tolower_tab = (const short *)&_C_tolower_[0],
+    .toupper_tab = (const short *)&_C_toupper_[0],
+    .mb_cur_max = (size_t)1,
+    .ldata = &_global_ldata,
+    .items = &_global_items[0],
+};
+
+struct _locale_impl_t _global_locale = {
+    .cache = &_global_cache,
     .query = { _C_LOCALE },
     .part_name = {
        [(size_t)LC_ALL     ] = _C_LOCALE,
diff -r 1ebb68451b98 -r 7487729e2e15 lib/libc/locale/localeconv.c
--- a/lib/libc/locale/localeconv.c      Sat May 22 11:20:18 2010 +0000
+++ b/lib/libc/locale/localeconv.c      Sat May 22 13:15:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: localeconv.c,v 1.17 2010/03/27 15:25:22 tnozaki Exp $ */
+/* $NetBSD: localeconv.c,v 1.18 2010/05/22 13:15:59 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: localeconv.c,v 1.17 2010/03/27 15:25:22 tnozaki Exp $");
+__RCSID("$NetBSD: localeconv.c,v 1.18 2010/05/22 13:15:59 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -41,8 +41,5 @@
 struct lconv *
 localeconv()
 {
-       struct _locale_impl_t *impl;
-
-       impl = *_current_locale();
-       return impl->cache.ldata;
+       return _current_cache()->ldata;
 }
diff -r 1ebb68451b98 -r 7487729e2e15 lib/libc/locale/nb_lc_template.h
--- a/lib/libc/locale/nb_lc_template.h  Sat May 22 11:20:18 2010 +0000
+++ b/lib/libc/locale/nb_lc_template.h  Sat May 22 13:15:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_template.h,v 1.2 2009/01/11 02:46:29 christos Exp $ */
+/* $NetBSD: nb_lc_template.h,v 1.3 2010/05/22 13:15:59 tnozaki Exp $ */
 
 /*-
  * Copyright (c)1999, 2008 Citrus Project,
@@ -235,7 +235,7 @@
                            = &part->name[0];
                        locale->part_impl[(size_t)_CATEGORY_ID]
                            = part->impl;
-                       _PREFIX(build_cache)(&locale->cache, part->impl);
+                       _PREFIX(build_cache)(locale->cache, part->impl);
                        if (locale == &_global_locale)
                                _PREFIX(fixup)(part->impl);
                }
diff -r 1ebb68451b98 -r 7487729e2e15 lib/libc/locale/nl_langinfo.c
--- a/lib/libc/locale/nl_langinfo.c     Sat May 22 11:20:18 2010 +0000
+++ b/lib/libc/locale/nl_langinfo.c     Sat May 22 13:15:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nl_langinfo.c,v 1.14 2010/03/27 15:25:22 tnozaki Exp $ */
+/* $NetBSD: nl_langinfo.c,v 1.15 2010/05/22 13:15:59 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nl_langinfo.c,v 1.14 2010/03/27 15:25:22 tnozaki Exp $");
+__RCSID("$NetBSD: nl_langinfo.c,v 1.15 2010/05/22 13:15:59 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -43,13 +43,10 @@
 nl_langinfo(nl_item item)
 {
        const char *s;
-       struct _locale_impl_t *impl;
 
        s = NULL;
-       if (item >= D_T_FMT && item <= ALT_DIGITS) {
-               impl = *_current_locale();
-               s = impl->cache.items[(size_t)item];
-       }
+       if (item >= D_T_FMT && item <= ALT_DIGITS)
+               s = _current_cache()->items[(size_t)item];
        if (s == NULL)
                s = "";
        return __UNCONST(s);
diff -r 1ebb68451b98 -r 7487729e2e15 lib/libc/locale/setlocale_local.h
--- a/lib/libc/locale/setlocale_local.h Sat May 22 11:20:18 2010 +0000
+++ b/lib/libc/locale/setlocale_local.h Sat May 22 13:15:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: setlocale_local.h,v 1.4 2010/03/27 15:25:22 tnozaki Exp $ */
+/* $NetBSD: setlocale_local.h,v 1.5 2010/05/22 13:15:59 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -49,7 +49,7 @@
 };
 
 struct _locale_impl_t {
-       struct _locale_cache_t cache;
+       struct _locale_cache_t *cache;
        char query[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)];
        const char *part_name[_LC_LAST];
        _locale_part_t part_impl[_LC_LAST];
@@ -71,4 +71,10 @@
 struct _locale_impl_t  **_current_locale(void);
 __END_DECLS
 
+static __inline struct _locale_cache_t *
+_current_cache(void)
+{
+       return (*_current_locale())->cache;
+}
+
 #endif /*_SETLOCALE_LOCAL_H_*/



Home | Main Index | Thread Index | Old Index