+/*
+FUNCTION
+ <<duplocale>>---duplicate a locale object
+
+INDEX
+ duplocale
+
+INDEX
+ _duplocale_r
+
+ANSI_SYNOPSIS
+ #include <locale.h>
+ locale_t duplocale(locale_t <[locobj]>);
+
+ locale_t _duplocale_r(void *<[reent]>, locale_t <[locobj]>);
+
+DESCRIPTION
+The <<duplocale>> function shall create a duplicate copy of the locale
+object referenced by the <[locobj]> argument.
+
+If the <[locobj]> argument is LC_GLOBAL_LOCALE, duplocale() shall create
+a new locale object containing a copy of the global locale determined by
+the setlocale() function.
+
+The behavior is undefined if the <[locobj]> argument is not a valid locale
+object handle.
+
+RETURNS
+Upon successful completion, the <<duplocale>> function shall return a
+handle for a new locale object. Otherwise <<duplocale>> shall return
+(locale_t) <<0>> and set errno to indicate the error.
+
+PORTABILITY
+<<duplocale>> is POSIX-1.2008.
+*/
+
#include <newlib.h>
#include <reent.h>
#include <stdlib.h>
+/*
+FUNCTION
+ <<freelocale>>---free resources allocated for a locale object
+
+INDEX
+ freelocale
+
+INDEX
+ _freelocale_r
+
+ANSI_SYNOPSIS
+ #include <locale.h>
+ locale_t freelocale(locale_t <[locobj]>);
+
+ locale_t _freelocale_r(void *<[reent]>, locale_t <[locobj]>);
+
+DESCRIPTION
+The <<freelocale>> function shall cause the resources allocated for a
+locale object returned by a call to the <<newlocale>> or <<duplocale>>
+functions to be released.
+
+The behavior is undefined if the <[locobj]> argument is the special locale
+object LC_GLOBAL_LOCALE or is not a valid locale object handle.
+
+Any use of a locale object that has been freed results in undefined
+behavior.
+
+RETURNS
+None.
+
+PORTABILITY
+<<freelocale>> is POSIX-1.2008.
+*/
+
#include <newlib.h>
#include <reent.h>
#include <stdlib.h>
+/*
+FUNCTION
+ <<newlocale>>---create or modify a locale object
+
+INDEX
+ newlocale
+
+INDEX
+ _newlocale_r
+
+ANSI_SYNOPSIS
+ #include <locale.h>
+ locale_t newlocale(int <[category_mask]>, const char *<[locale]>,
+ locale_t <[locobj]>);
+
+ locale_t _newlocale_r(void *<[reent]>, int <[category_mask]>,
+ const char *<[locale]>, locale_t <[locobj]>);
+
+DESCRIPTION
+The <<newlocale>> function shall create a new locale object or modify an
+existing one. If the base argument is (locale_t) <<0>>, a new locale
+object shall be created. It is unspecified whether the locale object
+pointed to by base shall be modified, or freed and a new locale object
+created.
+
+The category_mask argument specifies the locale categories to be set or
+modified. Values for category_mask shall be constructed by a
+bitwise-inclusive OR of the symbolic constants LC_CTYPE_MASK,
+LC_NUMERIC_MASK, LC_TIME_MASK, LC_COLLATE_MASK, LC_MONETARY_MASK, and
+LC_MESSAGES_MASK, or any of the other implementation-defined LC_*_MASK
+values defined in <locale.h>.
+
+For each category with the corresponding bit set in category_mask the
+data from the locale named by locale shall be used. In the case of
+modifying an existing locale object, the data from the locale named by
+locale shall replace the existing data within the locale object. If a
+completely new locale object is created, the data for all sections not
+requested by category_mask shall be taken from the default locale.
+
+The following preset values of locale are defined for all settings of
+category_mask:
+
+"POSIX" Specifies the minimal environment for C-language translation
+called the POSIX locale.
+
+"C" Equivalent to "POSIX".
+
+"" Specifies an implementation-defined native environment. This
+ corresponds to the value of the associated environment variables,
+ LC_* and LANG; see the Base Definitions volume of POSIX.1‐2008,
+ Chapter 7, Locale and Chapter 8, Environment Variables.
+
+If the base argument is not (locale_t) <<0>> and the <<newlocale>>
+function call succeeds, the contents of base are unspecified.
+Applications shall ensure that they stop using base as a locale object
+before calling <<newlocale>>. If the function call fails and the base
+argument is not (locale_t) <<0>>, the contents of base shall remain
+valid and unchanged.
+
+The behavior is undefined if the base argument is the special locale
+object LC_GLOBAL_LOCALE, or is not a valid locale object handle and is
+not (locale_t) <<0>>.
+
+RETURNS
+Upon successful completion, the <<newlocale>> function shall return a
+handle which the caller may use on subsequent calls to <<duplocale>>,
+<<freelocale>>, and other functions taking a locale_t argument.
+
+Upon failure, the <<newlocale>> function shall return (locale_t) <<0>>
+and set errno to indicate the error.
+
+PORTABILITY
+<<newlocale>> is POSIX-1.2008.
+*/
+
#include <newlib.h>
#include <errno.h>
#include <reent.h>
+/*
+FUNCTION
+ <<uselocale>>---free resources allocated for a locale object
+
+INDEX
+ uselocale
+
+INDEX
+ _uselocale_r
+
+ANSI_SYNOPSIS
+ #include <locale.h>
+ locale_t uselocale(locale_t <[locobj]>);
+
+ locale_t _uselocale_r(void *<[reent]>, locale_t <[locobj]>);
+
+DESCRIPTION
+The <<uselocale>> function shall set the current locale for the current
+thread to the locale represented by newloc.
+
+The value for the newloc argument shall be one of the following:
+
+1. A value returned by the <<newlocale>> or <<duplocale>> functions
+
+2. The special locale object descriptor LC_GLOBAL_LOCALE
+
+3. (locale_t) <<0>>
+
+Once the <<uselocale>> function has been called to install a thread-local
+locale, the behavior of every interface using data from the current
+locale shall be affected for the calling thread. The current locale for
+other threads shall remain unchanged.
+
+If the newloc argument is (locale_t) <<0>>, the object returned is the
+current locale or LC_GLOBAL_LOCALE if there has been no previous call to
+<<uselocale>> for the current thread.
+
+If the newloc argument is LC_GLOBAL_LOCALE, the thread shall use the
+global locale determined by the <<setlocale>> function.
+
+RETURNS
+Upon successful completion, the <<uselocale>> function shall return the
+locale handle from the previous call for the current thread, or
+LC_GLOBAL_LOCALE if there was no such previous call. Otherwise,
+<<uselocale>> shall return (locale_t) <<0>> and set errno to indicate
+the error.
+
+
+PORTABILITY
+<<uselocale>> is POSIX-1.2008.
+*/
+
#include <newlib.h>
#include <reent.h>
#include <stdlib.h>