NetBSD re-synchronization of the source tree

This brings our tree to NetBSD 7.0, as found on -current on the
10-10-2015.

This updates:
 - LLVM to 3.6.1
 - GCC to GCC 5.1
 - Replace minix/commands/zdump with usr.bin/zdump
 - external/bsd/libelf has moved to /external/bsd/elftoolchain/
 - Import ctwm
 - Drop sprintf from libminc

Change-Id: I149836ac18e9326be9353958bab9b266efb056f0
This commit is contained in:
2015-10-15 17:01:16 +02:00
parent 8933525b85
commit 0a6a1f1d05
32425 changed files with 2998623 additions and 1342348 deletions

View File

@@ -1,5 +1,5 @@
# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
# $NetBSD: Makefile.inc,v 1.79 2013/08/19 10:59:39 joerg Exp $
# $NetBSD: Makefile.inc,v 1.80 2014/09/24 18:16:37 christos Exp $
# string sources
.PATH: ${ARCHDIR}/string ${.CURDIR}/string
@@ -18,7 +18,7 @@ SRCS+= bm.c stpcpy.c stpncpy.c \
SRCS+= bcmp.c bcopy.c bzero.c ffs.c memchr.c memcmp.c memset.c
SRCS+= strcat.c strcmp.c strcpy.c strcspn.c strlen.c
SRCS+= strncat.c strncmp.c strncpy.c strpbrk.c strsep.c
SRCS+= strspn.c strstr.c swab.c
SRCS+= strspn.c strstr.c swab.c strnstr.c
SRCS+= explicit_memset.c consttime_memequal.c
SRCS+= memccpy.c memcpy.c memmem.c memmove.c
@@ -58,6 +58,7 @@ MLINKS+=strcpy.3 strncpy.3 strcpy.3 stpcpy.3 strcpy.3 stpncpy.3
MLINKS+=strlcpy.3 strlcat.3
MLINKS+=strlen.3 strnlen.3
MLINKS+=strstr.3 strcasestr.3
MLINKS+=strstr.3 strnstr.3
MLINKS+=memchr.3 memrchr.3
MLINKS+=strtok.3 strtok_r.3
MLINKS+=strerror.3 strerror_r.3 strerror.3 perror.3 \

View File

@@ -29,7 +29,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)bcopy.3 8.1 (Berkeley) 6/4/93
.\" $NetBSD: bcopy.3,v 1.14 2012/05/05 21:24:19 dholland Exp $
.\" $NetBSD: bcopy.3,v 1.15 2015/06/20 04:18:00 dholland Exp $
.\"
.Dd May 5, 2012
.Dt BCOPY 3
@@ -79,7 +79,7 @@ arguments in the opposite order from these.
.Xr strncpy 3
.Sh STANDARDS
The
.Fn bcmp
.Fn bcopy
function conforms to
.St -p1003.1-2001 .
The

View File

