Home | History | Annotate | Download | only in include
History log of /src/lib/libc/include/namespace.h
RevisionDateAuthorComments
 1.206  02-Mar-2025  riastradh libc: New _r variants of heapsort, mergesort, qsort.

Also kheapsort_r for kernel/standalone use.

These variants allow the caller to pass a cookie through to the
comparison function, e.g. if you want to sort an array of indices
into a buffer.

qsort_r is new in POSIX.1-2024; the others are obvious analogues of
our nonstandard extensions for heapsort and mergesort.

PR lib/58931: qsort_r() missing
 1.205  17-Aug-2024  riastradh libc: Add _l variants of the cNrtomb and mbrtocN functions.

These accept an explicit locale parameter, rather than using the
current locale.

Visible under _NETBSD_SOURCE, not exposed otherwise.

NOTE: This adds libc symbols. Riding the libc minor bump for the
non-_l variants of these from two days ago -- hope that's not pushing
it too far.

PR lib/58613: c*rtomb, mbrtoc* should have locale-parametric _l
variants
 1.204  15-Aug-2024  riastradh libc: c32rtomb and mbrtoc32 are used internally, so weak-alias them.

PR lib/52374: <uchar.h> missing
 1.203  31-May-2022  riastradh branches: 1.203.2;
libc: Reintroduce getentropy.

