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