Subject: Re: mklocale, take 2
To: None <itojun@iijlab.net>
From: James Chacon <jchacon@genuity.net>
List: tech-userlevel
Date: 10/18/2001 03:39:46
>>>> 	to be sure i have to check standard, but IIRC the change should not be
>>>> 	made.  __*int* references, as well as these _BSD_*_T #defines, were
>>>> 	made due to the inclusion file ordering issue.
>>>IIRC,
>>>netbsd don't have that problem
>>>since rune.h and runetype.h are not exposed to user.
>>>(i.e. we don't have to support arbitrary inclusion order.)
>
>	hmm, my memory was worng then.

Actually this did cause me to try and compile everything on non-native systems
and on a macppc 1.5.2 box I enabled USE_NEW_TOOLCHAIN on.

Turns out I missed one thing: mbstate_t, which is relatively new as of late.

Wrapping the RuneState struct definition with #ifdef _LIBC does the trick and
I'm finishing a build now to make sure this works correctly.

Diffs for runetype.h are attached if anyone is curious on the final changes.

James

Index: lib/libc/locale/runetype.h
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/locale/runetype.h,v
retrieving revision 1.5
diff -u -r1.5 runetype.h
--- lib/libc/locale/runetype.h  2001/03/26 19:55:43     1.5
+++ lib/libc/locale/runetype.h  2001/10/18 07:38:51
@@ -41,36 +41,13 @@
 #ifndef        _RUNETYPE_H_
 #define        _RUNETYPE_H_
 
-#include <sys/cdefs.h>
-#include <machine/ansi.h>
-
-#include <machine/int_types.h>
-typedef __uint64_t     __runepad_t;
-
-#ifdef _BSD_SIZE_T_
-typedef        _BSD_SIZE_T_    size_t;
-#undef _BSD_SIZE_T_
-#endif
+#include <inttypes.h>
+#include <wchar.h>
 
-#ifdef _BSD_WCHAR_T_
-typedef        _BSD_WCHAR_T_   wchar_t;
-#undef _BSD_WCHAR_T_
-#endif
-
-#ifdef _BSD_WINT_T_
-typedef        _BSD_WINT_T_    wint_t;
-#undef _BSD_WINT_T_
-#endif
-
-#ifdef _BSD_MBSTATE_T_
-typedef        _BSD_MBSTATE_T_ mbstate_t;
-#undef _BSD_MBSTATE_T_
-#endif
+#include <sys/cdefs.h>
+#include <sys/types.h>
 
-#ifdef _BSD_RUNE_T_
-typedef        _BSD_RUNE_T_    rune_t;
-#undef _BSD_RUNE_T_
-#endif
+typedef uint64_t       __runepad_t;
 
 extern size_t __mb_len_max_runtime;
 #define __MB_LEN_MAX_RUNTIME   __mb_len_max_runtime
@@ -82,7 +59,7 @@
 /*
  * The lower 8 bits of runetype[] contain the digit value of the rune.
  */
-typedef __uint32_t _RuneType;
+typedef uint32_t _RuneType;
 #define        _CTYPE_A        0x00000100L     /* Alpha */
 #define        _CTYPE_C        0x00000200L     /* Control */
 #define        _CTYPE_D        0x00000400L     /* Digit */
@@ -109,17 +86,17 @@
  * rune file format.  network endian.
  */
 typedef struct {
-       __int32_t       __min;          /* First rune of the range */
-       __int32_t       __max;          /* Last rune (inclusive) of the range */
-       __int32_t       __map;          /* What first maps to in maps */
-       __uint32_t      __pad1;         /* backward compatibility */
+       int32_t         __min;          /* First rune of the range */
+       int32_t         __max;          /* Last rune (inclusive) of the range */
+       int32_t         __map;          /* What first maps to in maps */
+       uint32_t        __pad1;         /* backward compatibility */
        __runepad_t     __pad2;         /* backward compatibility */
 } _FileRuneEntry __attribute__((__packed__));
 
 
 typedef struct {
-       __uint32_t      __nranges;      /* Number of ranges stored */
-       __uint32_t      __pad1;         /* backward compatibility */
+       uint32_t        __nranges;      /* Number of ranges stored */
+       uint32_t        __pad1;         /* backward compatibility */
        __runepad_t     __pad2;         /* backward compatibility */
 } _FileRuneRange __attribute__((__packed__));
 
@@ -130,12 +107,12 @@
 
        __runepad_t     __pad1;         /* backward compatibility */
        __runepad_t     __pad2;         /* backward compatibility */
-       __int32_t       __invalid_rune;
-       __uint32_t      __pad3;         /* backward compatibility */
+       int32_t         __invalid_rune;
+       uint32_t        __pad3;         /* backward compatibility */
 
        _RuneType       __runetype[_CACHED_RUNES];
-       __int32_t       __maplower[_CACHED_RUNES];
-       __int32_t       __mapupper[_CACHED_RUNES];
+       int32_t         __maplower[_CACHED_RUNES];
+       int32_t         __mapupper[_CACHED_RUNES];
 
        /*
         * The following are to deal with Runes larger than _CACHED_RUNES - 1.
@@ -147,8 +124,8 @@
        _FileRuneRange  __mapupper_ext;
 
        __runepad_t     __pad4;         /* backward compatibility */
-       __int32_t       __variable_len; /* how long that data is */
-       __uint32_t      __pad5;         /* backward compatibility */
+       int32_t         __variable_len; /* how long that data is */
+       uint32_t        __pad5;         /* backward compatibility */
 
        /* variable size data follows */
 } _FileRuneLocale __attribute__((__packed__));
@@ -166,12 +143,14 @@
 
 
 typedef struct {
-       __uint32_t      __nranges;      /* Number of ranges stored */
+       uint32_t        __nranges;      /* Number of ranges stored */
        _RuneEntry      *__rune_ranges;
 } _RuneRange;
 
 
 struct _RuneLocale;
+struct _RuneState;
+#ifdef _LIBC
 typedef struct _RuneState {
        size_t          __sizestate;
        void            (*__initstate) __P((struct _RuneLocale *, void *));
@@ -180,7 +159,7 @@
        void            (*__unpackstate)
                __P((struct _RuneLocale *, void *, const mbstate_t *));
 } _RuneState;
-
+#endif
 
 typedef size_t (*__rune_mbrtowc_t) __P((struct _RuneLocale *, rune_t *,
        const char *, size_t, void *));