@@ -1,4 +1,4 @@
/* $NetBSD: bm.c,v 1.12 2012/06/25 22:32:46 abs Exp $ */
/* $NetBSD: bm.c,v 1.13 2014/06/23 10:43:25 shm Exp $ */
/*-
* Copyright (c) 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)bm.c 8.7 (Berkeley) 6/21/94";
#else
__RCSID("$NetBSD: bm.c,v 1.12 2012/06/25 22:32:46 abs Exp $");
__RCSID("$NetBSD: bm.c,v 1.13 2014/06/23 10:43:25 shm Exp $");
#endif
#endif /* LIBC_SCCS && not lint */
@@ -162,10 +162,8 @@ bm_free(bm_pat *pat)
_DIAGASSERT(pat != NULL);
if (pat->pat != NULL)
free(pat->pat);
if (pat->delta != NULL)
free(pat->delta);
free(pat->pat);
free(pat->delta);
free(pat);
}
@@ -194,7 +192,7 @@ bm_exec(bm_pat *pat, u_char *base, size_t n)
e = base + n - 3 * pat->patlen;
while (s < e) {
k = d0[*s]; /* ufast skip loop */
while (k) {
while (k && s < e) {
k = d0[*(s += k)];
k = d0[*(s += k)];
}

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: consttime_memequal.3,v 1.2 2013/08/28 15:24:41 riastradh Exp $
.\" $NetBSD: consttime_memequal.3,v 1.5 2015/03/23 07:41:16 apb Exp $
.\"
.\" Copyright (c) 2013 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 28, 2013
.Dd March 23, 2015
.Dt CONSTTIME_MEMEQUAL 3
.Os
.Sh NAME
@@ -48,8 +48,8 @@ bytes of memory at
.Fa b1
and
.Fa b2
for equality, returning zero if they are distinct and nonzero if they
are identical.
for equality, returning 0 if they are distinct and 1 if they are
identical.
.Pp
The time taken by
.Fn consttime_memequal
@@ -78,6 +78,13 @@ does not return a lexicographic ordering on the data at
and
.Fa b2 ;
it tells only whether they are equal.
.Nx
does not provide a
.Fn consttime_memcmp
function, because all known use cases that require
.Sq constant time
memory comparison also require only comparison for equality,
not lexicographic ordering.
.Sh SEE ALSO
.Xr explicit_memset 3 ,
.Xr memcmp 3

View File

@@ -30,9 +30,9 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)strcpy.3 8.1 (Berkeley) 6/4/93
.\" $NetBSD: strcpy.3,v 1.20 2009/05/02 09:37:32 wiz Exp $
.\" $NetBSD: strcpy.3,v 1.23 2015/04/01 20:18:17 riastradh Exp $
.\"
.Dd May 1, 2009
.Dd April 1, 2015
.Dt STRCPY 3
.Os
.Sh NAME
@@ -92,6 +92,12 @@ Otherwise,
is
.Em not
terminated.
.Pp
The strings
.Fa src
and
.Fa dst
may not overlap.
.Sh RETURN VALUES
The
.Fn strcpy

View File

@@ -1,70 +0,0 @@
/* $NetBSD: strcspn.c,v 1.18 2012/03/21 00:35:50 christos Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: strcspn.c,v 1.18 2012/03/21 00:35:50 christos Exp $");
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
#include <string.h>
/* 64bit version is in strspn.c */
#if ULONG_MAX != 0xffffffffffffffffull
size_t
strcspn(const char *s, const char *charset)
{
static const uint8_t idx[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
const char *t;
uint8_t set[32];
#define UC(a) ((unsigned int)(unsigned char)(a))
_DIAGASSERT(s != NULL);
_DIAGASSERT(charset != NULL);
if (charset[0] == '\0')
return strlen(s);
if (charset[1] == '\0') {
for (t = s; *t != '\0'; ++t)
if (*t == *charset)
break;
return t - s;
}
(void)memset(set, 0, sizeof(set));
for (; *charset != '\0'; ++charset)
set[UC(*charset) >> 3] |= idx[UC(*charset) & 7];
for (t = s; *t != '\0'; ++t)
if (set[UC(*t) >> 3] & idx[UC(*t) & 7])
break;
return t - s;
}
#endif

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: strerror.3,v 1.17 2010/10/25 07:37:11 wiz Exp $
.\" $NetBSD: strerror.3,v 1.18 2015/05/09 19:01:53 dholland Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)strerror.3 8.1 (Berkeley) 6/9/93
.Dd October 24, 2010
.Dd May 9, 2015
.Dt STRERROR 3
.Os
.Sh NAME
@@ -171,11 +171,13 @@ function conforms to
.St -p1003.1-2001 .
.Sh HISTORY
The
.Fn strerror
and
.Fn perror
functions first appeared in
.Bx 4.4 .
function first appeared in
.At v4 .
The
.Fn strerror
function first appeared in
.Bx 4.3 Reno .
The
.Fn strerror_r
function first appeared in

View File

@@ -1,4 +1,4 @@
/* $NetBSD: strerror.c,v 1.16 2013/09/02 07:59:32 joerg Exp $ */
/* $NetBSD: strerror.c,v 1.17 2015/01/20 18:31:25 christos Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: strerror.c,v 1.16 2013/09/02 07:59:32 joerg Exp $");
__RCSID("$NetBSD: strerror.c,v 1.17 2015/01/20 18:31:25 christos Exp $");
#define __SETLOCALE_SOURCE__

View File

@@ -1,6 +1,7 @@
/* $NetBSD: strncat.c,v 1.12 2012/06/25 22:32:46 abs Exp $ */
/* $NetBSD: strnstr.c,v 1.1 2014/09/24 22:21:33 christos Exp $ */
/*-
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -35,42 +36,36 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)strncat.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)strstr.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: strncat.c,v 1.12 2012/06/25 22:32:46 abs Exp $");
__RCSID("$NetBSD: strnstr.c,v 1.1 2014/09/24 22:21:33 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
/* FreeBSD: head/lib/libc/string/strnstr.c 251069 2013-05-28 20:57:40Z emaste */
#include <assert.h>
#include <string.h>
#ifdef _FORTIFY_SOURCE
#undef strncat
#endif
/*
* Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes
* are written at dst (at most n+1 bytes being appended). Return dst.
* Find the first occurrence of find in s, where the search is limited to the
* first slen characters of s.
*/
char *
strncat(char *dst, const char *src, size_t n)
strnstr(const char *s, const char *find, size_t slen)
{
char c, sc;
size_t len;
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
if (n != 0) {
char *d = dst;
const char *s = src;
while (*d != 0)
d++;
if ((c = *find++) != '\0') {
len = strlen(find);
do {
if ((*d = *s++) == 0)
break;
d++;
} while (--n != 0);
*d = 0;
do {
if (slen-- < 1 || (sc = *s++) == '\0')
return NULL;
} while (sc != c);
if (len > slen)
return NULL;
} while (strncmp(s, find, len) != 0);
s--;
}
return (dst);
return __UNCONST(s);
}

View File

@@ -1,75 +0,0 @@
/* $NetBSD: strpbrk.c,v 1.20 2011/11/22 00:37:09 joerg Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: strpbrk.c,v 1.20 2011/11/22 00:37:09 joerg Exp $");
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
#include <string.h>
#define FAST_STRPBRK 1
#define UC(a) ((unsigned int)(unsigned char)(a))
#ifdef FAST_STRPBRK
#define ADD_NEW_TO_SET(i) (set[inv[i] = idx++] = (i))
#define IS_IN_SET(i) (inv[i] < idx && set[inv[i]] == (i))
#define ADD_TO_SET(i) (void)(IS_IN_SET(i) || /*LINTED no effect*/ADD_NEW_TO_SET(i))
#else
#define IS_IN_SET(i) (set[(i) >> 3] & idx[(i) & 7])
#define ADD_TO_SET(i) (void)(set[(i) >> 3] |= idx[(i) & 7])
#endif
char *
strpbrk(const char *s, const char *charset)
{
#ifdef FAST_STRPBRK
uint8_t set[256], inv[256], idx = 0;
#else
static const size_t idx[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
uint8_t set[32];
(void)memset(set, 0, sizeof(set));
#endif
_DIAGASSERT(s != NULL);
_DIAGASSERT(charset != NULL);
if (charset[0] == '\0')
return NULL;
if (charset[1] == '\0')
return strchr(s, charset[0]);
for (; *charset != '\0'; ++charset)
ADD_TO_SET(UC(*charset));
for (; *s != '\0'; ++s)
if (IS_IN_SET(UC(*s)))
return __UNCONST(s);
return NULL;
}

View File

@@ -1,151 +0,0 @@
/* $NetBSD: strspn.c,v 1.18 2012/03/21 00:35:50 christos Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: strspn.c,v 1.18 2012/03/21 00:35:50 christos Exp $");
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
#include <string.h>
#if ULONG_MAX != 0xffffffffffffffffull
size_t
strspn(const char *s, const char *charset)
{
static const uint8_t idx[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
uint8_t set[32];
const char *t;
#define UC(a) ((unsigned int)(unsigned char)(a))
_DIAGASSERT(s != NULL);
_DIAGASSERT(charset != NULL);
if (charset[0] == '\0')
return 0;
if (charset[1] == '\0') {
for (t = s; *t != '\0'; ++t) {
if (*t != *charset)
break;
}
return t - s;
}
(void)memset(set, 0, sizeof(set));
for (; *charset != '\0'; ++charset)
set[UC(*charset) >> 3] |= idx[UC(*charset) & 7];
for (t = s; *t != '\0'; ++t)
if ((set[UC(*t) >> 3] & idx[UC(*t) & 7]) == 0)
break;
return t - s;
}
#else
/* 64 bit system, use four 64 bits registers for bitmask */
static size_t
strspn_x(const char *s_s, const char *charset_s, unsigned long invert)
{
const unsigned char *s = (const unsigned char *)s_s;
const unsigned char *charset = (const unsigned char *)charset_s;
unsigned long m_0, m_4, m_8, m_c;
unsigned char ch, next_ch;
unsigned long bit;
unsigned long check;
size_t count;
/* Four 64bit registers have one bit for each character value */
m_0 = 0;
m_4 = 0;
m_8 = 0;
m_c = 0;
for (ch = *charset; ch != 0; ch = next_ch) {
next_ch = *++charset;
bit = 1ul << (ch & 0x3f);
if (__predict_true(ch < 0x80)) {
if (ch < 0x40)
m_0 |= bit;
else
m_4 |= bit;
} else {
if (ch < 0xc0)
m_8 |= bit;
else
m_c |= bit;
}
}
/* For strcspn() we just invert the validity set */
m_0 ^= invert;
m_4 ^= invert;
m_8 ^= invert;
m_c ^= invert;
/*
* We could do remove the lsb from m_0 to terminate at the
* end of the input string.
* However prefetching the next char is benifitial and we must
* not read the byte after the \0 - as it might fault!
* So we take the 'hit' of the compare against 0.
*/
ch = *s++;
for (count = 0; ch != 0; ch = next_ch) {
next_ch = s[count];
if (__predict_true(ch < 0x80)) {
check = m_0;
if (ch >= 0x40)
check = m_4;
} else {
check = m_8;
if (ch >= 0xc0)
check = m_c;
}
if (!((check >> (ch & 0x3f)) & 1))
break;
count++;
}
return count;
}
size_t
strspn(const char *s, const char *charset)
{
return strspn_x(s, charset, 0);
}
size_t
strcspn(const char *s, const char *charset)
{
return strspn_x(s, charset, ~0ul);
}
#endif

View File

@@ -31,13 +31,13 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)strstr.3 8.1 (Berkeley) 6/4/93
.\" $NetBSD: strstr.3,v 1.10 2006/10/16 08:48:45 wiz Exp $
.\" $NetBSD: strstr.3,v 1.12 2014/09/24 18:43:21 wiz Exp $
.\"
.Dd July 3, 2004
.Dd September 24, 2014
.Dt STRSTR 3
.Os
.Sh NAME
.Nm strstr , strcasestr
.Nm strstr , strcasestr , strnstr
.Nd locate a substring in a string
.Sh LIBRARY
.Lb libc
@@ -47,6 +47,8 @@
.Fn strstr "const char *big" "const char *little"
.Ft char *
.Fn strcasestr "const char *big" "const char *little"
.Ft char *
.Fn strnstr "const char *big" "const char *little" "size_t len"
.Sh DESCRIPTION
The
.Fn strstr
@@ -61,6 +63,24 @@ The
function is similar to
.Fn strstr ,
but ignores the case of both strings.
The
.Fn strnstr
function
locates the first occurrence of the NUL-terminated string
.Fa little
in the string
.Fa big ,
where not more than
.Fa len
characters are searched.
Characters that appear after a
.Ql \e0
character are not searched.
Since the
.Fn strnstr
function is a
.Nx
specific API, it should only be used when portability is not a concern.
.Sh RETURN VALUES
If
.Fa little
@@ -107,3 +127,8 @@ The
function
conforms to
.St -isoC .
.Sh HISTORY
The
.Fn strnstr
function originated in
.Fx .