This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: [RFC] PR 6015: number formatting is not mt-safe


On Fri, 2002-03-22 at 17:45, Benjamin Kosnik wrote:

>   template<typename _Tv>
>     int
>     __convert_from_v(char* __out, const int __size, const char* __fmt,
> 		     _Tv __v, const __c_locale& __cloc, int __prec = -1)
>     {
>       int __ret;
>       __c_locale __old = __uselocale(__cloc);
>       if (__prec >= 0)
>         __ret = snprintf(__out, __size, __fmt, __prec, __v);
>       else
>         __ret = snprintf(__out, __size, __fmt, __v);
>       __uselocale(__old);
> 
>       return __ret;
>     }

It's not obvious from this, but the code above is thread-safe.  See

  http://www.cygnus.com/~drepper/tllocale.ps.bz2

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

Attachment: signature.asc
Description: This is a digitally signed message part


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