Skip to content

Commit

Permalink
Libc-1158.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
saagarjha committed Nov 12, 2019
1 parent a020d12 commit 1b5a2ca
Show file tree
Hide file tree
Showing 131 changed files with 8,889 additions and 3,423 deletions.
43 changes: 43 additions & 0 deletions .upstream_base_commits
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#freebsd = https://github.com/freebsd/freebsd.git
#openbsd = https://github.com/robertbachmann/openbsd-libc.git
gen/FreeBSD/basename.c freebsd lib/libc/gen/basename.c 26f49abeef12bd43e9671edee6df7b9905c97a47
gen/FreeBSD/basename.3 freebsd lib/libc/gen/basename.3 26f49abeef12bd43e9671edee6df7b9905c97a47
gen/FreeBSD/clock.3 freebsd lib/libc/gen/clock.3 5b882020081a138285227631c46a406c08e17bc8
gen/FreeBSD/ctermid.3 freebsd lib/libc/gen/ctermid.3 5b882020081a138285227631c46a406c08e17bc8
gen/FreeBSD/getbsize.c freebsd lib/libc/gen/getbsize.c 5b882020081a138285227631c46a406c08e17bc8
gen/FreeBSD/readpassphrase.c freebsd lib/libc/gen/readpassphrase.c 1f19a8fc755a14865a5a5b67d5fa895c4b7cf622
gen/FreeBSD/readpassphrase.3 freebsd lib/libc/gen/readpassphrase.3 e0a2d4f15ed9e93fcb62544ed65f7a98e2339c3b
gen/FreeBSD/times.3 freebsd lib/libc/gen/times.3 5b882020081a138285227631c46a406c08e17bc8
gen/FreeBSD/unvis.c freebsd contrib/libc-vis/unvis.c 9e3e4b88576d01efe1f56469cac79e116bb62c67
gen/FreeBSD/unvis.3 freebsd contrib/libc-vis/unvis.3 9e3e4b88576d01efe1f56469cac79e116bb62c67
gen/FreeBSD/usleep.3 freebsd lib/libc/gen/usleep.3 5b882020081a138285227631c46a406c08e17bc8
gen/FreeBSD/vis.c freebsd contrib/libc-vis/unvis.c 9e3e4b88576d01efe1f56469cac79e116bb62c67
gen/FreeBSD/vis.3 freebsd contrib/libc-vis/unvis.3 9e3e4b88576d01efe1f56469cac79e116bb62c67
gen/FreeBSD/vis.h freebsd contrib/libc-vis/unvis.3 9e3e4b88576d01efe1f56469cac79e116bb62c67
gen/fts.c openbsd gen/fts.c 2a32c97c979d267fa99a362943265700bfcac5fd
include/readpassphrase.h freebsd include/readpassphrase.h e0a2d4f15ed9e93fcb62544ed65f7a98e2339c3b
locale/FreeBSD/ascii.c freebsd lib/libc/locale/ascii.c 93e484e00e1e2dc498a7f4c45c0019e43b8ec5b2
locale/FreeBSD/isspecial.3 freebsd freebsd/lib/libc/locale/isspecial.3 5b882020081a138285227631c46a406c08e17bc8
locale/FreeBSD/none.c freebsd lib/libc/locale/ascii.c 93e484e00e1e2dc498a7f4c45c0019e43b8ec5b2
locale/FreeBSD/setlocale.3 freebsd lib/libc/locale/setlocale.3 2131182e401759b74104a541a3b43cf2ee6a7434
man/FreeBSD/environ.7 freebsd share/man/man7/environ.7 5b882020081a138285227631c46a406c08e17bc8
net/FreeBSD/linkaddr.c freebsd lib/libc/net/linkaddr.c 9240f72512c0357636b2e19554d6141ee21edc5f
stdio/FreeBSD/mktemp.3 freebsd lib/libc/stdio/mktemp.3 2895e1352cf3788606924d800c3a5c589520ea00
stdio/FreeBSD/mktemp.c freebsd lib/libc/stdio/mktemp.c 2895e1352cf3788606924d800c3a5c589520ea00
stdio/FreeBSD/printf.3 freebsd lib/libc/stdio/printf.3 cfc3df2b8f708ce8494d9d556e3472a5c8c21b8a
stdio/FreeBSD/wprintf.3 freebsd lib/libc/stdio/wprintf.3 5b882020081a138285227631c46a406c08e17bc8
stdlib/FreeBSD/getenv.3 freebsd lib/libc/stdlib/getenv.3 3eb0ea4663f0ae19c4983e80963a121463224508
stdlib/FreeBSD/getopt_long.3 freebsd lib/libc/stdlib/getopt_long.3 5b882020081a138285227631c46a406c08e17bc8
stdlib/FreeBSD/reallocf.c freebsd lib/libc/stdlib/reallocf.c 3dc97c4341b6c5a0163c12badc7f50628cecf4e6
stdtime/FreeBSD/strptime.c freebsd lib/libc/stdtime/strptime.c 52d53d171566c2cd975d2db86a291e516d34d9fe
stdtime/FreeBSD/strptime.3 freebsd lib/libc/stdtime/strptime.3 52d53d171566c2cd975d2db86a291e516d34d9fe
string/FreeBSD/memcmp.3 freebsd lib/libc/string/memcmp.3 3eb0ea4663f0ae19c4983e80963a121463224508
string/FreeBSD/strcpy.3 freebsd lib/libc/string/strcpy.3 cfc3df2b8f708ce8494d9d556e3472a5c8c21b8a
string/FreeBSD/strpbrk.3 freebsd lib/libc/string/strpbrk.3 5b882020081a138285227631c46a406c08e17bc8
string/FreeBSD/strspn.3 freebsd lib/libc/string/strspn.3 5b882020081a138285227631c46a406c08e17bc8
string/FreeBSD/strstr.3 freebsd lib/libc/string/strstr.3 cfc3df2b8f708ce8494d9d556e3472a5c8c21b8a
tests/netbsd_getcwd.c freebsd contrib/netbsd-tests/lib/libc/gen/t_getcwd.c 6f5b3c1fa3e9554a26cbf6401366ff8b0f0506fe
tests/netbsd_getenv_thread.c freebsd contrib/netbsd-tests/lib/libc/stdlib/t_getenv_thread.c 3f09b8d0af642c2aeb96a4d667cefb7fe3bce443
tests/netbsd_stat.c freebsd contrib/netbsd-tests/lib/libc/sys/t_stat.c 6f5b3c1fa3e9554a26cbf6401366ff8b0f0506fe
tests/netbsd_strptime.c freebsd contrib/netbsd-tests/lib/libc/time/t_strptime.c 52d53d171566c2cd975d2db86a291e516d34d9fe
tests/netbsd_vis.c freebsd contrib/netbsd-tests/lib/libc/gen/t_vis.c 52d53d171566c2cd975d2db86a291e516d34d9fe
1,626 changes: 1,515 additions & 111 deletions Libc.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions Platforms/bridgeos/Makefile.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Selectable features for Apple Watch
#

