This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Does --enable-clocale=gnu work on Linux/ia64?


On Mon, Nov 26, 2001 at 10:43:57AM +0100, Jakub Jelinek wrote:
> On Sun, Nov 25, 2001 at 10:17:35PM -0800, Benjamin Kosnik wrote:
> > 
> > > > Well, on x86 and powerpc, wchar_t is long int. Gcc won't complain about
> > > > casting from char* to wchar_t. However, on ia64, wchar_t is int. Gcc is
> > > > not very happy. I think that part of libstdc++ is pretty much broken.
> > 
> > Backstory for Ulrich.
> > 
> > > 2001-11-25  H.J. Lu <hjl@gnu.org>
> > > 
> > > 	* config/locale/moneypunct_members_gnu.cc
> > > 	(_M_initialize_moneypunct): Cast "char *" to "long int" before
> > > 	casting to wchar_t for _NL_NUMERIC_DECIMAL_POINT_WC and
> > > 	_NL_NUMERIC_THOUSANDS_SEP_WC.
> > > 	* config/locale/numpunct_members_gnu.cc 
> > > 	(_M_initialize_numpunct): Likewise.
> > > 
> > > -	  _M_decimal_point = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
> > > -	  _M_thousands_sep = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
> > > +	  long int ch;
> > > +	  ch = reinterpret_cast<long int>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
> > > +	  _M_decimal_point = (wchar_t) ch;
> > 
> > C++ style casts, like        static_cast<wchar_t>(ch);
> > 
> > Looks ok to me. Uli?
> > 
> > Did you try this on x86 and ia64?
> 
> Whatever cast you use, this is wrong.
> categories.def:
>   DEFINE_ELEMENT (_NL_NUMERIC_DECIMAL_POINT_WC, "numeric-decimal-point-wc", std, word)
>   DEFINE_ELEMENT (_NL_NUMERIC_THOUSANDS_SEP_WC, "numeric-thousands-sep-wc", std, word)
> localeinfo.h:
>   union locale_data_value
>   {
>     const uint32_t *wstr;
>     const char *string;
>     unsigned int word;
>   }

Since we expose __nl_langinfo_l, shouldn't we also expose union
locale_data_value?

>   values __flexarr;     /* Items, usually pointers into `filedata'.  */
> nl_langinfo.c:
>   /* Return the string for the specified item.  */
>   return (char *) data->values[index].string;
> 
> So, what you need to do is:
> 
>   union { const char *string; unsigned int word; } __tmp;
>   __tmp.string = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
>   _M_decimal_point = static_cast<wchar_t>(ch);

Did you mean

_M_decimal_point = static_cast<wchar_t>(__tmp.word);

> 
> resp:
>   _M_decimal_point = static_cast<wchar_t>(((union { const char *s; unsinged int w; }){ s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).w)
> Otherwise, big endian looses.
> 
> 	Jakub


H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]