13c87aa1dSDavid Chisnall.\" Copyright (c) 2011 The FreeBSD Foundation 23c87aa1dSDavid Chisnall.\" 33c87aa1dSDavid Chisnall.\" This documentation was written by David Chisnall under sponsorship from 43c87aa1dSDavid Chisnall.\" the FreeBSD Foundation. 53c87aa1dSDavid Chisnall.\" 63c87aa1dSDavid Chisnall.\" Redistribution and use in source and binary forms, with or without 73c87aa1dSDavid Chisnall.\" modification, are permitted provided that the following conditions 83c87aa1dSDavid Chisnall.\" are met: 93c87aa1dSDavid Chisnall.\" 1. Redistributions of source code must retain the above copyright 103c87aa1dSDavid Chisnall.\" notice, this list of conditions and the following disclaimer. 113c87aa1dSDavid Chisnall.\" 2. Redistributions in binary form must reproduce the above copyright 123c87aa1dSDavid Chisnall.\" notice, this list of conditions and the following disclaimer in the 133c87aa1dSDavid Chisnall.\" documentation and/or other materials provided with the distribution. 143c87aa1dSDavid Chisnall.\" 153c87aa1dSDavid Chisnall.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 163c87aa1dSDavid Chisnall.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 173c87aa1dSDavid Chisnall.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 183c87aa1dSDavid Chisnall.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 193c87aa1dSDavid Chisnall.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 203c87aa1dSDavid Chisnall.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 213c87aa1dSDavid Chisnall.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 223c87aa1dSDavid Chisnall.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 233c87aa1dSDavid Chisnall.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 243c87aa1dSDavid Chisnall.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 253c87aa1dSDavid Chisnall.\" SUCH DAMAGE. 263c87aa1dSDavid Chisnall.\" 274f79ce7bSSergey Kandaurov.Dd September 17, 2011 283c87aa1dSDavid Chisnall.Dt DUPLOCALE 3 293c87aa1dSDavid Chisnall.Os 303c87aa1dSDavid Chisnall.Sh NAME 313c87aa1dSDavid Chisnall.Nm duplocale 323c87aa1dSDavid Chisnall.Nd duplicate an locale 333c87aa1dSDavid Chisnall.Sh LIBRARY 343c87aa1dSDavid Chisnall.Lb libc 353c87aa1dSDavid Chisnall.Sh SYNOPSIS 36*58912ae7SDavid Chisnall.In locale.h 373c87aa1dSDavid Chisnall.Ft locale_t 383c87aa1dSDavid Chisnall.Fn duplocale "locale_t locale" 393c87aa1dSDavid Chisnall.Sh DESCRIPTION 403c87aa1dSDavid ChisnallDuplicates an existing 413c87aa1dSDavid Chisnall.Fa locale_t 423c87aa1dSDavid Chisnallreturning a new 433c87aa1dSDavid Chisnall.Fa locale_t 44a3fb6da9SGlen Barberthat refers to the same locale values but has an independent internal state. 453c87aa1dSDavid ChisnallVarious functions, such as 463c87aa1dSDavid Chisnall.Xr mblen 3 47a3fb6da9SGlen Barberrequire a persistent state. 4884493996SDavid E. O'BrienThese functions formerly used static variables and calls to them from multiple 4984493996SDavid E. O'Brienthreads had undefined behavior. 5084493996SDavid E. O'BrienThey now use fields in the 513c87aa1dSDavid Chisnall.Fa locale_t 523c87aa1dSDavid Chisnallassociated with the current thread by 533c87aa1dSDavid Chisnall.Xr uselocale 3 . 543c87aa1dSDavid ChisnallThese calls are therefore only thread safe on threads with a unique per-thread 553c87aa1dSDavid Chisnalllocale. 563c87aa1dSDavid ChisnallThe locale returned by this call must be freed with 573c87aa1dSDavid Chisnall.Xr freelocale 3 . 583c87aa1dSDavid Chisnall.Sh SEE ALSO 593c87aa1dSDavid Chisnall.Xr freelocale 3 , 603c87aa1dSDavid Chisnall.Xr localeconv 3 , 613c87aa1dSDavid Chisnall.Xr newlocale 3 , 623c87aa1dSDavid Chisnall.Xr querylocale 3 , 633c87aa1dSDavid Chisnall.Xr uselocale 3 , 643c87aa1dSDavid Chisnall.Xr xlocale 3 653c87aa1dSDavid Chisnall.Sh STANDARDS 66cc7a693fSSergey KandaurovThis function conforms to 6767ff590bSSergey Kandaurov.St -p1003.1-2008 . 6812afe06cSJoel Dahl.Sh BUGS 6912afe06cSJoel DahlIdeally, 7012afe06cSJoel Dahl.Xr uselocale 3 7112afe06cSJoel Dahlshould make a copy of the 7212afe06cSJoel Dahl.Fa locale_t 7312afe06cSJoel Dahlimplicitly to ensure thread safety, 7412afe06cSJoel Dahland a copy of the global locale should be installed lazily on each thread. 7512afe06cSJoel DahlThe FreeBSD implementation does not do this, 7612afe06cSJoel Dahlfor compatibility with Darwin. 77