# Legacy *64 APIs
#FEATURE_LEGACY_64_APIS = 1

# Legacy crt1.o environ support
#FEATURE_LEGACY_CRT1_ENVIRON = 1

# Legacy rune APIs
#FEATURE_LEGACY_RUNE_APIS = 1

# Legacy utmp APIs
#FEATURE_LEGACY_UTMP_APIS = 1

# OSThermalNotification APIs
FEATURE_THERM_NOTIFICATION_APIS = 1

# Move localtime to /var/db/timezone
FEATURE_MOVE_LOCALTIME = 0

# Use TZDIR symlink in /var/db
FEATURE_TZDIR_SYMLINK = 0

# No pre-1050 variants (should match sys/cdefs.h)
FEATURE_ONLY_1050_VARIANTS = 1

# No legacy variants (should match sys/cdefs.h)
FEATURE_ONLY_UNIX_CONFORMANCE = 1

# Only 64-bit ino_t (should match sys/cdefs.h)
FEATURE_ONLY_64_BIT_INO_T = 1

# Patch 3333969
#FEATURE_PATCH_3333969 = 1

# Patch 3417676
#FEATURE_PATCH_3417676 = 1

# plockstat dtrace support
#FEATURE_PLOCKSTAT = 1

# Timezone change notification
FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1

# Smaller stdio buffers
FEATURE_SMALL_STDIOBUF = 1

# Disable registration of specific signals (<rdar://problem/21952708>)
FEATURE_SIGNAL_RESTRICTION = 1
52 changes: 52 additions & 0 deletions darwin/compatibility_hacks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/

#if !TARGET_OS_IPHONE

#define WEAK_SYMBOL_LD_CMD(sym, version) \
__asm__(".section __TEXT,__const\n\t" \
".globl $ld$weak$os" #version "$_" #sym "\n\t" \
"$ld$weak$os" #version "$_" #sym ":\n\t" \
" .byte 0\n\t" \
".previous")

#define ADDED_IN_10_12(sym) WEAK_SYMBOL_LD_CMD(sym, 10.11)

ADDED_IN_10_12(getentropy);

ADDED_IN_10_12(clock_getres);
ADDED_IN_10_12(clock_gettime);
ADDED_IN_10_12(clock_settime);

ADDED_IN_10_12(basename_r);
ADDED_IN_10_12(dirname_r);

ADDED_IN_10_12(mkostemp);
ADDED_IN_10_12(mkostemps);

