diff options
author | Gordon Ross <gwr@nexenta.com> | 2015-10-01 11:18:47 -0400 |
---|---|---|
committer | Gordon Ross <gwr@nexenta.com> | 2015-10-22 14:43:29 -0400 |
commit | bc09504ff1ed70f84c9713b732281f14a9ef49b2 (patch) | |
tree | 93646b9d8455cfc1a5054b7cb4d65e0b88abdbb3 | |
parent | cf397aabe4e38964cfeb03e56ca8b407986c3a10 (diff) | |
download | illumos-gate-bc09504ff1ed70f84c9713b732281f14a9ef49b2.tar.gz |
6350 localedef native build improvements
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Dan McDonald <danmcd@omniti.com>
-rw-r--r-- | usr/src/cmd/localedef/Makefile | 22 | ||||
-rw-r--r-- | usr/src/cmd/localedef/collate.c | 2 | ||||
-rw-r--r-- | usr/src/lib/libc/port/locale/collate.c | 7 | ||||
-rw-r--r-- | usr/src/lib/libc/port/locale/collate.h | 67 | ||||
-rw-r--r-- | usr/src/lib/libc/port/locale/collatefile.h | 108 | ||||
-rw-r--r-- | usr/src/lib/libc/port/locale/localeimpl.c | 1 | ||||
-rw-r--r-- | usr/src/lib/libc/port/locale/localeimpl.h | 3 | ||||
-rw-r--r-- | usr/src/lib/libc/port/locale/runetype.h | 6 | ||||
-rw-r--r-- | usr/src/lib/libc/port/locale/setlocale.c | 1 |
9 files changed, 139 insertions, 78 deletions
diff --git a/usr/src/cmd/localedef/Makefile b/usr/src/cmd/localedef/Makefile index 03432dbcf8..b7cab95d67 100644 --- a/usr/src/cmd/localedef/Makefile +++ b/usr/src/cmd/localedef/Makefile @@ -25,7 +25,7 @@ include ../Makefile.cmd OBJS = charmap.o collate.o ctype.o messages.o monetary.o numeric.o time.o \ scanner.o localedef.o wide.o parser.tab.o -NOBJS = $(OBJS:%.o=native/%.o) +NOBJS = $(OBJS:%.o=native/%.o) native/avl.o native/mkdirp.o HDRS = localedef.h @@ -38,16 +38,9 @@ CERRWARN += -_gcc=-Wno-uninitialized CERRWARN += -_gcc=-Wno-unused-label LDLIBS += -lgen LDLIBS += -lavl -NATIVELDLIBS += -lgen -# -# Unfortunately, we have a chicken and an egg problem. libavl is becoming -# public, which means that all of its symbols are in a version that the build -# machine doesn't have and traditionally there has been no libavl compilation -# symlink. Therefore, because we know that we only support building on illumos, -# we regrettably have to link explicitly against the full library path. Sorry. -# -NATIVELDLIBS += /usr/lib/libavl.so.1 +NATIVELDLIBS= + YFLAGS = -d -b parser CLEANFILES = $(NOBJS) $(OBJS) parser.tab.c parser.tab.h @@ -278,7 +271,14 @@ $(NDIR): $(NDIR)/%.o: %.c $(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c $< - $(POST_PROCESS_O) + +$(NDIR)/avl.o : ../../common/avl/avl.c + $(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c \ + ../../common/avl/avl.c + +$(NDIR)/mkdirp.o : ../../lib/libgen/common/mkdirp.c + $(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c \ + ../../lib/libgen/common/mkdirp.c $(NPROG): $(NDIR) .WAIT $(NOBJS) $(LINK.c) $(NOBJS) -o $@ $(NATIVELDLIBS) diff --git a/usr/src/cmd/localedef/collate.c b/usr/src/cmd/localedef/collate.c index 7a3c65dbbd..6fefe5f648 100644 --- a/usr/src/cmd/localedef/collate.c +++ b/usr/src/cmd/localedef/collate.c @@ -30,7 +30,7 @@ #include <limits.h> #include "localedef.h" #include "parser.tab.h" -#include "collate.h" +#include "collatefile.h" /* * Design notes. diff --git a/usr/src/lib/libc/port/locale/collate.c b/usr/src/lib/libc/port/locale/collate.c index 75814a9a9f..4dead90973 100644 --- a/usr/src/lib/libc/port/locale/collate.c +++ b/usr/src/lib/libc/port/locale/collate.c @@ -44,7 +44,12 @@ #include <sys/mman.h> #include "collate.h" -#include "setlocale.h" +#include "localeimpl.h" + +/* Check file format vs libc runtime. (See collatefile.h) */ +#if COLL_WEIGHTS_MAX != COLLATE_WEIGHTS_MAX +#error "COLL_WEIGHTS_MAX != COLLATE_WEIGHTS_MAX" +#endif /* * See the comments in usr/src/cmd/localedef/collate.c for further diff --git a/usr/src/lib/libc/port/locale/collate.h b/usr/src/lib/libc/port/locale/collate.h index d3496be7cf..e9b3cbd2b0 100644 --- a/usr/src/lib/libc/port/locale/collate.h +++ b/usr/src/lib/libc/port/locale/collate.h @@ -1,6 +1,6 @@ /* + * Copyright 2015 Nexenta Systmes, Inc. All rights reserved. * Copyright 2013 Garrett D'Amore <garrett@damore.org> - * Copyright 2010 Nexenta Systmes, Inc. All rights reserved. * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua> * at Electronni Visti IA, Kiev, Ukraine. * All rights reserved. @@ -30,71 +30,18 @@ #ifndef _COLLATE_H_ #define _COLLATE_H_ +/* + * This file defines the libc interface to LC_COLLATE data. + */ + #include <sys/types.h> #include <limits.h> -#include <locale.h> +#include "collatefile.h" #include "localeimpl.h" -#define COLLATE_STR_LEN 24 /* should be 64-bit multiple */ -#define COLLATE_VERSION "IllumosCollate2\n" - -#define COLLATE_MAX_PRIORITY (0x7fffffff) /* max signed value */ -#define COLLATE_SUBST_PRIORITY (0x40000000) /* bit indicates subst table */ - -#define DIRECTIVE_UNDEF 0x00 -#define DIRECTIVE_FORWARD 0x01 -#define DIRECTIVE_BACKWARD 0x02 -#define DIRECTIVE_POSITION 0x04 -#define DIRECTIVE_UNDEFINED 0x08 /* special last weight for UNDEFINED */ - -#define DIRECTIVE_DIRECTION_MASK (DIRECTIVE_FORWARD | DIRECTIVE_BACKWARD) - /* - * The collate file format is as follows: - * - * char version[COLLATE_STR_LEN]; // must be COLLATE_VERSION - * collate_info_t info; // see below, includes padding - * collate_char_pri_t char_data[256]; // 8 bit char values - * collate_subst_t subst[*]; // 0 or more substitutions - * collate_chain_pri_t chains[*]; // 0 or more chains - * collate_large_pri_t large[*]; // extended char priorities - * - * Note that all structures must be 32-bit aligned, as each structure - * contains 32-bit member fields. The entire file is mmap'd, so its - * critical that alignment be observed. It is not generally safe to - * use any 64-bit values in the structures. + * This is the run-time (in-memory) form of LC_COLLATE data. */ - -typedef struct collate_info { - uint8_t directive_count; - uint8_t directive[COLL_WEIGHTS_MAX]; - int32_t pri_count[COLL_WEIGHTS_MAX]; - int32_t flags; - int32_t chain_count; - int32_t large_count; - int32_t subst_count[COLL_WEIGHTS_MAX]; - int32_t undef_pri[COLL_WEIGHTS_MAX]; -} collate_info_t; - -typedef struct collate_char { - int32_t pri[COLL_WEIGHTS_MAX]; -} collate_char_t; - -typedef struct collate_chain { - wchar_t str[COLLATE_STR_LEN]; - int32_t pri[COLL_WEIGHTS_MAX]; -} collate_chain_t; - -typedef struct collate_large { - int32_t val; - collate_char_t pri; -} collate_large_t; - -typedef struct collate_subst { - int32_t key; - int32_t pri[COLLATE_STR_LEN]; -} collate_subst_t; - struct lc_collate { int lc_is_posix; diff --git a/usr/src/lib/libc/port/locale/collatefile.h b/usr/src/lib/libc/port/locale/collatefile.h new file mode 100644 index 0000000000..a6d7fdf0f4 --- /dev/null +++ b/usr/src/lib/libc/port/locale/collatefile.h @@ -0,0 +1,108 @@ +/* + * Copyright 2015 Nexenta Systmes, Inc. All rights reserved. + * Copyright 2013 Garrett D'Amore <garrett@damore.org> + * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua> + * at Electronni Visti IA, Kiev, Ukraine. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _COLLATEFILE_H_ +#define _COLLATEFILE_H_ + +/* + * This file defines the format of collation data files. + * These are the files loaded to support LC_COLLATE category + * locale data. Please note that this must define the file + * format in a way that allows localedef to build such files + * without assuming that the build system has all the same + * locale.h defines and structures, which means this should + * remain independent of things like limits.h values. + */ + +#include <sys/types.h> + +/* NB: libc build ensure this is == COLL_WEIGHTS_MAX (from limits.h) */ +#define COLLATE_WEIGHTS_MAX 10 + +#define COLLATE_STR_LEN 24 /* should be 64-bit multiple */ +#define COLLATE_VERSION "IllumosCollate2\n" + +#define COLLATE_MAX_PRIORITY (0x7fffffff) /* max signed value */ +#define COLLATE_SUBST_PRIORITY (0x40000000) /* bit indicates subst table */ + +#define DIRECTIVE_UNDEF 0x00 +#define DIRECTIVE_FORWARD 0x01 +#define DIRECTIVE_BACKWARD 0x02 +#define DIRECTIVE_POSITION 0x04 +#define DIRECTIVE_UNDEFINED 0x08 /* special last weight for UNDEFINED */ + +#define DIRECTIVE_DIRECTION_MASK (DIRECTIVE_FORWARD | DIRECTIVE_BACKWARD) + +/* + * The collate file format is as follows: + * + * char version[COLLATE_STR_LEN]; // must be COLLATE_VERSION + * collate_info_t info; // see below, includes padding + * collate_char_pri_t char_data[256]; // 8 bit char values + * collate_subst_t subst[*]; // 0 or more substitutions + * collate_chain_pri_t chains[*]; // 0 or more chains + * collate_large_pri_t large[*]; // extended char priorities + * + * Note that all structures must be 32-bit aligned, as each structure + * contains 32-bit member fields. The entire file is mmap'd, so its + * critical that alignment be observed. It is not generally safe to + * use any 64-bit values in the structures. + */ + +typedef struct collate_info { + uint8_t directive_count; + uint8_t directive[COLLATE_WEIGHTS_MAX]; + int32_t pri_count[COLLATE_WEIGHTS_MAX]; + int32_t flags; + int32_t chain_count; + int32_t large_count; + int32_t subst_count[COLLATE_WEIGHTS_MAX]; + int32_t undef_pri[COLLATE_WEIGHTS_MAX]; +} collate_info_t; + +typedef struct collate_char { + int32_t pri[COLLATE_WEIGHTS_MAX]; +} collate_char_t; + +typedef struct collate_chain { + wchar_t str[COLLATE_STR_LEN]; + int32_t pri[COLLATE_WEIGHTS_MAX]; +} collate_chain_t; + +typedef struct collate_large { + int32_t val; + collate_char_t pri; +} collate_large_t; + +typedef struct collate_subst { + int32_t key; + int32_t pri[COLLATE_STR_LEN]; +} collate_subst_t; + +#endif /* !_COLLATEFILE_H_ */ diff --git a/usr/src/lib/libc/port/locale/localeimpl.c b/usr/src/lib/libc/port/locale/localeimpl.c index c1817060bc..f7e3ab240f 100644 --- a/usr/src/lib/libc/port/locale/localeimpl.c +++ b/usr/src/lib/libc/port/locale/localeimpl.c @@ -97,6 +97,7 @@ extern struct lc_messages lc_messages_posix; extern struct lc_time lc_time_posix; extern struct lc_ctype lc_ctype_posix; extern struct lc_collate lc_collate_posix; +extern struct _RuneLocale _DefaultRuneLocale; static struct _locale posix_locale = { /* locdata */ diff --git a/usr/src/lib/libc/port/locale/localeimpl.h b/usr/src/lib/libc/port/locale/localeimpl.h index 857666bf14..5d1eb9c451 100644 --- a/usr/src/lib/libc/port/locale/localeimpl.h +++ b/usr/src/lib/libc/port/locale/localeimpl.h @@ -28,7 +28,6 @@ #include <locale.h> #include <xlocale.h> #include "setlocale.h" -#include "runetype.h" /* private locale structures */ @@ -70,7 +69,7 @@ struct _locale { const struct lc_monetary *monetary; const struct lc_numeric *numeric; const struct lc_time *time; - const _RuneLocale *runelocale; + const struct _RuneLocale *runelocale; /* * The loaded value is used for localeconv. In paticular, when diff --git a/usr/src/lib/libc/port/locale/runetype.h b/usr/src/lib/libc/port/locale/runetype.h index 3abdd1afa9..467a47ba8e 100644 --- a/usr/src/lib/libc/port/locale/runetype.h +++ b/usr/src/lib/libc/port/locale/runetype.h @@ -97,19 +97,19 @@ typedef int __rune_t; /* rune_t (see above) */ /* * The lower 8 bits of runetype[] contain the digit value of the rune. */ -typedef struct { +typedef struct _RuneEntry { __rune_t __min; /* First rune of the range */ __rune_t __max; /* Last rune (inclusive) of the range */ __rune_t __map; /* What first maps to in maps */ unsigned *__types; /* Array of types in range */ } _RuneEntry; -typedef struct { +typedef struct _RuneRange { int __nranges; /* Number of ranges stored */ _RuneEntry *__ranges; /* Pointer to the ranges */ } _RuneRange; -typedef struct { +typedef struct _RuneLocale { char __magic[8]; /* Magic saying what version we are */ char __encoding[32]; /* ASCII name of encoding */ diff --git a/usr/src/lib/libc/port/locale/setlocale.c b/usr/src/lib/libc/port/locale/setlocale.c index 18628a3135..d2b308565d 100644 --- a/usr/src/lib/libc/port/locale/setlocale.c +++ b/usr/src/lib/libc/port/locale/setlocale.c @@ -47,6 +47,7 @@ #include "collate.h" #include "lnumeric.h" /* for struct lc_numeric */ #include "lctype.h" /* for struct lc_ctype */ +#include "runetype.h" #include "setlocale.h" #include "../i18n/_loc_path.h" #include "localeimpl.h" |