xref: /dflybsd-src/lib/libc/locale/duplocale.3 (revision 1c87de762681b4307ca18e82243f6ca308dcab6d)
10d5acd74SJohn Marino.\" Copyright (c) 2011 The FreeBSD Foundation
20d5acd74SJohn Marino.\" All rights reserved.
30d5acd74SJohn Marino.\"
40d5acd74SJohn Marino.\" This documentation was written by David Chisnall under sponsorship from
50d5acd74SJohn Marino.\" the FreeBSD Foundation.
60d5acd74SJohn Marino.\"
70d5acd74SJohn Marino.\" Redistribution and use in source and binary forms, with or without
80d5acd74SJohn Marino.\" modification, are permitted provided that the following conditions
90d5acd74SJohn Marino.\" are met:
100d5acd74SJohn Marino.\" 1. Redistributions of source code must retain the above copyright
110d5acd74SJohn Marino.\"    notice, this list of conditions and the following disclaimer.
120d5acd74SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright
130d5acd74SJohn Marino.\"    notice, this list of conditions and the following disclaimer in the
140d5acd74SJohn Marino.\"    documentation and/or other materials provided with the distribution.
150d5acd74SJohn Marino.\"
160d5acd74SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
170d5acd74SJohn Marino.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
180d5acd74SJohn Marino.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
190d5acd74SJohn Marino.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
200d5acd74SJohn Marino.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
210d5acd74SJohn Marino.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
220d5acd74SJohn Marino.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
230d5acd74SJohn Marino.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
240d5acd74SJohn Marino.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
250d5acd74SJohn Marino.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
260d5acd74SJohn Marino.\" SUCH DAMAGE.
270d5acd74SJohn Marino.\"
28*1c87de76Szrj.\" $FreeBSD: head/lib/libc/locale/duplocale.3 281925 2015-04-24 10:17:55Z theraven $
290d5acd74SJohn Marino.\"
300d5acd74SJohn Marino.Dd September 17, 2011
310d5acd74SJohn Marino.Dt DUPLOCALE 3
320d5acd74SJohn Marino.Os
330d5acd74SJohn Marino.Sh NAME
340d5acd74SJohn Marino.Nm duplocale
350d5acd74SJohn Marino.Nd duplicate an locale
360d5acd74SJohn Marino.Sh LIBRARY
370d5acd74SJohn Marino.Lb libc
380d5acd74SJohn Marino.Sh SYNOPSIS
39*1c87de76Szrj.In locale.h
400d5acd74SJohn Marino.Ft locale_t
410d5acd74SJohn Marino.Fn duplocale "locale_t locale"
420d5acd74SJohn Marino.Sh DESCRIPTION
430d5acd74SJohn MarinoDuplicates an existing
440d5acd74SJohn Marino.Fa locale_t
450d5acd74SJohn Marinoreturning a new
460d5acd74SJohn Marino.Fa locale_t
470d5acd74SJohn Marinothat refers to the same locale values but has an independent internal state.
480d5acd74SJohn MarinoVarious functions, such as
490d5acd74SJohn Marino.Xr mblen 3
500d5acd74SJohn Marinorequire a persistent state.
510d5acd74SJohn MarinoThese functions formerly used static variables and calls to them from multiple
520d5acd74SJohn Marinothreads had undefined behavior.
530d5acd74SJohn MarinoThey now use fields in the
540d5acd74SJohn Marino.Fa locale_t
550d5acd74SJohn Marinoassociated with the current thread by
560d5acd74SJohn Marino.Xr uselocale 3 .
570d5acd74SJohn MarinoThese calls are therefore only thread safe on threads with a unique per-thread
580d5acd74SJohn Marinolocale.
590d5acd74SJohn MarinoThe locale returned by this call must be freed with
600d5acd74SJohn Marino.Xr freelocale 3 .
610d5acd74SJohn Marino.Sh SEE ALSO
620d5acd74SJohn Marino.Xr freelocale 3 ,
630d5acd74SJohn Marino.Xr localeconv 3 ,
640d5acd74SJohn Marino.Xr newlocale 3 ,
650d5acd74SJohn Marino.Xr querylocale 3 ,
660d5acd74SJohn Marino.Xr uselocale 3 ,
670d5acd74SJohn Marino.Xr xlocale 3
680d5acd74SJohn Marino.Sh STANDARDS
690d5acd74SJohn MarinoThis function conforms to
700d5acd74SJohn Marino.St -p1003.1-2008 .
710d5acd74SJohn Marino.Sh BUGS
720d5acd74SJohn MarinoIdeally,
730d5acd74SJohn Marino.Xr uselocale 3
740d5acd74SJohn Marinoshould make a copy of the
750d5acd74SJohn Marino.Fa locale_t
760d5acd74SJohn Marinoimplicitly to ensure thread safety,
770d5acd74SJohn Marinoand a copy of the global locale should be installed lazily on each thread.
788d975f05SSascha WildnerThe
798d975f05SSascha Wildner.Fx
808d975f05SSascha Wildnerimplementation does not do this, for compatibility with Darwin.
81