This was introduced two years ago when the getrandom/getentropy API
question was still open, and removed because the discussion was
ongoing. Now getentropy is more widely adopted and soon to be in
POSIX. So reintroduce the symbol into libc since we'll be keeping it
anyway. Discussion of details of the semantics, as interpreted by
NetBSD, is ongoing, but the symbol needs to get in before the
netbsd-10 branch. The draft POSIX text is
(https://www.opengroup.org/austin/docs/austin_1110.pdf):

SYNOPSIS
#include <unistd.h>

int getentropy(void *buffer, size_t length);

DESCRIPTION
The getentropy() function shall write length bytes of data
starting at the location pointed to by buffer. The output
shall be unpredictable high quality random data, generated by
a cryptographically secure pseudo-random number
generator. The maximum permitted value for the length
argument is given by the {GETENTROPY_MAX} symbolic constant
defined in <limits.h>.

RETURN VALUES
Upon successful completion, getentropy() shall return 0;
otherwise, -1 shall be retunred and errno set to indicate the
error.

ERRORS
The getentropy() function shall fail if:

[EINVAL] The value of length is greater than
{GETENTROPY_MAX}.

The getentropy() function may fail if:

[ENOSYS] The system does not provide the necessary
source of entropy.

RATIONALE
The getentropy() function is not a cancellation point.

Minor changes from the previous introduction of getentropy into libc:

- Return EINVAL, not EIO, on buflen > 256.
- Define GETENTROPY_MAX in limits.h.

The declaration of getentropy in unistd.h and definition of
GETENTROPY_MAX in limits.h are currently conditional on
_NETBSD_SOURCE. When the next revision of POSIX is finalized, we can
expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this
can be done as a pullup without breaking existing compiled programs.
 1.202  11-Sep-2021  andvar Add missing double p and d for stopped and overriden accordingly.
Fix few more typos along the way, mainly in copy-pasted comments.
 1.201  04-Jul-2021  rillig libc: remove special handling for lint

In namespace.h 1.102 from 2005-07-16, the #ifndef was added to fix the
broken lint2 pass. Somewhere between 2005 and now, lint has been
changed so that it does not need this workaround anymore.

After usr.bin/xlint/lint1/tree.c 1.303 from 2021-06-30, the #ifndef in
namespace.h caused the only warning about an implicit function
declaration in the whole NetBSD tree, in lib/libc/gen/sysconf.c:149,
where _getpagesize was not defined, but only getpagesize.
 1.200  22-Sep-2020  nia remove getentropy bits
 1.199  06-May-2020  nia Add getentropy() to libc - a simple wrapper to access the kernel CSPRNG.

Posted to tech-userlevel@ a week ago and reviewed by riastradh@.

GETENTROPY(3) Library Functions Manual GETENTROPY(3)

NAME
getentropy - fill a buffer with high quality random data

LIBRARY
Standard C Library (libc, -lc)

SYNOPSIS
#include <unistd.h>

int
getentropy(void *buf, size_t buflen);

DESCRIPTION
The getentropy() function fills a buffer with high quality random data,
suitable for seeding cryptographically secure psuedorandom number
generators.

getentropy() is only intended for seeding random number generators and is
not intended for use by regular code which simply needs secure random
data. For this purpose, please use arc4random(3).

The maximum value for buflen is 256 bytes.

IMPLEMENTATION NOTES
getentropy() reads from the sysctl(7) variable kern.arandom.

RETURN VALUES
The getentropy() function returns 0 on success, and -1 if an error
occurred.

ERRORS
getentropy() will succeed unless:

[EFAULT] The buf argument points to an invalid memory address.

[EIO] Too many bytes were requested.

SEE ALSO
arc4random(3), rnd(4)

STANDARDS
The getentropy() function is non-standard.

HISTORY
The getentropy() function first appeared in OpenBSD 5.6, then in
FreeBSD 12.0, and NetBSD 10.
 1.198  18-Apr-2020  thorpej Rename "syscall" to "_syscall" and provide "syscall" as a weak alias.
 1.197  22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.196  17-Jan-2018  kamil branches: 1.196.4;
Revert to commits as they broke few rump tests

"Include namespace.h in a few of libc source files
[...]
This change finishes elimination of usage of the global name of the
following symbols:
- close -> _close
- execve -> _execve
- fcntl -> _fcntl
- setcontext -> _setcontext
- wait6 -> _wait6
- write -> _write
- writev -> _writev"

"Register more syscalls in namespace.h (of libc)

Add weak symbols for:
- fcntl
- close
- execve
- setcontext
- wait6
- write
- writev"

These changes broke:

fs/nfs/t_rquotad:get_nfs_be_1_both
fs/nfs/t_rquotad:get_nfs_be_1_group
fs/nfs/t_rquotad:get_nfs_be_1_user
fs/nfs/t_rquotad:get_nfs_le_1_both
fs/nfs/t_rquotad:get_nfs_le_1_group
fs/nfs/t_rquotad:get_nfs_le_1_user
lib/librumphijack/t_config:fdoff
lib/librumphijack/t_tcpip:http
lib/librumphijack/t_tcpip:nfs
lib/librumphijack/t_vfs:cpcopy
lib/librumphijack/t_vfs:mv_x
lib/librumphijack/t_vfs:paxcopy
net/net/t_forwarding:ipforwarding_fastforward_v4
net/net/t_forwarding:ipforwarding_fastforward_v6
net/net/t_forwarding:ipforwarding_fragment_v4
net/net/t_forwarding:ipforwarding_misc
net/net/t_mtudisc6:mtudisc6_basic

This revert fixes the failures, except lib/librumphijack/t_vfs.

The original changes were added in order to facilitate a usage of
sanitizers against programs linked with NetBSD's libc. It is no longer
needed, so abandon these changes.

Sponsored by <The NetBSD Foundation>
 1.195  07-Jan-2018  kamil Revert asctime() namespacing

asctime() is optionally a cancellation point in the POSIX spec.
It's not true for NetBSD.

Requested by <joerg>
 1.194  07-Jan-2018  kamil Revert namespacing of atoi(3)

Sanitizers can handle recursive interceptions in some / most cases, if they
will cause damage the problem will be not workaroundable without libc
changes - I will be back to it.

Keep namespace of asctime() as this can be a cancellation point according
to POSIX. Right now it's not implemented on NetBSD. Defer it for later.

Keep weak symbols and namespace for wait6(2) as this could be a
cancellation point as well. Defer this for later.

Sanitizers's [recursive] interceptors are a hack and moving one way or
another can cause new sets of problems. Recursive ones can be useful and
cause problems (on Linux there are known with with signal handlers).

Sponsored by <The NetBSD Foundation>
 1.193  05-Jan-2018  kamil Register new weak symbol in libc for internal usage: atoi

The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

Add atoi to namespace.h.

Register a new __weak_alias() entry for atoi() in atoi.c.

atoi() is used internally in getrpcent(), rresvport_af(), ftok(), err(),
__llvm_profile_write_file(), llvm_gcda_start_file(), citrus_iconv_open(),
getprotoent_r(), __rpc_uaddr2taddr_af(), __res_nopt_rdata() and
servent_parseline().

This revision switches the internal usage to the internal symbol.

Sponsored by <The NetBSD Foundation>
 1.192  05-Jan-2018  kamil Register new weak symbol in libc for internal usage: asctime

The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

Add asctime to namespace.h.

Register a new __weak_alias() entry for asctime() in asctime.c.

acstime() is used internally in ctime and __ctime50. This revision switches
the internal usage to the internal symbol.

Sponsored by <The NetBSD Foundation>
 1.191  05-Jan-2018  kamil Register dl_iterate_phdr in the libc's namespace.h

The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

Stop using the public global name of dl_iterate_phdr in tls/tls.c:
__libc_static_tls_setup().

Follow the approach with other dlopen(3)-like functions with the
namespace.h in the dl_iterate_phdr() case. Use internally a weak symbol:
__dl_iterate_phdr instead of dl_iterate_phdr.

Sponsored by <The NetBSD Foundation>
 1.190  05-Jan-2018  kamil Register more syscalls in namespace.h (of libc)

Add weak symbols for:
- fcntl
- close
- execve
- setcontext
- wait6
- write
- writev

These syscalls are already marked as WEAKASM, generating weak references.

Sponsored by <The NetBSD Foundation>
 1.189  30-Nov-2017  riastradh Import SHA-3 code into libc and libkern.

No new public symbols in libc, but publishing the symbols is a simple
matter if/when we decide to do so.

Proposed on tech-kern and tech-userlevel with no objections:

https://mail-index.NetBSD.org/tech-kern/2017/11/11/msg022581.html
https://mail-index.NetBSD.org/tech-userlevel/2017/11/11/msg010968.html
 1.188  22-Oct-2017  riastradh xref libc/README
 1.187  22-Oct-2017  christos Add an explanation of how namespace.h works.
 1.186  08-Feb-2017  maya Make paccept a weak symbol in preparation for using it in another function
 1.185  13-Jan-2017  christos branches: 1.185.2;
allow overriding snprintf/vsnprintf
 1.184  12-Jan-2017  christos undo SSP damage from -Wsystem-headers
 1.183  12-Jan-2017  christos Add strerror_ss_r to be used by syslog_ss
 1.182  24-Sep-2016  christos remove mpool_getf
 1.181  24-Sep-2016  christos bump for the flags version of db routines
 1.180  03-Apr-2016  christos branches: 1.180.2;
userland bits for wait6/waitid.
 1.179  10-Sep-2015  christos namespace protect allocaddrinfo
 1.178  01-May-2015  christos - new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
 1.177  17-Feb-2015  joerg Introduce reallocarr(3) for easy (re)allocation of memory with overflow
checks. Compared to OpenBSD's reallocarray, makes it easier to avoid memory
leaks on allocation failures and it doesn't depend on malloc(0) != NULL
for correct error checking. Compared to plain realloc, it also avoids
the problem of intermediate integer overflows. The trade-off is the use
of void * to side step C type system with regard to generic pointer to
pointer.
 1.176  26-Sep-2014  christos add execvpe, execlpe (reviewed by phone)
 1.175  25-Sep-2014  manu Fix argument paddiing for posix_fallocate and fdiscard with gcc 1.x
 1.174  13-Jun-2014  joerg branches: 1.174.2;
Add asysctl(3) and asysctlbyname(3) wrappers for the common idiom of
fetching dynamically sized data via sysctl.
 1.173  16-Jan-2014  christos branches: 1.173.2;
remove dups
 1.172  16-Jan-2014  christos namespace protection for the new err functions
 1.171  16-Jan-2014  joerg Fix (v)errc/(v)warnc.
 1.170  05-Dec-2013  joerg Add cdbr_open_mem.
 1.169  28-Aug-2013  riastradh Publish explicit_memset and consttime_memequal in userland libc.

Remove the double-underscore from the userland versions, and do the
weak alias dance instead, now that these are public parts of libc.

As discussed on tech-userlevel:

https://mail-index.netbsd.org/tech-userlevel/2013/06/24/msg007843.html
(option 3)
 1.168  19-Aug-2013  joerg Add strerror_l.
 1.167  19-Aug-2013  joerg Add nl_langinfo_l, catopen_l and wcsftime_l.
 1.166  30-Apr-2013  joerg Make that to process PATH_LOCALE the first time _find_category is
called. Use this to implement newlocale and provide duplocale/freelocale
as well. Based on patches by Takehiko Nozaki with simplications and fix
for the init order by myself.
 1.165  21-Apr-2013  joerg Store time-specific locale data directly in the locale.
Ad dstrftime_l, strftime_lz and strptime_l.
 1.164  19-Apr-2013  joerg Add scanf_l and wscanf_l families.
 1.163  19-Apr-2013  joerg Add dummy strcoll_l and strxfrm_l.
 1.162  19-Apr-2013  joerg Add explicit locale versions for the printf family. Replace asprintf,
snprintf and sprintf with simple wrappers around the corresponding
va_list functions to reduce code duplication.
 1.161  18-Apr-2013  joerg Add wcscoll_l, wcsxfrm_l, wcsncasecmp_l, wcscasecmp_l, btowc_l,
mbrlen_l, mbsinit_l, mbsrtowcs_l, wcrtomb_l, wcsrtombs_l and wctob_l.
 1.160  18-Apr-2013  joerg Add wcstof_l, wcstod_l and wcstold_l.
 1.159  18-Apr-2013  joerg Add strtof_l, strtod_l and strtold_l.
 1.158  16-Apr-2013  joerg Add strtol_l and friends. Switch _citrus_bcs_strtol to use plain
strtol_l unless in tools mode. Add note to retire the BCS code on the
next libc major bump.
 1.157  16-Apr-2013  joerg Add wcwidth_l, wcswidth_l and the wctype.h family of *_l functions.
 1.156  20-Aug-2012  dsl branches: 1.156.2;
I'm fairly sure the libc rules require that arc4random_addrandom,
arc4random_buf, arc4random_stir and arc4random_uniform be weak.
 1.155  09-Jul-2012  rmind Add weak symbol for murmurhash2.
 1.154  03-Jun-2012  joerg Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
 1.153  12-Apr-2012  christos name protection for getpassfd
 1.152  12-Apr-2012  christos Add a new getpass implementation that does not mess with signals, and
include getpass_r
 1.151  02-Mar-2012  christos PR/46111: Wolfgang Stukenbrock: Add yp_setbindtries(3) so that yp operations
don't hang forever if requested.
 1.150  15-Feb-2012  joerg branches: 1.150.2;
Make sure that membar_producer gets the proper namespace mangling for libc.
 1.149  04-Jul-2011  manu branches: 1.149.2;
Import xdr_sizeof() from FreeBSD
 1.148  26-Mar-2011  christos add fpgetprec/fpsetprec
 1.147  12-Mar-2011  christos Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
the buffer is not large enough, instead of silently truncating.
 1.146  16-Dec-2010  christos Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.
 1.145  17-Nov-2010  tron Provide proper namespace protection for rbtree(3) because it is now
used by "libc" internally.
 1.144  13-Nov-2010  christos forgot to commit this one for two months!
add vdprintf.
 1.143  06-Sep-2010  jakllsch New vdprintf needs "namespace protection".
 1.142  25-Apr-2010  joerg Add the constant database reader (cdbr(3)) and writer ((cdbw(3)).
They implement a space efficent write-once database with fast access
path. Switch the services(5) database to use cdb. The size of the
database file decreases from 2.1MB disk space to 307KB. Access
performance is about the same if setservent(0) is used and about an
order of magnitude faster otherwise. services_mkdb defaults to the new
format, but can optionally create the old db(3) format as well for
statically linked legacy applications.
 1.141  19-Mar-2010  joerg Namespace protection for mi_vector_hash.
 1.140  02-Dec-2009  roy Protect getline.
 1.139  01-Dec-2009  roy Protect getdelim when used internally.
 1.138  26-May-2009  joerg Add SHA224 implementation to libc.
Make libcrypto use the SHA2 implementation of libc.
Bump minor versions of libc and libcrypto.
 1.137  11-Jan-2009  christos merge christos-time_t
 1.136  05-Dec-2008  ad Add fdopendir(), from Solaris/Linux.
 1.135  20-Nov-2008  matt Add new ptree (Patricia / RADIX tree) implementation to NetBSD.
 1.134  31-Oct-2008  christos branches: 1.134.2;
Import syslogd SoC project by Martin Schuette:
- new syslog protocol api syslogp(3) that supports structured data
and draft-rfc timestamps
- reliable tcp connections with queueing
- encrypted connections
 1.133  04-Aug-2008  matt branches: 1.133.4; 1.133.6;
Add C99 functions imaxabs and imaxdiv.
 1.132  25-Jun-2008  ad Add getlogin_r. Manual page changes mostly lifted from FreeBSD.
 1.131  28-Apr-2008  martin branches: 1.131.2;
Remove clause 3 and 4 from TNF licenses
 1.130  02-Feb-2008  christos branches: 1.130.4;
namespace protection for csetexpandtc()
 1.129  03-Jun-2007  christos branches: 1.129.4;
- add read and readlink since they are used internally
- protect vsnprintf and vsnprintf since for lex(1) generated files <stdio.h>
is included before "namespace.h".
 1.128  10-May-2007  he The sl_delete function needs namespace protection added here as well.
 1.127  18-Feb-2007  christos SHA512_Last is not public anymore.
 1.126  17-Feb-2007  christos Define for SHA512_Last.
 1.125  08-Nov-2006  drochner branches: 1.125.2; 1.125.6;
cleanup unused stuff after hmac_* removal
 1.124  03-Nov-2006  christos protect the *syslog_ss
 1.123  28-Oct-2006  christos add {v,}snprintf_ss
 1.122  25-Oct-2006  christos add _r functions for syslog from OpenBSD
 1.121  24-Aug-2006  mrg remove duplicates added in previous commit.
 1.120  23-Aug-2006  christos I think we want both wcs{c,n}casecmp weak.
 1.119  23-Aug-2006  mrg add wcsdup, wcscasecmp and wcsncasecmp. fixes build problems..
 1.118  12-Aug-2006  christos - Add strndup and stresep
- Use stresep so in fstab so that we can mount paths with white space in them.
 1.117  23-Jun-2006  christos branches: 1.117.2;
Make these weak as Matthias Drochner pointed out.
 1.116  05-May-2006  rpaulo Add support for RFC 3542 Adv. Socket API for IPv6 (which obsoletes 2292).
* RFC 3542 isn't binary compatible with RFC 2292.
* RFC 2292 support is on by default but can be disabled.
* update ping6, telnet and traceroute6 to the new API.

From the KAME project (www.kame.net).
Reviewed by core.
 1.115  17-Apr-2006  salo Add setttyentpath(), functionally equivalent to setttyent() but takes an
additional argument to read the ttys information from an alternate path
istead of _PATH_TTYS.

Required for upcoming init(8) changes.

Mostly from <apb>.

Bump libc minor.
 1.114  16-Apr-2006  christos namespace protect wcstod too, and fix the protection in wcstold and wcstof.
 1.113  15-Apr-2006  tnozaki wcstod(3) is conform to ISO C90 Ammendant1 (FreeBSD's manpage is incorrect...).
don't __weak_alias'ize it and fix manpage.
 1.112  15-Apr-2006  tnozaki add c99 wcstof(3) and wcstold(3).
requested by skrll AT netbsd DOT org, thanks.

bump libc minor 138 -> 139.
 1.111  15-Mar-2006  kleink Add strtof(3) and strtold(3); welcome libc 12.137.
 1.110  26-Jan-2006  kleink Need to give the various rpc locks private names (prefixing them with
__rpc_). Rather than scattering changes around the 3rd-party RPC
code, place them in namespace.h.
 1.109  26-Sep-2005  christos the sha2 functions have an _.
 1.108  25-Sep-2005  elad Fix weak aliasing after recent changes.

Inspired by comments from christos@, xtraeme@, mlelstv@, mhitch@, mrg@,
and uwe@; all the bugs are mine.
 1.107  25-Sep-2005  christos add getenv_r and ttyname_r
 1.106  07-Aug-2005  veego Last change to namespace.h had an wrong entry: in6addr_nodelocal_allrouters
instead of in6addr_linklocal_allrouters.
Bump the shared library minor version.

Thanks to Klaus Klein for the hint what went wrong.
 1.105  07-Aug-2005  christos add missing in6addr_linklocal_allrouters.
 1.104  30-Jul-2005  christos - Fix the remaining indr_references so that they define lint symbols.
- Add an internal symbol for strerror_r (thanks klaus for noticing)
- Remove internal __strerror
 1.103  17-Jul-2005  christos Add comments at the end of #endif's; Requested by Havard Eidnes.
 1.102  16-Jul-2005  christos don't play #define games with lint. Breaks pass2.
 1.101  15-May-2005  yamt add fgetwln.
 1.100  07-Apr-2005  christos statvfs is both a function name and a struct tag. Defining it to _statvfs
causes lint to complain because it sees both struct statvfs and struct
_statvfs. Fix by changing the macro to have arguments.
XXX[1]: Probably this should be done for the rest of the functions that have
the same names as struct tags.
XXX[2]: Is there a better way?
 1.99  02-Apr-2005  christos PR/29849, PR/29850: Add getpwent_r and getgrent_r
 1.98  09-Feb-2005  kleink branches: 1.98.2;
A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.97  06-Jan-2005  lukem Implement getgroupmembership(3). This is similar to getgrouplist(3), except
that the "int maxgroups" and "int *ngroups" parameters are separated into
two separate parameters which makes it possible to call multiple nsswitch
back-ends and have the results correctly merged.
getgrouplist(3) is now implemented using getgroupmembership(3).

Proposed on tech-userlevel on December 1, 2004.
 1.96  16-Dec-2004  kleink Internally rename getdevmajor(); noted by Geoff Wing.
 1.95  05-Oct-2004  lukem Overhaul the use of nsdispatch(3) by public APIs so that the back-end
methods use va_list in a manner that is directly related to the public API.
This makes it much easier to write dynamic nsswitch backends for getpwent(3).
Per my proposal on tech-userlevel.

Implement getpwgid_r() and getpwnam_r() APIs per the POSIX 1003.1, 2004 Ed.
These aren't fully reentrant or threadsafe yet, because the compat stuff
currently uses non-reentrant data sources (getnetgrent(3), getpwent(3)),
and there is probably some locking to be improved in the backends.
This will be fixed in the near future.
We also need to add _SC_GETPW_R_SIZE_MAX to sysconf(3).

Fix the compat `+' prototype override so getpwnam(3) and getpwuid(3) DTRT.

Improve the description of pw_class and pw_gecos.
 1.94  04-Oct-2004  lukem crank copyright
 1.93  04-Oct-2004  lukem Overhaul the use of nsdispatch(3) by public APIs so that the back-end
methods use va_list in a manner that is directly related to the public API.
This makes it much easier to write dynamic nsswitch backends for getgrent(3).
Per my proposal on tech-userlevel.

Implement getgrgid_r() and getgrnam_r() APIs per the POSIX 1003.1, 2004 Ed.
These aren't fully reentrant or threadsafe yet, because the compat stuff
currently uses non-reentrant data sources (getnetgrent(3), getgrent(3)),
and there is probably some locking to be improved in the backends.
This will be fixed in the near future.
We also need to add _SC_GETGR_R_SIZE_MAX to sysconf(3).
 1.92  17-Aug-2004  ginsbach namespace protection for gethostent()
 1.91  02-Jun-2004  christos delete duplicate namespace protection.
 1.90  21-May-2004  christos namespace protection for resolver routines.
 1.89  10-May-2004  drochner After discussion with christos, turn fgetstr() into an internal function.
Its API in inherently non-threadsafe (and it depends on certain properties
of the underlying stdio implementation), so it shouldn't be a first-class
function for general use, polluting the application namespace.
Also remove the FLOCKFILE() code from it - this is under control of the
calling function now.
(XXX I'm not sure whether the FLOCKFILE() should be kept in fgetln(),
this function cannot be used in multiple threads anyway. It doesn't
hurt much, and it might prevent corruption of internal FILE structures.)
 1.88  09-May-2004  kleink We now need an internal name for fileno(), since when buildling libc
_REENTRANT we can no longer use the macro version from <stdio.h>.
 1.87  27-Apr-2004  kleink Remove internal names for dbm_*(3); these are not required at this time.
 1.86  21-Apr-2004  christos protect fgetstr
 1.85  08-Apr-2004  atatat Weak aliases for sysctlfoobar() functions.
 1.84  04-Mar-2004  kleink branches: 1.84.2;
* Turn isinf(3) and isnan(3) into C99-style macros.
* Make it possible for ports to override these (i.e., VAX).
* Remove isnanl(), which was internal to libc only.
 1.83  19-Feb-2004  christos _r functions for services and protocols; also add the inet_cidr_* function
which will come next.
 1.82  18-Sep-2003  jdolecek remove pw_dup()
 1.81  13-Sep-2003  itojun weak alias for pw_dup
 1.80  13-Sep-2003  itojun use internal names for randomid()
 1.79  27-Jun-2003  tshiozak Citrus iconv support(4)
add iconv external I/F (iconv.h - iconv_open()/iconv()/iconv_close()) and
iconv(1) utility.
TODO:
- bump libc minor.
- add iconv data files.
- create manpages: iconv_open(3)/iconv(3)/iconv_close(3)/iconv(1)/
mkesdb(1)/mkcsmapper(1).
 1.78  28-May-2003  christos add readdir_r alias
 1.77  17-May-2003  thorpej Add isinfl() and isnanl().
 1.76  13-Feb-2003  nathanw Implement pthread_atfork() (in libc, because the required threadlib
stub behavior is exactly the same as the usual behavior).
 1.75  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.74  30-Nov-2002  lukem - Migrate fparseln(3) from libutil to libc, where it should have been in
the first place...
- Bump libutil major (to 7.0) and libc minor (to 12.91).
 1.73  29-Nov-2002  lukem add strsuftoll(3) and strsuftollx(3) - parse a string for a number
with an optional suffix, product (two numbers separated by `x'), and
provide range checking
 1.72  08-Nov-2002  fvdl Add rpc_control.
 1.71  17-Apr-2002  kleink branches: 1.71.2;
Need internal names for strlcat() and strlcpy().
 1.70  24-Jan-2002  lukem - Implement pwcache_userdb(3), which changes the routines that
user_from_uid(3) and uid_from_user(3) use to lookup user information.
- Implement pwcache_groupdb(3), which changes the routines that
group_from_gid(3) and gid_from_group(3) use to lookup group information.
- Ensure that private functions in pwcache.c are declared static
- Use strlcpy(3) instead of strncpy(3)
 1.69  14-Jan-2002  thorpej * Add WSYSCALL() to SYS.h, which creates a system call with an
internal name and a weak alias for the name.
* Add a WEAKASM syscall list, and process it.
* Make sysarch() have an internal name (_sysarch()).
 1.68  13-Jan-2002  thorpej Add internal names for fp{get,set}{mask,round,sticky}(), and
externally-visible weak aliases for the internal names.
 1.67  19-Sep-2001  aymeric move adjtime and clock_settime where they belong, now that they are C functions.
Apart from being TRT, this makes a.out builds work again.
 1.66  16-Sep-2001  manu Added support to use the clockctl driver if present for adjtime(),
clock_settime(), ntp_adjtime() and settimeofday(). The super-user still
always use the plain system call.
Approved by Christos
 1.65  07-May-2001  kleink Internally rename sysconf() to __sysconf() to make its latter name suitable
for use from public headers. Also, do so on all platforms.
 1.64  28-Apr-2001  kleink * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.63  13-Apr-2001  kleink Need an internal name for asprintf(3).
 1.62  31-Mar-2001  kleink Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.
 1.61  19-Mar-2001  atatat Add md2 routines to libc.
 1.60  19-Feb-2001  cgd branches: 1.60.2;
define getprogname to _getprogname for internal use
 1.59  20-Oct-2000  briggs Add {__,}fmtcheck(), a function specified by Bill Sommerfeld to check
a user-supplied format string against a fallback format string to ensure
that they will consume arguments of the same type.

libc minor bump for new API entry point.
 1.58  28-Sep-2000  kleink Need an internal name for pipe(2).
 1.57  08-Jul-2000  kleink XCU5: Add fseeko() and ftello() functions which provide the functionality of
fseek() and ftell(), respectively, but operate on file offsets of type off_t.
 1.56  05-Jul-2000  kleink Lexicographically sort in previous.
 1.55  05-Jul-2000  ad Pull in RIPEMD-160 functions from OpenBSD - this has the same API as our MD4,
MD5 and SHA1 stuff.
 1.54  26-Jun-2000  kleink Need an internal name for fork().
 1.53  23-Jun-2000  kleink Add internal names for brk() and sbrk().
 1.52  02-Jun-2000  fvdl branches: 1.52.2;
Add new RPC code, based on Sun's TI-RPC code. Adapted to not use XTI,
but sockets instead, internally. Old, backward compatible interfaces
maintained.
 1.51  08-May-2000  kleink branches: 1.51.2;
Need an internal name for send(); noticed by itojun.
 1.50  24-Apr-2000  itojun use BSDI-origin if_{index,name}* functions. they use getifaddrs(3) as
backend and are more robust against SIOCGIFCONF alignment issue.
now getifaddrs always takes care of the issue. (sync with kame tree)
use weak symbol just in case.
 1.49  24-Apr-2000  itojun supply weak alias for IPv6-related library additions. sorry to be late.
 1.48  02-Apr-2000  christos protect getopt_long.
 1.47  02-Apr-2000  minoura Move dl* function definitions to libc on ELF.
Based on the patch supplied by Takuya Shiozaki <tshiozak@astec.co.jp>.
See http://mail-index.netbsd.org/tech-userlevel/2000/02/23/0000.html.
 1.46  08-Mar-2000  kleink No longer need internal names for strtoq() and strtouq().
 1.45  06-Mar-2000  kleink Add ISO C99 long long integer general utility interfaces; partially addresses
PR standards/9482.
 1.44  23-Jan-2000  mycroft Ditto for nlist().
 1.43  22-Jan-2000  mycroft Don't do the namespace hack for timezone() here; it causes lint, and we don't
need it anyway.
 1.42  01-Dec-1999  thorpej Implement XDR routines for 64-bit integer data types:
- xdr_int64_t(), xdr_u_int64_t(), per NetBSD convention.
- xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), xdr_u_longlong_t(), a'la
Solaris, implemented in terms of the above.
 1.41  25-Nov-1999  wennmach Added #defines for svis, strsvis, strsvisx
 1.40  20-Sep-1999  kleink branches: 1.40.4;
Need internal names for these, too.
 1.39  15-Sep-1999  kleink Add indirect reference stubs for inet_[ap]ton() for environments not supporting
weak aliases; addresses PR lib/7435 but leaves the original file intact.
 1.38  17-Aug-1999  mycroft getsubopt(3) has a weak alias.
 1.37  09-Mar-1999  kleink Functionally back out namespace.h revision 1.7 and perror.c revision 1.15;
perror() is an identifier reserved by ANSI/ISO C, and in case of a redefition
the behavior is undefined.
 1.36  06-Feb-1999  kleink Add l64a_r(), a reentrant version of l64a(); found in the Multithreading
Extension of SVID4.
 1.35  04-Feb-1999  explorer add sha1 functions, like md5/4
 1.34  25-Jan-1999  lukem namespace protect hesiod stuff
 1.33  20-Jan-1999  lukem protect nsdispatch. sort entries
 1.32  30-Nov-1998  thorpej Need an internal name for the (new) sys_nsig.
 1.31  20-Oct-1998  kleink Need internal names for MD[45]{Init,Final,Update}().
 1.30  18-Oct-1998  kleink Replace use of getdtablesize() with (the non-deprecated) sysconf(), hence no
need for an internal name for the former any more; suggested by Matthew Green.
 1.29  16-Oct-1998  kleink getsubopt() isn't used internally.
 1.28  16-Oct-1998  kleink Need an internal name for herror().
 1.27  16-Oct-1998  kleink Need an internal name for tzname.
 1.26  16-Oct-1998  kleink Need an internal name for signal().
 1.25  16-Oct-1998  kleink Need an internal name for fgetln().
 1.24  15-Oct-1998  kleink Need an internal name for dn_expand().
 1.23  14-Oct-1998  kleink Need internal names for {end,set}hostent().
 1.22  14-Oct-1998  kleink Need internal names for res_init(), res_mkquery(), res_query() and res_search().
 1.21  14-Oct-1998  kleink Need internal names for ftruncate(), lseek(), mmap(), pread() and pwrite().
 1.20  13-Oct-1998  kleink Need an internal name for inet_aton().
 1.19  13-Oct-1998  kleink Need internal names for gethostby{addr,name}().
 1.18  13-Oct-1998  kleink Need an internal name for getdomainname().
 1.17  13-Oct-1998  kleink Need an internal name for strsep().
 1.16  13-Oct-1998  kleink Need an internal name for strdup().
 1.15  13-Oct-1998  kleink Need an internal name for isatty().
 1.14  13-Oct-1998  kleink Need internal names for isinf() and isnan().
 1.13  13-Oct-1998  kleink Need internal names for snprintf() and vsnprintf().
 1.12  13-Oct-1998  kleink Need an internal name for fdopen().
 1.11  08-Oct-1998  kleink Add an internal name for getdtablesize(), since it's being used internally.
 1.10  27-Sep-1998  kleink Add missing renaming of tcgetsid().
 1.9  27-Sep-1998  kleink Add an internal name for strtok_r().
 1.8  10-Sep-1998  kleink Add asctime_r(), ctime_r(), gmtime_r() and localtime_r().
 1.7  28-Jul-1998  mycroft Add an internal name for perror(3).
 1.6  20-Dec-1997  kleink Add lockf(), an alternate interface to perform advisory record locking;
per XPG4.2.
 1.5  02-Nov-1997  kleink Add basename() and dirname(), from XPG4.2.
 1.4  21-Jul-1997  jtc Put TNF copyright on this file
 1.3  21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.2  27-Feb-1995  cgd branches: 1.2.4;
clean up Id
 1.1  09-Feb-1995  jtc branches: 1.1.2;
Initial set of ANSI clean namespace mappings.
 1.1.2.7  02-May-1995  jtc #include "namespace.h"
 1.1.2.6  26-Apr-1995  jtc namespace exec*() and *dir() functions, like sysv
 1.1.2.5  25-Apr-1995  jtc signal set manipulation functions are used by abort()
 1.1.2.4  25-Apr-1995  jtc Namespace protect isatty(), it's used by stdio to determine default
buffering characteristics for streams.
 1.1.2.3  18-Apr-1995  jtc namespace protect isnan() and isinf()
 1.1.2.2  25-Mar-1995  jtc updated
 1.1.2.1  13-Mar-1995  jtc add mappings for syscalls and time and date routines
 1.2.4.8  20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.2.4.7  19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.2.4.6  18-Sep-1996  jtc snapshot namespace cleanup: stdlib
 1.2.4.5  17-Sep-1996  jtc snapshot namespace cleanup: time
 1.2.4.4  17-Sep-1996  jtc snapshot namespace cleanup: yp
 1.2.4.3  17-Sep-1996  jtc snapshot namespace cleanup: termios
 1.2.4.2  16-Sep-1996  jtc snapshot namespace cleanup: rpc & xdr
 1.2.4.1  16-Sep-1996  jtc snapshot namespace cleanup
 1.40.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.51.2.1  23-Jun-2000  minoura Import of most recent XPG4DL dated 2000.06.23.
 1.52.2.3  22-Apr-2002  he Pull up revision 1.71 (via patch, requested by kleink):
Use internal names for strlcat() and strlcpy().
 1.52.2.2  29-Sep-2000  kleink Pull up rev. 1.58 (approved by thorpej):
Add internal name for pipe().
 1.52.2.1  22-Aug-2000  kleink Pull up revs. 1.53-1.54 (approved by thorpej):
Add internal names for brk(), sbrk() and fork().
 1.60.2.10  08-Jan-2003  thorpej Need an internal name for kill().
 1.60.2.9  10-Dec-2002  thorpej Sync with HEAD.
 1.60.2.8  11-Nov-2002  nathanw Catch up to -current
 1.60.2.7  02-Aug-2002  nathanw Adapt to new stub name for sysarch.
 1.60.2.6  25-Apr-2002  nathanw Catch up to -current.
 1.60.2.5  25-Feb-2002  nathanw Move setlogin() stub to C code, and namespace-protect it.
 1.60.2.4  06-Feb-2002  nathanw Add internal names for flockfile(), ftrylockfile(), and funlockfile().
 1.60.2.3  28-Jan-2002  nathanw Catch up to -current.
 1.60.2.2  08-Oct-2001  nathanw Catch up to -current.
 1.60.2.1  05-Mar-2001  nathanw User-level support for LWPs and scheduler activations.
SVR4-style ucontext code by Klaus Klein.
 1.71.2.1  06-Jan-2003  jmc Pull up revisions 1.71-1.72 (requested by fvdl in ticket #1037)
Add rpc_control.
 1.84.2.3  11-Sep-2004  he Pull up revision 1.92 (requested by ginsbach in ticket #834):
Restore gethostent() as a supported interface. Yes, it
may be obsolete, but it is specified by IEEE Std 1003.1,
2004 Edition (POSIX) and the X/Open standards (Issue 66
and XNS 5.2).
 1.84.2.2  11-May-2004  tron Pull up revision 1.88 (requested by kleink in ticket #311):
We now need an internal name for fileno(), since when buildling libc
_REENTRANT we can no longer use the macro version from <stdio.h>.
 1.84.2.1  08-Apr-2004  jdc Pull up revision 1.85 (requested by atatat in ticket #90)

Weak aliases for sysctlfoobar() functions.
 1.98.2.2  28-Jan-2006  tron Pull up following revision(s) (requested by kleink in ticket #1142):
lib/libc/rpc/mt_misc.c: revision 1.5
lib/libc/include/namespace.h: revision 1.110
Need to give the various rpc locks private names (prefixing them with
__rpc_). Rather than scattering changes around the 3rd-party RPC
code, place them in namespace.h.
 1.98.2.1  11-Jul-2005  tron Pull up revision 1.99 (requested by lukem in ticket #540):
PR/29849, PR/29850: Add getpwent_r and getgrent_r
 1.117.2.2  27-Aug-2006  riz Pull up following revision(s) (requested by tron in ticket #64):
lib/libc/include/namespace.h: revision 1.119
lib/libc/string/wcsdup.c: revision 1.1
lib/libc/string/wcscasecmp.c: revision 1.1
lib/libc/include/namespace.h: revision 1.120
distrib/sets/lists/base/shl.mi: revision 1.366
lib/libc/shlib_version: revision 1.182
include/wchar.h: revision 1.26
lib/libc/string/Makefile.inc: revision 1.62
lib/libc/string/Makefile.inc: revision 1.63
lib/libc/string/wcsncasecmp.c: revision 1.1
PR/34238: Aleksey Cheusov: add wcsdup, wcscasecmp and wcsncasecmp functions
libc 147 for wcsdup and wcs{n,}casecmp
include one more new file.
add wcsdup, wcscasecmp and wcsncasecmp. fixes build problems..
I think we want both wcs{c,n}casecmp weak.
 1.117.2.1  27-Aug-2006  riz Pull up following revision(s) (requested by tron in ticket #63):
regress/lib/libc/string/Makefile: revision 1.9
lib/libc/string/strsep.3: revision 1.17
lib/libc/string/strsep.3: revision 1.18
regress/lib/libc/string/stresep/Makefile: revision 1.1
distrib/sets/lists/base/shl.mi: revision 1.364
regress/lib/libc/string/stresep/stresep_test.c: revision 1.1
lib/libc/gen/fstab.c: revision 1.28
lib/libc/shlib_version: revision 1.181
lib/libc/string/strndup.c: revision 1.1
lib/libc/string/strdup.3: revision 1.13
lib/libc/string/strdup.3: revision 1.14
lib/libc/string/Makefile.inc: revision 1.61
include/string.h: revision 1.31
distrib/sets/lists/comp/mi: revision 1.909
lib/libc/string/stresep.c: revision 1.1
lib/libc/include/namespace.h: revision 1.118
- Add strndup and stresep
- Use stresep so in fstab so that we can mount paths with white space in th=
em.
Add stresep and strndup.
add regression test for stresep.
libc 146
man pages for stresep and strndup.
Mark up NULL.
stresep, not strnsep. Remove duplicate "the". Bump date for previous.
 1.125.6.1  22-Jul-2009  snj Apply patch (requested by joerg in ticket #1338):
- Add support for SHA224 to libc
- Fix Big Endian support in some cases
- Use libc support in libcrypto
 1.125.2.1  22-Jul-2009  snj Apply patch (requested by joerg in ticket #1338):
- Add support for SHA224 to libc
- Fix Big Endian support in some cases
- Use libc support in libcrypto
 1.129.4.1  23-Mar-2008  matt sync with HEAD
 1.130.4.1  18-May-2008  yamt sync with head.
 1.131.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.133.6.1  14-Jul-2009  snj branches: 1.133.6.1.2;
Pull up following revisions (requested by joerg in ticket #855):
common/lib/libc/hash/sha2/sha2.c: revisions 1.8-1.18 via patch
crypto/dist/openssl/crypto/evp/m_sha1.c: revisions 1.2-1.3 via patch
distrib/sets/lists/base/md.amd64: revision 1.51 via patch
distrib/sets/lists/base/md.sparc64: revision 1.46 via patch
distrib/sets/lists/base/shl.mi: revision 1.474 via patch
distrib/sets/lists/comp/mi: revision 1.1263 via patch
lib/libc/shlib_version: patch
lib/libc/hash/sha2/Makefile.inc: revision 1.4 via patch
lib/libc/hash/sha2/sha2.3: revision 1.5 via patch
lib/libc/hash/sha2/sha224hl.c: revision 1.1 via patch
lib/libc/include/namespace.h: revision 1.138 via patch
lib/libcrypto/libc-sha256.c: revision 1.1 via patch
lib/libcrypto/libc-sha512.c: revision 1.1 via patch
lib/libcrypto/sha.inc: revision 1.10 via patch
lib/libcrypto/shlib_version: patch
sys/lib/libkern/arch/vax/Makefile.inc: revision 1.21 via patch
sys/sys/sha2.h: revision 1.3 via patch
Add SHA224 implementation to libc.
Make libcrypto use the SHA2 implementation of libc.
Bump minor versions of libc and libcrypto.
 1.133.6.1.2.1  21-Apr-2010  matt sync to netbsd-5
 1.133.4.1  14-Jul-2009  snj Pull up following revisions (requested by joerg in ticket #855):
common/lib/libc/hash/sha2/sha2.c: revisions 1.8-1.18 via patch
crypto/dist/openssl/crypto/evp/m_sha1.c: revisions 1.2-1.3 via patch
distrib/sets/lists/base/md.amd64: revision 1.51 via patch
distrib/sets/lists/base/md.sparc64: revision 1.46 via patch
distrib/sets/lists/base/shl.mi: revision 1.474 via patch
distrib/sets/lists/comp/mi: revision 1.1263 via patch
lib/libc/shlib_version: patch
lib/libc/hash/sha2/Makefile.inc: revision 1.4 via patch
lib/libc/hash/sha2/sha2.3: revision 1.5 via patch
lib/libc/hash/sha2/sha224hl.c: revision 1.1 via patch
lib/libc/include/namespace.h: revision 1.138 via patch
lib/libcrypto/libc-sha256.c: revision 1.1 via patch
lib/libcrypto/libc-sha512.c: revision 1.1 via patch
lib/libcrypto/sha.inc: revision 1.10 via patch
lib/libcrypto/shlib_version: patch
sys/sys/sha2.h: revision 1.3 via patch
Add SHA224 implementation to libc.
Make libcrypto use the SHA2 implementation of libc.
Bump minor versions of libc and libcrypto.
 1.134.2.7  10-Jan-2009  christos revert previous resolver patch. Not meant for christos-time_t
 1.134.2.6  04-Jan-2009  christos merge with head.
 1.134.2.5  10-Nov-2008  christos fix difftime.
 1.134.2.4  10-Nov-2008  christos this completes the symbol implementation for now. New we need to debug...
 1.134.2.3  09-Nov-2008  christos version some more stuff and add sys_foo aliases.
 1.134.2.2  08-Nov-2008  christos time_t changes
 1.134.2.1  31-Oct-2008  christos file namespace.h was added on branch christos-time_t on 2008-11-08 21:45:38 +0000
 1.149.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.149.2.2  30-Oct-2012  yamt sync with head
 1.149.2.1  17-Apr-2012  yamt sync with head
 1.150.2.1  23-Jun-2012  riz Pull up following revision(s) (requested by joerg in ticket #328):
lib/libc/gen/devname.c: revision 1.22
distrib/sparc64/instfs/dot.profile: revision 1.7
distrib/i386/cdroms/install.sh: revision 1.3
tests/lib/libcurses/director/director.c: revision 1.10
lib/libc/include/reentrant.h: revision 1.15
distrib/amd64/cdroms/install.sh: revision 1.3
tests/include/t_paths.c: revision 1.12
share/man/man7/hier.7: revision 1.101
etc/rc.d/sysdb: revision 1.24
include/stdlib.h: revision 1.99
tests/lib/libcurses/Makefile: revision 1.3
distrib/sparc64/cdroms/installcd/install.sh: revision 1.3
distrib/i386/cdroms/Makefile.cdrom: revision 1.27
lib/libc/gen/ttyname.c: revision 1.25
usr.bin/tic/Makefile: revision 1.2
tools/compat/Makefile: revision 1.57
lib/libterminfo/compile.c: revision 1.7
lib/libc/gen/ttyname.c: revision 1.26
lib/libterminfo/compile.c: revision 1.8
tools/compat/Makefile: revision 1.59
tools/compat/cdbw.h: revision 1.1
distrib/i386/installimage/install.sh: revision 1.2
lib/libc/include/namespace.h: revision 1.154
usr.bin/tic/tic.c: revision 1.13
usr.bin/tic/tic.c: revision 1.14
usr.bin/tic/tic.c: revision 1.15
distrib/sets/lists/base/mi: revision 1.996
usr.bin/tic/tic.c: revision 1.16
usr.sbin/dev_mkdb/dev_mkdb.8: revision 1.13
usr.bin/tic/tic.c: revision 1.17
usr.bin/tic/tic.c: revision 1.18
tools/compat/cdbr.h: revision 1.1
distrib/sparc64/instfs/list: revision 1.25
usr.bin/tic/tic.c: revision 1.19
lib/libc/cdb/cdbw.c: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.4
lib/libc/cdb/cdbw.3: revision 1.5
share/terminfo/Makefile: revision 1.3
usr.sbin/dev_mkdb/dev_mkdb.c: revision 1.29
usr.sbin/dev_mkdb/Makefile: revision 1.8
lib/libc/gen/ttyname.3: revision 1.23
lib/libc/gen/ttyname.3: revision 1.24
lib/libc/cdb/cdbr.c: revision 1.3
include/cdbw.h: revision 1.2
distrib/sparc64/cdroms/installcd/Makefile: revision 1.15
lib/libc/gen/devname.3: revision 1.12
tools/compat/compat_defs.h: revision 1.85
tools/compat/compat_defs.h: revision 1.86
lib/libterminfo/term_private.h: revision 1.10
lib/libterminfo/term.c: revision 1.14
usr.bin/tic/tic.1: revision 1.10
lib/libterminfo/term.c: revision 1.15
lib/libterminfo/Makefile.hash: revision 1.5
lib/libterminfo/term.c: revision 1.16
distrib/amd64/installimage/install.sh: revision 1.2
share/man/man5/rc.conf.5: revision 1.152
distrib/sets/lists/tests/mi: revision 1.472
distrib/amd64/cdroms/Makefile.cdrom: revision 1.7
include/paths.h: revision 1.41
bin/ps/ps.1: revision 1.101
lib/libterminfo/terminfo.5.in: revision 1.16
usr.bin/tic/tic.c: revision 1.20
lib/libterminfo/terminfo.5.in: revision 1.17
Prefer __printflike.
Use queue(3)
Replace linear lookup with hash table, reducing runtime by 60%.
Use e* from util.h.
One more strdup -> estrdup.
Maintain nalias and nterm on the fly.
Add void for ttyslot prototype.
Use memcmp in place of strncmp, since length is known to no longer than
either of the arguments.
Fix a number of memory leaks. Keep final loop of the cleanup in tic(1)
under #ifdef __VALGRIND__ though.
Add __predict_true / __predict_false definitions.
Add a special seeder for cdbw_output that gives stable results.
Hook up cdbw(3) for the tool build.
Prototype for cdbw_stable_seeder.
Provide a usable thr_once for !_REENTRANT
Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
Switch terminfo(3) to cdb(5).
Fix typos.
Make Alan Barrett happy and add ().
Add cdbr(3) support to tools/compat.
Bump date for previous.
Relax consistency to make it possible to match valid entries.
Prefix devname's buffer with /dev/ as ttyname is supposed to return the
full path. Reported by Dave Huang.
 1.156.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.156.2.1  23-Jun-2013  tls resync from head
 1.173.2.1  10-Aug-2014  tls Rebase.
 1.174.2.2  16-May-2015  snj Pull up following revision(s) (requested by christos in ticket #781):
common/lib/libc/stdlib/strtoi.c: revision 1.2
common/lib/libc/stdlib/strtou.c: revision 1.2
distrib/sets/lists/debug/mi: revision 1.113
distrib/sets/lists/tests/mi: revision 1.617
lib/libc/include/namespace.h: revision 1.178
lib/libc/stdlib/Makefile.inc: revision 1.90 via patch
lib/libc/stdlib/strtoi.3: revisions 1.1, 1.2
lib/libc/stdlib/strtol.3: revision 1.32
lib/libc/stdlib/strtou.3: revisions 1.1, 1.2
lib/libc/stdlib/strtoul.3: revisions 1.30, 1.31
tests/lib/libc/stdlib/Makefile: revision 1.25
tests/lib/libc/stdlib/t_strtoi.c: revision 1.1
- new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
--
Sort ERRORS and SEE ALSO.
--
Sort ERRORS and SEE ALSO.
--
Sort SEE ALSO.
 1.174.2.1  08-Feb-2015  snj Pull up following revision(s) (requested by christos in ticket #472):
lib/libc/include/namespace.h: revision 1.175
lib/libc/sys/Makefile.inc: revision 1.225, 1.227
lib/libc/sys/fdiscard.2: revision 1.3
lib/libc/sys/fdiscard.c: revision 1.1
lib/libc/sys/posix_fallocate.c: revision 1.1
Fix argument paddiing for posix_fallocate and fdiscard with gcc 1.x
--
PR/49617: Kirk Russell: posix_fallocate() should be returning an error on
failure, without setting errno, so make it PSEUDO_NOERROR, by adding a new
category GLUENOERR.
--
PR/49617: Kirk Russell: Describe the posix_fallocate return values correctly.
 1.180.2.2  20-Mar-2017  pgoyette Sync with HEAD
 1.180.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.185.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.196.4.2  21-Apr-2020  martin Sync with HEAD
 1.196.4.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.203.2.1  14-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #976):

lib/libc/locale/c32rtomb.3: revision 1.10
lib/libc/locale/c32rtomb.3: revision 1.9
lib/libc/locale/c32rtomb.3: revision 1.11
tests/lib/libc/locale/t_mbrtoc32.c: revision 1.1
distrib/sets/lists/base/shl.mi: revision 1.988
lib/libc/include/namespace.h: revision 1.204
lib/libc/include/namespace.h: revision 1.205
lib/libc/locale/mbrtoc16.3: revision 1.1
lib/libc/locale/mbrtoc16.c: revision 1.1
lib/libc/locale/mbrtoc16.3: revision 1.2
lib/libc/locale/mbrtoc16.c: revision 1.2
lib/libc/locale/mbrtoc16.3: revision 1.3
lib/libc/locale/mbrtoc16.c: revision 1.3
lib/libc/locale/mbrtoc32.3: revision 1.1
lib/libc/locale/mbrtoc32.c: revision 1.1
tests/lib/libc/locale/t_c16rtomb.c: revision 1.1
lib/libc/locale/mbrtoc32.c: revision 1.2
lib/libc/locale/mbrtoc16.3: revision 1.4
lib/libc/locale/mbrtoc16.c: revision 1.4
lib/libc/locale/mbrtoc32.3: revision 1.2
tests/lib/libc/locale/t_c16rtomb.c: revision 1.2
lib/libc/locale/mbrtoc32.c: revision 1.3
lib/libc/locale/mbrtoc16.3: revision 1.5
lib/libc/locale/mbrtoc16.c: revision 1.5
lib/libc/locale/mbrtoc32.3: revision 1.3
tests/lib/libc/locale/t_c16rtomb.c: revision 1.3
lib/libc/locale/mbrtoc32.c: revision 1.4
lib/libc/locale/mbrtoc16.3: revision 1.6
lib/libc/locale/mbrtoc16.c: revision 1.6
lib/libc/locale/mbrtoc32.3: revision 1.4
tests/lib/libc/locale/t_c16rtomb.c: revision 1.4
lib/libc/locale/mbrtoc32.c: revision 1.5
lib/libc/locale/mbrtoc16.3: revision 1.7
lib/libc/locale/mbrtoc16.c: revision 1.7
lib/libc/locale/mbrtoc32.3: revision 1.5
tests/lib/libc/locale/t_c16rtomb.c: revision 1.5
lib/libc/locale/mbrtoc32.c: revision 1.6
lib/libc/locale/mbrtoc16.3: revision 1.8
lib/libc/locale/mbrtoc32.3: revision 1.6
tests/lib/libc/locale/t_c16rtomb.c: revision 1.6
lib/libc/locale/mbrtoc32.c: revision 1.7
lib/libc/locale/mbrtoc16.3: revision 1.9
lib/libc/locale/mbrtoc32.3: revision 1.7
lib/libc/locale/mbrtoc32.c: revision 1.8
lib/libc/locale/mbrtoc32.3: revision 1.8
lib/libc/locale/mbrtoc32.c: revision 1.9
distrib/sets/lists/comp/mi: revision 1.2468
lib/libc/locale/mbrtoc32.3: revision 1.9
distrib/sets/lists/comp/mi: revision 1.2469
lib/libc/locale/c32rtomb.h: revision 1.1
lib/libc/locale/c32rtomb.h: revision 1.2
include/Makefile: revision 1.147
share/man/man3/uchar.3: revision 1.1
share/man/man3/uchar.3: revision 1.2
tests/lib/libc/locale/t_c32rtomb.c: revision 1.1
distrib/sets/lists/comp/mi: revision 1.2470
lib/libc/locale/c16rtomb.3: revision 1.1
lib/libc/locale/c16rtomb.c: revision 1.1
lib/libc/locale/c16rtomb.3: revision 1.2
lib/libc/locale/c16rtomb.c: revision 1.2
lib/libc/locale/c16rtomb.3: revision 1.3
lib/libc/locale/c16rtomb.c: revision 1.3
lib/libc/locale/c16rtomb.3: revision 1.4
lib/libc/locale/c16rtomb.c: revision 1.4
lib/libc/locale/c16rtomb.3: revision 1.5
lib/libc/locale/c16rtomb.c: revision 1.5
lib/libc/locale/c16rtomb.3: revision 1.6
lib/libc/locale/c16rtomb.c: revision 1.6
lib/libc/locale/c16rtomb.3: revision 1.7
lib/libc/locale/c16rtomb.c: revision 1.7
lib/libc/locale/c16rtomb.3: revision 1.8
lib/libc/locale/c16rtomb.3: revision 1.9
distrib/sets/lists/tests/mi: revision 1.1330
distrib/sets/lists/tests/mi: revision 1.1331
distrib/sets/lists/tests/mi: revision 1.1332
tests/lib/libc/locale/t_uchar.c: revision 1.1
tests/lib/libc/locale/t_uchar.c: revision 1.2
tests/lib/libc/locale/t_uchar.c: revision 1.3
tests/lib/libc/locale/t_mbrtoc16.c: revision 1.1
tests/lib/libc/locale/t_mbrtoc16.c: revision 1.2
tests/lib/libc/locale/t_mbrtoc16.c: revision 1.3
include/uchar.h: revision 1.1
include/uchar.h: revision 1.2
include/uchar.h: revision 1.3
include/uchar.h: revision 1.4
include/uchar.h: revision 1.5
tests/lib/libc/locale/t_c8rtomb.c: revision 1.1
include/uchar.h: revision 1.6
tests/lib/libc/locale/t_c8rtomb.c: revision 1.2
tests/lib/libc/locale/t_c8rtomb.c: revision 1.3
tests/lib/libc/locale/t_c8rtomb.c: revision 1.4
share/man/man3/Makefile: revision 1.93
tests/lib/libc/locale/t_c8rtomb.c: revision 1.5
tests/lib/libc/locale/t_c8rtomb.c: revision 1.6
tests/lib/libc/locale/t_c8rtomb.c: revision 1.7
lib/libc/shlib_version: revision 1.297
lib/libc/locale/c16rtomb.3: revision 1.10
lib/libc/locale/c16rtomb.3: revision 1.11
tests/lib/libc/locale/t_mbrtoc8.c: revision 1.1
tests/lib/libc/locale/t_mbrtoc8.c: revision 1.2
tests/lib/libc/locale/t_mbrtoc8.c: revision 1.3
lib/libc/locale/mbrtoc16.3: revision 1.10
tests/lib/libc/locale/Makefile: revision 1.15
tests/lib/libc/locale/Makefile: revision 1.16
tests/lib/libc/locale/Makefile: revision 1.17
tests/lib/libc/locale/Makefile: revision 1.18
distrib/sets/lists/debug/mi: revision 1.442
distrib/sets/lists/debug/mi: revision 1.443
distrib/sets/lists/debug/mi: revision 1.444
lib/libc/locale/c8rtomb.3: revision 1.1
lib/libc/locale/c8rtomb.c: revision 1.1
lib/libc/locale/c8rtomb.3: revision 1.2
lib/libc/locale/c8rtomb.c: revision 1.2
lib/libc/locale/c8rtomb.3: revision 1.3
lib/libc/locale/c8rtomb.c: revision 1.3
lib/libc/locale/c8rtomb.3: revision 1.4
lib/libc/locale/c8rtomb.c: revision 1.4
lib/libc/locale/c8rtomb.3: revision 1.5
lib/libc/locale/c8rtomb.c: revision 1.5
lib/libc/locale/c8rtomb.3: revision 1.6
lib/libc/locale/c8rtomb.c: revision 1.6
lib/libc/locale/c8rtomb.3: revision 1.7
lib/libc/locale/c8rtomb.3: revision 1.8
lib/libc/locale/c8rtomb.3: revision 1.9
lib/libc/locale/mbrtoc32.h: revision 1.1
lib/libc/locale/mbrtoc32.h: revision 1.2
lib/libc/locale/mbrtoc8.c: revision 1.1
lib/libc/locale/mbrtoc8.3: revision 1.1
lib/libc/locale/mbrtoc8.c: revision 1.2
lib/libc/locale/mbrtoc8.3: revision 1.2
lib/libc/locale/mbrtoc8.c: revision 1.3
lib/libc/locale/mbrtoc8.3: revision 1.3
lib/libc/locale/mbrtoc8.c: revision 1.4
lib/libc/locale/mbrtoc8.3: revision 1.4
lib/libc/locale/Makefile.inc: revision 1.66
lib/libc/locale/mbrtoc8.c: revision 1.5
lib/libc/locale/mbrtoc8.3: revision 1.5
lib/libc/locale/Makefile.inc: revision 1.67
lib/libc/locale/mbrtoc8.c: revision 1.6
lib/libc/locale/mbrtoc8.3: revision 1.6
lib/libc/locale/mbrtoc8.c: revision 1.7
lib/libc/locale/mbrtoc8.3: revision 1.7
lib/libc/locale/mbrtoc8.c: revision 1.8
lib/libc/locale/c32rtomb.3: revision 1.1
lib/libc/locale/c32rtomb.c: revision 1.1
lib/libc/locale/c32rtomb.3: revision 1.2
lib/libc/locale/c32rtomb.c: revision 1.2
lib/libc/locale/c32rtomb.3: revision 1.3
lib/libc/locale/c32rtomb.c: revision 1.3
lib/libc/locale/c32rtomb.3: revision 1.4
lib/libc/locale/c32rtomb.c: revision 1.4
lib/libc/locale/c32rtomb.3: revision 1.5
lib/libc/locale/c32rtomb.c: revision 1.5
lib/libc/locale/c32rtomb.3: revision 1.6
lib/libc/locale/c32rtomb.c: revision 1.6
lib/libc/locale/c32rtomb.3: revision 1.7
lib/libc/locale/c32rtomb.3: revision 1.8

(all via patch)


tests/lib/libc/locale/Makefile: Sort.
No functional change intended.
Preparation for PR lib/52374.

uchar.h: New header file for C11 (and C++11) compliance.

Implementation of the new functions mbrtoc16, c16rtomb, mbrtoc32, and
c32rtomb to come later. Updates for C23 to come later.
PR lib/52374: <uchar.h> missing

libc: New C11 functions mbrtoc16, mbrtoc32, c16rtomb, c32rtomb.

The mbrtoc16/32 functions read mulitbyte strings according to the
current locale into UTF-16/32 code unit sequences; the c16/32rtomb
functions write UTF-16/32 code unit sequences into multibyte strings
according to the current locale. The `r' means restartable: they
work incrementally and pick up where they left off.

NOTE: This bumps the libc minor version, since it adds new symbols.

PR lib/52374: <uchar.h> missing
mbrtoc16(3), mbrtoc32(3): Fix \n in man page examples.
Need to write \en to pacify roff.
PR lib/52374: <uchar.h> missing

c16rtomb(3), c32rtomb(3): Fix more \n in man pages.
Also, tighten an assertion: we left room for a NUL byte at the end.
PR lib/52374: <uchar.h> missing

libc: Use the more idiomatic alignof from stdalign.h.
No functional change intended.
PR lib/52374: <uchar.h> missing

mbrtoc16(3): Simplify surrogate state test.

Turn the finer-grained test into an assertion.
No semantic change intended: we are supposed to control this state,
and we always arrange it this way. (But in principle this could
change the behaviour of buggy programs that violate the mbstate_t
abstraction.)
PR lib/52374: <uchar.h> missing

libc: New functions c8rtomb(3) and mbrtoc8(3).

New in C23, for converting from UTF-8 to locale-dependent multibyte
sequences (c8rtomb) or vice versa (mbrtoc8), along with the new type
char8_t.

Conditional on either:
- _NETBSD_SOURCE
- _ISOC23_SOURCE
- __STDC_VERSION__ >= 202311L
(Riding the libc minor bump from this morning for the UTF-16/UTF-32
versions from C11.)

PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb
libc: c32rtomb and mbrtoc32 are used internally, so weak-alias them.
PR lib/52374: <uchar.h> missing
c8rtomb(3), mbrtoc8(3): Use namespace.h to get private aliases.

This way applications defining the symbols c32rtomb or mbrtoc32 won't
clobber our private definitions, which are slightly more constrained
about their use of mbstate_t than is obvious from the interface
contract.

PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb
mbrtoc16(3), mbrtoc32(3): brush up markup

Split long .Fn lines into Fo/Fa/Fc. Dont indent the list of return
values. Don't use artisanal -width.

Untabify code examples - indented literal displays don't have correct
tab stops consistent with tab stops in the fixed font code, so the
lines end up misaligned in the PostScript output.

c16rtomb(3), c32rtomb(3): brush up markup

mbrtoc16(3), mbrtoc32(3): Simplify return value language.
Also expand BMP only once.
PR lib/52374: <uchar.h> missing

mbrtoc16(3), mbrtoc32(3): No state overlap with mbrtoc8 or c8rtomb.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

mbrtoc32(3): Clarify control flow.
No need for another goto here; let's keep it clearly structured with
a single `out' label.
No functional change intended.
PR lib/52374: <uchar.h> missing

c8rtomb(3), mbrtoc8(3): brush up markup

mbrtoc8(3): Simplify return value language.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

c16rtomb(3), c32rtomb(3): Specify what happens if ps is null.
PR lib/52374: <uchar.h> missing

c8rtomb(3): Specify what happens when ps is null.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

c16rtomb(3), c32rtomb(3): No state overlap with mbrtoc8 or c8rtomb.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

mbrtoc16(3), mbrtoc32(3): Work on deturgidifying prose.
Still maybe not great but at least there's less jargon in most of the
text, without really losing any content.
PR lib/52374: <uchar.h> missing

mbrtoc8(3): Work on deturgidifying prose.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

mbrtoc16(3), mbrtoc32(3): Restore word accidentally removed.
PR lib/52374: <uchar.h> missing

mbrtoc8(3): Restore word accidentally removed.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

c8rtomb(3): Fix possible error descriptions.
The argument c8 can't be a surrogate code point itself (they're in
the range [0xd800,0xdfff], beyond 8-bit values), but the bits of a
surrogate code point could be forced into the UTF-8 format, which is
also invalid.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

c16rtomb(3), c32rtomb(3): Attempt a deturgidification pass.
Limit the jargon around surrogates.
PR lib/52374: <uchar.h> missing

c8rtomb(3): Clarify prose and fix example in caveat.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb
c16rtomb(3), c32rtomb(3), mbrtoc16(3), mbrtoc32(3): xref c8 versions.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

mbrtoc16(3): Clarify how many bytes are consumed in special cases.
Fix overlap in RETURN VALUES section.
PR lib/52374: <uchar.h> missing

mbrtoc8(3): Clarify how many bytes are consumed in special cases.
Fix overlap in RETURN VALUES section.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

pass lint, XXX see lint bug.

libc: Add _l variants of the cNrtomb and mbrtocN functions.
These accept an explicit locale parameter, rather than using the
current locale.
Visible under _NETBSD_SOURCE, not exposed otherwise.
NOTE: This adds libc symbols. Riding the libc minor bump for the
non-_l variants of these from two days ago -- hope that's not pushing
it too far.
PR lib/58613: c*rtomb, mbrtoc* should have locale-parametric _l
variants

c8rtomb(3), c16rtomb(3): Add tests for incomplete NUL termination.
PR lib/58615: incomplete c8rtomb, c16rtomb handles NUL termination
wrong

c8rtomb(3), c16rtomb(3): Fix NUL handling.
PR lib/58615: incomplete c8rtomb, c16rtomb handles NUL termination
wrong

c8rtomb(3), c16rtomb(3), c32rtomb(3): Test stateful shift sequences.
PR lib/58612: c8rtomb/c16rtomb/c32rtomb yield suboptimal shift
sequences

c8rtomb(3): Fix digit error in shift sequence test.
PR lib/58612: c8rtomb/c16rtomb/c32rtomb yield suboptimal shift
sequences

c8rtomb(3): Nix __CTASSERT after case label.
I put this in to make it (machine-verifiably) clear that zeroing the
state is the same as returning to the initial conversion state, as
the standard requires, but this is causing build trouble (and will
likely cause more trouble if pulled up) because some definitions of
__CTASSERT make a declaration which is forbidden after a label, so
let's remove it.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

mbrtoc8(3): Fix pasto in comment at top.
No functional change intended.
PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb

mbrtoc8: remove lint-specific workarounds
No binary change.

mbrtoc8: fix comments

mbrtoc16, mbrtoc32: fix comments, remove lint-specific workarounds
No binary change.
t_c8rtomb, t_c16rtomb: Simplify comment.
ESC $ B is technically rather the JIS X 0208-1983 shift sequence, but
since I don't see any way to provoke the JIS X 0208-1978 shift
sequence to come flying out of this conversion (ESC $ @), and I'm not
sure there's any difference in the interpretation, let's just say JIS
X 0208.
PR lib/58612: c8rtomb/c16rtomb/c32rtomb yield suboptimal shift
sequences

c32rtomb(3): Use conversion state to handle shift sequences.
For conversion of Unicode scalar values to coding systems requiring
shift sequences, such as ISO-2022-JP, _citrus_iconv_convert will
always produce:
1. a shift sequence from the initial state to some nondefault state,
like from US-ASCII to JIS X 0208
2. the encoding of the desired characater
3. a shift sequence restoring the initial state
This is unnecessary if the output is already in the state needed to
encoded the desired character. For example, this method produces
seven bytes to encode each YEN SIGN in ISO-2022-JP -- and fourteen,
to encode two consecutive ones -- even though the shift sequence is
only three bytes long and once shifted YEN SIGN takes only one byte.
Instead, convert the Unicode scalar value to a locale-dependent wide
character and encode that, by composing
- _citrus_iconv_convert
=> gives us a multibyte encoding of the character from the initial
state (and restoring the initial state afterward)
- mbrtowc with initial conversion state
=> gives us the single wide character representation
XXX If combining characters are possible here, this may fail.
- wcrtomb with caller's conversion tsate
=> gives us a state-dependent multibyte encoding of the character
XXX Is there a cheaper way to convert from Unicode scalar value to
locale-dependent wide character? It is not obvious to me from the
largely undocumented Citrus machinery, but it would obviously be
better than this somewhat circuitous Rube Goldberg contraption of
chained multibyte APIs.
PR lib/58612: c8rtomb/c16rtomb/c32rtomb yield suboptimal shift
sequences

mbrtoc8(3), mbrtoc16(3): Test consuming shift sequences with state.
This has the side effect of testing mbrtoc32(3) because they are both
defined in terms of it.
PR lib/58618: mbrtocN(3) fails to keep shift state

c8rtomb(3), c16rtomb(3), c32rtomb(3): Suggest MB_LEN_MAX in example.
This way it avoids variable-length arrays, by always allocating the
maximum space that could be occupied by MB_CUR_MAX.

mbrtoc32(3): Use conversion state to handle shift sequences.
PR lib/58618: mbrtocN(3) fails to keep shift state

mbrtoc32(3): Fix name and type of mbrtowc_l return value.
This was from `int mbtowc_l(...)' in an earlier draft and I didn't
update it to size_t when I changed the draft to mbrtowc_l. Caught by
lint.
`mb_len' avoids (harmless) clash with standard C function mblen(3).
PR lib/58618: mbrtocN(3) fails to keep shift state

c32rtomb(3): Fix type of wcrtomb_l return value.
This was from `int wctomb_l(...)' in an earlier draft and I didn't
update it to size_t when I changed the draft to wcrtomb_l. Caught by
lint.
`wc_len' mirrors `mb_len' in the complementary code in mbrtoc32(3) to
avoid clash with standard C function mblen(3).
PR lib/58612: c8rtomb/c16rtomb/c32rtomb yield suboptimal shift
sequences

c8rtomb(3), c16rtomb(3), c32rtomb(3): Attempt to simplify language.

c8rtomb(3), c16rtomb(3), c32rtomb(3): Fix null string output case.
This ignores c8/c16/c32, produces no output anywhere, and just resets
ps to the initial conversion state.
Also just use 0 in the example, not '\0' or L'\0'. This works for
C11, which prefers '\0' and L'\0', for and C23, which introduced the
new u8'\0', u'\0' (UTF-16), and U'\0' (UTF-32).
c16rtomb, c32rtomb, mbrtoc8: fix page numbers in comments
mbrtoc8(3), mbrtoc16(3), mbrtoc32(3): Say 0 for zero code unit.
Rather than deal with differences between C11 and C23 in notation,
'\0' vs L'\0' vs u8'\0' vs u'\0' vs U'\0'.
uchar.h: Include <sys/featuretest.h> before testing _*_SOURCE.
PR lib/58752: various header files test _*_SOURCE macros but don't
include sys/featuretest.h
PR lib/52374: <uchar.h> missing

uchar.h: Need <sys/cdefs.h> for __restrict.
PR lib/52374: <uchar.h> missing

uchar.h: Simplify __cpp_char8_t and __cplusplus conditionals.
No functional change intended.
PR lib/52374: <uchar.h> missing

tests/lib/libc/locale/t_uchar: Test for char8_t, mbrtoc8, c8rtomb.
PR lib/58752: various header files test _*_SOURCE macros but don't
include sys/featuretest.h
PR lib/52374: <uchar.h> missing

tests/t_uchar: fix copy-and-paste typo

RSS XML Feed