Yaakov Selkowitz
9f90ae0435
Feature test macros overhaul: string.h and strings.h overlaps
...
strings.h is the header mandated for these functions in POSIX.1 prior to
2008 (when most of these were removed). The declarations in string.h are
only for BSD compatibility. But when both headers are included, avoid
duplicate declarations.
Also, mark stpcpy and stpncpy as POSIX.1-2008.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-04-13 23:50:11 -05:00
Sebastian Huber
55c239d834
Add timingsafe_memcmp()
...
This function is used by LibreSSL and OpenSSH and is provided by the
OpenBSD libc.
* libc/include/string.h (timingsafe_memcmp): Declare.
* libc/string/timingsafe_memcmp.c: New file.
* libc/string/Makefile.am: Add new file.
* libc/string/Makefile.in: Regenerate.
2016-03-18 12:33:40 +01:00
Sebastian Huber
559fd77dda
Add timingsafe_bcmp()
...
This function is used by LibreSSL and OpenSSH and is provided by the
OpenBSD libc.
* libc/include/string.h (timingsafe_bcmp): Declare.
* libc/string/timingsafe_bcmp.c: New file.
* libc/string/Makefile.am: Add new file.
* libc/string/Makefile.in: Regenerate.
2016-03-18 12:33:40 +01:00
Sebastian Huber
8740fa7fd0
Add explicit_bzero()
...
This function is used by LibreSSL and OpenSSH and is provided by the
OpenBSD libc.
* libc/include/string.h (explicit_bzero): Declare.
* libc/string/explicit_bzero.c: New file.
* libc/string/Makefile.am: Add new file.
* libc/string/Makefile.in: Regenerate.
2016-03-18 12:33:40 +01:00
Yaakov Selkowitz
615d63599b
Feature test macros overhaul: string.h
...
Throughout, remove __STRICT_ANSI__ and use the proper internal macros.
bcmp, bcopy, bzero, index, and rindex were in POSIX prior to 2008.
memrchr is GNU.
strdup and strndup are POSIX.1-2008.
The int-returning form of strerror_r is POSIX.1-2001.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:07 -05:00
Yaakov Selkowitz
79e419de62
Rework handling of basename variants
...
As a commonly-included header, the #define basename in <string.h> can
affect code which uses "basename" for its own purposes (e.g. struct
members or C++ namespaced functions). When such cases occur and some
code includes <string.h> and some not, then errors result. OTOH,
<libgen.h> is rarely used, and that's where the renaming occurs in
glibc, so code using <libgen.h> should already be safe.
* libc/include/libgen.h (basename): Define as __xpg_basename
for source compatibility with glibc.
Declare with __ASMNAME("basename") for ABI compatibility.
* libc/include/string.h (basename): Define as basename for
source compatibility with glibc.
Declare with __ASMNAME("__gnu_basename") for ABI compatibility.
2015-07-06 14:58:51 -05:00
Corinna Vinschen
97a5dda2b0
Fix basename prototype collision string.h vs libgen.h
...
* libc/include/libgen.h (basename): Drop defining _BASENAME_DEFINED.
Always define macro basename. Add comment to explain why.
* libc/include/string.h (basename): Check for basename instead of
_BASENAME_DEFINED. Drop __GNUC__ branch, always use basename macro.
Change comment to explain why. Add nonnull function attribute.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:03:45 +02:00
Yaakov Selkowitz
d67052321e
string: add GNU basename(3)
...
* libc/include/libgen.h (_BASENAME_DEFINED): Define.
* libc/include/string.h (basename): Declare.
* libc/string/Makefile.am (ELIX_4_SOURCES): Add gnu_basename.c.
* libc/string/Makefile.in: Regenerate.
* libc/string/gnu_basename.c: New file.
2015-04-23 21:57:07 +02:00
Nick Clifton
b9e7cd9a84
* libc/include/complex.h (cabsl): Add prototype.
...
(cimagl): Add prototype.
(creall): Add prototype.
* libc/include/ieeefp.h: Include float.h.
(EXT_EXPBITS, EXT_FRACHBITS, EXT_FRACLBITS)
(EXT_EXP_INFNAN. EXT_EXP_BIAS, EXT_FRACBITS): Define.
(struct ieee_ext, union ieee_ext_u): New types for long double
support.
* libc/include/math.h (finitel): Add prototype.
(hypotl): Add prototype.
(sqrtl): Add prototype.
* libm/common/Makefile.am (lsrc): Add sl_finite.c.
* libm/common/Makefile.in: Regenerate.
* libm/common/fdlibm.h (__ieee754_hypotl): Add prototype.
* libm/common/hypotl.c (hypotl): Add implementation for when long
double is larger than double.
* libm/common/sqrtl.c (sqrtl): Likewise.
* libm/common/sl_finite.c: New file. Adds implementation of the
finitel function.
* libm/complex/Makefile.am (lsrc): Define.
(libcomplex_la_SOURCES): Add lsrc.
(lib_a_SOURCES): Add lsrc.
* libm/complex/Makefile.in: Regenerate.
* libm/complex/cabs.c: Add documentation of cabsl function.
* libm/complex/cimag.c: Add documentation of cimagl function.
* libm/complex/creall.c: Add documentation of creall function.
* libm/complex/cabsl.c: New file. Adds implementation of the
cabsl function.
* libm/complex/cimagl.c: New file. Adds implementation of the
cimagl function.
* libm/complex/creall.c: New file. Adds implementation of the
creall function.
* libm/math/Makefile.am (lsrc): Define.
(libmath_la_SOURCES): Add lsrc.
(lib_a_SOURCES): Add lsrc.
* libm/math/Makefile.in: Regenerate.
* libm/math/el_hypot.c: New file. Adds implementation of the
__ieee754_hypotl function.
2015-02-06 16:14:04 +00:00
Jon TURNEY
e7ebfb119e
2014-10-29 Jon Turney <jon.turney@dronecode.org.uk>
...
* libc/include/string.h: Correct guard for strcasecmp().
2014-10-30 11:25:17 +00:00
Corinna Vinschen
da77c6d1e5
* libc/include/string.h (ffsl): Declare as GNU function.
...
(ffsll): Ditto.
2014-10-08 21:04:59 +00:00
Jeff Johnston
ad9ed96b6b
2014-09-17 Joel Sherrill <joel.sherrill@oarcorp.com>
...
Thomas Uhle <thomas.uhle@eas.iis.fraunhofer.de>
* libc/include/string.h: Correct guard for strnlen().
2014-09-16 19:59:01 +00:00
Joel Sherrill
81c17949f0
2014-08-18 Joel Sherrill <joel.sherrill@oarcorp.com>
...
* libc/include/string.h: Improve language and OS standard guards.
2014-08-18 14:18:10 +00:00
Corinna Vinschen
b143d094ee
* libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,
...
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo()
and getaddrinfo() to increase standards compliance and match glibc.
* libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c,
libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c,
libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c,
libc/string/strtok_r.c, libc/string/strxfrm.c
libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c,
libc/machine/cris/memcpy.c: Add __restrict to prototype to
increase standards compliance.
2013-07-23 07:05:31 +00:00
Yaakov Selkowitz
e3928ce48c
* libc/include/string.h (rawmemchr): Declare.
...
* libc/string/Makefile.am (ELIX_4_SOURCES): Add rawmemchr.c.
(CHEWOUT_FILES): Add rawmemchr.def.
* libc/string/Makefile.in: Regenerate.
* libc/string/rawmemchr.c: New file.
2013-06-24 15:11:24 +00:00
Corinna Vinschen
38305196bf
* libc/include/string.h: Fix preprocessor expressions using
...
_XOPEN_SOURCE.
2013-01-12 10:55:09 +00:00
Corinna Vinschen
de1e3bb2c9
* libc/include/locale.h (NULL): Fetch definition via stddef.h.
...
* libc/include/stdio.h (NULL): Ditto.
* libc/include/stdlib.h (NULL): Ditto.
* libc/include/string.h (NULL): Ditto.
* libc/include/wchar.h (NULL): Ditto.
* libc/include/rpc/types.h (NULL): Ditto.
* libc/include/time.h (NULL): Ditto. Include stddef.h earlier.
2012-11-01 11:51:12 +00:00
Corinna Vinschen
6f7ae529ad
* libc/include/string.h (strdup, strndup): Declare if not
...
__STRICT_ANSI__ or _XOPEN_SOURCE is defined appropriately.
2012-10-22 15:16:48 +00:00
Corinna Vinschen
507b172d8d
* libc/include/string.h (memrchr): Declare.
...
* libc/string/Makefile.am (ELIX_4_SOURCES): Add memrchr.c.
(CHEWOUT_FILES): Add memrchr.def.
* libc/string/Makefile.in: Regenerate.
* libc/string/memrchr.c: New file.
2012-05-10 08:34:08 +00:00
Jeff Johnston
38e356f0e4
2011-06-09 Yaakov Selkowitz <yselkowitz@...>
...
* libc/include/string.h (strdupa): New macro function.
(strndupa): New macro function.
2011-06-10 18:30:38 +00:00
Eric Blake
4805b60ccf
strerror: allow user hook to comply with POSIX rules
...
* libc/string/strerror.c (strerror): Split body into...
(_strerror_r): ...new reentrant function.
* libc/string/u_strerr.c (_user_strerror): Update signature.
* libc/include/stdio.h (_strerror_r): New prototype.
* libc/posix/collate.c (__collate_err): Adjust callers.
* libc/stdio/perror.c (_perror_r): Likewise.
* libc/string/strerror_r.c (strerror_r): Likewise.
* libc/string/xpg_strerror_r.c (__xpg_strerror_r): Likewise.
2011-05-25 18:41:10 +00:00
Corinna Vinschen
43ff4129ce
* libc/include/string.h (strchrnul): Declare.
...
* libc/string/strchrnul.c: New file.
* libc/string/Makefile.am (ELIX_2_SOURCES): Add strchrnul.c.
* libc/string/Makefile.in: Regenerate.
2011-03-28 14:51:28 +00:00
Corinna Vinschen
4b43b20be8
* libc/include/string.h: Include sys/cdefs.h.
2011-03-03 11:11:41 +00:00
Corinna Vinschen
977cd4175e
* libc/include/sys/cdefs.h (__CONCAT1): Define.
...
(__CONCAT): Define.
(__STRING): Define.
(__XSTRING): Define.
(__ASMNAME): Define.
* libc/include/string.h (strerror_r): Use __ASMNAME to take target
specific label prefixes into account.
2011-03-03 10:37:09 +00:00
Eric Blake
7c10a76dec
strerror_r: provide POSIX implementation
...
* libc/include/string.h (strerror_r): Update declaration.
* libc/string/strerror.c (strerror): Update documentation.
* libc/string/strerror_r.c (strerror_r): Always return
NUL-terminated string; don't overwrite too-short buf.
* libc/string/xpg_strerror_r.c (__xpg_strerror_r): Implement POSIX
variant.
* libc/string/Makefile.am (GENERAL_SOURCES): Build new file.
* libc/string/Makefile.in: Regenerate.
2011-02-10 16:48:18 +00:00
Corinna Vinschen
84ca64afa6
* libc/include/string.h: Make strsignal() available unconditionally.
2011-01-10 10:59:42 +00:00
Eric Blake
8fa475e4b1
Per Posix, strsignal returns non-const char*.
...
* libc/include/string.h (strsignal): Fix return type.
2008-06-18 15:27:41 +00:00
Eric Blake
40617efc8b
Make strstr and strcasestr O(n), not O(n^2); add memmem.
...
* libc/string/str-two-way.h: New file.
* libc/string/memmem.c (memmem): New file.
* libc/include/string.h (memmem): Declare for all platforms.
* libc/string/strstr.c (strstr): Provide O(n) implementation when
not optimizing for space.
* libc/string/strcasestr.c (strcasestr): Likewise.
* libc/string/Makefile.am (ELIX_SOURCES): Rename to...
(ELIX_2_SOURCES): ...this.
(ELIX_4_SOURCES): New category, for memmem.
(lib_a_SOURCES, libstring_la_SOURCES): Build new file.
(CHEWOUT_FILES): Build documentation for memmem.
* libc/string/strings.tex: Include new docs.
2008-01-12 04:25:55 +00:00
Corinna Vinschen
5d8b97a694
* libc/include/string.h: Add prototypes for stpcpy and stpncpy.
...
* libc/string/Makefile.am (ELIX_SOURCES): Add stpcpy.c and
stpncpy.c.
(CHEWOUT_FILES): Add stpcpy.def and stpncpy.def.
* libc/string/Makefile.in: Regenerate.
* libc/string/stpcpy.c: New file.
* libc/string/stpncpy.c: New file.
* libc/string/strings.tex: Add stpcpy and stpncpy.
2007-06-28 17:07:23 +00:00
Jeff Johnston
6fb374754d
2007-06-08 Jeff Johnston <jjohnstn@redhat.com>
...
* libc/string/strcasestr.c: New file.
* libc/include/string.h: Add strcasestr.
* libc/string/strings.tex: Add strcasestr.
* libc/string/Makefile.am: Ditto.
* libc/string/Makefile.in: Regenerated.
2007-06-08 18:38:51 +00:00
Christopher Faylor
86c6c4212f
* libc/include/string.h: Add cygwin-specific function declaration.
2005-11-08 22:10:33 +00:00
Christopher Faylor
dbeee890d4
* libc/include/string.h: Revert previous change.
2005-08-26 04:33:02 +00:00
Christopher Faylor
377d3ea0e2
* libc/include/string.h: For Cygwin, Define strerror_r as per ISO C.
2005-08-25 23:02:24 +00:00
Jeff Johnston
dbfa92dd94
2005-01-24 Jeff Johnston <jjohnstn@redhat.com>
...
* libc/include/string.h: Remove Linux-specific declaration of
strsignal and add #include <sys/string.h>.
* libc/include/sys/string.h: New file.
* libc/include/sys/linux/sys/string.h: New file with strsignal
declaration deleted above.
2005-01-24 18:46:09 +00:00
Jeff Johnston
d254189b38
2002-07-23 Jeff Johnston <jjohnstn@redhat.com>
...
* libc/include/string.h: Add mempcpy, strndup, and _strndup_r
prototypes.
* libc/stdlib/Makefile.am: Remove strdup.c and strdup_r.c.
* libc/stdlib/Makefile.in: Regenerated.
* libc/stdlib/strdup.c: Removed.
* libc/stdlib/strdup_r.c: Removed.
* libc/string/Makefile.am: Add strdup.c, strdup_r.c, memccpy.c,
mempcpy.c, strndup.c, and strndup_r.c.
* libc/string/Makefile.in: Regenerated.
* libc/string/memccpy.c: New file.
* libc/string/mempcpy.c: Ditto.
* libc/string/strndup.c: Ditto.
* libc/string/strndup_r.c: Ditto.
* libc/string/strdup.c: New file moved from stdlib.
* libc/string/strdup_r.c: Ditto.
* libc/string/strings.tex: Add memccpy and mempcpy documentation.
2002-07-23 21:38:00 +00:00
Jeff Johnston
c1a3171f2d
2002-06-27 Benjamin Kosnik <bkoz@redhat.com>
...
* libc/include/stdio.h: Untangle, add _BEGIN_STD_C and _END_STD_C.
* libc/include/time.h: Same.
* libc/include/string.h: Same.
* libc/include/stdlib.h: Same.
* libc/include/signal.h: Same.
* libc/include/setjmp.h: Same.
* libc/include/math.h: Same.
* libc/include/locale.h: Same.
* libc/include/ctype.h: Same.
* libc/include/machine/setjmp.h: Same.
* libc/include/_ansi.h (_BEGIN_STD_C): Add.
(_END_STD_C): Add.
2002-06-27 23:58:38 +00:00
Jeff Johnston
39e65e0113
2002-06-05 Jeff Johnston <jjohnstn@redhat.com>
...
* libc/include/string.h[__linux__]: Add strsignal prototype.
* libc/include/sys/lock.h: New file with default locking support.
* libc/include/sys/reent.h: Add signal buffer support for strsignal
and psignal.
* libc/posix/Makefile.am: Add support for readdir_r.c.
* libc/posix/Makefile.in: Regenerated.
* libc/posix/closedir.c: Add locking support and hash table cleanup.
* libc/posix/opendir.c: Add lock support.
* libc/posix/readdir.c: Ditto.
* libc/posix/rewinddir.c: Ditto.
* libc/posix/scandir.c: Ditto.
* libc/posix/seekdir.c: Ditto.
* libc/posix/telldir.c: Ditto plus add _cleanupdir routine to
clean up leftover hash table entries.
* libc/posix/readdir_r.c: New file.
* libc/sys/linux/Makefile.am: Add psignal.c and strsignal.c support.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/sys/dirent.h: Add dd_lock to DIR structure.
* libc/sys/linux/sys/signal.h: Add psignal prototype.
* libc/sys/linux/psignal.c: New file.
* libc/sys/linux/strsignal.c: Ditto.
2002-06-05 20:58:59 +00:00
Jeff Johnston
d29587b478
2002-05-24 Jeff Johnston <jjohnstn@redhat.com>
...
* libc/include/string.h: Add strnlen and strerror_r prototypes.
* libc/string/Makefile.am: Add strnlen.c and strerror_r.c support.
* libc/string/Makefile.in: Regenerated.
* libc/string/strerror_r.c: New file.
* libc/string/strnlen.c: New file.
* libc/sys/linux/Makefile.am: Add rename.c.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/rename.c: New file to override default rename.
2002-05-24 23:44:39 +00:00
Jeff Johnston
afe5651795
2002-05-23 Jeff Johnston <jjohnstn@redhat.com>
...
* libc/include/string.h (bcmp, bcopy, bzero): Change prototypes
to use void * pointers and comply with Single Unix spec.
* libc/string/bcmp.c: Change to use void * instead of char *.
* libc/string/bcopy.c: Ditto.
* libc/string/bzero.c: Ditto.
2002-05-23 18:46:04 +00:00
Thomas Fitzsimmons
7d2ce8983d
2002-05-10 Mark Bradshaw <bradshaw@staff.crosswalk.com>
...
* libc/include/string.h (!__STRICT_ANSI__): Add strlcat and strlcpy.
* libc/string/Makefile.am: Add strlcat.c and strlcpy.c.
* libc/string/strlcat.c: New file.
* libc/string/strlcpy.c: New file.
2002-05-13 19:33:01 +00:00
Geoffrey Keating
44e36af42b
* libc/string/swab.c: Specify that it's defined in <unistd.h>.
...
* libc/include/string.h: Don't include <sys/types.h>,
as it causes really bad namespace pollution. Don't declare
swab(), it is properly declared in unistd.h.
2000-08-30 18:30:16 +00:00
Christopher Faylor
d51d968a80
* libc/include/string.h: Work around problem with strsignal and gdb.
2000-06-03 03:03:03 +00:00
Christopher Faylor
d2dd57657c
* libc/include/ctype.h: __CYGWIN32__ -> __CYGWIN__
...
* libc/include/malloc.h: Ditto.
* libc/include/process.h: Ditto.
* libc/include/stdio.h: Ditto.
* libc/include/stdlib.h: Ditto.
* libc/include/time.h: Ditto.
* libc/include/machine/setjmp.h: Ditto.
* libc/include/sys/errno.h: Ditto.
* libc/include/sys/signal.h: Ditto.
* libc/include/sys/stat.h: Ditto.
* libc/include/sys/time.h: Ditto.
* libc/include/sys/unistd.h: Ditto.
* libc/include/string.h: Ditto. strsignal should return a const char *.
2000-05-30 17:18:05 +00:00
Jeff Johnston
5ed2f523e5
Fri Mar 10 16:09:20 2000 Jeff Johnston <jjohnstn@cygnus.com>
...
* libc/include/string.h: Include <sys/types.h>.
2000-03-10 21:13:28 +00:00
Jeff Johnston
e9c9497815
Thu Mar 9 17:20:41 2000 Jeff Johnston <jjohnstn@cygnus.com>
...
* libc/include/string.h: Changed last argument back to ssize_t
to make it compatible with XPG4 definition which is
defined in <unistd.h>. There is a conflict in the SVID 3
and XPG4 definitions and newlib will settle with XPG4.
* libc/string/swab.c: Ditto.
2000-03-09 22:25:01 +00:00
Jeff Johnston
3072163c0f
Wed Mar 8 17:11:41 2000 Jeff Johnston <jjohnstn@cygnus.com>
...
* libc/include/string.h: Changed last argument to size_t.
* libc/string/swab.c: Changed last argument to size_t.
2000-03-08 22:16:06 +00:00
Alexandre Oliva
85dd2e5b73
* libc/string/Makefile.am (lib_a_SOURCES): Added swab.c.
...
(CHEWOUT_FILES): Added swab.def.
* libc/string/Makefile.in: Rebuilt.
* libc/string/string.tex: Include swab.def.
* libc/include/string.h (swab): Declare.
* libc/string/swab.c: New file.
2000-03-08 03:46:01 +00:00
Christopher Faylor
8a0efa53e4
import newlib-2000-02-17 snapshot
2000-02-17 19:39:52 +00:00