#endif /* TARGET_OS_IPHONE */
2 changes: 1 addition & 1 deletion db/btree/FreeBSD/bt_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ __bt_first(BTREE *t, const DBT *key, EPG *erval, int *exactp)
* page) and return it.
*/
if ((ep = __bt_search(t, key, exactp)) == NULL)
return (0);
return (RET_SPECIAL);
if (*exactp) {
if (F_ISSET(t, B_NODUPS)) {
*erval = *ep;
Expand Down
115 changes: 44 additions & 71 deletions gen/FreeBSD/arc4random.3
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.\" $OpenBSD: arc4random.3,v 1.2 1997/04/27 22:40:25 angelos Exp $
.\" $OpenBSD: arc4random.3,v 1.34 2014/07/19 16:11:16 naddy Exp $
.\"
.\" Copyright 1997 Niels Provos <[email protected]>
.\" All rights reserved.
.\"
Expand Down Expand Up @@ -28,100 +29,72 @@
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" Manual page, using -mandoc macros
.\" $FreeBSD: src/lib/libc/gen/arc4random.3,v 1.18 2008/07/22 11:33:49 ache Exp $
.\"
.Dd April 15, 1997
.Dd July 30, 2015
.Dt ARC4RANDOM 3
.Os
.Sh NAME
.Nm arc4random ,
.Nm arc4random_buf ,
.Nm arc4random_uniform ,
.Nm arc4random_stir ,
.Nm arc4random_addrandom
.Nd arc4 random number generator
.Sh LIBRARY
.Lb libc
.Nm arc4random_uniform
.Nd random number generator
.Sh SYNOPSIS
.In stdlib.h
.Ft u_int32_t
.Ft uint32_t
.Fn arc4random "void"
.Ft void
.Fn arc4random_buf "void *buf" "size_t nbytes"
.Ft u_int32_t
.Fn arc4random_uniform "u_int32_t upper_bound"
.Ft void
.Fn arc4random_stir "void"
.Ft void
.Fn arc4random_addrandom "unsigned char *dat" "int datlen"
.Ft uint32_t
.Fn arc4random_uniform "uint32_t upper_bound"
.Sh DESCRIPTION
The
.Fn arc4random
function uses the key stream generator employed by the
arc4 cipher, which uses 8*8 8 bit S-Boxes.
The S-Boxes
can be in about
.if t 2\u\s71700\s10\d
.if n (2**1700)
states.
The
.Fn arc4random
function returns pseudo-random numbers in the range of 0 to
.if t 2\u\s731\s10\d\(mi1,
.if n (2**32)\(mi1,
and therefore has twice the range of
.Xr rand 3
.Pp
These functions use a cryptographic pseudo-random number generator to generate
high quality random bytes very quickly. One data pool is used for all
consumers in a process, so that consumption under program flow can act as
additional stirring. The subsystem is re-seeded from the kernel random number
subsystem on a regular basis, and also upon
.Xr fork 2 .
.Pp
This family of functions provides higher quality random data than those
described in
.Xr rand 3 ,
.Xr random 3 ,
and
.Xr random 3 .
.Xr rand48 3 .
They can be called in almost environments, including
.Xr chroot 2
and their use is encouraged over all other standard library functions for
random numbers.
.Pp
.Fn arc4random
returns a single 32-bit value.
.Pp
.Fn arc4random_buf
function fills the region
fills the region
.Fa buf
of length
.Fa nbytes
with ARC4-derived random data.
with random data.
.Pp
.Fn arc4random_uniform
will return a uniformly distributed random number less than
will return a single 32-bit value, uniformly distributed but less than
.Fa upper_bound .
.Fn arc4random_uniform
is recommended over constructions like
This is recommended over constructions like
.Dq Li arc4random() % upper_bound
as it avoids "modulo bias" when the upper bound is not a power of two.
.Pp
The
.Fn arc4random_stir
function reads data from
.Pa /dev/urandom
and uses it to permute the S-Boxes via
.Fn arc4random_addrandom .
.Pp
There is no need to call
.Fn arc4random_stir
before using
.Fn arc4random
functions family, since
they automatically initialize themselves.
.Sh EXAMPLES
The following produces a drop-in replacement for the traditional
.Fn rand
and
.Fn random
functions using
.Fn arc4random :
.Pp
.Dl "#define foo4random() (arc4random() % ((unsigned)RAND_MAX + 1))"
In the worst case, this function may require multiple iterations
to ensure uniformity.
.Sh RETURN VALUES
These functions are always successful, and no return value is
reserved to indicate an error.
.Sh SEE ALSO
.Xr rand 3 ,
.Xr rand48 3 ,
.Xr random 3 ,
.Xr srandomdev 3
.Xr random 4
.Sh HISTORY
.Pa RC4
has been designed by RSA Data Security, Inc.
It was posted anonymously
to the USENET and was confirmed to be equivalent by several sources who
had access to the original cipher.
Since
.Pa RC4
used to be a trade secret, the cipher is now referred to as
.Pa ARC4 .
The original version of this random number generator used the RC4 (also known
as ARC4) algorithm. In OS X 10.12 it was replaced with the NIST-approved AES
cipher, and it may be replaced again in the future as cryptographic techniques
advance. A good mnemonic is
.Dq A Replacement Call for Random .
Loading

0 comments on commit 1b5a2ca

Please sign in to comment.