Home | History | Annotate | Download | only in include
History log of /src/include/string.h
RevisionDateAuthorComments
 1.58  09-Dec-2024  nros memccpy, strdup and strndup are in C23

7.26.2.2 memccpy
7.26.2.6 strdup
7.26.2.7 strndup
 1.57  02-Nov-2024  riastradh memset_explicit(3): Add C23 alias for explicit_memset.

PR standards/58607: C23: <string.h> memset_explicit
 1.56  01-Nov-2024  riastradh string.h: Fix various symbol visibility issues.

1. Order declarations according to POSIX 2024 to make this easier to
review side-by-side with the spec.
2. Fix visibility of memccpy: XSI-only, not POSIX in general; require
_XOPEN_SOURCE, not just _POSIX_C_SOURCE.
3. Omit redundant _XOPEN_SOURCE test around stpcpy/stpncpy.
4. Hide strdup in POSIX 2001. Not POSIX (without XSI) until 2008.
5. Hide strerror_r until POSIX 2001. Can't find evidence of it in
any earlier POSIX or X/Open. (Not 100% sure on this one, maybe
someone can double-check my research.)
6. Add restrict to strlcat/strlcpy.
7. Omit redundant _XOPEN_SOURCE test around strndup and strnlen.
8. Hide strtok_r until POSIX 2001. Can't find evidence of it in
any earlier POSIX or X/Open. (Not 100% sure on this one, maybe
someone can double-check my research.)

Carry the restrict qualifiers on strlcat/strlcpy to libkern too.

Main reference:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/string.h.html

PR standards/58804: string.h: wrong visibility for memccpy
 1.55  01-Nov-2024  nia libc: Expose some newly-standard C functions in POSIX.1-2024 mode
 1.54  01-Aug-2023  christos branches: 1.54.2;
Add companion mempcpy to wmempcpy, bump.
 1.53  09-Aug-2021  andvar fix various typos in compatibility, mainly in comments.
 1.52  20-Feb-2018  kamil Mark in string.h: memccpy(3) and strdup(3) as _POSIX_C_SOURCE >= 2001
 1.51  12-Oct-2016  christos branches: 1.51.6;
add strchrnull
 1.50  10-Mar-2016  leot branches: 1.50.2;
strndup() is part of XSI from The Open Group Base Specification Issue 7 and had
a similar history of stpcpy(), stpncpy() and strnlen().
Make it visible under XOPEN_SOURCE>=700 too (not just _NETBSD_SOURCE).

ok dholland@
 1.49  24-Sep-2014  christos add strnstr from FreeBSD
 1.48  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.47  28-Aug-2013  riastradh Make explicit_memset match memset's return value.
 1.46  27-Aug-2013  joerg Remove outdated comment.
 1.45  19-Aug-2013  joerg Add strerror_l.
 1.44  24-Jun-2013  riastradh Replace consttime_bcmp/explicit_bzero by consttime_memequal/explicit_memset.

consttime_memequal is the same as the old consttime_bcmp.
explicit_memset is to memset as explicit_bzero was to bcmp.

Passes amd64 release and i386/ALL, but I'm sure I missed some spots,
so please let me know.
 1.43  21-Apr-2013  joerg __BEGIN_DECLS/__END_DECLS
 1.42  19-Apr-2013  joerg Add dummy strcoll_l and strxfrm_l.
 1.41  30-Aug-2012  drochner branches: 1.41.2;
Add "consttime_bcmp" and "explicit_bzero" functions for both kernel
abd userland, as proposed on tech-security, with explicit_bzero using
a volatile function pointer as suggested by Alan Barrett.
Both do what the name says. For userland, both are prefixed by "__"
to keep them out of the user namespace.
Change some memset/memcmp uses to the new functions where it makes
sense -- these are just some examples, more to come.
 1.40  20-Apr-2012  joerg Do not wrap other header files with extern "C".
 1.39  22-Jul-2009  kleink branches: 1.39.8;
Declare strsignal(3) in <string.h>, per POSIX-2008, and adjust
documentation accordingly.

Fixes PR standards/41325 from Perry E. Metzger.
 1.38  01-May-2009  perry note that we have strsignal but it is in the wrong include file.
 1.37  01-May-2009  perry Add prototypes for stpcpy, stpncpy, strnlen, added in the latest POSIX.

Implementations in libc to follow.

For POSIX compliance, we are still missing:

strcoll_l
strerror_l
strsignal
strxfrm_l
 1.36  10-Apr-2009  christos add memrchr
 1.35  19-Oct-2007  christos branches: 1.35.18;
kill _NETBSD_TOOLS.
 1.34  18-Oct-2007  christos Introduce _NETBSD_TOOLS for symbols the are needed in tools build
 1.33  02-Aug-2007  kristerw branches: 1.33.2; 1.33.4;
Do not include SSP files unless _FORTIFY_SOURCE > 0.
 1.32  30-May-2007  tls Match usage of FORTIFY_SOURCE on other platforms by not requiring special
include path: the normal header files now include the "SSP" ones (which one
should note are not really named right: SSP and FORTIFY_SOURCE are independent
features).

Disable USE_SSP on targets where the compiler doesn't support it at all
(mips, alpha) or it's known broken (sh3). But enable FORTIFY_SOURCE,
without SSP, on those platforms -- tested on mipsel.
 1.31  12-Aug-2006  christos branches: 1.31.2; 1.31.4;
Add stresep and strndup.
 1.30  28-Jul-2005  christos branches: 1.30.2;
Add strerror_r.
 1.29  13-Mar-2005  perry Add prototype for memmem(3). It is API compatible with the version in Linux.
 1.28  03-Feb-2005  perry de-__P -- the hack is long since useless. Discussed with christos,
matt, kleink, others. Approved by christos.
 1.27  12-Jul-2004  kleink Move the strcasestr() prototype to the local extensions section.
Also __P() it; this should be consistent within a single header.
 1.26  03-Jul-2004  junyoung Add strcasestr(3), case insensitive version of strstr(3).
Bump libc minor.

From FreeBSD.
 1.25  07-Aug-2003  agc branches: 1.25.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22270, verified by myself.
 1.24  28-Apr-2003  bjh21 Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.23  22-Mar-2001  kleink Sprinkle some restrict qualifiers.
 1.22  10-Jan-2000  kleink branches: 1.22.6;
Move <null.h> to <sys/null.h> for the purpose of avoiding conflicts due to
std C headers including it, and a kernel module written in C++ would benfit
as well.
 1.21  22-Dec-1999  kleink For the benefit of G++'s null pointer constant implementation, #define NULL
as __null with egcs 1.0 (GCC 2.90) and above. As several headers are affected
by this change, move the definition into a new header file, <null.h>, to ease
maintenance.
 1.20  09-Sep-1999  kleink strlcat() and strlcpy() aren't ISO/IEC 9899:1990.
 1.19  08-Sep-1999  lukem prototypes for strlcat() and strlcpy()
 1.18  27-Jul-1998  mycroft branches: 1.18.2;
Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*
 1.17  26-Jul-1998  mycroft KNF nit.
 1.16  26-Jul-1998  mycroft const poisoning.
 1.15  06-May-1998  kleink Make strtok_r() available to _XOPEN_SOURCE >= 500, and fix the protection of
memccpy() and strdup().
 1.14  27-Apr-1998  tv Move the #include <strings.h> line inside a !defined(_XOPEN_SOURCE) block
(not just !POSIX and !ANSI)
 1.13  03-Feb-1998  perry restore include of sys/featuretest.h
 1.12  02-Feb-1998  perry remove sys/featuretest.h -- why did kleink add it?
 1.11  02-Feb-1998  perry merge lite-2
 1.10  02-Feb-1998  kleink Per XPG4.2, move the prototypes of bcmp(), bcopy(), bzero(), ffs(), index(),
rindex(), strcasecmp() and strncasecmp() to <strings.h>. For now, include
<strings.h> to get these prototypes; this should go away eventually.
Also, protect the prototypes of strtok_r() and strsep().
 1.9  12-Jan-1998  kleink Per XPG4, move the prototype of swab() from <string.h> to <unistd.h>.
 1.8  16-Oct-1997  christos move setmode and strsignal to unistd.h
 1.7  13-Jul-1997  christos Add missing strtok_r prototype
 1.6  26-Oct-1994  cgd new RCS ID format.
 1.5  02-Aug-1994  jtc branches: 1.5.2;
Added prototype for new function strsignal()
 1.4  21-May-1994  cgd add _BSD's to ansi types
 1.3  11-Oct-1993  jtc Changed preprocessor conditional so non-standard functions would not be
declared in a _POSIX_SOURCE environment.
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  02-Feb-1998  perry import lite-2
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.2  02-Aug-1994  jtc Added prototype for new function strsignal()
 1.5.2.1  02-Aug-1994  jtc file string.h was added on branch netbsd-1-0 on 1994-08-02 05:03:47 +0000
 1.18.2.1  05-Jul-2000  he Pull up revisions 1.19-1.20 (requested by he):
Add declarations for strlcat() and strlcpy().
 1.22.6.1  08-Apr-2001  nathanw Merge trunk onto branch.
 1.25.2.2  14-Jul-2004  tron Pull up revision 1.27 (requested by kleink in ticket #643):
Move the strcasestr() prototype to the local extensions section.
Also __P() it; this should be consistent within a single header.
 1.25.2.1  12-Jul-2004  he Pull up revision 1.26 (requested by junyoung in ticket #638):
Add strcasestr(3), case insensitive version of strstr(3).
 1.30.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.31.4.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.31.2.2  24-Aug-2007  liamjfoy Pull up following revision(s) (requested by kristerw in ticket #833):
include/unistd.h: revision 1.112
lib/libc/ssp/snprintf_chk.c: revision 1.4
lib/libc/ssp/sprintf_chk.c: revision 1.4
lib/libc/ssp/vsprintf_chk.c: revision 1.4
lib/libc/ssp/gets_chk.c: revision 1.4
include/stdio.h: revision 1.70
lib/libc/ssp/vsnprintf_chk.c: revision 1.4
lib/libc/ssp/fgets_chk.c: revision 1.4
include/strings.h: revision 1.12
include/string.h: revision 1.33
Do not include SSP files unless _FORTIFY_SOURCE > 0.
Update includes so that this builds for USE_FORT=no too.
 1.31.2.1  22-Jul-2007  liamjfoy Pull up to netbsd-4 (requested by christos in ticket #773):

Move libssp to libc.
 1.33.4.2  02-Aug-2007  kristerw Do not include SSP files unless _FORTIFY_SOURCE > 0.
 1.33.4.1  02-Aug-2007  kristerw file string.h was added on branch matt-mips64 on 2007-08-02 21:49:11 +0000
 1.33.2.1  06-Nov-2007  matt sync with HEAD
 1.35.18.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.39.8.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.39.8.2  30-Oct-2012  yamt sync with head
 1.39.8.1  23-May-2012  yamt sync with head.
 1.41.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.41.2.1  23-Jun-2013  tls resync from head
 1.50.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.51.6.1  25-Feb-2018  snj Pull up following revision(s) (requested by kamil in ticket #561):
include/string.h: 1.52
Mark in string.h: memccpy(3) and strdup(3) as _POSIX_C_SOURCE >= 2001
 1.54.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed