]> git.saurik.com Git - apple/libc.git/commitdiff
Libc-1158.1.2.tar.gz macos-1012 os-x-1012 v1158.1.2
authorApple <opensource@apple.com>
Thu, 22 Sep 2016 17:39:59 +0000 (17:39 +0000)
committerApple <opensource@apple.com>
Thu, 22 Sep 2016 17:39:59 +0000 (17:39 +0000)
133 files changed:
.upstream_base_commits [new file with mode: 0644]
Libc.xcodeproj/project.pbxproj
Platforms/bridgeos/Makefile.inc [new file with mode: 0644]
darwin/compatibility_hacks.c [new file with mode: 0644]
db/btree/FreeBSD/bt_seq.c
gen/FreeBSD/arc4random.3
gen/FreeBSD/arc4random.c
gen/FreeBSD/basename.3
gen/FreeBSD/basename.c
gen/FreeBSD/clock.3
gen/FreeBSD/ctermid.3
gen/FreeBSD/dirname.3
gen/FreeBSD/dirname.c
gen/FreeBSD/err.c
gen/FreeBSD/getbsize.3
gen/FreeBSD/getbsize.c
gen/FreeBSD/getlogin.c
gen/FreeBSD/raise.c [deleted file]
gen/FreeBSD/readpassphrase.3
gen/FreeBSD/readpassphrase.c
gen/FreeBSD/sysctl.c
gen/FreeBSD/times.3
gen/FreeBSD/unvis.3
gen/FreeBSD/unvis.c
gen/FreeBSD/usleep.3
gen/FreeBSD/vis.3
gen/FreeBSD/vis.c
gen/assumes.h [deleted file]
gen/clock_gettime.3 [new file with mode: 0644]
gen/clock_gettime.c [new file with mode: 0644]
gen/fts.c
gen/raise.c [new file with mode: 0644]
gen/tcsetattr.3
gmon/gmon.c
include/err.h
include/fts.h
include/libgen.h
include/limits.h
include/readpassphrase.h
include/signal.h
include/stdio.h
include/stdlib.h
include/string.h
include/sys/cdefs.h
include/time.h
include/unistd.h
include/vis.h
include/xlocale/_stdio.h
locale/FreeBSD/ascii.c
locale/FreeBSD/collate.c
locale/FreeBSD/isspecial.3
locale/FreeBSD/ldpart.c
locale/FreeBSD/none.c
locale/FreeBSD/setlocale.3
locale/FreeBSD/setlocale.c
locale/FreeBSD/setlocale.h
locale/FreeBSD/setrunelocale.c
locale/rune.3
locale/xlocale.c
locale/xlocale_private.h
man/FreeBSD/environ.7 [new file with mode: 0644]
man/environ.7 [deleted file]
man/manpages.lst
net/FreeBSD/linkaddr.c
net/inet_ntop.c
net/rcmdsh.3 [deleted file]
os/assumes.c
os/assumes.h
os/debug_private.c
secure/strlcat_chk.c
stdio/FreeBSD/findfp.c
stdio/FreeBSD/getdelim.c
stdio/FreeBSD/mktemp.3
stdio/FreeBSD/mktemp.c
stdio/FreeBSD/tmpfile.c
stdio/FreeBSD/vfprintf.c
stdio/FreeBSD/vfwprintf.c
stdio/FreeBSD/wprintf.3
stdlib/FreeBSD/getenv.3
stdlib/FreeBSD/getenv.c
stdlib/FreeBSD/getopt_long.3
stdlib/FreeBSD/putenv.c
stdlib/FreeBSD/setenv.c
stdtime/FreeBSD/strptime.3
stdtime/FreeBSD/strptime.c
stdtime/getdate.c
string/FreeBSD/memcmp.3
string/FreeBSD/strcspn.3 [deleted file]
string/FreeBSD/strpbrk.3
string/FreeBSD/strspn.3
string/FreeBSD/strstr.3
string/alias.list [deleted file]
sys/_libc_fork_child.c
sys/_libc_init.c
tests/Libc.plist [deleted file]
tests/Makefile [new file with mode: 0644]
tests/arc4random.c [new file with mode: 0644]
tests/clock.c [new file with mode: 0644]
tests/fts_find.c [new file with mode: 0644]
tests/getdate.c [new file with mode: 0644]
tests/getenv.c [new file with mode: 0644]
tests/install.sh [deleted file]
tests/libctest.xcconfig [deleted file]
tests/libctest.xcodeproj/project.pbxproj [deleted file]
tests/locale.c [new file with mode: 0644]
tests/mktemp.c [new file with mode: 0644]
tests/net.c [new file with mode: 0644]
tests/netbsd_getcwd.c [new file with mode: 0644]
tests/netbsd_getenv_thread.c [new file with mode: 0644]
tests/netbsd_stat.c [new file with mode: 0644]
tests/netbsd_strptime.c [new file with mode: 0644]
tests/netbsd_vis.c [new file with mode: 0644]
tests/nxheap.c
tests/psort.c
tests/readpassphrase.c [new file with mode: 0644]
tests/runtests [deleted file]
tests/stdio.c [new file with mode: 0644]
tests/stdtime.c [new file with mode: 0644]
tests/strlcat.c
tests/strptime.c [new file with mode: 0644]
tests/test_list.txt [deleted file]
tests/wchar.c [new file with mode: 0644]
util/mkpath_np.c
xcodescripts/alias.list [new file with mode: 0644]
xcodescripts/build_linklists.sh
xcodescripts/eos.xcconfig
xcodescripts/force_libc_to_build.sh
xcodescripts/generate_features.pl
xcodescripts/headers.sh
xcodescripts/libc.xcconfig
xcodescripts/libc_static.xcconfig [new file with mode: 0644]
xcodescripts/skip_installhdrs.sh [new file with mode: 0644]
xcodescripts/variants.xcconfig

diff --git a/.upstream_base_commits b/.upstream_base_commits
new file mode 100644 (file)
index 0000000..8e1a061
--- /dev/null
@@ -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
index 09565fa02c80ccf22c5b86c6795ec92f89a7be2f..a7b58ed9cc3e1e152b07152491b4b0a1ffc76a69 100644 (file)
@@ -13,7 +13,7 @@
                        buildPhases = (
                        );
                        dependencies = (
-                               925E7FFB19E8946700AC7889 /* PBXTargetDependency */,
+                               928F25D51BEAD2AE007B13C7 /* PBXTargetDependency */,
                        );
                        name = Libc_tests;
                        productName = Libc_tests;
 /* End PBXAggregateTarget section */
 
 /* Begin PBXBuildFile section */
+               147CDFD91B7C232100831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
+               147CDFDA1B7C232900831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
+               147CDFDB1B7C232A00831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
+               147CDFDC1B7C232F00831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
+               147CDFDD1B7C233000831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
+               147CDFDE1B7C233100831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
+               147CDFDF1B7C233100831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
+               147CDFE01B7C233200831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
+               147CDFE11B7C233300831EC6 /* clock_gettime.c in Sources */ = {isa = PBXBuildFile; fileRef = 147CDFD01B7C14FA00831EC6 /* clock_gettime.c */; };
                2DF67CDE184F9CBE00B83A3D /* debug_private.c in Sources */ = {isa = PBXBuildFile; fileRef = 2DF67CDD184F9CBE00B83A3D /* debug_private.c */; };
                2DF67CDF184F9CBE00B83A3D /* debug_private.c in Sources */ = {isa = PBXBuildFile; fileRef = 2DF67CDD184F9CBE00B83A3D /* debug_private.c */; };
                2DF67CE0184F9CBE00B83A3D /* debug_private.c in Sources */ = {isa = PBXBuildFile; fileRef = 2DF67CDD184F9CBE00B83A3D /* debug_private.c */; };
@@ -33,6 +42,7 @@
                3F169A3E1643B7BA0029E851 /* memccpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F169A3C1643B7BA0029E851 /* memccpy_chk.c */; };
                3F18DE21162A732C008B15AC /* memset_s.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F18DE20162A732C008B15AC /* memset_s.c */; };
                3F267F38163FC8880089A0A6 /* rb.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F267F36163FC8880089A0A6 /* rb.c */; };
+               3F34A15D1C4AA80B000D4A82 /* raise.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53761138D9E990028D27C /* raise.c */; };
                3F51210416C317FD00AFB431 /* chk_fail.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B1E138D9E990028D27C /* chk_fail.c */; };
                3F51210516C317FD00AFB431 /* memccpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F169A3C1643B7BA0029E851 /* memccpy_chk.c */; };
                3F51210616C317FD00AFB431 /* memcpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B20138D9E990028D27C /* memcpy_chk.c */; };
                63D4061113DDF4340094DD56 /* strncat.c in Sources */ = {isa = PBXBuildFile; fileRef = 63D4060F13DDF4340094DD56 /* strncat.c */; };
                63D4061313DDF6A30094DD56 /* strlcat.c in Sources */ = {isa = PBXBuildFile; fileRef = 63D4061213DDF6A20094DD56 /* strlcat.c */; };
                63D4061413DDF6A30094DD56 /* strlcat.c in Sources */ = {isa = PBXBuildFile; fileRef = 63D4061213DDF6A20094DD56 /* strlcat.c */; };
+               92ABC7E91D375FC2000DF880 /* compatibility_hacks.c in Sources */ = {isa = PBXBuildFile; fileRef = 92ABC7E81D375FC2000DF880 /* compatibility_hacks.c */; };
                B10BC41C14338AEB005E4366 /* regcomp.c in Sources */ = {isa = PBXBuildFile; fileRef = B122F2B11432B95B00AF95D0 /* regcomp.c */; settings = {COMPILER_FLAGS = "-DHAVE_CONFIG_H -I$(SRCROOT)/regex/TRE -I$(SRCROOT)/regex/FreeBSD"; }; };
                B122F2C71432B95B00AF95D0 /* regcomp.c in Sources */ = {isa = PBXBuildFile; fileRef = B122F2B11432B95B00AF95D0 /* regcomp.c */; };
                B122F2C91432B95B00AF95D0 /* regexec.c in Sources */ = {isa = PBXBuildFile; fileRef = B122F2B21432B95B00AF95D0 /* regexec.c */; };
                B19C64611450F90200032373 /* sync_volume_np.c in Sources */ = {isa = PBXBuildFile; fileRef = B19C645B1450F90200032373 /* sync_volume_np.c */; };
                B19C64621450F90200032373 /* sync_volume_np.c in Sources */ = {isa = PBXBuildFile; fileRef = B19C645B1450F90200032373 /* sync_volume_np.c */; };
                B19C64631450F90200032373 /* sync_volume_np.c in Sources */ = {isa = PBXBuildFile; fileRef = B19C645B1450F90200032373 /* sync_volume_np.c */; };
+               C0E343921C582ECB00E749C2 /* mcount.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B53819138D9E990028D27C /* mcount.s */; };
+               C0E343931C582ECB00E749C2 /* strcpy.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B5383D138D9E990028D27C /* strcpy.s */; };
+               C0E343941C582ECB00E749C2 /* strlcat.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B5383E138D9E990028D27C /* strlcat.s */; };
+               C0E343951C582ECB00E749C2 /* strlcpy.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B5383F138D9E990028D27C /* strlcpy.s */; };
+               C0E343961C582ECB00E749C2 /* strlen.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B53840138D9E990028D27C /* strlen.s */; };
+               C0E343971C582ECB00E749C2 /* strncpy.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B53842138D9E990028D27C /* strncpy.s */; };
+               C0E343981C582ECB00E749C2 /* strlen.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B535CF138D9E980028D27C /* strlen.s */; };
+               C0E343991C582ECB00E749C2 /* strnlen.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B535D2138D9E980028D27C /* strnlen.s */; };
+               C0E3439A1C582ECB00E749C2 /* strstr.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B535D3138D9E980028D27C /* strstr.s */; };
+               C0E3439B1C582ECB00E749C2 /* mcount.s in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DF9138D9E9A0028D27C /* mcount.s */; };
+               C0E3439C1C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E3439D1C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E3439E1C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E3439F1C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E343A01C582ECB00E749C2 /* init_cpu_capabilities.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B535B6138D9E980028D27C /* init_cpu_capabilities.c */; };
+               C0E343A11C582ECB00E749C2 /* creat.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B535F8138D9E980028D27C /* creat.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_CREAT"; }; };
+               C0E343A21C582ECB00E749C2 /* gethostid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B535FC138D9E980028D27C /* gethostid.c */; };
+               C0E343A31C582ECB00E749C2 /* getwd.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B535FE138D9E980028D27C /* getwd.c */; };
+               C0E343A41C582ECB00E749C2 /* killpg.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53601138D9E980028D27C /* killpg.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_KILLPG"; }; };
+               C0E343A51C582ECB00E749C2 /* sethostid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53603138D9E980028D27C /* sethostid.c */; };
+               C0E343A61C582ECB00E749C2 /* setpgrp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53604138D9E980028D27C /* setpgrp.c */; };
+               C0E343A71C582ECB00E749C2 /* setrgid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53606138D9E980028D27C /* setrgid.c */; };
+               C0E343A81C582ECB00E749C2 /* setruid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53608138D9E980028D27C /* setruid.c */; };
+               C0E343A91C582ECB00E749C2 /* setregid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5360A138D9E980028D27C /* setregid.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_SETREGID"; }; };
+               C0E343AA1C582ECB00E749C2 /* setreuid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5360B138D9E980028D27C /* setreuid.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_SETREUID"; }; };
+               C0E343AB1C582ECB00E749C2 /* sigaltstk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5360C138D9E980028D27C /* sigaltstk.c */; };
+               C0E343AC1C582ECB00E749C2 /* sigcompat.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5360E138D9E980028D27C /* sigcompat.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_SIGPAUSE"; }; };
+               C0E343AD1C582ECB00E749C2 /* kvm.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53616138D9E980028D27C /* kvm.c */; };
+               C0E343AE1C582ECB00E749C2 /* forceLibcToBuild.c in Sources */ = {isa = PBXBuildFile; fileRef = C9D9432A138DB72000FB7ACC /* forceLibcToBuild.c */; };
+               C0E343AF1C582ECB00E749C2 /* bt_close.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53620138D9E980028D27C /* bt_close.c */; };
+               C0E343B01C582ECB00E749C2 /* bt_conv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53621138D9E980028D27C /* bt_conv.c */; };
+               C0E343B11C582ECB00E749C2 /* bt_debug.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53622138D9E980028D27C /* bt_debug.c */; };
+               C0E343B21C582ECB00E749C2 /* bt_delete.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53623138D9E980028D27C /* bt_delete.c */; };
+               C0E343B31C582ECB00E749C2 /* bt_get.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53624138D9E980028D27C /* bt_get.c */; };
+               C0E343B41C582ECB00E749C2 /* bt_open.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53625138D9E980028D27C /* bt_open.c */; };
+               C0E343B51C582ECB00E749C2 /* bt_overflow.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53626138D9E980028D27C /* bt_overflow.c */; };
+               C0E343B61C582ECB00E749C2 /* bt_page.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53628138D9E980028D27C /* bt_page.c */; };
+               C0E343B71C582ECB00E749C2 /* bt_put.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53629138D9E980028D27C /* bt_put.c */; };
+               C0E343B81C582ECB00E749C2 /* bt_search.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5362A138D9E980028D27C /* bt_search.c */; };
+               C0E343B91C582ECB00E749C2 /* bt_seq.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5362B138D9E980028D27C /* bt_seq.c */; };
+               C0E343BA1C582ECB00E749C2 /* bt_split.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5362D138D9E980028D27C /* bt_split.c */; };
+               C0E343BB1C582ECB00E749C2 /* bt_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5362F138D9E980028D27C /* bt_utils.c */; };
+               C0E343BC1C582ECB00E749C2 /* db.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53636138D9E980028D27C /* db.c */; };
+               C0E343BD1C582ECB00E749C2 /* hash.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5363B138D9E980028D27C /* hash.c */; };
+               C0E343BE1C582ECB00E749C2 /* hash_bigkey.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5363F138D9E980028D27C /* hash_bigkey.c */; };
+               C0E343BF1C582ECB00E749C2 /* hash_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53641138D9E980028D27C /* hash_buf.c */; };
+               C0E343C01C582ECB00E749C2 /* hash_func.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53643138D9E980028D27C /* hash_func.c */; };
+               C0E343C11C582ECB00E749C2 /* hash_log2.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53645138D9E980028D27C /* hash_log2.c */; };
+               C0E343C21C582ECB00E749C2 /* hash_page.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53647138D9E980028D27C /* hash_page.c */; };
+               C0E343C31C582ECB00E749C2 /* ndbm.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53649138D9E980028D27C /* ndbm.c */; };
+               C0E343C41C582ECB00E749C2 /* mpool.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5365A138D9E980028D27C /* mpool.c */; };
+               C0E343C51C582ECB00E749C2 /* rec_close.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53661138D9E980028D27C /* rec_close.c */; };
+               C0E343C61C582ECB00E749C2 /* rec_delete.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53662138D9E980028D27C /* rec_delete.c */; };
+               C0E343C71C582ECB00E749C2 /* rec_get.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53663138D9E980028D27C /* rec_get.c */; };
+               C0E343C81C582ECB00E749C2 /* rec_open.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53664138D9E980028D27C /* rec_open.c */; };
+               C0E343C91C582ECB00E749C2 /* rec_put.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53665138D9E980028D27C /* rec_put.c */; };
+               C0E343CA1C582ECB00E749C2 /* rec_search.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53666138D9E980028D27C /* rec_search.c */; };
+               C0E343CB1C582ECB00E749C2 /* rec_seq.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53667138D9E980028D27C /* rec_seq.c */; };
+               C0E343CC1C582ECB00E749C2 /* rec_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53668138D9E980028D27C /* rec_utils.c */; };
+               C0E343CD1C582ECB00E749C2 /* brk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5366E138D9E980028D27C /* brk.c */; };
+               C0E343CE1C582ECB00E749C2 /* bsd_signal.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53670138D9E980028D27C /* bsd_signal.c */; };
+               C0E343CF1C582ECB00E749C2 /* lchflags.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53672138D9E980028D27C /* lchflags.c */; };
+               C0E343D01C582ECB00E749C2 /* lchmod.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53674138D9E980028D27C /* lchmod.c */; };
+               C0E343D11C582ECB00E749C2 /* lutimes.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53676138D9E980028D27C /* lutimes.c */; };
+               C0E343D21C582ECB00E749C2 /* statvfs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53679138D9E980028D27C /* statvfs.c */; };
+               C0E343D31C582ECB00E749C2 /* tcgetsid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5367B138D9E980028D27C /* tcgetsid.c */; };
+               C0E343D41C582ECB00E749C2 /* _ldbl_util.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5368E138D9E980028D27C /* _ldbl_util.c */; };
+               C0E343D51C582ECB00E749C2 /* _hdtoa.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53691138D9E980028D27C /* _hdtoa.c */; };
+               C0E343D61C582ECB00E749C2 /* _ldtoa.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53693138D9E980028D27C /* _ldtoa.c */; };
+               C0E343D71C582ECB00E749C2 /* gdtoa-dmisc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53695138D9E980028D27C /* gdtoa-dmisc.c */; };
+               C0E343D81C582ECB00E749C2 /* gdtoa-dtoa.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53696138D9E980028D27C /* gdtoa-dtoa.c */; };
+               C0E343D91C582ECB00E749C2 /* gdtoa-gdtoa.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53697138D9E980028D27C /* gdtoa-gdtoa.c */; };
+               C0E343DA1C582ECB00E749C2 /* gdtoa-gethex.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53698138D9E980028D27C /* gdtoa-gethex.c */; };
+               C0E343DB1C582ECB00E749C2 /* gdtoa-gmisc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5369A138D9E980028D27C /* gdtoa-gmisc.c */; };
+               C0E343DC1C582ECB00E749C2 /* gdtoa-hd_init.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5369B138D9E980028D27C /* gdtoa-hd_init.c */; };
+               C0E343DD1C582ECB00E749C2 /* gdtoa-hexnan.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5369C138D9E980028D27C /* gdtoa-hexnan.c */; };
+               C0E343DE1C582ECB00E749C2 /* gdtoa-misc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5369E138D9E980028D27C /* gdtoa-misc.c */; };
+               C0E343DF1C582ECB00E749C2 /* gdtoa-smisc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536A0138D9E980028D27C /* gdtoa-smisc.c */; };
+               C0E343E01C582ECB00E749C2 /* gdtoa-strtod.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536A1138D9E980028D27C /* gdtoa-strtod.c */; };
+               C0E343E11C582ECB00E749C2 /* gdtoa-strtodg.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536A3138D9E980028D27C /* gdtoa-strtodg.c */; };
+               C0E343E21C582ECB00E749C2 /* gdtoa-strtof.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536A5138D9E980028D27C /* gdtoa-strtof.c */; };
+               C0E343E31C582ECB00E749C2 /* gdtoa-strtoIg.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536A7138D9E980028D27C /* gdtoa-strtoIg.c */; };
+               C0E343E41C582ECB00E749C2 /* gdtoa-strtopdd.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536A8138D9E980028D27C /* gdtoa-strtopdd.c */; };
+               C0E343E51C582ECB00E749C2 /* gdtoa-strtopx.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536AA138D9E980028D27C /* gdtoa-strtopx.c */; };
+               C0E343E61C582ECB00E749C2 /* gdtoa-strtord.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536AC138D9E980028D27C /* gdtoa-strtord.c */; };
+               C0E343E71C582ECB00E749C2 /* gdtoa-sum.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536AE138D9E980028D27C /* gdtoa-sum.c */; };
+               C0E343E81C582ECB00E749C2 /* gdtoa-ulp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536AF138D9E980028D27C /* gdtoa-ulp.c */; };
+               C0E343E91C582ECB00E749C2 /* glue.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536B5138D9E980028D27C /* glue.c */; };
+               C0E343EA1C582ECB00E749C2 /* machdep_ldisd.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536B6138D9E980028D27C /* machdep_ldisd.c */; };
+               C0E343EB1C582ECB00E749C2 /* machdep_ldisdd.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536B8138D9E980028D27C /* machdep_ldisdd.c */; };
+               C0E343EC1C582ECB00E749C2 /* machdep_ldisQ.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536BA138D9E980028D27C /* machdep_ldisQ.c */; };
+               C0E343ED1C582ECB00E749C2 /* machdep_ldisx.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536BB138D9E980028D27C /* machdep_ldisx.c */; };
+               C0E343EE1C582ECB00E749C2 /* authentication.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536D5138D9E990028D27C /* authentication.c */; };
+               C0E343EF1C582ECB00E749C2 /* backtrace.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536D7138D9E990028D27C /* backtrace.c */; };
+               C0E343F01C582ECB00E749C2 /* confstr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536DB138D9E990028D27C /* confstr.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_CONFSTR"; }; };
+               C0E343F11C582ECB00E749C2 /* crypt.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536DD138D9E990028D27C /* crypt.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_ENCRYPT -DLIBC_ALIAS_SETKEY"; }; };
+               C0E343F21C582ECB00E749C2 /* devname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536DF138D9E990028D27C /* devname.c */; };
+               C0E343F31C582ECB00E749C2 /* disklabel.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536E1138D9E990028D27C /* disklabel.c */; };
+               C0E343F41C582ECB00E749C2 /* errlst.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536E2138D9E990028D27C /* errlst.c */; };
+               C0E343F51C582ECB00E749C2 /* filesec.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536E4138D9E990028D27C /* filesec.c */; };
+               C0E343F61C582ECB00E749C2 /* _rand48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536E6138D9E990028D27C /* _rand48.c */; };
+               C0E343F71C582ECB00E749C2 /* alarm.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536EA138D9E990028D27C /* alarm.c */; };
+               C0E343F81C582ECB00E749C2 /* arc4random.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536EC138D9E990028D27C /* arc4random.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E343F91C582ECB00E749C2 /* assert.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536EE138D9E990028D27C /* assert.c */; };
+               C0E343FA1C582ECB00E749C2 /* basename.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536F2138D9E990028D27C /* basename.c */; };
+               C0E343FB1C582ECB00E749C2 /* clock.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536F5138D9E990028D27C /* clock.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_CLOCK"; }; };
+               C0E343FC1C582ECB00E749C2 /* closedir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536F6138D9E990028D27C /* closedir.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_CLOSEDIR -include gen/__dirent.h"; }; };
+               C0E343FD1C582ECB00E749C2 /* ctermid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536FA138D9E990028D27C /* ctermid.c */; };
+               C0E343FE1C582ECB00E749C2 /* daemon.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B536FD138D9E990028D27C /* daemon.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E343FF1C582ECB00E749C2 /* dirname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53701138D9E990028D27C /* dirname.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E344001C582ECB00E749C2 /* drand48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53703138D9E990028D27C /* drand48.c */; };
+               C0E344011C582ECB00E749C2 /* erand48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53705138D9E990028D27C /* erand48.c */; };
+               C0E344021C582ECB00E749C2 /* err.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53709138D9E990028D27C /* err.c */; };
+               C0E344031C582ECB00E749C2 /* exec.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5370D138D9E990028D27C /* exec.c */; };
+               C0E344041C582ECB00E749C2 /* fmtcheck.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53710138D9E990028D27C /* fmtcheck.c */; };
+               C0E344051C582ECB00E749C2 /* fmtmsg.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53712138D9E990028D27C /* fmtmsg.c */; };
+               C0E344061C582ECB00E749C2 /* fnmatch.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53716138D9E990028D27C /* fnmatch.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_FNMATCH"; }; };
+               C0E344071C582ECB00E749C2 /* ftok.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5371A138D9E990028D27C /* ftok.c */; };
+               C0E344081C582ECB00E749C2 /* getbsize.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5371C138D9E990028D27C /* getbsize.c */; };
+               C0E344091C582ECB00E749C2 /* getcap.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5371E138D9E990028D27C /* getcap.c */; };
+               C0E3440A1C582ECB00E749C2 /* getcwd.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53722138D9E990028D27C /* getcwd.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E3440B1C582ECB00E749C2 /* gethostname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53726138D9E990028D27C /* gethostname.c */; };
+               C0E3440C1C582ECB00E749C2 /* getlogin.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53728138D9E990028D27C /* getlogin.c */; };
+               C0E3440D1C582ECB00E749C2 /* getmntinfo.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5372C138D9E990028D27C /* getmntinfo.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E3440E1C582ECB00E749C2 /* getpagesize.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5372F138D9E990028D27C /* getpagesize.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E3440F1C582ECB00E749C2 /* getpeereid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53732138D9E990028D27C /* getpeereid.c */; };
+               C0E344101C582ECB00E749C2 /* getprogname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53735138D9E990028D27C /* getprogname.c */; };
+               C0E344111C582ECB00E749C2 /* glob.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53739138D9E990028D27C /* glob.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_GLOB"; }; };
+               C0E344121C582ECB00E749C2 /* isatty.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5373B138D9E990028D27C /* isatty.c */; };
+               C0E344131C582ECB00E749C2 /* jrand48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5373D138D9E990028D27C /* jrand48.c */; };
+               C0E344141C582ECB00E749C2 /* lcong48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5373F138D9E990028D27C /* lcong48.c */; };
+               C0E344151C582ECB00E749C2 /* lockf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53743138D9E990028D27C /* lockf.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_LOCKF"; }; };
+               C0E344161C582ECB00E749C2 /* lrand48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53745138D9E990028D27C /* lrand48.c */; };
+               C0E344171C582ECB00E749C2 /* mrand48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53749138D9E990028D27C /* mrand48.c */; };
+               C0E344181C582ECB00E749C2 /* nice.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5374C138D9E990028D27C /* nice.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_NICE"; }; };
+               C0E344191C582ECB00E749C2 /* nrand48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5374E138D9E990028D27C /* nrand48.c */; };
+               C0E3441A1C582ECB00E749C2 /* opendir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53750138D9E990028D27C /* opendir.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS___OPENDIR2 -DLIBC_ALIAS_OPENDIR -include gen/__dirent.h"; }; };
+               C0E3441B1C582ECB00E749C2 /* pause.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53753138D9E990028D27C /* pause.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_PAUSE"; }; };
+               C0E3441C1C582ECB00E749C2 /* popen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53757138D9E990028D27C /* popen.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_POPEN"; }; };
+               C0E3441D1C582ECB00E749C2 /* psignal.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5375F138D9E990028D27C /* psignal.c */; };
+               C0E3441E1C582ECB00E749C2 /* raise.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53761138D9E990028D27C /* raise.c */; };
+               C0E3441F1C582ECB00E749C2 /* readdir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53766138D9E990028D27C /* readdir.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -include gen/__dirent.h"; }; };
+               C0E344201C582ECB00E749C2 /* readpassphrase.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53769138D9E990028D27C /* readpassphrase.c */; };
+               C0E344211C582ECB00E749C2 /* rewinddir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5376B138D9E990028D27C /* rewinddir.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_REWINDDIR -include gen/__dirent.h"; }; };
+               C0E344221C582ECB00E749C2 /* scandir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5376E138D9E990028D27C /* scandir.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -include gen/__dirent.h"; }; };
+               C0E344231C582ECB00E749C2 /* seed48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53771138D9E990028D27C /* seed48.c */; };
+               C0E344241C582ECB00E749C2 /* seekdir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53773138D9E990028D27C /* seekdir.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_SEEKDIR -include gen/__dirent.h"; }; };
+               C0E344251C582ECB00E749C2 /* sethostname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53774138D9E990028D27C /* sethostname.c */; };
+               C0E344261C582ECB00E749C2 /* setmode.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53776138D9E990028D27C /* setmode.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_SETMODE"; }; };
+               C0E344271C582ECB00E749C2 /* setprogname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53778138D9E990028D27C /* setprogname.c */; };
+               C0E344281C582ECB00E749C2 /* siginterrupt.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5377C138D9E990028D27C /* siginterrupt.c */; };
+               C0E344291C582ECB00E749C2 /* siglist.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5377D138D9E990028D27C /* siglist.c */; };
+               C0E3442A1C582ECB00E749C2 /* signal.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53781138D9E990028D27C /* signal.c */; };
+               C0E3442B1C582ECB00E749C2 /* sleep.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53787138D9E990028D27C /* sleep.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_SLEEP"; }; };
+               C0E3442C1C582ECB00E749C2 /* srand48.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53789138D9E990028D27C /* srand48.c */; };
+               C0E3442D1C582ECB00E749C2 /* stringlist.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5378C138D9E990028D27C /* stringlist.c */; };
+               C0E3442E1C582ECB00E749C2 /* sysconf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5378E138D9E990028D27C /* sysconf.c */; };
+               C0E3442F1C582ECB00E749C2 /* sysctl.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53792138D9E990028D27C /* sysctl.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E344301C582ECB00E749C2 /* sysctlbyname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53794138D9E990028D27C /* sysctlbyname.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E344311C582ECB00E749C2 /* sysctlnametomib.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53795138D9E990028D27C /* sysctlnametomib.c */; };
+               C0E344321C582ECB00E749C2 /* telldir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53796138D9E990028D27C /* telldir.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS__SEEKDIR -DLIBC_ALIAS_TELLDIR -include gen/__dirent.h"; }; };
+               C0E344331C582ECB00E749C2 /* termios.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5379A138D9E990028D27C /* termios.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_TCDRAIN"; }; };
+               C0E344341C582ECB00E749C2 /* time.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5379E138D9E990028D27C /* time.c */; };
+               C0E344351C582ECB00E749C2 /* times.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537A2138D9E990028D27C /* times.c */; };
+               C0E344361C582ECB00E749C2 /* timezone.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537A4138D9E990028D27C /* timezone.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E344371C582ECB00E749C2 /* ttyname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537A7138D9E990028D27C /* ttyname.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_TTYNAME_R"; }; };
+               C0E344381C582ECB00E749C2 /* ttyslot.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537A9138D9E990028D27C /* ttyslot.c */; };
+               C0E344391C582ECB00E749C2 /* ualarm.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537AC138D9E990028D27C /* ualarm.c */; };
+               C0E3443A1C582ECB00E749C2 /* ulimit.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537B0138D9E990028D27C /* ulimit.c */; };
+               C0E3443B1C582ECB00E749C2 /* unvis.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537B2138D9E990028D27C /* unvis.c */; };
+               C0E3443C1C582ECB00E749C2 /* usleep.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537B6138D9E990028D27C /* usleep.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_USLEEP"; }; };
+               C0E3443D1C582ECB00E749C2 /* utime.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537BA138D9E990028D27C /* utime.c */; };
+               C0E3443E1C582ECB00E749C2 /* vis.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537BC138D9E990028D27C /* vis.c */; };
+               C0E3443F1C582ECB00E749C2 /* wait.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537BE138D9E990028D27C /* wait.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_WAIT"; }; };
+               C0E344401C582ECB00E749C2 /* wait3.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537C0138D9E990028D27C /* wait3.c */; };
+               C0E344411C582ECB00E749C2 /* waitpid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537C1138D9E990028D27C /* waitpid.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_WAITPID"; }; };
+               C0E344421C582ECB00E749C2 /* fts.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537C4138D9E990028D27C /* fts.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_FTS_CHILDREN -DLIBC_ALIAS_FTS_CLOSE -DLIBC_ALIAS_FTS_OPEN -DLIBC_ALIAS_FTS_OPEN_B -DLIBC_ALIAS_FTS_READ -DLIBC_ALIAS_FTS_SET"; }; };
+               C0E344431C582ECB00E749C2 /* get_compat.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537C6138D9E990028D27C /* get_compat.c */; };
+               C0E344441C582ECB00E749C2 /* getloadavg.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537CA138D9E990028D27C /* getloadavg.c */; };
+               C0E344451C582ECB00E749C2 /* getttyent.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537CC138D9E990028D27C /* getttyent.c */; };
+               C0E344461C582ECB00E749C2 /* getusershell.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537CE138D9E990028D27C /* getusershell.c */; };
+               C0E344471C582ECB00E749C2 /* getvfsbyname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537D0138D9E990028D27C /* getvfsbyname.c */; };
+               C0E344481C582ECB00E749C2 /* nanosleep.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537DC138D9E990028D27C /* nanosleep.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_NANOSLEEP"; }; };
+               C0E344491C582ECB00E749C2 /* utmpx.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537E4138D9E990028D27C /* utmpx.c */; };
+               C0E3444A1C582ECB00E749C2 /* nftw.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537E6138D9E990028D27C /* nftw.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_FTW -DLIBC_ALIAS_NFTW"; }; };
+               C0E3444B1C582ECB00E749C2 /* nlist.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537E8138D9E990028D27C /* nlist.c */; };
+               C0E3444C1C582ECB00E749C2 /* oldsyslog.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537EA138D9E990028D27C /* oldsyslog.c */; };
+               C0E3444D1C582ECB00E749C2 /* setlogin.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537F2138D9E990028D27C /* setlogin.c */; };
+               C0E3444E1C582ECB00E749C2 /* sigsetops.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537F4138D9E990028D27C /* sigsetops.c */; };
+               C0E3444F1C582ECB00E749C2 /* strtofflags.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B537F9138D9E990028D27C /* strtofflags.c */; };
+               C0E344501C582ECB00E749C2 /* thread_stack_pcs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53800138D9E990028D27C /* thread_stack_pcs.c */; };
+               C0E344511C582ECB00E749C2 /* uname.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53803138D9E990028D27C /* uname.c */; };
+               C0E344521C582ECB00E749C2 /* utmpx-darwin.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53804138D9E990028D27C /* utmpx-darwin.c */; };
+               C0E344531C582ECB00E749C2 /* wordexp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53808138D9E990028D27C /* wordexp.c */; };
+               C0E344541C582ECB00E749C2 /* gmon.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5380B138D9E990028D27C /* gmon.c */; };
+               C0E344551C582ECB00E749C2 /* ascii.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53902138D9E990028D27C /* ascii.c */; };
+               C0E344561C582ECB00E749C2 /* big5.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53905138D9E990028D27C /* big5.c */; };
+               C0E344571C582ECB00E749C2 /* btowc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53909138D9E990028D27C /* btowc.c */; };
+               C0E344581C582ECB00E749C2 /* collate.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5390B138D9E990028D27C /* collate.c */; };
+               C0E344591C582ECB00E749C2 /* collcmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5390F138D9E990028D27C /* collcmp.c */; };
+               C0E3445A1C582ECB00E749C2 /* euc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53916138D9E990028D27C /* euc.c */; };
+               C0E3445B1C582ECB00E749C2 /* fix_grouping.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53918138D9E990028D27C /* fix_grouping.c */; };
+               C0E3445C1C582ECB00E749C2 /* gb18030.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5391B138D9E990028D27C /* gb18030.c */; };
+               C0E3445D1C582ECB00E749C2 /* gb2312.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5391E138D9E990028D27C /* gb2312.c */; };
+               C0E3445E1C582ECB00E749C2 /* gbk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53921138D9E990028D27C /* gbk.c */; };
+               C0E3445F1C582ECB00E749C2 /* ldpart.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53946138D9E990028D27C /* ldpart.c */; };
+               C0E344601C582ECB00E749C2 /* lmessages.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5394A138D9E990028D27C /* lmessages.c */; };
+               C0E344611C582ECB00E749C2 /* lmonetary.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5394E138D9E990028D27C /* lmonetary.c */; };
+               C0E344621C582ECB00E749C2 /* lnumeric.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53952138D9E990028D27C /* lnumeric.c */; };
+               C0E344631C582ECB00E749C2 /* localeconv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53958138D9E990028D27C /* localeconv.c */; };
+               C0E344641C582ECB00E749C2 /* mblen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5395C138D9E990028D27C /* mblen.c */; };
+               C0E344651C582ECB00E749C2 /* mbrlen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53962138D9E990028D27C /* mbrlen.c */; };
+               C0E344661C582ECB00E749C2 /* mbrtowc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53966138D9E990028D27C /* mbrtowc.c */; };
+               C0E344671C582ECB00E749C2 /* mbsinit.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5396A138D9E990028D27C /* mbsinit.c */; };
+               C0E344681C582ECB00E749C2 /* mbsnrtowcs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5396C138D9E990028D27C /* mbsnrtowcs.c */; };
+               C0E344691C582ECB00E749C2 /* mbsrtowcs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53970138D9E990028D27C /* mbsrtowcs.c */; };
+               C0E3446A1C582ECB00E749C2 /* mbstowcs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53974138D9E990028D27C /* mbstowcs.c */; };
+               C0E3446B1C582ECB00E749C2 /* mbtowc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53978138D9E990028D27C /* mbtowc.c */; };
+               C0E3446C1C582ECB00E749C2 /* mskanji.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5397B138D9E990028D27C /* mskanji.c */; };
+               C0E3446D1C582ECB00E749C2 /* nextwctype.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53980138D9E990028D27C /* nextwctype.c */; };
+               C0E3446E1C582ECB00E749C2 /* nl_langinfo.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53984138D9E990028D27C /* nl_langinfo.c */; };
+               C0E3446F1C582ECB00E749C2 /* nomacros.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53986138D9E990028D27C /* nomacros.c */; };
+               C0E344701C582ECB00E749C2 /* none.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53987138D9E990028D27C /* none.c */; };
+               C0E344711C582ECB00E749C2 /* rune.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53989138D9E990028D27C /* rune.c */; };
+               C0E344721C582ECB00E749C2 /* runetype.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5398B138D9E990028D27C /* runetype.c */; };
+               C0E344731C582ECB00E749C2 /* setlocale.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5398F138D9E990028D27C /* setlocale.c */; };
+               C0E344741C582ECB00E749C2 /* debug_private.c in Sources */ = {isa = PBXBuildFile; fileRef = 2DF67CDD184F9CBE00B83A3D /* debug_private.c */; };
+               C0E344751C582ECB00E749C2 /* setrunelocale.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53993138D9E990028D27C /* setrunelocale.c */; };
+               C0E344761C582ECB00E749C2 /* table.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53995138D9E990028D27C /* table.c */; };
+               C0E344771C582ECB00E749C2 /* tolower.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5399A138D9E990028D27C /* tolower.c */; };
+               C0E344781C582ECB00E749C2 /* toupper.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5399E138D9E990028D27C /* toupper.c */; };
+               C0E344791C582ECB00E749C2 /* utf2.c in Sources */ = {isa = PBXBuildFile; fileRef = C9FA32F8138E4A5C0089A94B /* utf2.c */; };
+               C0E3447A1C582ECB00E749C2 /* utf8.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539A6138D9E990028D27C /* utf8.c */; };
+               C0E3447B1C582ECB00E749C2 /* wcrtomb.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539AA138D9E990028D27C /* wcrtomb.c */; };
+               C0E3447C1C582ECB00E749C2 /* wcsftime.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539AE138D9E990028D27C /* wcsftime.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_WCSFTIME -DLIBC_ALIAS_WCSFTIME_L"; }; };
+               C0E3447D1C582ECB00E749C2 /* wcsnrtombs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539B0138D9E990028D27C /* wcsnrtombs.c */; };
+               C0E3447E1C582ECB00E749C2 /* wcsrtombs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539B4138D9E990028D27C /* wcsrtombs.c */; };
+               C0E3447F1C582ECB00E749C2 /* wcstod.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539B8138D9E990028D27C /* wcstod.c */; };
+               C0E344801C582ECB00E749C2 /* wcstof.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539BA138D9E990028D27C /* wcstof.c */; };
+               C0E344811C582ECB00E749C2 /* wcstoimax.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539BC138D9E990028D27C /* wcstoimax.c */; };
+               C0E344821C582ECB00E749C2 /* wcstol.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539C0138D9E990028D27C /* wcstol.c */; };
+               C0E344831C582ECB00E749C2 /* wcstold.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539C2138D9E990028D27C /* wcstold.c */; };
+               C0E344841C582ECB00E749C2 /* wcstoll.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539C4138D9E990028D27C /* wcstoll.c */; };
+               C0E344851C582ECB00E749C2 /* wcstombs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539C8138D9E990028D27C /* wcstombs.c */; };
+               C0E344861C582ECB00E749C2 /* wcstoul.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539CA138D9E990028D27C /* wcstoul.c */; };
+               C0E344871C582ECB00E749C2 /* wcstoull.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539CC138D9E990028D27C /* wcstoull.c */; };
+               C0E344881C582ECB00E749C2 /* wcstoumax.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539CE138D9E990028D27C /* wcstoumax.c */; };
+               C0E344891C582ECB00E749C2 /* wctob.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539D0138D9E990028D27C /* wctob.c */; };
+               C0E3448A1C582ECB00E749C2 /* wctomb.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539D4138D9E990028D27C /* wctomb.c */; };
+               C0E3448B1C582ECB00E749C2 /* wctrans.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539D8138D9E990028D27C /* wctrans.c */; };
+               C0E3448C1C582ECB00E749C2 /* wctype.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539DC138D9E990028D27C /* wctype.c */; };
+               C0E3448D1C582ECB00E749C2 /* wcwidth.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539E0138D9E990028D27C /* wcwidth.c */; };
+               C0E3448E1C582ECB00E749C2 /* frune.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539E3138D9E990028D27C /* frune.c */; };
+               C0E3448F1C582ECB00E749C2 /* isctype.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539E5138D9E990028D27C /* isctype.c */; };
+               C0E344901C582ECB00E749C2 /* iswctype.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539E7138D9E990028D27C /* iswctype.c */; };
+               C0E344911C582ECB00E749C2 /* lconv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539E8138D9E990028D27C /* lconv.c */; };
+               C0E344921C582ECB00E749C2 /* mbrune.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539EB138D9E990028D27C /* mbrune.c */; };
+               C0E344931C582ECB00E749C2 /* runedepreciated.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539EF138D9E990028D27C /* runedepreciated.c */; };
+               C0E344941C582ECB00E749C2 /* setinvalidrune.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539F1138D9E990028D27C /* setinvalidrune.c */; };
+               C0E344951C582ECB00E749C2 /* xlocale.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B539F7138D9E990028D27C /* xlocale.c */; };
+               C0E344961C582ECB00E749C2 /* addr2ascii.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A16138D9E990028D27C /* addr2ascii.c */; };
+               C0E344971C582ECB00E749C2 /* ascii2addr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A17138D9E990028D27C /* ascii2addr.c */; };
+               C0E344981C582ECB00E749C2 /* inet_addr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A1A138D9E990028D27C /* inet_addr.c */; };
+               C0E344991C582ECB00E749C2 /* inet_lnaof.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A1C138D9E990028D27C /* inet_lnaof.c */; };
+               C0E3449A1C582ECB00E749C2 /* inet_makeaddr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A1D138D9E990028D27C /* inet_makeaddr.c */; };
+               C0E3449B1C582ECB00E749C2 /* inet_net_ntop.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A20138D9E990028D27C /* inet_net_ntop.c */; };
+               C0E3449C1C582ECB00E749C2 /* inet_net_pton.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A21138D9E990028D27C /* inet_net_pton.c */; };
+               C0E3449D1C582ECB00E749C2 /* inet_neta.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A23138D9E990028D27C /* inet_neta.c */; };
+               C0E3449E1C582ECB00E749C2 /* inet_netof.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A24138D9E990028D27C /* inet_netof.c */; };
+               C0E3449F1C582ECB00E749C2 /* inet_network.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A25138D9E990028D27C /* inet_network.c */; };
+               C0E344A01C582ECB00E749C2 /* inet_ntoa.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A27138D9E990028D27C /* inet_ntoa.c */; };
+               C0E344A11C582ECB00E749C2 /* linkaddr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A2A138D9E990028D27C /* linkaddr.c */; };
+               C0E344A21C582ECB00E749C2 /* nsap_addr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A2B138D9E990028D27C /* nsap_addr.c */; };
+               C0E344A31C582ECB00E749C2 /* recv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A2D138D9E990028D27C /* recv.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_RECV"; }; };
+               C0E344A41C582ECB00E749C2 /* send.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A2F138D9E990028D27C /* send.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_SEND"; }; };
+               C0E344A51C582ECB00E749C2 /* sockatmark.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A33138D9E990028D27C /* sockatmark.c */; };
+               C0E344A61C582ECB00E749C2 /* sourcefilter.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A36138D9E990028D27C /* sourcefilter.c */; };
+               C0E344A71C582ECB00E749C2 /* msgcat.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A3F138D9E990028D27C /* msgcat.c */; };
+               C0E344A81C582ECB00E749C2 /* acl.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A4C138D9E990028D27C /* acl.c */; };
+               C0E344A91C582ECB00E749C2 /* acl_entry.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A59138D9E990028D27C /* acl_entry.c */; };
+               C0E344AA1C582ECB00E749C2 /* acl_file.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A5A138D9E990028D27C /* acl_file.c */; };
+               C0E344AB1C582ECB00E749C2 /* acl_flag.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A5B138D9E990028D27C /* acl_flag.c */; };
+               C0E344AC1C582ECB00E749C2 /* acl_perm.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A68138D9E990028D27C /* acl_perm.c */; };
+               C0E344AD1C582ECB00E749C2 /* acl_translate.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53A6F138D9E990028D27C /* acl_translate.c */; };
+               C0E344AE1C582ECB00E749C2 /* regerror.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B0E138D9E990028D27C /* regerror.c */; };
+               C0E344AF1C582ECB00E749C2 /* chk_fail.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B1E138D9E990028D27C /* chk_fail.c */; };
+               C0E344B01C582ECB00E749C2 /* memcpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B20138D9E990028D27C /* memcpy_chk.c */; };
+               C0E344B11C582ECB00E749C2 /* memmove_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B21138D9E990028D27C /* memmove_chk.c */; };
+               C0E344B21C582ECB00E749C2 /* memset_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B22138D9E990028D27C /* memset_chk.c */; };
+               C0E344B31C582ECB00E749C2 /* snprintf_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B23138D9E990028D27C /* snprintf_chk.c */; };
+               C0E344B41C582ECB00E749C2 /* sprintf_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B24138D9E990028D27C /* sprintf_chk.c */; };
+               C0E344B51C582ECB00E749C2 /* stpcpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B25138D9E990028D27C /* stpcpy_chk.c */; };
+               C0E344B61C582ECB00E749C2 /* stpncpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B26138D9E990028D27C /* stpncpy_chk.c */; };
+               C0E344B71C582ECB00E749C2 /* strcat_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B27138D9E990028D27C /* strcat_chk.c */; };
+               C0E344B81C582ECB00E749C2 /* strcpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B28138D9E990028D27C /* strcpy_chk.c */; };
+               C0E344B91C582ECB00E749C2 /* strlcat_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3FA8F3081643AB4300D37078 /* strlcat_chk.c */; };
+               C0E344BA1C582ECB00E749C2 /* strlcpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3FA8F3091643AB4300D37078 /* strlcpy_chk.c */; };
+               C0E344BB1C582ECB00E749C2 /* strncat_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B29138D9E990028D27C /* strncat_chk.c */; };
+               C0E344BC1C582ECB00E749C2 /* strncpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B2A138D9E990028D27C /* strncpy_chk.c */; };
+               C0E344BD1C582ECB00E749C2 /* vsnprintf_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B2B138D9E990028D27C /* vsnprintf_chk.c */; };
+               C0E344BE1C582ECB00E749C2 /* vsprintf_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B2C138D9E990028D27C /* vsprintf_chk.c */; };
+               C0E344BF1C582ECB00E749C2 /* _flock_stub.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B2F138D9E990028D27C /* _flock_stub.c */; };
+               C0E344C01C582ECB00E749C2 /* asprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B30138D9E990028D27C /* asprintf.c */; };
+               C0E344C11C582ECB00E749C2 /* clrerr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B32138D9E990028D27C /* clrerr.c */; };
+               C0E344C21C582ECB00E749C2 /* dprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B33138D9E990028D27C /* dprintf.c */; };
+               C0E344C31C582ECB00E749C2 /* fclose.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B36138D9E990028D27C /* fclose.c */; };
+               C0E344C41C582ECB00E749C2 /* fdopen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B38138D9E990028D27C /* fdopen.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_FDOPEN"; }; };
+               C0E344C51C582ECB00E749C2 /* feof.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B3A138D9E990028D27C /* feof.c */; };
+               C0E344C61C582ECB00E749C2 /* ferror.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B3C138D9E990028D27C /* ferror.c */; };
+               C0E344C71C582ECB00E749C2 /* fflush.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B3E138D9E990028D27C /* fflush.c */; };
+               C0E344C81C582ECB00E749C2 /* fgetc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B40138D9E990028D27C /* fgetc.c */; };
+               C0E344C91C582ECB00E749C2 /* fgetln.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B43138D9E990028D27C /* fgetln.c */; };
+               C0E344CA1C582ECB00E749C2 /* fgetpos.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B45138D9E990028D27C /* fgetpos.c */; };
+               C0E344CB1C582ECB00E749C2 /* fgets.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B47138D9E990028D27C /* fgets.c */; };
+               C0E344CC1C582ECB00E749C2 /* fgetwc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B48138D9E990028D27C /* fgetwc.c */; };
+               C0E344CD1C582ECB00E749C2 /* fgetwln.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B4C138D9E990028D27C /* fgetwln.c */; };
+               C0E344CE1C582ECB00E749C2 /* fgetws.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B50138D9E990028D27C /* fgetws.c */; };
+               C0E344CF1C582ECB00E749C2 /* fileno.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B52138D9E990028D27C /* fileno.c */; };
+               C0E344D01C582ECB00E749C2 /* findfp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B53138D9E990028D27C /* findfp.c */; };
+               C0E344D11C582ECB00E749C2 /* flags.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B55138D9E990028D27C /* flags.c */; };
+               C0E344D21C582ECB00E749C2 /* bcopy.c in Sources */ = {isa = PBXBuildFile; fileRef = 3FD14572171D42B300B7BAF5 /* bcopy.c */; settings = {COMPILER_FLAGS = "-momit-leaf-frame-pointer"; }; };
+               C0E344D31C582ECB00E749C2 /* fopen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B5C138D9E990028D27C /* fopen.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_FOPEN"; }; };
+               C0E344D41C582ECB00E749C2 /* fprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B5E138D9E990028D27C /* fprintf.c */; };
+               C0E344D51C582ECB00E749C2 /* fpurge.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B60138D9E990028D27C /* fpurge.c */; };
+               C0E344D61C582ECB00E749C2 /* fputc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B61138D9E990028D27C /* fputc.c */; };
+               C0E344D71C582ECB00E749C2 /* fputs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B64138D9E990028D27C /* fputs.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_FPUTS"; }; };
+               C0E344D81C582ECB00E749C2 /* fputwc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B66138D9E990028D27C /* fputwc.c */; };
+               C0E344D91C582ECB00E749C2 /* fputws.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B6A138D9E990028D27C /* fputws.c */; };
+               C0E344DA1C582ECB00E749C2 /* fread.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B6E138D9E990028D27C /* fread.c */; };
+               C0E344DB1C582ECB00E749C2 /* freopen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B70138D9E990028D27C /* freopen.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_FREOPEN"; }; };
+               C0E344DC1C582ECB00E749C2 /* fscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B72138D9E990028D27C /* fscanf.c */; };
+               C0E344DD1C582ECB00E749C2 /* fseek.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B76138D9E990028D27C /* fseek.c */; };
+               C0E344DE1C582ECB00E749C2 /* fsetpos.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B77138D9E990028D27C /* fsetpos.c */; };
+               C0E344DF1C582ECB00E749C2 /* ftell.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B78138D9E990028D27C /* ftell.c */; };
+               C0E344E01C582ECB00E749C2 /* funopen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B7B138D9E990028D27C /* funopen.c */; };
+               C0E344E11C582ECB00E749C2 /* fvwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B7D138D9E990028D27C /* fvwrite.c */; };
+               C0E344E21C582ECB00E749C2 /* fwalk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B7F138D9E990028D27C /* fwalk.c */; };
+               C0E344E31C582ECB00E749C2 /* fwide.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B82138D9E990028D27C /* fwide.c */; };
+               C0E344E41C582ECB00E749C2 /* fwprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B83138D9E990028D27C /* fwprintf.c */; };
+               C0E344E51C582ECB00E749C2 /* fwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B85138D9E990028D27C /* fwrite.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_FWRITE"; }; };
+               C0E344E61C582ECB00E749C2 /* fwscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B87138D9E990028D27C /* fwscanf.c */; };
+               C0E344E71C582ECB00E749C2 /* getc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B8B138D9E990028D27C /* getc.c */; };
+               C0E344E81C582ECB00E749C2 /* getchar.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B8C138D9E990028D27C /* getchar.c */; };
+               C0E344E91C582ECB00E749C2 /* getdelim.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B8D138D9E990028D27C /* getdelim.c */; };
+               C0E344EA1C582ECB00E749C2 /* getline.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B90138D9E990028D27C /* getline.c */; };
+               C0E344EB1C582ECB00E749C2 /* gets.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B91138D9E990028D27C /* gets.c */; };
+               C0E344EC1C582ECB00E749C2 /* getw.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B92138D9E990028D27C /* getw.c */; };
+               C0E344ED1C582ECB00E749C2 /* getwc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B95138D9E990028D27C /* getwc.c */; };
+               C0E344EE1C582ECB00E749C2 /* getwchar.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B97138D9E990028D27C /* getwchar.c */; };
+               C0E344EF1C582ECB00E749C2 /* makebuf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53B9C138D9E990028D27C /* makebuf.c */; };
+               C0E344F01C582ECB00E749C2 /* mktemp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BA0138D9E990028D27C /* mktemp.c */; };
+               C0E344F11C582ECB00E749C2 /* perror.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BA2138D9E990028D27C /* perror.c */; };
+               C0E344F21C582ECB00E749C2 /* printf-pos.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BA3138D9E990028D27C /* printf-pos.c */; };
+               C0E344F31C582ECB00E749C2 /* printf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BA7138D9E990028D27C /* printf.c */; };
+               C0E344F41C582ECB00E749C2 /* putc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BAF138D9E990028D27C /* putc.c */; };
+               C0E344F51C582ECB00E749C2 /* putchar.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BB0138D9E990028D27C /* putchar.c */; };
+               C0E344F61C582ECB00E749C2 /* puts.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BB1138D9E990028D27C /* puts.c */; };
+               C0E344F71C582ECB00E749C2 /* putw.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BB3138D9E990028D27C /* putw.c */; };
+               C0E344F81C582ECB00E749C2 /* putwc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BB6138D9E990028D27C /* putwc.c */; };
+               C0E344F91C582ECB00E749C2 /* putwchar.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BB8138D9E990028D27C /* putwchar.c */; };
+               C0E344FA1C582ECB00E749C2 /* refill.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BBA138D9E990028D27C /* refill.c */; };
+               C0E344FB1C582ECB00E749C2 /* remove.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BBE138D9E990028D27C /* remove.c */; };
+               C0E344FC1C582ECB00E749C2 /* rewind.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BBF138D9E990028D27C /* rewind.c */; };
+               C0E344FD1C582ECB00E749C2 /* rget.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BC1138D9E990028D27C /* rget.c */; };
+               C0E344FE1C582ECB00E749C2 /* scanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BC4138D9E990028D27C /* scanf.c */; };
+               C0E344FF1C582ECB00E749C2 /* setbuf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BC8138D9E990028D27C /* setbuf.c */; };
+               C0E345001C582ECB00E749C2 /* setbuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BC9138D9E990028D27C /* setbuffer.c */; };
+               C0E345011C582ECB00E749C2 /* setvbuf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BCA138D9E990028D27C /* setvbuf.c */; };
+               C0E345021C582ECB00E749C2 /* snprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BCB138D9E990028D27C /* snprintf.c */; };
+               C0E345031C582ECB00E749C2 /* sprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BCD138D9E990028D27C /* sprintf.c */; };
+               C0E345041C582ECB00E749C2 /* sscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BCF138D9E990028D27C /* sscanf.c */; };
+               C0E345051C582ECB00E749C2 /* stdio.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BD3138D9E990028D27C /* stdio.c */; };
+               C0E345061C582ECB00E749C2 /* swprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BD4138D9E990028D27C /* swprintf.c */; };
+               C0E345071C582ECB00E749C2 /* swscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BD6138D9E990028D27C /* swscanf.c */; };
+               C0E345081C582ECB00E749C2 /* tempnam.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BD8138D9E990028D27C /* tempnam.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_TEMPNAM"; }; };
+               C0E345091C582ECB00E749C2 /* tmpfile.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BDA138D9E990028D27C /* tmpfile.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -D_DARWIN_UNLIMITED_STREAMS"; }; };
+               C0E3450A1C582ECB00E749C2 /* tmpnam.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BDD138D9E990028D27C /* tmpnam.c */; };
+               C0E3450B1C582ECB00E749C2 /* ungetc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BE1138D9E990028D27C /* ungetc.c */; };
+               C0E3450C1C582ECB00E749C2 /* ungetwc.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BE4138D9E990028D27C /* ungetwc.c */; };
+               C0E3450D1C582ECB00E749C2 /* vasprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BE6138D9E990028D27C /* vasprintf.c */; };
+               C0E3450E1C582ECB00E749C2 /* vdprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BE8138D9E990028D27C /* vdprintf.c */; };
+               C0E3450F1C582ECB00E749C2 /* vfprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BEA138D9E990028D27C /* vfprintf.c */; };
+               C0E345101C582ECB00E749C2 /* vfscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BEC138D9E990028D27C /* vfscanf.c */; };
+               C0E345111C582ECB00E749C2 /* vfwprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BEE138D9E9A0028D27C /* vfwprintf.c */; };
+               C0E345121C582ECB00E749C2 /* vfwscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BF0138D9E9A0028D27C /* vfwscanf.c */; };
+               C0E345131C582ECB00E749C2 /* vprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BF2138D9E9A0028D27C /* vprintf.c */; };
+               C0E345141C582ECB00E749C2 /* vscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BF4138D9E9A0028D27C /* vscanf.c */; };
+               C0E345151C582ECB00E749C2 /* vsnprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BF6138D9E9A0028D27C /* vsnprintf.c */; };
+               C0E345161C582ECB00E749C2 /* vsprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BF8138D9E9A0028D27C /* vsprintf.c */; };
+               C0E345171C582ECB00E749C2 /* vsscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BFA138D9E9A0028D27C /* vsscanf.c */; };
+               C0E345181C582ECB00E749C2 /* vswprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BFC138D9E9A0028D27C /* vswprintf.c */; };
+               C0E345191C582ECB00E749C2 /* vswscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53BFE138D9E9A0028D27C /* vswscanf.c */; };
+               C0E3451A1C582ECB00E749C2 /* vwprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C00138D9E9A0028D27C /* vwprintf.c */; };
+               C0E3451B1C582ECB00E749C2 /* vwscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C02138D9E9A0028D27C /* vwscanf.c */; };
+               C0E3451C1C582ECB00E749C2 /* wbuf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C04138D9E9A0028D27C /* wbuf.c */; };
+               C0E3451D1C582ECB00E749C2 /* wprintf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C08138D9E9A0028D27C /* wprintf.c */; };
+               C0E3451E1C582ECB00E749C2 /* wscanf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C0C138D9E9A0028D27C /* wscanf.c */; };
+               C0E3451F1C582ECB00E749C2 /* wsetup.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C0E138D9E9A0028D27C /* wsetup.c */; };
+               C0E345201C582ECB00E749C2 /* a64l.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C18138D9E9A0028D27C /* a64l.c */; };
+               C0E345211C582ECB00E749C2 /* _Exit_.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C1A138D9E9A0028D27C /* _Exit_.c */; };
+               C0E345221C582ECB00E749C2 /* abort.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C1D138D9E9A0028D27C /* abort.c */; };
+               C0E345231C582ECB00E749C2 /* abs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C21138D9E9A0028D27C /* abs.c */; };
+               C0E345241C582ECB00E749C2 /* atexit.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C26138D9E9A0028D27C /* atexit.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E345251C582ECB00E749C2 /* atof.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C2C138D9E9A0028D27C /* atof.c */; };
+               C0E345261C582ECB00E749C2 /* atoi.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C30138D9E9A0028D27C /* atoi.c */; };
+               C0E345271C582ECB00E749C2 /* atol.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C34138D9E9A0028D27C /* atol.c */; };
+               C0E345281C582ECB00E749C2 /* atoll.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C36138D9E9A0028D27C /* atoll.c */; };
+               C0E345291C582ECB00E749C2 /* bsearch.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C3A138D9E9A0028D27C /* bsearch.c */; };
+               C0E3452A1C582ECB00E749C2 /* div.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C3E138D9E9A0028D27C /* div.c */; };
+               C0E3452B1C582ECB00E749C2 /* exit.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C40138D9E9A0028D27C /* exit.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E3452C1C582ECB00E749C2 /* getenv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C44138D9E9A0028D27C /* getenv.c */; };
+               C0E3452D1C582ECB00E749C2 /* getopt.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C47138D9E9A0028D27C /* getopt.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_GETOPT"; }; };
+               C0E3452E1C582ECB00E749C2 /* getopt_long.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C4A138D9E9A0028D27C /* getopt_long.c */; };
+               C0E3452F1C582ECB00E749C2 /* getsubopt.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C4D138D9E9A0028D27C /* getsubopt.c */; };
+               C0E345301C582ECB00E749C2 /* hcreate.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C4F138D9E9A0028D27C /* hcreate.c */; };
+               C0E345311C582ECB00E749C2 /* heapsort.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C50138D9E9A0028D27C /* heapsort.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E345321C582ECB00E749C2 /* heapsort_b.c in Sources */ = {isa = PBXBuildFile; fileRef = C9D94357138EC0C600FB7ACC /* heapsort_b.c */; };
+               C0E345331C582ECB00E749C2 /* heapsort_r.c in Sources */ = {isa = PBXBuildFile; fileRef = C9D94358138EC0C600FB7ACC /* heapsort_r.c */; };
+               C0E345341C582ECB00E749C2 /* imaxabs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C54138D9E9A0028D27C /* imaxabs.c */; };
+               C0E345351C582ECB00E749C2 /* imaxdiv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C57138D9E9A0028D27C /* imaxdiv.c */; };
+               C0E345361C582ECB00E749C2 /* insque.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C5A138D9E9A0028D27C /* insque.c */; };
+               C0E345371C582ECB00E749C2 /* labs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C5D138D9E9A0028D27C /* labs.c */; };
+               C0E345381C582ECB00E749C2 /* ldiv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C60138D9E9A0028D27C /* ldiv.c */; };
+               C0E345391C582ECB00E749C2 /* llabs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C63138D9E9A0028D27C /* llabs.c */; };
+               C0E3453A1C582ECB00E749C2 /* lldiv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C66138D9E9A0028D27C /* lldiv.c */; };
+               C0E3453B1C582ECB00E749C2 /* lsearch.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C69138D9E9A0028D27C /* lsearch.c */; };
+               C0E3453C1C582ECB00E749C2 /* merge.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C6C138D9E9A0028D27C /* merge.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E3453D1C582ECB00E749C2 /* putenv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C6F138D9E9A0028D27C /* putenv.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_PUTENV"; }; };
+               C0E3453E1C582ECB00E749C2 /* qsort.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C73138D9E9A0028D27C /* qsort.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E3453F1C582ECB00E749C2 /* qsort_r.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C75138D9E9A0028D27C /* qsort_r.c */; };
+               C0E345401C582ECB00E749C2 /* radixsort.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C78138D9E9A0028D27C /* radixsort.c */; };
+               C0E345411C582ECB00E749C2 /* rand.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C7C138D9E9A0028D27C /* rand.c */; };
+               C0E345421C582ECB00E749C2 /* random.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C7F138D9E9A0028D27C /* random.c */; };
+               C0E345431C582ECB00E749C2 /* reallocf.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C81138D9E9A0028D27C /* reallocf.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E345441C582ECB00E749C2 /* realpath.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C84138D9E9A0028D27C /* realpath.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_REALPATH"; }; };
+               C0E345451C582ECB00E749C2 /* remque.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C86138D9E9A0028D27C /* remque.c */; };
+               C0E345461C582ECB00E749C2 /* setenv.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C87138D9E9A0028D27C /* setenv.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_REALPATH"; }; };
+               C0E345471C582ECB00E749C2 /* strhash.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C89138D9E9A0028D27C /* strhash.c */; };
+               C0E345481C582ECB00E749C2 /* strtoimax.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C8D138D9E9A0028D27C /* strtoimax.c */; };
+               C0E345491C582ECB00E749C2 /* strtol.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C91138D9E9A0028D27C /* strtol.c */; };
+               C0E3454A1C582ECB00E749C2 /* strtoll.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C93138D9E9A0028D27C /* strtoll.c */; };
+               C0E3454B1C582ECB00E749C2 /* strtoq.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C95138D9E9A0028D27C /* strtoq.c */; };
+               C0E3454C1C582ECB00E749C2 /* strtoul.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C99138D9E9A0028D27C /* strtoul.c */; };
+               C0E3454D1C582ECB00E749C2 /* strtoull.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C9B138D9E9A0028D27C /* strtoull.c */; };
+               C0E3454E1C582ECB00E749C2 /* strtoumax.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C9D138D9E9A0028D27C /* strtoumax.c */; };
+               C0E3454F1C582ECB00E749C2 /* strtouq.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53C9F138D9E9A0028D27C /* strtouq.c */; };
+               C0E345501C582ECB00E749C2 /* system.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CA3138D9E9A0028D27C /* system.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_SYSTEM"; }; };
+               C0E345511C582ECB00E749C2 /* tdelete.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CA5138D9E9A0028D27C /* tdelete.c */; };
+               C0E345521C582ECB00E749C2 /* tfind.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CA6138D9E9A0028D27C /* tfind.c */; };
+               C0E345531C582ECB00E749C2 /* tsearch.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CA9138D9E9A0028D27C /* tsearch.c */; };
+               C0E345541C582ECB00E749C2 /* twalk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CAA138D9E9A0028D27C /* twalk.c */; };
+               C0E345551C582ECB00E749C2 /* grantpt.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CAC138D9E9A0028D27C /* grantpt.c */; };
+               C0E345561C582ECB00E749C2 /* l64a.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CAD138D9E9A0028D27C /* l64a.c */; };
+               C0E345571C582ECB00E749C2 /* strfmon.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CB2138D9E9A0028D27C /* strfmon.c */; };
+               C0E345581C582ECB00E749C2 /* ecvt.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CB7138D9E9A0028D27C /* ecvt.c */; };
+               C0E345591C582ECB00E749C2 /* gcvt.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CB9138D9E9A0028D27C /* gcvt.c */; };
+               C0E3455A1C582ECB00E749C2 /* qsort_b-fbsd.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CBD138D9E9A0028D27C /* qsort_b-fbsd.c */; };
+               C0E3455B1C582ECB00E749C2 /* asctime.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CC2138D9E9A0028D27C /* asctime.c */; };
+               C0E3455C1C582ECB00E749C2 /* difftime.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CC6138D9E9A0028D27C /* difftime.c */; };
+               C0E3455D1C582ECB00E749C2 /* ftime.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CC9138D9E9A0028D27C /* ftime.c */; };
+               C0E3455E1C582ECB00E749C2 /* localtime.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CCA138D9E9A0028D27C /* localtime.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_MKTIME"; }; };
+               C0E3455F1C582ECB00E749C2 /* strftime.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CCF138D9E9A0028D27C /* strftime.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_STRFTIME -DLIBC_ALIAS_STRFTIME_L"; }; };
+               C0E345601C582ECB00E749C2 /* strptime.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CD3138D9E9A0028D27C /* strptime.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_STRPTIME -DLIBC_ALIAS_STRPTIME_L"; }; };
+               C0E345611C582ECB00E749C2 /* time32.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CD6138D9E9A0028D27C /* time32.c */; };
+               C0E345621C582ECB00E749C2 /* timelocal.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CD7138D9E9A0028D27C /* timelocal.c */; };
+               C0E345631C582ECB00E749C2 /* getdate.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CE0138D9E9A0028D27C /* getdate.c */; settings = {COMPILER_FLAGS = "-D_DARWIN_UNLIMITED_STREAMS"; }; };
+               C0E345641C582ECB00E749C2 /* timezone_unix03.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CE3138D9E9A0028D27C /* timezone_unix03.c */; };
+               C0E345651C582ECB00E749C2 /* index.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53CF7138D9E9A0028D27C /* index.c */; };
+               C0E345661C582ECB00E749C2 /* memmem.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D06138D9E9A0028D27C /* memmem.c */; };
+               C0E345671C582ECB00E749C2 /* rindex.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D10138D9E9A0028D27C /* rindex.c */; };
+               C0E345681C582ECB00E749C2 /* strcasecmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D15138D9E9A0028D27C /* strcasecmp.c */; };
+               C0E345691C582ECB00E749C2 /* strcasestr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D17138D9E9A0028D27C /* strcasestr.c */; };
+               C0E3456A1C582ECB00E749C2 /* strcoll.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D26138D9E9A0028D27C /* strcoll.c */; };
+               C0E3456B1C582ECB00E749C2 /* strcspn.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D2D138D9E9A0028D27C /* strcspn.c */; };
+               C0E3456C1C582ECB00E749C2 /* strdup.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D30138D9E9A0028D27C /* strdup.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E3456D1C582ECB00E749C2 /* strerror.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D33138D9E9A0028D27C /* strerror.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_STRERROR"; }; };
+               C0E3456E1C582ECB00E749C2 /* strlen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D3C138D9E9A0028D27C /* strlen.c */; };
+               C0E3456F1C582ECB00E749C2 /* strmode.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D40138D9E9A0028D27C /* strmode.c */; };
+               C0E345701C582ECB00E749C2 /* strndup.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D44138D9E9A0028D27C /* strndup.c */; };
+               C0E345711C582ECB00E749C2 /* strnlen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D45138D9E9A0028D27C /* strnlen.c */; };
+               C0E345721C582ECB00E749C2 /* strnstr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D46138D9E9A0028D27C /* strnstr.c */; };
+               C0E345731C582ECB00E749C2 /* strpbrk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D49138D9E9A0028D27C /* strpbrk.c */; };
+               C0E345741C582ECB00E749C2 /* strrchr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D4C138D9E9A0028D27C /* strrchr.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E345751C582ECB00E749C2 /* strsep.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D4F138D9E9A0028D27C /* strsep.c */; };
+               C0E345761C582ECB00E749C2 /* strsignal.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D50138D9E9A0028D27C /* strsignal.c */; };
+               C0E345771C582ECB00E749C2 /* strspn.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D54138D9E9A0028D27C /* strspn.c */; };
+               C0E345781C582ECB00E749C2 /* strstr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D57138D9E9A0028D27C /* strstr.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS)"; }; };
+               C0E345791C582ECB00E749C2 /* strtok.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D5A138D9E9A0028D27C /* strtok.c */; };
+               C0E3457A1C582ECB00E749C2 /* strxfrm.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D5D138D9E9A0028D27C /* strxfrm.c */; };
+               C0E3457B1C582ECB00E749C2 /* swab.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D61138D9E9A0028D27C /* swab.c */; };
+               C0E3457C1C582ECB00E749C2 /* wcpcpy.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D63138D9E9A0028D27C /* wcpcpy.c */; };
+               C0E3457D1C582ECB00E749C2 /* wcpncpy.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D64138D9E9A0028D27C /* wcpncpy.c */; };
+               C0E3457E1C582ECB00E749C2 /* wcscasecmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D65138D9E9A0028D27C /* wcscasecmp.c */; };
+               C0E3457F1C582ECB00E749C2 /* wcscat.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D67138D9E9A0028D27C /* wcscat.c */; };
+               C0E345801C582ECB00E749C2 /* wcschr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D68138D9E9A0028D27C /* wcschr.c */; };
+               C0E345811C582ECB00E749C2 /* wcscmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D69138D9E9A0028D27C /* wcscmp.c */; };
+               C0E345821C582ECB00E749C2 /* wcscoll.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D6C138D9E9A0028D27C /* wcscoll.c */; };
+               C0E345831C582ECB00E749C2 /* wcscpy.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D6E138D9E9A0028D27C /* wcscpy.c */; };
+               C0E345841C582ECB00E749C2 /* wcscspn.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D6F138D9E9A0028D27C /* wcscspn.c */; };
+               C0E345851C582ECB00E749C2 /* wcsdup.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D70138D9E9A0028D27C /* wcsdup.c */; };
+               C0E345861C582ECB00E749C2 /* wcslcat.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D71138D9E9A0028D27C /* wcslcat.c */; };
+               C0E345871C582ECB00E749C2 /* wcslcpy.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D72138D9E9A0028D27C /* wcslcpy.c */; };
+               C0E345881C582ECB00E749C2 /* wcslen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D73138D9E9A0028D27C /* wcslen.c */; };
+               C0E345891C582ECB00E749C2 /* wcsncasecmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D74138D9E9A0028D27C /* wcsncasecmp.c */; };
+               C0E3458A1C582ECB00E749C2 /* wcsncat.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D76138D9E9A0028D27C /* wcsncat.c */; };
+               C0E3458B1C582ECB00E749C2 /* wcsncmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D77138D9E9A0028D27C /* wcsncmp.c */; };
+               C0E3458C1C582ECB00E749C2 /* wcsncpy.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D78138D9E9A0028D27C /* wcsncpy.c */; };
+               C0E3458D1C582ECB00E749C2 /* wcsnlen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D79138D9E9A0028D27C /* wcsnlen.c */; };
+               C0E3458E1C582ECB00E749C2 /* wcspbrk.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D7A138D9E9A0028D27C /* wcspbrk.c */; };
+               C0E3458F1C582ECB00E749C2 /* wcsrchr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D7B138D9E9A0028D27C /* wcsrchr.c */; };
+               C0E345901C582ECB00E749C2 /* wcsspn.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D7C138D9E9A0028D27C /* wcsspn.c */; };
+               C0E345911C582ECB00E749C2 /* wcsstr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D7D138D9E9A0028D27C /* wcsstr.c */; };
+               C0E345921C582ECB00E749C2 /* wcstok.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D80138D9E9A0028D27C /* wcstok.c */; };
+               C0E345931C582ECB00E749C2 /* wcswidth.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D83138D9E9A0028D27C /* wcswidth.c */; };
+               C0E345941C582ECB00E749C2 /* wcsxfrm.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D87138D9E9A0028D27C /* wcsxfrm.c */; };
+               C0E345951C582ECB00E749C2 /* wmemchr.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D8B138D9E9A0028D27C /* wmemchr.c */; };
+               C0E345961C582ECB00E749C2 /* wmemcmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D8C138D9E9A0028D27C /* wmemcmp.c */; };
+               C0E345971C582ECB00E749C2 /* wmemcpy.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D8D138D9E9A0028D27C /* wmemcpy.c */; };
+               C0E345981C582ECB00E749C2 /* wmemmove.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D8E138D9E9A0028D27C /* wmemmove.c */; };
+               C0E345991C582ECB00E749C2 /* wmemset.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D8F138D9E9A0028D27C /* wmemset.c */; };
+               C0E3459A1C582ECB00E749C2 /* _libc_init.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D94138D9E9A0028D27C /* _libc_init.c */; };
+               C0E3459B1C582ECB00E749C2 /* _libc_fork_child.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D95138D9E9A0028D27C /* _libc_fork_child.c */; };
+               C0E3459C1C582ECB00E749C2 /* chmodx_np.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D99138D9E9A0028D27C /* chmodx_np.c */; };
+               C0E3459D1C582ECB00E749C2 /* crt_externs.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D9C138D9E9A0028D27C /* crt_externs.c */; };
+               C0E3459E1C582ECB00E749C2 /* fork.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D9E138D9E9A0028D27C /* fork.c */; };
+               C0E3459F1C582ECB00E749C2 /* getgroups.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53D9F138D9E9A0028D27C /* getgroups.c */; };
+               C0E345A01C582ECB00E749C2 /* gettimeofday.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DA2138D9E9A0028D27C /* gettimeofday.c */; };
+               C0E345A11C582ECB00E749C2 /* msgctl.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DA6138D9E9A0028D27C /* msgctl.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_MSGCTL -DKERNEL"; }; };
+               C0E345A21C582ECB00E749C2 /* stack_protector.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DA9138D9E9A0028D27C /* stack_protector.c */; };
+               C0E345A31C582ECB00E749C2 /* openx_np.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DAB138D9E9A0028D27C /* openx_np.c */; };
+               C0E345A41C582ECB00E749C2 /* OSMemoryNotification.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DAC138D9E9A0028D27C /* OSMemoryNotification.c */; };
+               C0E345A51C582ECB00E749C2 /* OSThermalNotification.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DAD138D9E9A0028D27C /* OSThermalNotification.c */; };
+               C0E345A61C582ECB00E749C2 /* posix_spawn.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DAE138D9E9A0028D27C /* posix_spawn.c */; };
+               C0E345A71C582ECB00E749C2 /* semctl.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DB2138D9E9A0028D27C /* semctl.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_SEMCTL -DKERNEL"; }; };
+               C0E345A81C582ECB00E749C2 /* settimeofday.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DB3138D9E9A0028D27C /* settimeofday.c */; };
+               C0E345A91C582ECB00E749C2 /* shmctl.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DB4138D9E9A0028D27C /* shmctl.c */; settings = {COMPILER_FLAGS = "-DLIBC_ALIAS_SHMCTL -DKERNEL"; }; };
+               C0E345AA1C582ECB00E749C2 /* sigaction.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DB5138D9E9A0028D27C /* sigaction.c */; };
+               C0E345AB1C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E345AC1C582ECB00E749C2 /* statx_np.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DBC138D9E9A0028D27C /* statx_np.c */; };
+               C0E345AD1C582ECB00E749C2 /* umaskx_np.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DBE138D9E9A0028D27C /* umaskx_np.c */; };
+               C0E345AE1C582ECB00E749C2 /* fparseln.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DC8138D9E9A0028D27C /* fparseln.c */; };
+               C0E345AF1C582ECB00E749C2 /* login.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DCA138D9E9A0028D27C /* login.c */; };
+               C0E345B01C582ECB00E749C2 /* login_tty.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DCB138D9E9A0028D27C /* login_tty.c */; };
+               C0E345B11C582ECB00E749C2 /* logout.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DCC138D9E9A0028D27C /* logout.c */; };
+               C0E345B21C582ECB00E749C2 /* logwtmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DCD138D9E9A0028D27C /* logwtmp.c */; };
+               C0E345B31C582ECB00E749C2 /* mkpath_np.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F89F3DD13E9194C00F6856C /* mkpath_np.c */; };
+               C0E345B41C582ECB00E749C2 /* opendev.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DD0138D9E9A0028D27C /* opendev.c */; };
+               C0E345B51C582ECB00E749C2 /* pty.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DD2138D9E9A0028D27C /* pty.c */; };
+               C0E345B61C582ECB00E749C2 /* clear.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DD9138D9E9A0028D27C /* clear.c */; };
+               C0E345B71C582ECB00E749C2 /* compare.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DDA138D9E9A0028D27C /* compare.c */; };
+               C0E345B81C582ECB00E749C2 /* copy.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DDB138D9E9A0028D27C /* copy.c */; };
+               C0E345B91C582ECB00E749C2 /* gen_uuid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DDC138D9E9A0028D27C /* gen_uuid.c */; };
+               C0E345BA1C582ECB00E749C2 /* isnull.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DDE138D9E9A0028D27C /* isnull.c */; };
+               C0E345BB1C582ECB00E749C2 /* pack.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DE0138D9E9A0028D27C /* pack.c */; };
+               C0E345BC1C582ECB00E749C2 /* parse.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DE1138D9E9A0028D27C /* parse.c */; };
+               C0E345BD1C582ECB00E749C2 /* unpack.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DE2138D9E9A0028D27C /* unpack.c */; };
+               C0E345BE1C582ECB00E749C2 /* unparse.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DE3138D9E9A0028D27C /* unparse.c */; };
+               C0E345BF1C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E345C01C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E345C11C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E345C21C582ECB00E749C2 /* (null) in Sources */ = {isa = PBXBuildFile; };
+               C0E345C31C582ECB00E749C2 /* scandir_b.c in Sources */ = {isa = PBXBuildFile; fileRef = C9EB350E138F769B0075BB52 /* scandir_b.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -include gen/__dirent.h"; }; };
+               C0E345C41C582ECB00E749C2 /* init_cpu_capabilities.c in Sources */ = {isa = PBXBuildFile; fileRef = C921D3831395B7DD001CE070 /* init_cpu_capabilities.c */; };
+               C0E345C51C582ECB00E749C2 /* pthread_getspecific.s in Sources */ = {isa = PBXBuildFile; fileRef = C921D3841395B7DD001CE070 /* pthread_getspecific.s */; };
+               C0E345C61C582ECB00E749C2 /* pthread_self.s in Sources */ = {isa = PBXBuildFile; fileRef = C921D3851395B7DD001CE070 /* pthread_self.s */; };
+               C0E345C71C582ECB00E749C2 /* pthread_set_self.s in Sources */ = {isa = PBXBuildFile; fileRef = C921D3861395B7DD001CE070 /* pthread_set_self.s */; };
+               C0E345C81C582ECB00E749C2 /* start_wqthread.s in Sources */ = {isa = PBXBuildFile; fileRef = C921D3871395B7DD001CE070 /* start_wqthread.s */; };
+               C0E345C91C582ECB00E749C2 /* thread_start.s in Sources */ = {isa = PBXBuildFile; fileRef = C921D3881395B7DD001CE070 /* thread_start.s */; };
+               C0E345CA1C582ECB00E749C2 /* strcpy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6310518613D4D966004F7BA8 /* strcpy.c */; };
+               C0E345CB1C582ECB00E749C2 /* strlcpy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6310518B13D4DABD004F7BA8 /* strlcpy.c */; };
+               C0E345CC1C582ECB00E749C2 /* strncpy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6310518E13D4DAEA004F7BA8 /* strncpy.c */; };
+               C0E345CD1C582ECB00E749C2 /* stpcpy.c in Sources */ = {isa = PBXBuildFile; fileRef = 63D4060513DDEDF10094DD56 /* stpcpy.c */; };
+               C0E345CE1C582ECB00E749C2 /* stpncpy.c in Sources */ = {isa = PBXBuildFile; fileRef = 63D4060913DDEEA10094DD56 /* stpncpy.c */; };
+               C0E345CF1C582ECB00E749C2 /* strcat.c in Sources */ = {isa = PBXBuildFile; fileRef = 63D4060C13DDF26A0094DD56 /* strcat.c */; };
+               C0E345D01C582ECB00E749C2 /* strncat.c in Sources */ = {isa = PBXBuildFile; fileRef = 63D4060F13DDF4340094DD56 /* strncat.c */; };
+               C0E345D11C582ECB00E749C2 /* strlcat.c in Sources */ = {isa = PBXBuildFile; fileRef = 63D4061213DDF6A20094DD56 /* strlcat.c */; };
+               C0E345D21C582ECB00E749C2 /* sync_volume_np.c in Sources */ = {isa = PBXBuildFile; fileRef = B19C645B1450F90200032373 /* sync_volume_np.c */; };
+               C0E345D31C582ECB00E749C2 /* dirfd.c in Sources */ = {isa = PBXBuildFile; fileRef = 3FB7E1B4146EF2E000843438 /* dirfd.c */; };
+               C0E345D41C582ECB00E749C2 /* eos_stubs.c in Sources */ = {isa = PBXBuildFile; fileRef = C925D1FB151805C6003D315B /* eos_stubs.c */; };
+               C0E345D51C582ECB00E749C2 /* strnlen.s in Sources */ = {isa = PBXBuildFile; fileRef = 63505E3A1548525D00B637D7 /* strnlen.s */; };
+               C0E345D61C582ECB00E749C2 /* assumes.c in Sources */ = {isa = PBXBuildFile; fileRef = 4B2C64A215519BAF00342BFA /* assumes.c */; };
+               C0E345D71C582ECB00E749C2 /* inet_ntop.c in Sources */ = {isa = PBXBuildFile; fileRef = FC2ED60E157D4BE70098EC69 /* inet_ntop.c */; };
+               C0E345D81C582ECB00E749C2 /* inet_pton.c in Sources */ = {isa = PBXBuildFile; fileRef = FC2ED60F157D4BE70098EC69 /* inet_pton.c */; };
+               C0E345D91C582ECB00E749C2 /* memccpy_chk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F169A3C1643B7BA0029E851 /* memccpy_chk.c */; };
+               C0E345DB1C582ECB00E749C2 /* libBase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C9C2A94D138DFFD900287F00 /* libBase.a */; };
+               C0E345DC1C582ECB00E749C2 /* libFreeBSD.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C9257ED0138E1B5000B3107C /* libFreeBSD.a */; };
+               C0E345DD1C582ECB00E749C2 /* libvCancelable.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C9D94360138EC3E300FB7ACC /* libvCancelable.a */; };
+               C0E345DE1C582ECB00E749C2 /* libTRE.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B122F2AD1432B8E600AF95D0 /* libTRE.a */; };
                C921D3891395B7DD001CE070 /* init_cpu_capabilities.c in Sources */ = {isa = PBXBuildFile; fileRef = C921D3831395B7DD001CE070 /* init_cpu_capabilities.c */; };
                C921D38A1395B7DD001CE070 /* pthread_getspecific.s in Sources */ = {isa = PBXBuildFile; fileRef = C921D3841395B7DD001CE070 /* pthread_getspecific.s */; };
                C921D38B1395B7DD001CE070 /* pthread_self.s in Sources */ = {isa = PBXBuildFile; fileRef = C921D3851395B7DD001CE070 /* pthread_self.s */; };
                C9257F34138E1C8200B3107C /* pause.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53753138D9E990028D27C /* pause.c */; };
                C9257F35138E1C8200B3107C /* popen.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53757138D9E990028D27C /* popen.c */; };
                C9257F37138E1C8200B3107C /* psignal.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5375F138D9E990028D27C /* psignal.c */; };
-               C9257F38138E1C8200B3107C /* raise.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53761138D9E990028D27C /* raise.c */; };
                C9257F39138E1C8200B3107C /* readdir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53766138D9E990028D27C /* readdir.c */; settings = {COMPILER_FLAGS = "-include gen/__dirent.h"; }; };
                C9257F3A138E1C8200B3107C /* readpassphrase.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53769138D9E990028D27C /* readpassphrase.c */; };
                C9257F3B138E1C8200B3107C /* rewinddir.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B5376B138D9E990028D27C /* rewinddir.c */; settings = {COMPILER_FLAGS = "-include gen/__dirent.h"; }; };
                C95B86B5138F53DB004311DA /* parse.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DE1138D9E9A0028D27C /* parse.c */; };
                C95B86B6138F53DB004311DA /* unpack.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DE2138D9E9A0028D27C /* unpack.c */; };
                C95B86B7138F53DB004311DA /* unparse.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B53DE3138D9E9A0028D27C /* unparse.c */; };
-               C965CBF2143BBEC7003912CE /* deps.c in Sources */ = {isa = PBXBuildFile; fileRef = C965CBF1143BBEC7003912CE /* deps.c */; };
                C9765EB2138EC61900741512 /* init_cpu_capabilities.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B535B6138D9E980028D27C /* init_cpu_capabilities.c */; };
                C9765EB9138EC61900741512 /* creat.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B535F8138D9E980028D27C /* creat.c */; settings = {COMPILER_FLAGS = "$(FreeBSD_CFLAGS) -DLIBC_ALIAS_CREAT"; }; };
                C9765EBA138EC61900741512 /* gethostid.c in Sources */ = {isa = PBXBuildFile; fileRef = C9B535FC138D9E980028D27C /* gethostid.c */; };
                        remoteGlobalIDString = 3F51206A16C3174300AFB431;
                        remoteInfo = FortifySource;
                };
-               925E7FFA19E8946700AC7889 /* PBXContainerItemProxy */ = {
+               928F25D41BEAD2AE007B13C7 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
-                       containerPortal = 9268CA8919E4D1350058F6A6 /* libctest.xcodeproj */;
+                       containerPortal = C9B53597138D9A690028D27C /* Project object */;
                        proxyType = 1;
-                       remoteGlobalIDString = E4D01DC5108E708E00FAA873;
-                       remoteInfo = all;
+                       remoteGlobalIDString = 928F25D01BEACED7007B13C7;
+                       remoteInfo = darwintests;
                };
-               9268CAB219E4D1360058F6A6 /* PBXContainerItemProxy */ = {
+               B122F2D81432BA8700AF95D0 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
-                       containerPortal = 9268CA8919E4D1350058F6A6 /* libctest.xcodeproj */;
-                       proxyType = 2;
-                       remoteGlobalIDString = FC2897C8127FCD4500B86C0C;
-                       remoteInfo = nxheap;
+                       containerPortal = C9B53597138D9A690028D27C /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = B122F0E71432B8E600AF95D0;
+                       remoteInfo = TRE;
                };
-               9268CAB419E4D1360058F6A6 /* PBXContainerItemProxy */ = {
+               C0E343851C582ECB00E749C2 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
-                       containerPortal = 9268CA8919E4D1350058F6A6 /* libctest.xcodeproj */;
-                       proxyType = 2;
-                       remoteGlobalIDString = C99475AF15924ADA009FC2A7;
-                       remoteInfo = strlcat;
+                       containerPortal = C9B53597138D9A690028D27C /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = C9C2A94C138DFFD900287F00;
+                       remoteInfo = Base;
                };
-               9268CAB819E4D1360058F6A6 /* PBXContainerItemProxy */ = {
+               C0E343871C582ECB00E749C2 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
-                       containerPortal = 9268CA8919E4D1350058F6A6 /* libctest.xcodeproj */;
-                       proxyType = 2;
-                       remoteGlobalIDString = E423CC22199C5AC200A527F4;
-                       remoteInfo = psort;
+                       containerPortal = C9B53597138D9A690028D27C /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = C9257ECF138E1B5000B3107C;
+                       remoteInfo = FreeBSD;
                };
-               B122F2D81432BA8700AF95D0 /* PBXContainerItemProxy */ = {
+               C0E343891C582ECB00E749C2 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = C9B53597138D9A690028D27C /* Project object */;
                        proxyType = 1;
                        remoteGlobalIDString = B122F0E71432B8E600AF95D0;
                        remoteInfo = TRE;
                };
+               C0E3438B1C582ECB00E749C2 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = C9B53597138D9A690028D27C /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = C9D9435F138EC3E300FB7ACC;
+                       remoteInfo = Variant_Cancelable;
+               };
+               C0E3438D1C582ECB00E749C2 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = C9B53597138D9A690028D27C /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = C95B7ED9138F3C55004311DA;
+                       remoteInfo = Variant_DarwinExtsn;
+               };
+               C0E345E51C58323000E749C2 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = C9B53597138D9A690028D27C /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = C0E343831C582ECB00E749C2;
+                       remoteInfo = libc_static;
+               };
                C925D2001518FA5D003D315B /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = C9B53597138D9A690028D27C /* Project object */;
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXFileReference section */
+               147CDFCF1B7C14FA00831EC6 /* clock_gettime.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = clock_gettime.3; sourceTree = "<group>"; };
+               147CDFD01B7C14FA00831EC6 /* clock_gettime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = clock_gettime.c; sourceTree = "<group>"; };
                2B9D61B6157D667000AF25B8 /* trace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = trace.h; path = os/trace.h; sourceTree = "<group>"; };
                2DF67CDD184F9CBE00B83A3D /* debug_private.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = debug_private.c; path = os/debug_private.c; sourceTree = "<group>"; };
                2DF67CE7184F9CD000B83A3D /* debug_private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = debug_private.h; path = os/debug_private.h; sourceTree = "<group>"; };
                63D4060C13DDF26A0094DD56 /* strcat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = strcat.c; sourceTree = "<group>"; };
                63D4060F13DDF4340094DD56 /* strncat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = strncat.c; sourceTree = "<group>"; };
                63D4061213DDF6A20094DD56 /* strlcat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = strlcat.c; sourceTree = "<group>"; };
-               9268CA8919E4D1350058F6A6 /* libctest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libctest.xcodeproj; path = tests/libctest.xcodeproj; sourceTree = "<group>"; };
+               92ABC7E81D375FC2000DF880 /* compatibility_hacks.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = compatibility_hacks.c; sourceTree = "<group>"; };
                B122F2AD1432B8E600AF95D0 /* libTRE.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTRE.a; sourceTree = BUILT_PRODUCTS_DIR; };
                B122F2AF1432B95B00AF95D0 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
                B122F2B11432B95B00AF95D0 /* regcomp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regcomp.c; sourceTree = "<group>"; };
                B1795372158B0E35008990E8 /* xprintf_exec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xprintf_exec.c; sourceTree = "<group>"; };
                B19C64591450F8B900032373 /* sync_volume_np.3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = sync_volume_np.3; sourceTree = "<group>"; };
                B19C645B1450F90200032373 /* sync_volume_np.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sync_volume_np.c; sourceTree = "<group>"; };
+               C06E02D11CA0C9CA00B07322 /* tests */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tests; sourceTree = "<group>"; };
+               C0E343811C58299D00E749C2 /* skip_installhdrs.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = skip_installhdrs.sh; sourceTree = "<group>"; };
+               C0E345E21C582ECB00E749C2 /* libc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libc.a; sourceTree = BUILT_PRODUCTS_DIR; };
+               C0E345E31C58300F00E749C2 /* libc_static.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = libc_static.xcconfig; sourceTree = "<group>"; };
                C9194B4C140E3BC700BE0C3A /* build_linklists.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build_linklists.sh; sourceTree = "<group>"; };
                C921D3831395B7DD001CE070 /* init_cpu_capabilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = init_cpu_capabilities.c; sourceTree = "<group>"; };
                C921D3841395B7DD001CE070 /* pthread_getspecific.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = pthread_getspecific.s; sourceTree = "<group>"; };
                C9258105138E2D3100B3107C /* libNetBSD.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libNetBSD.a; sourceTree = BUILT_PRODUCTS_DIR; };
                C925D1FB151805C6003D315B /* eos_stubs.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = eos_stubs.c; sourceTree = "<group>"; };
                C93D6150143D31E300EB9023 /* sanitise_headers.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sanitise_headers.sh; sourceTree = "<group>"; };
-               C94212CC13900C8A004BA536 /* libc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libc.a; sourceTree = BUILT_PRODUCTS_DIR; };
+               C94212CC13900C8A004BA536 /* libc_dyld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libc_dyld.a; sourceTree = BUILT_PRODUCTS_DIR; };
                C942135913904CBC004BA536 /* manpages.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = manpages.sh; sourceTree = "<group>"; };
                C942135A13905D1C004BA536 /* manpages.lst */ = {isa = PBXFileReference; explicitFileType = text; path = manpages.lst; sourceTree = "<group>"; };
                C95B7ED8138F3C11004311DA /* rune32.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = rune32.h; sourceTree = "<group>"; };
                C95B8176138F3C55004311DA /* libvDarwinExtsn.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libvDarwinExtsn.a; sourceTree = BUILT_PRODUCTS_DIR; };
                C95B8421138F52B0004311DA /* libvDarwinExtsnCancelable.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libvDarwinExtsnCancelable.a; sourceTree = BUILT_PRODUCTS_DIR; };
                C95B86C7138F53DB004311DA /* libvPre1050.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libvPre1050.a; sourceTree = BUILT_PRODUCTS_DIR; };
-               C965CBF1143BBEC7003912CE /* deps.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = deps.c; sourceTree = BUILT_PRODUCTS_DIR; };
                C965CBF4143BC1BF003912CE /* force_libc_to_build.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = force_libc_to_build.sh; sourceTree = "<group>"; };
                C9766150138EC9D400741512 /* patch_headers_variants.pl */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = patch_headers_variants.pl; sourceTree = "<group>"; };
                C9766153138ECF0000741512 /* variants.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = variants.xcconfig; sourceTree = "<group>"; };
                C9B536BD138D9E980028D27C /* gd_qnan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = gd_qnan.h; sourceTree = "<group>"; };
                C9B536BE138D9E980028D27C /* gdtoa.tgz */ = {isa = PBXFileReference; lastKnownFileType = file; path = gdtoa.tgz; sourceTree = "<group>"; };
                C9B536C1138D9E990028D27C /* __dirent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = __dirent.h; sourceTree = "<group>"; };
-               C9B536D4138D9E990028D27C /* assumes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = assumes.h; sourceTree = "<group>"; };
                C9B536D5138D9E990028D27C /* authentication.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = authentication.c; sourceTree = "<group>"; };
                C9B536D6138D9E990028D27C /* backtrace.3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = backtrace.3; sourceTree = "<group>"; };
                C9B536D7138D9E990028D27C /* backtrace.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = backtrace.c; sourceTree = "<group>"; };
                C9B53A33138D9E990028D27C /* sockatmark.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = sockatmark.c; sourceTree = "<group>"; };
                C9B53A34138D9E990028D27C /* sourcefilter.3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = sourcefilter.3; sourceTree = "<group>"; };
                C9B53A36138D9E990028D27C /* sourcefilter.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = sourcefilter.c; sourceTree = "<group>"; };
-               C9B53A39138D9E990028D27C /* rcmdsh.3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = rcmdsh.3; sourceTree = "<group>"; };
                C9B53A3C138D9E990028D27C /* catclose.3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = catclose.3; sourceTree = "<group>"; };
                C9B53A3D138D9E990028D27C /* catgets.3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = catgets.3; sourceTree = "<group>"; };
                C9B53A3E138D9E990028D27C /* catopen.3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = catopen.3; sourceTree = "<group>"; };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               C0E345DA1C582ECB00E749C2 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               C0E345DB1C582ECB00E749C2 /* libBase.a in Frameworks */,
+                               C0E345DC1C582ECB00E749C2 /* libFreeBSD.a in Frameworks */,
+                               C0E345DD1C582ECB00E749C2 /* libvCancelable.a in Frameworks */,
+                               C0E345DE1C582ECB00E749C2 /* libTRE.a in Frameworks */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                C9257ECD138E1B5000B3107C /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        name = os;
                        sourceTree = "<group>";
                };
-               9268CA8A19E4D1350058F6A6 /* Products */ = {
-                       isa = PBXGroup;
-                       children = (
-                               9268CAB319E4D1360058F6A6 /* nxheap */,
-                               9268CAB519E4D1360058F6A6 /* strlcat */,
-                               9268CAB919E4D1360058F6A6 /* psort */,
-                       );
-                       name = Products;
-                       sourceTree = "<group>";
-               };
                B122F2AE1432B95B00AF95D0 /* TRE */ = {
                        isa = PBXGroup;
                        children = (
                                C9B53DD3138D9E9A0028D27C /* uuid */,
                                C9B53DEF138D9E9A0028D27C /* x86_64 */,
                                C9C2A946138DF66900287F00 /* xcodescripts */,
-                               9268CA8919E4D1350058F6A6 /* libctest.xcodeproj */,
                                C9B535A9138D9E890028D27C /* Products */,
-                               C965CBF1143BBEC7003912CE /* deps.c */,
+                               C06E02D11CA0C9CA00B07322 /* tests */,
                        );
                        indentWidth = 4;
                        sourceTree = "<group>";
                                C95B86C7138F53DB004311DA /* libvPre1050.a */,
                                C9EB3266138F6D880075BB52 /* libvLegacy.a */,
                                C9EB350D138F75580075BB52 /* libvInode32.a */,
-                               C94212CC13900C8A004BA536 /* libc.a */,
+                               C94212CC13900C8A004BA536 /* libc_dyld.a */,
                                B122F2AD1432B8E600AF95D0 /* libTRE.a */,
                                C97A721C1517AF53005E1998 /* libc_eOS.a */,
                                3F5120F116C3174300AFB431 /* libFortifySource.a */,
+                               C0E345E21C582ECB00E749C2 /* libc.a */,
                        );
                        name = Products;
                        sourceTree = "<group>";
                        isa = PBXGroup;
                        children = (
                                C9ECE2761950E384008E8672 /* atexit_receipt.c */,
+                               92ABC7E81D375FC2000DF880 /* compatibility_hacks.c */,
                                C9D9432A138DB72000FB7ACC /* forceLibcToBuild.c */,
                                C9B535B6138D9E980028D27C /* init_cpu_capabilities.c */,
                                C9B53616138D9E980028D27C /* kvm.c */,
                C9B536C0138D9E980028D27C /* gen */ = {
                        isa = PBXGroup;
                        children = (
+                               147CDFCF1B7C14FA00831EC6 /* clock_gettime.3 */,
+                               147CDFD01B7C14FA00831EC6 /* clock_gettime.c */,
                                C9B536C1138D9E990028D27C /* __dirent.h */,
-                               C9B536D4138D9E990028D27C /* assumes.h */,
                                C9B536D5138D9E990028D27C /* authentication.c */,
                                C9B536D6138D9E990028D27C /* backtrace.3 */,
                                C9B536D7138D9E990028D27C /* backtrace.c */,
                                C9B537EA138D9E990028D27C /* oldsyslog.c */,
                                C9B537ED138D9E990028D27C /* posix_memalign.3 */,
                                C9B537EE138D9E990028D27C /* pwcache.3 */,
+                               C9B53761138D9E990028D27C /* raise.c */,
                                C9B537F2138D9E990028D27C /* setlogin.c */,
                                C9B537F3138D9E990028D27C /* sigsetops.3 */,
                                C9B537F4138D9E990028D27C /* sigsetops.c */,
                                C9B5375D138D9E990028D27C /* psignal.3 */,
                                C9B5375F138D9E990028D27C /* psignal.c */,
                                C9B53760138D9E990028D27C /* raise.3 */,
-                               C9B53761138D9E990028D27C /* raise.c */,
                                C9B53762138D9E990028D27C /* rand48.3 */,
                                C9B53764138D9E990028D27C /* rand48.h */,
                                C9B53766138D9E990028D27C /* readdir.c */,
                                C9B53A12138D9E990028D27C /* byteorder.3 */,
                                C9B53A13138D9E990028D27C /* ethers.3 */,
                                C9B53A14138D9E990028D27C /* FreeBSD */,
-                               C9B53A39138D9E990028D27C /* rcmdsh.3 */,
                        );
                        path = net;
                        sourceTree = "<group>";
                                63D4060913DDEEA10094DD56 /* stpncpy.c */,
                                63D4060C13DDF26A0094DD56 /* strcat.c */,
                                6310518613D4D966004F7BA8 /* strcpy.c */,
-                               E4A877A6174D82FB000DBB55 /* alias.list */,
                                63D4061213DDF6A20094DD56 /* strlcat.c */,
                                6310518B13D4DABD004F7BA8 /* strlcpy.c */,
                                63D4060F13DDF4340094DD56 /* strncat.c */,
                C9C2A946138DF66900287F00 /* xcodescripts */ = {
                        isa = PBXGroup;
                        children = (
+                               E4A877A6174D82FB000DBB55 /* alias.list */,
                                C9C2A948138DF7DD00287F00 /* libc.xcconfig */,
                                C9766153138ECF0000741512 /* variants.xcconfig */,
                                C9AE91AE1517CDAC00A2626C /* eos.xcconfig */,
+                               C0E345E31C58300F00E749C2 /* libc_static.xcconfig */,
                                E41BEA97178E72E100E348BB /* Libc.order */,
                                3F45E3121A6DC12E00AFF01E /* abort_unsupported.sh */,
                                C9194B4C140E3BC700BE0C3A /* build_linklists.sh */,
                                C965CBF4143BC1BF003912CE /* force_libc_to_build.sh */,
                                C93D6150143D31E300EB9023 /* sanitise_headers.sh */,
                                3FF283231A4764240098AD2C /* sim-compat-symlink.sh */,
+                               C0E343811C58299D00E749C2 /* skip_installhdrs.sh */,
                        );
                        path = xcodescripts;
                        sourceTree = "<group>";
                };
 /* End PBXGroup section */
 
+/* Begin PBXLegacyTarget section */
+               928F25D01BEACED7007B13C7 /* darwintests */ = {
+                       isa = PBXLegacyTarget;
+                       buildArgumentsString = "$(ACTION)";
+                       buildConfigurationList = 928F25D11BEACED7007B13C7 /* Build configuration list for PBXLegacyTarget "darwintests" */;
+                       buildPhases = (
+                       );
+                       buildToolPath = /usr/bin/make;
+                       buildWorkingDirectory = tests/;
+                       dependencies = (
+                       );
+                       name = darwintests;
+                       passBuildSettingsInEnvironment = 1;
+                       productName = darwintests;
+               };
+/* End PBXLegacyTarget section */
+
 /* Begin PBXNativeTarget section */
                3F51206A16C3174300AFB431 /* FortifySource */ = {
                        isa = PBXNativeTarget;
                        productReference = B122F2AD1432B8E600AF95D0 /* libTRE.a */;
                        productType = "com.apple.product-type.library.static";
                };
+               C0E343831C582ECB00E749C2 /* libc_static */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = C0E345DF1C582ECB00E749C2 /* Build configuration list for PBXNativeTarget "libc_static" */;
+                       buildPhases = (
+                               C0E3438E1C582ECB00E749C2 /* Build Link List */,
+                               C0E3438F1C582ECB00E749C2 /* Generate libc-features.h */,
+                               C0E343901C582ECB00E749C2 /* Patch Headers */,
+                               C0E343911C582ECB00E749C2 /* Sources */,
+                               C0E345DA1C582ECB00E749C2 /* Frameworks */,
+                               C0E345E41C5830C200E749C2 /* Symlink libc.a to a loaderd path */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                               C0E343841C582ECB00E749C2 /* PBXTargetDependency */,
+                               C0E343861C582ECB00E749C2 /* PBXTargetDependency */,
+                               C0E343881C582ECB00E749C2 /* PBXTargetDependency */,
+                               C0E3438A1C582ECB00E749C2 /* PBXTargetDependency */,
+                               C0E3438C1C582ECB00E749C2 /* PBXTargetDependency */,
+                       );
+                       name = libc_static;
+                       productName = "Variant Cancelable";
+                       productReference = C0E345E21C582ECB00E749C2 /* libc.a */;
+                       productType = "com.apple.product-type.library.static";
+               };
                C9257ECF138E1B5000B3107C /* FreeBSD */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = C9257ED3138E1B5000B3107C /* Build configuration list for PBXNativeTarget "FreeBSD" */;
                        productReference = C9258105138E2D3100B3107C /* libNetBSD.a */;
                        productType = "com.apple.product-type.library.static";
                };
-               C942102D13900C8A004BA536 /* libc.a */ = {
+               C942102D13900C8A004BA536 /* libc_dyld */ = {
                        isa = PBXNativeTarget;
-                       buildConfigurationList = C94212C913900C8A004BA536 /* Build configuration list for PBXNativeTarget "libc.a" */;
+                       buildConfigurationList = C94212C913900C8A004BA536 /* Build configuration list for PBXNativeTarget "libc_dyld" */;
                        buildPhases = (
                                C942102E13900C8A004BA536 /* Generate libc-features.h */,
                                C942103013900C8A004BA536 /* Patch Headers */,
                                C942103113900C8A004BA536 /* Sources */,
                                C94212C713900C8A004BA536 /* Frameworks */,
+                               C0E343821C5829F500E749C2 /* Symlink libc_dyld.a to libc.a */,
                        );
                        buildRules = (
                        );
                        dependencies = (
                        );
-                       name = libc.a;
+                       name = libc_dyld;
                        productName = "Variant Cancelable";
-                       productReference = C94212CC13900C8A004BA536 /* libc.a */;
+                       productReference = C94212CC13900C8A004BA536 /* libc_dyld.a */;
                        productType = "com.apple.product-type.library.static";
                };
                C95B7ED9138F3C55004311DA /* Variant_DarwinExtsn */ = {
                                C9EB3515138F771F0075BB52 /* PBXTargetDependency */,
                                3F51211716C318EB00AFB431 /* PBXTargetDependency */,
                                C942130913901709004BA536 /* PBXTargetDependency */,
+                               C0E345E61C58323000E749C2 /* PBXTargetDependency */,
                                C925D2031518FEBE003D315B /* PBXTargetDependency */,
                        );
                        name = libsystem_c.dylib;
                                        925E7FE619E8945900AC7889 = {
                                                CreatedOnToolsVersion = 6.1;
                                        };
+                                       928F25D01BEACED7007B13C7 = {
+                                               CreatedOnToolsVersion = 7.1;
+                                       };
                                };
                        };
                        buildConfigurationList = C9B5359A138D9A690028D27C /* Build configuration list for PBXProject "Libc" */;
                        mainGroup = C9B53595138D9A690028D27C;
                        productRefGroup = C9B535A9138D9E890028D27C /* Products */;
                        projectDirPath = "";
-                       projectReferences = (
-                               {
-                                       ProductGroup = 9268CA8A19E4D1350058F6A6 /* Products */;
-                                       ProjectRef = 9268CA8919E4D1350058F6A6 /* libctest.xcodeproj */;
-                               },
-                       );
                        projectRoot = "";
                        targets = (
                                C9D9432E138DB73300FB7ACC /* libsystem_c.dylib */,
-                               C942102D13900C8A004BA536 /* libc.a */,
+                               C942102D13900C8A004BA536 /* libc_dyld */,
+                               C0E343831C582ECB00E749C2 /* libc_static */,
                                C97A6F1E1517AF53005E1998 /* libc_eOS.a */,
                                C9B53E2B138DA0610028D27C /* Platform */,
                                C9C2A94C138DFFD900287F00 /* Base */,
                                C9EB326F138F75580075BB52 /* Variant_Inode32 */,
                                3F51206A16C3174300AFB431 /* FortifySource */,
                                925E7FE619E8945900AC7889 /* Libc_tests */,
+                               928F25D01BEACED7007B13C7 /* darwintests */,
                        );
                };
 /* End PBXProject section */
 
-/* Begin PBXReferenceProxy section */
-               9268CAB319E4D1360058F6A6 /* nxheap */ = {
-                       isa = PBXReferenceProxy;
-                       fileType = "compiled.mach-o.executable";
-                       path = nxheap;
-                       remoteRef = 9268CAB219E4D1360058F6A6 /* PBXContainerItemProxy */;
-                       sourceTree = BUILT_PRODUCTS_DIR;
-               };
-               9268CAB519E4D1360058F6A6 /* strlcat */ = {
-                       isa = PBXReferenceProxy;
-                       fileType = "compiled.mach-o.executable";
-                       path = strlcat;
-                       remoteRef = 9268CAB419E4D1360058F6A6 /* PBXContainerItemProxy */;
-                       sourceTree = BUILT_PRODUCTS_DIR;
-               };
-               9268CAB919E4D1360058F6A6 /* psort */ = {
-                       isa = PBXReferenceProxy;
-                       fileType = "compiled.mach-o.executable";
-                       path = psort;
-                       remoteRef = 9268CAB819E4D1360058F6A6 /* PBXContainerItemProxy */;
-                       sourceTree = BUILT_PRODUCTS_DIR;
-               };
-/* End PBXReferenceProxy section */
-
 /* Begin PBXShellScriptBuildPhase section */
                3F45E3181A6DC13C00AFF01E /* Enforce SUPPORTED_PLATFORMS */ = {
                        isa = PBXShellScriptBuildPhase;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                3FF283291A4764370098AD2C /* Simulator Build Compat Symlink */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
+               C0E343821C5829F500E749C2 /* Symlink libc_dyld.a to libc.a */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 8;
+                       files = (
+                       );
+                       inputPaths = (
+                               "$(SRCROOT)/xcodescripts/skip_installhdrs.sh",
+                       );
+                       name = "Symlink libc_dyld.a to libc.a";
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 1;
+                       shellPath = /bin/sh;
+                       shellScript = ". \"${SCRIPT_INPUT_FILE_0}\" /bin/ln -sf libc_dyld.a ${DSTROOT}${INSTALL_PATH}/libc.a";
+               };
+               C0E3438E1C582ECB00E749C2 /* Build Link List */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputPaths = (
+                               "$(SRCROOT)/xcodescripts/build_linklists.sh",
+                       );
+                       name = "Build Link List";
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/bash;
+                       shellScript = ". \"${SCRIPT_INPUT_FILE_0}\"";
+               };
+               C0E3438F1C582ECB00E749C2 /* Generate libc-features.h */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Generate libc-features.h";
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
+                       showEnvVarsInLog = 0;
+               };
+               C0E343901C582ECB00E749C2 /* Patch Headers */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Patch Headers";
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/bash;
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       showEnvVarsInLog = 0;
+               };
+               C0E345E41C5830C200E749C2 /* Symlink libc.a to a loaderd path */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 8;
+                       files = (
+                       );
+                       inputPaths = (
+                               "$(SRCROOT)/xcodescripts/skip_installhdrs.sh",
+                       );
+                       name = "Symlink libc.a to a loaderd path";
+                       outputPaths = (
+                               "${DSTROOT}/usr/local/lib/loaderd/libc.a",
+                       );
+                       runOnlyForDeploymentPostprocessing = 1;
+                       shellPath = /bin/sh;
+                       shellScript = ". \"${SCRIPT_INPUT_FILE_0}\" /bin/ln -sf ../../../../${INSTALL_PATH}/libc.a ${DSTROOT}/usr/local/lib/loaderd/libc.a";
+               };
                C9194B4B140E3A7100BE0C3A /* Build Link Lists */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 2147483647;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C942103013900C8A004BA536 /* Patch Headers */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/bash;
-                       shellScript = "perl ${SRCROOT}/xcodescripts/patch_headers_variants.pl \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
                        showEnvVarsInLog = 0;
                };
                C942135B13905EB9004BA536 /* Install Manpages */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C95B7EDB138F3C55004311DA /* Patch Headers */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/bash;
-                       shellScript = "perl ${SRCROOT}/xcodescripts/patch_headers_variants.pl \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
                        showEnvVarsInLog = 0;
                };
                C95B8185138F52B0004311DA /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C95B8186138F52B0004311DA /* Patch Headers */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/bash;
-                       shellScript = "perl ${SRCROOT}/xcodescripts/patch_headers_variants.pl \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
                        showEnvVarsInLog = 0;
                };
                C95B842B138F53DB004311DA /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C95B842C138F53DB004311DA /* Patch Headers */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/bash;
-                       shellScript = "perl ${SRCROOT}/xcodescripts/patch_headers_variants.pl \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
                        showEnvVarsInLog = 0;
                };
                C965CBF3143BBFF7003912CE /* Remove deps.c */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/bash;
-                       shellScript = "perl ${SRCROOT}/xcodescripts/patch_headers_variants.pl \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
                        showEnvVarsInLog = 0;
                };
                C976616D138EF15900741512 /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C97A6F1F1517AF53005E1998 /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C97A6F221517AF53005E1998 /* Patch Headers */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/bash;
-                       shellScript = "perl ${SRCROOT}/xcodescripts/patch_headers_variants.pl \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
                        showEnvVarsInLog = 0;
                };
                C9950E6B1390D2DC009863B6 /* Install Headers */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C9BD3C3D138F189E00B389FD /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C9BD3C3E138F18B200B389FD /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C9BD3C3F138F18D200B389FD /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C9EB2FCA138F6D880075BB52 /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C9EB2FCB138F6D880075BB52 /* Patch Headers */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/bash;
-                       shellScript = "perl ${SRCROOT}/xcodescripts/patch_headers_variants.pl \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
                        showEnvVarsInLog = 0;
                };
                C9EB3270138F75580075BB52 /* Generate libc-features.h */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "perl $SRCROOT/xcodescripts/generate_features.pl";
+                       shellScript = "perl \"$SRCROOT/xcodescripts/generate_features.pl\"";
                        showEnvVarsInLog = 0;
                };
                C9EB3272138F75580075BB52 /* Patch Headers */ = {
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/bash;
-                       shellScript = "perl ${SRCROOT}/xcodescripts/patch_headers_variants.pl \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
+                       shellScript = "perl \"${SRCROOT}/xcodescripts/patch_headers_variants.pl\" \\\n    \"${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders\" \\\n    \"${DERIVED_FILES_DIR}/System.framework/Versions/B\"";
                        showEnvVarsInLog = 0;
                };
 /* End PBXShellScriptBuildPhase section */
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               C0E343911C582ECB00E749C2 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               C0E343921C582ECB00E749C2 /* mcount.s in Sources */,
+                               C0E343931C582ECB00E749C2 /* strcpy.s in Sources */,
+                               C0E343941C582ECB00E749C2 /* strlcat.s in Sources */,
+                               C0E343951C582ECB00E749C2 /* strlcpy.s in Sources */,
+                               C0E343961C582ECB00E749C2 /* strlen.s in Sources */,
+                               C0E343971C582ECB00E749C2 /* strncpy.s in Sources */,
+                               C0E343981C582ECB00E749C2 /* strlen.s in Sources */,
+                               C0E343991C582ECB00E749C2 /* strnlen.s in Sources */,
+                               C0E3439A1C582ECB00E749C2 /* strstr.s in Sources */,
+                               C0E3439B1C582ECB00E749C2 /* mcount.s in Sources */,
+                               C0E3439C1C582ECB00E749C2 /* (null) in Sources */,
+                               C0E3439D1C582ECB00E749C2 /* (null) in Sources */,
+                               C0E3439E1C582ECB00E749C2 /* (null) in Sources */,
+                               C0E3439F1C582ECB00E749C2 /* (null) in Sources */,
+                               C0E343A01C582ECB00E749C2 /* init_cpu_capabilities.c in Sources */,
+                               C0E343A11C582ECB00E749C2 /* creat.c in Sources */,
+                               C0E343A21C582ECB00E749C2 /* gethostid.c in Sources */,
+                               C0E343A31C582ECB00E749C2 /* getwd.c in Sources */,
+                               C0E343A41C582ECB00E749C2 /* killpg.c in Sources */,
+                               C0E343A51C582ECB00E749C2 /* sethostid.c in Sources */,
+                               C0E343A61C582ECB00E749C2 /* setpgrp.c in Sources */,
+                               C0E343A71C582ECB00E749C2 /* setrgid.c in Sources */,
+                               C0E343A81C582ECB00E749C2 /* setruid.c in Sources */,
+                               C0E343A91C582ECB00E749C2 /* setregid.c in Sources */,
+                               C0E343AA1C582ECB00E749C2 /* setreuid.c in Sources */,
+                               C0E343AB1C582ECB00E749C2 /* sigaltstk.c in Sources */,
+                               C0E343AC1C582ECB00E749C2 /* sigcompat.c in Sources */,
+                               C0E343AD1C582ECB00E749C2 /* kvm.c in Sources */,
+                               C0E343AE1C582ECB00E749C2 /* forceLibcToBuild.c in Sources */,
+                               C0E343AF1C582ECB00E749C2 /* bt_close.c in Sources */,
+                               C0E343B01C582ECB00E749C2 /* bt_conv.c in Sources */,
+                               C0E343B11C582ECB00E749C2 /* bt_debug.c in Sources */,
+                               C0E343B21C582ECB00E749C2 /* bt_delete.c in Sources */,
+                               C0E343B31C582ECB00E749C2 /* bt_get.c in Sources */,
+                               C0E343B41C582ECB00E749C2 /* bt_open.c in Sources */,
+                               C0E343B51C582ECB00E749C2 /* bt_overflow.c in Sources */,
+                               C0E343B61C582ECB00E749C2 /* bt_page.c in Sources */,
+                               C0E343B71C582ECB00E749C2 /* bt_put.c in Sources */,
+                               C0E343B81C582ECB00E749C2 /* bt_search.c in Sources */,
+                               C0E343B91C582ECB00E749C2 /* bt_seq.c in Sources */,
+                               C0E343BA1C582ECB00E749C2 /* bt_split.c in Sources */,
+                               C0E343BB1C582ECB00E749C2 /* bt_utils.c in Sources */,
+                               C0E343BC1C582ECB00E749C2 /* db.c in Sources */,
+                               C0E343BD1C582ECB00E749C2 /* hash.c in Sources */,
+                               C0E343BE1C582ECB00E749C2 /* hash_bigkey.c in Sources */,
+                               C0E343BF1C582ECB00E749C2 /* hash_buf.c in Sources */,
+                               C0E343C01C582ECB00E749C2 /* hash_func.c in Sources */,
+                               C0E343C11C582ECB00E749C2 /* hash_log2.c in Sources */,
+                               C0E343C21C582ECB00E749C2 /* hash_page.c in Sources */,
+                               C0E343C31C582ECB00E749C2 /* ndbm.c in Sources */,
+                               C0E343C41C582ECB00E749C2 /* mpool.c in Sources */,
+                               C0E343C51C582ECB00E749C2 /* rec_close.c in Sources */,
+                               C0E343C61C582ECB00E749C2 /* rec_delete.c in Sources */,
+                               C0E343C71C582ECB00E749C2 /* rec_get.c in Sources */,
+                               C0E343C81C582ECB00E749C2 /* rec_open.c in Sources */,
+                               C0E343C91C582ECB00E749C2 /* rec_put.c in Sources */,
+                               C0E343CA1C582ECB00E749C2 /* rec_search.c in Sources */,
+                               C0E343CB1C582ECB00E749C2 /* rec_seq.c in Sources */,
+                               C0E343CC1C582ECB00E749C2 /* rec_utils.c in Sources */,
+                               C0E343CD1C582ECB00E749C2 /* brk.c in Sources */,
+                               C0E343CE1C582ECB00E749C2 /* bsd_signal.c in Sources */,
+                               C0E343CF1C582ECB00E749C2 /* lchflags.c in Sources */,
+                               C0E343D01C582ECB00E749C2 /* lchmod.c in Sources */,
+                               C0E343D11C582ECB00E749C2 /* lutimes.c in Sources */,
+                               C0E343D21C582ECB00E749C2 /* statvfs.c in Sources */,
+                               C0E343D31C582ECB00E749C2 /* tcgetsid.c in Sources */,
+                               C0E343D41C582ECB00E749C2 /* _ldbl_util.c in Sources */,
+                               C0E343D51C582ECB00E749C2 /* _hdtoa.c in Sources */,
+                               C0E343D61C582ECB00E749C2 /* _ldtoa.c in Sources */,
+                               C0E343D71C582ECB00E749C2 /* gdtoa-dmisc.c in Sources */,
+                               C0E343D81C582ECB00E749C2 /* gdtoa-dtoa.c in Sources */,
+                               C0E343D91C582ECB00E749C2 /* gdtoa-gdtoa.c in Sources */,
+                               C0E343DA1C582ECB00E749C2 /* gdtoa-gethex.c in Sources */,
+                               C0E343DB1C582ECB00E749C2 /* gdtoa-gmisc.c in Sources */,
+                               C0E343DC1C582ECB00E749C2 /* gdtoa-hd_init.c in Sources */,
+                               C0E343DD1C582ECB00E749C2 /* gdtoa-hexnan.c in Sources */,
+                               C0E343DE1C582ECB00E749C2 /* gdtoa-misc.c in Sources */,
+                               C0E343DF1C582ECB00E749C2 /* gdtoa-smisc.c in Sources */,
+                               C0E343E01C582ECB00E749C2 /* gdtoa-strtod.c in Sources */,
+                               C0E343E11C582ECB00E749C2 /* gdtoa-strtodg.c in Sources */,
+                               C0E343E21C582ECB00E749C2 /* gdtoa-strtof.c in Sources */,
+                               C0E343E31C582ECB00E749C2 /* gdtoa-strtoIg.c in Sources */,
+                               C0E343E41C582ECB00E749C2 /* gdtoa-strtopdd.c in Sources */,
+                               C0E343E51C582ECB00E749C2 /* gdtoa-strtopx.c in Sources */,
+                               C0E343E61C582ECB00E749C2 /* gdtoa-strtord.c in Sources */,
+                               C0E343E71C582ECB00E749C2 /* gdtoa-sum.c in Sources */,
+                               C0E343E81C582ECB00E749C2 /* gdtoa-ulp.c in Sources */,
+                               C0E343E91C582ECB00E749C2 /* glue.c in Sources */,
+                               C0E343EA1C582ECB00E749C2 /* machdep_ldisd.c in Sources */,
+                               C0E343EB1C582ECB00E749C2 /* machdep_ldisdd.c in Sources */,
+                               C0E343EC1C582ECB00E749C2 /* machdep_ldisQ.c in Sources */,
+                               C0E343ED1C582ECB00E749C2 /* machdep_ldisx.c in Sources */,
+                               C0E343EE1C582ECB00E749C2 /* authentication.c in Sources */,
+                               C0E343EF1C582ECB00E749C2 /* backtrace.c in Sources */,
+                               C0E343F01C582ECB00E749C2 /* confstr.c in Sources */,
+                               C0E343F11C582ECB00E749C2 /* crypt.c in Sources */,
+                               C0E343F21C582ECB00E749C2 /* devname.c in Sources */,
+                               C0E343F31C582ECB00E749C2 /* disklabel.c in Sources */,
+                               C0E343F41C582ECB00E749C2 /* errlst.c in Sources */,
+                               C0E343F51C582ECB00E749C2 /* filesec.c in Sources */,
+                               C0E343F61C582ECB00E749C2 /* _rand48.c in Sources */,
+                               C0E343F71C582ECB00E749C2 /* alarm.c in Sources */,
+                               C0E343F81C582ECB00E749C2 /* arc4random.c in Sources */,
+                               C0E343F91C582ECB00E749C2 /* assert.c in Sources */,
+                               C0E343FA1C582ECB00E749C2 /* basename.c in Sources */,
+                               C0E343FB1C582ECB00E749C2 /* clock.c in Sources */,
+                               C0E343FC1C582ECB00E749C2 /* closedir.c in Sources */,
+                               C0E343FD1C582ECB00E749C2 /* ctermid.c in Sources */,
+                               C0E343FE1C582ECB00E749C2 /* daemon.c in Sources */,
+                               C0E343FF1C582ECB00E749C2 /* dirname.c in Sources */,
+                               C0E344001C582ECB00E749C2 /* drand48.c in Sources */,
+                               C0E344011C582ECB00E749C2 /* erand48.c in Sources */,
+                               C0E344021C582ECB00E749C2 /* err.c in Sources */,
+                               C0E344031C582ECB00E749C2 /* exec.c in Sources */,
+                               C0E344041C582ECB00E749C2 /* fmtcheck.c in Sources */,
+                               C0E344051C582ECB00E749C2 /* fmtmsg.c in Sources */,
+                               C0E344061C582ECB00E749C2 /* fnmatch.c in Sources */,
+                               C0E344071C582ECB00E749C2 /* ftok.c in Sources */,
+                               C0E344081C582ECB00E749C2 /* getbsize.c in Sources */,
+                               C0E344091C582ECB00E749C2 /* getcap.c in Sources */,
+                               C0E3440A1C582ECB00E749C2 /* getcwd.c in Sources */,
+                               C0E3440B1C582ECB00E749C2 /* gethostname.c in Sources */,
+                               C0E3440C1C582ECB00E749C2 /* getlogin.c in Sources */,
+                               C0E3440D1C582ECB00E749C2 /* getmntinfo.c in Sources */,
+                               C0E3440E1C582ECB00E749C2 /* getpagesize.c in Sources */,
+                               C0E3440F1C582ECB00E749C2 /* getpeereid.c in Sources */,
+                               C0E344101C582ECB00E749C2 /* getprogname.c in Sources */,
+                               C0E344111C582ECB00E749C2 /* glob.c in Sources */,
+                               C0E344121C582ECB00E749C2 /* isatty.c in Sources */,
+                               C0E344131C582ECB00E749C2 /* jrand48.c in Sources */,
+                               C0E344141C582ECB00E749C2 /* lcong48.c in Sources */,
+                               C0E344151C582ECB00E749C2 /* lockf.c in Sources */,
+                               C0E344161C582ECB00E749C2 /* lrand48.c in Sources */,
+                               C0E344171C582ECB00E749C2 /* mrand48.c in Sources */,
+                               C0E344181C582ECB00E749C2 /* nice.c in Sources */,
+                               C0E344191C582ECB00E749C2 /* nrand48.c in Sources */,
+                               C0E3441A1C582ECB00E749C2 /* opendir.c in Sources */,
+                               C0E3441B1C582ECB00E749C2 /* pause.c in Sources */,
+                               C0E3441C1C582ECB00E749C2 /* popen.c in Sources */,
+                               C0E3441D1C582ECB00E749C2 /* psignal.c in Sources */,
+                               C0E3441E1C582ECB00E749C2 /* raise.c in Sources */,
+                               C0E3441F1C582ECB00E749C2 /* readdir.c in Sources */,
+                               C0E344201C582ECB00E749C2 /* readpassphrase.c in Sources */,
+                               C0E344211C582ECB00E749C2 /* rewinddir.c in Sources */,
+                               C0E344221C582ECB00E749C2 /* scandir.c in Sources */,
+                               C0E344231C582ECB00E749C2 /* seed48.c in Sources */,
+                               C0E344241C582ECB00E749C2 /* seekdir.c in Sources */,
+                               C0E344251C582ECB00E749C2 /* sethostname.c in Sources */,
+                               C0E344261C582ECB00E749C2 /* setmode.c in Sources */,
+                               C0E344271C582ECB00E749C2 /* setprogname.c in Sources */,
+                               C0E344281C582ECB00E749C2 /* siginterrupt.c in Sources */,
+                               C0E344291C582ECB00E749C2 /* siglist.c in Sources */,
+                               C0E3442A1C582ECB00E749C2 /* signal.c in Sources */,
+                               C0E3442B1C582ECB00E749C2 /* sleep.c in Sources */,
+                               C0E3442C1C582ECB00E749C2 /* srand48.c in Sources */,
+                               C0E3442D1C582ECB00E749C2 /* stringlist.c in Sources */,
+                               C0E3442E1C582ECB00E749C2 /* sysconf.c in Sources */,
+                               C0E3442F1C582ECB00E749C2 /* sysctl.c in Sources */,
+                               C0E344301C582ECB00E749C2 /* sysctlbyname.c in Sources */,
+                               C0E344311C582ECB00E749C2 /* sysctlnametomib.c in Sources */,
+                               C0E344321C582ECB00E749C2 /* telldir.c in Sources */,
+                               C0E344331C582ECB00E749C2 /* termios.c in Sources */,
+                               C0E344341C582ECB00E749C2 /* time.c in Sources */,
+                               C0E344351C582ECB00E749C2 /* times.c in Sources */,
+                               C0E344361C582ECB00E749C2 /* timezone.c in Sources */,
+                               C0E344371C582ECB00E749C2 /* ttyname.c in Sources */,
+                               C0E344381C582ECB00E749C2 /* ttyslot.c in Sources */,
+                               C0E344391C582ECB00E749C2 /* ualarm.c in Sources */,
+                               C0E3443A1C582ECB00E749C2 /* ulimit.c in Sources */,
+                               C0E3443B1C582ECB00E749C2 /* unvis.c in Sources */,
+                               C0E3443C1C582ECB00E749C2 /* usleep.c in Sources */,
+                               C0E3443D1C582ECB00E749C2 /* utime.c in Sources */,
+                               C0E3443E1C582ECB00E749C2 /* vis.c in Sources */,
+                               C0E3443F1C582ECB00E749C2 /* wait.c in Sources */,
+                               C0E344401C582ECB00E749C2 /* wait3.c in Sources */,
+                               C0E344411C582ECB00E749C2 /* waitpid.c in Sources */,
+                               C0E344421C582ECB00E749C2 /* fts.c in Sources */,
+                               C0E344431C582ECB00E749C2 /* get_compat.c in Sources */,
+                               C0E344441C582ECB00E749C2 /* getloadavg.c in Sources */,
+                               C0E344451C582ECB00E749C2 /* getttyent.c in Sources */,
+                               C0E344461C582ECB00E749C2 /* getusershell.c in Sources */,
+                               C0E344471C582ECB00E749C2 /* getvfsbyname.c in Sources */,
+                               C0E344481C582ECB00E749C2 /* nanosleep.c in Sources */,
+                               C0E344491C582ECB00E749C2 /* utmpx.c in Sources */,
+                               C0E3444A1C582ECB00E749C2 /* nftw.c in Sources */,
+                               C0E3444B1C582ECB00E749C2 /* nlist.c in Sources */,
+                               C0E3444C1C582ECB00E749C2 /* oldsyslog.c in Sources */,
+                               C0E3444D1C582ECB00E749C2 /* setlogin.c in Sources */,
+                               C0E3444E1C582ECB00E749C2 /* sigsetops.c in Sources */,
+                               C0E3444F1C582ECB00E749C2 /* strtofflags.c in Sources */,
+                               C0E344501C582ECB00E749C2 /* thread_stack_pcs.c in Sources */,
+                               C0E344511C582ECB00E749C2 /* uname.c in Sources */,
+                               C0E344521C582ECB00E749C2 /* utmpx-darwin.c in Sources */,
+                               C0E344531C582ECB00E749C2 /* wordexp.c in Sources */,
+                               C0E344541C582ECB00E749C2 /* gmon.c in Sources */,
+                               C0E344551C582ECB00E749C2 /* ascii.c in Sources */,
+                               C0E344561C582ECB00E749C2 /* big5.c in Sources */,
+                               C0E344571C582ECB00E749C2 /* btowc.c in Sources */,
+                               C0E344581C582ECB00E749C2 /* collate.c in Sources */,
+                               C0E344591C582ECB00E749C2 /* collcmp.c in Sources */,
+                               C0E3445A1C582ECB00E749C2 /* euc.c in Sources */,
+                               C0E3445B1C582ECB00E749C2 /* fix_grouping.c in Sources */,
+                               C0E3445C1C582ECB00E749C2 /* gb18030.c in Sources */,
+                               C0E3445D1C582ECB00E749C2 /* gb2312.c in Sources */,
+                               C0E3445E1C582ECB00E749C2 /* gbk.c in Sources */,
+                               C0E3445F1C582ECB00E749C2 /* ldpart.c in Sources */,
+                               C0E344601C582ECB00E749C2 /* lmessages.c in Sources */,
+                               C0E344611C582ECB00E749C2 /* lmonetary.c in Sources */,
+                               C0E344621C582ECB00E749C2 /* lnumeric.c in Sources */,
+                               C0E344631C582ECB00E749C2 /* localeconv.c in Sources */,
+                               C0E344641C582ECB00E749C2 /* mblen.c in Sources */,
+                               C0E344651C582ECB00E749C2 /* mbrlen.c in Sources */,
+                               C0E344661C582ECB00E749C2 /* mbrtowc.c in Sources */,
+                               C0E344671C582ECB00E749C2 /* mbsinit.c in Sources */,
+                               C0E344681C582ECB00E749C2 /* mbsnrtowcs.c in Sources */,
+                               C0E344691C582ECB00E749C2 /* mbsrtowcs.c in Sources */,
+                               C0E3446A1C582ECB00E749C2 /* mbstowcs.c in Sources */,
+                               C0E3446B1C582ECB00E749C2 /* mbtowc.c in Sources */,
+                               C0E3446C1C582ECB00E749C2 /* mskanji.c in Sources */,
+                               C0E3446D1C582ECB00E749C2 /* nextwctype.c in Sources */,
+                               C0E3446E1C582ECB00E749C2 /* nl_langinfo.c in Sources */,
+                               C0E3446F1C582ECB00E749C2 /* nomacros.c in Sources */,
+                               C0E344701C582ECB00E749C2 /* none.c in Sources */,
+                               C0E344711C582ECB00E749C2 /* rune.c in Sources */,
+                               C0E344721C582ECB00E749C2 /* runetype.c in Sources */,
+                               C0E344731C582ECB00E749C2 /* setlocale.c in Sources */,
+                               C0E344741C582ECB00E749C2 /* debug_private.c in Sources */,
+                               C0E344751C582ECB00E749C2 /* setrunelocale.c in Sources */,
+                               C0E344761C582ECB00E749C2 /* table.c in Sources */,
+                               C0E344771C582ECB00E749C2 /* tolower.c in Sources */,
+                               C0E344781C582ECB00E749C2 /* toupper.c in Sources */,
+                               C0E344791C582ECB00E749C2 /* utf2.c in Sources */,
+                               C0E3447A1C582ECB00E749C2 /* utf8.c in Sources */,
+                               C0E3447B1C582ECB00E749C2 /* wcrtomb.c in Sources */,
+                               C0E3447C1C582ECB00E749C2 /* wcsftime.c in Sources */,
+                               C0E3447D1C582ECB00E749C2 /* wcsnrtombs.c in Sources */,
+                               C0E3447E1C582ECB00E749C2 /* wcsrtombs.c in Sources */,
+                               C0E3447F1C582ECB00E749C2 /* wcstod.c in Sources */,
+                               C0E344801C582ECB00E749C2 /* wcstof.c in Sources */,
+                               C0E344811C582ECB00E749C2 /* wcstoimax.c in Sources */,
+                               C0E344821C582ECB00E749C2 /* wcstol.c in Sources */,
+                               C0E344831C582ECB00E749C2 /* wcstold.c in Sources */,
+                               C0E344841C582ECB00E749C2 /* wcstoll.c in Sources */,
+                               C0E344851C582ECB00E749C2 /* wcstombs.c in Sources */,
+                               C0E344861C582ECB00E749C2 /* wcstoul.c in Sources */,
+                               C0E344871C582ECB00E749C2 /* wcstoull.c in Sources */,
+                               C0E344881C582ECB00E749C2 /* wcstoumax.c in Sources */,
+                               C0E344891C582ECB00E749C2 /* wctob.c in Sources */,
+                               C0E3448A1C582ECB00E749C2 /* wctomb.c in Sources */,
+                               C0E3448B1C582ECB00E749C2 /* wctrans.c in Sources */,
+                               C0E3448C1C582ECB00E749C2 /* wctype.c in Sources */,
+                               C0E3448D1C582ECB00E749C2 /* wcwidth.c in Sources */,
+                               C0E3448E1C582ECB00E749C2 /* frune.c in Sources */,
+                               C0E3448F1C582ECB00E749C2 /* isctype.c in Sources */,
+                               C0E344901C582ECB00E749C2 /* iswctype.c in Sources */,
+                               C0E344911C582ECB00E749C2 /* lconv.c in Sources */,
+                               C0E344921C582ECB00E749C2 /* mbrune.c in Sources */,
+                               C0E344931C582ECB00E749C2 /* runedepreciated.c in Sources */,
+                               C0E344941C582ECB00E749C2 /* setinvalidrune.c in Sources */,
+                               C0E344951C582ECB00E749C2 /* xlocale.c in Sources */,
+                               C0E344961C582ECB00E749C2 /* addr2ascii.c in Sources */,
+                               C0E344971C582ECB00E749C2 /* ascii2addr.c in Sources */,
+                               C0E344981C582ECB00E749C2 /* inet_addr.c in Sources */,
+                               C0E344991C582ECB00E749C2 /* inet_lnaof.c in Sources */,
+                               C0E3449A1C582ECB00E749C2 /* inet_makeaddr.c in Sources */,
+                               C0E3449B1C582ECB00E749C2 /* inet_net_ntop.c in Sources */,
+                               C0E3449C1C582ECB00E749C2 /* inet_net_pton.c in Sources */,
+                               C0E3449D1C582ECB00E749C2 /* inet_neta.c in Sources */,
+                               C0E3449E1C582ECB00E749C2 /* inet_netof.c in Sources */,
+                               C0E3449F1C582ECB00E749C2 /* inet_network.c in Sources */,
+                               C0E344A01C582ECB00E749C2 /* inet_ntoa.c in Sources */,
+                               C0E344A11C582ECB00E749C2 /* linkaddr.c in Sources */,
+                               C0E344A21C582ECB00E749C2 /* nsap_addr.c in Sources */,
+                               C0E344A31C582ECB00E749C2 /* recv.c in Sources */,
+                               C0E344A41C582ECB00E749C2 /* send.c in Sources */,
+                               C0E344A51C582ECB00E749C2 /* sockatmark.c in Sources */,
+                               C0E344A61C582ECB00E749C2 /* sourcefilter.c in Sources */,
+                               C0E344A71C582ECB00E749C2 /* msgcat.c in Sources */,
+                               C0E344A81C582ECB00E749C2 /* acl.c in Sources */,
+                               C0E344A91C582ECB00E749C2 /* acl_entry.c in Sources */,
+                               C0E344AA1C582ECB00E749C2 /* acl_file.c in Sources */,
+                               C0E344AB1C582ECB00E749C2 /* acl_flag.c in Sources */,
+                               C0E344AC1C582ECB00E749C2 /* acl_perm.c in Sources */,
+                               C0E344AD1C582ECB00E749C2 /* acl_translate.c in Sources */,
+                               C0E344AE1C582ECB00E749C2 /* regerror.c in Sources */,
+                               C0E344AF1C582ECB00E749C2 /* chk_fail.c in Sources */,
+                               C0E344B01C582ECB00E749C2 /* memcpy_chk.c in Sources */,
+                               C0E344B11C582ECB00E749C2 /* memmove_chk.c in Sources */,
+                               C0E344B21C582ECB00E749C2 /* memset_chk.c in Sources */,
+                               C0E344B31C582ECB00E749C2 /* snprintf_chk.c in Sources */,
+                               C0E344B41C582ECB00E749C2 /* sprintf_chk.c in Sources */,
+                               C0E344B51C582ECB00E749C2 /* stpcpy_chk.c in Sources */,
+                               C0E344B61C582ECB00E749C2 /* stpncpy_chk.c in Sources */,
+                               C0E344B71C582ECB00E749C2 /* strcat_chk.c in Sources */,
+                               C0E344B81C582ECB00E749C2 /* strcpy_chk.c in Sources */,
+                               C0E344B91C582ECB00E749C2 /* strlcat_chk.c in Sources */,
+                               C0E344BA1C582ECB00E749C2 /* strlcpy_chk.c in Sources */,
+                               C0E344BB1C582ECB00E749C2 /* strncat_chk.c in Sources */,
+                               C0E344BC1C582ECB00E749C2 /* strncpy_chk.c in Sources */,
+                               C0E344BD1C582ECB00E749C2 /* vsnprintf_chk.c in Sources */,
+                               C0E344BE1C582ECB00E749C2 /* vsprintf_chk.c in Sources */,
+                               C0E344BF1C582ECB00E749C2 /* _flock_stub.c in Sources */,
+                               C0E344C01C582ECB00E749C2 /* asprintf.c in Sources */,
+                               C0E344C11C582ECB00E749C2 /* clrerr.c in Sources */,
+                               C0E344C21C582ECB00E749C2 /* dprintf.c in Sources */,
+                               C0E344C31C582ECB00E749C2 /* fclose.c in Sources */,
+                               C0E344C41C582ECB00E749C2 /* fdopen.c in Sources */,
+                               C0E344C51C582ECB00E749C2 /* feof.c in Sources */,
+                               C0E344C61C582ECB00E749C2 /* ferror.c in Sources */,
+                               C0E344C71C582ECB00E749C2 /* fflush.c in Sources */,
+                               C0E344C81C582ECB00E749C2 /* fgetc.c in Sources */,
+                               C0E344C91C582ECB00E749C2 /* fgetln.c in Sources */,
+                               C0E344CA1C582ECB00E749C2 /* fgetpos.c in Sources */,
+                               C0E344CB1C582ECB00E749C2 /* fgets.c in Sources */,
+                               C0E344CC1C582ECB00E749C2 /* fgetwc.c in Sources */,
+                               C0E344CD1C582ECB00E749C2 /* fgetwln.c in Sources */,
+                               C0E344CE1C582ECB00E749C2 /* fgetws.c in Sources */,
+                               C0E344CF1C582ECB00E749C2 /* fileno.c in Sources */,
+                               C0E344D01C582ECB00E749C2 /* findfp.c in Sources */,
+                               C0E344D11C582ECB00E749C2 /* flags.c in Sources */,
+                               C0E344D21C582ECB00E749C2 /* bcopy.c in Sources */,
+                               C0E344D31C582ECB00E749C2 /* fopen.c in Sources */,
+                               C0E344D41C582ECB00E749C2 /* fprintf.c in Sources */,
+                               C0E344D51C582ECB00E749C2 /* fpurge.c in Sources */,
+                               C0E344D61C582ECB00E749C2 /* fputc.c in Sources */,
+                               C0E344D71C582ECB00E749C2 /* fputs.c in Sources */,
+                               C0E344D81C582ECB00E749C2 /* fputwc.c in Sources */,
+                               C0E344D91C582ECB00E749C2 /* fputws.c in Sources */,
+                               C0E344DA1C582ECB00E749C2 /* fread.c in Sources */,
+                               C0E344DB1C582ECB00E749C2 /* freopen.c in Sources */,
+                               C0E344DC1C582ECB00E749C2 /* fscanf.c in Sources */,
+                               C0E344DD1C582ECB00E749C2 /* fseek.c in Sources */,
+                               C0E344DE1C582ECB00E749C2 /* fsetpos.c in Sources */,
+                               C0E344DF1C582ECB00E749C2 /* ftell.c in Sources */,
+                               C0E344E01C582ECB00E749C2 /* funopen.c in Sources */,
+                               C0E344E11C582ECB00E749C2 /* fvwrite.c in Sources */,
+                               C0E344E21C582ECB00E749C2 /* fwalk.c in Sources */,
+                               C0E344E31C582ECB00E749C2 /* fwide.c in Sources */,
+                               C0E344E41C582ECB00E749C2 /* fwprintf.c in Sources */,
+                               C0E344E51C582ECB00E749C2 /* fwrite.c in Sources */,
+                               C0E344E61C582ECB00E749C2 /* fwscanf.c in Sources */,
+                               C0E344E71C582ECB00E749C2 /* getc.c in Sources */,
+                               C0E344E81C582ECB00E749C2 /* getchar.c in Sources */,
+                               C0E344E91C582ECB00E749C2 /* getdelim.c in Sources */,
+                               C0E344EA1C582ECB00E749C2 /* getline.c in Sources */,
+                               C0E344EB1C582ECB00E749C2 /* gets.c in Sources */,
+                               C0E344EC1C582ECB00E749C2 /* getw.c in Sources */,
+                               C0E344ED1C582ECB00E749C2 /* getwc.c in Sources */,
+                               C0E344EE1C582ECB00E749C2 /* getwchar.c in Sources */,
+                               C0E344EF1C582ECB00E749C2 /* makebuf.c in Sources */,
+                               C0E344F01C582ECB00E749C2 /* mktemp.c in Sources */,
+                               C0E344F11C582ECB00E749C2 /* perror.c in Sources */,
+                               C0E344F21C582ECB00E749C2 /* printf-pos.c in Sources */,
+                               C0E344F31C582ECB00E749C2 /* printf.c in Sources */,
+                               C0E344F41C582ECB00E749C2 /* putc.c in Sources */,
+                               C0E344F51C582ECB00E749C2 /* putchar.c in Sources */,
+                               C0E344F61C582ECB00E749C2 /* puts.c in Sources */,
+                               C0E344F71C582ECB00E749C2 /* putw.c in Sources */,
+                               C0E344F81C582ECB00E749C2 /* putwc.c in Sources */,
+                               C0E344F91C582ECB00E749C2 /* putwchar.c in Sources */,
+                               C0E344FA1C582ECB00E749C2 /* refill.c in Sources */,
+                               C0E344FB1C582ECB00E749C2 /* remove.c in Sources */,
+                               C0E344FC1C582ECB00E749C2 /* rewind.c in Sources */,
+                               C0E344FD1C582ECB00E749C2 /* rget.c in Sources */,
+                               C0E344FE1C582ECB00E749C2 /* scanf.c in Sources */,
+                               C0E344FF1C582ECB00E749C2 /* setbuf.c in Sources */,
+                               C0E345001C582ECB00E749C2 /* setbuffer.c in Sources */,
+                               C0E345011C582ECB00E749C2 /* setvbuf.c in Sources */,
+                               C0E345021C582ECB00E749C2 /* snprintf.c in Sources */,
+                               C0E345031C582ECB00E749C2 /* sprintf.c in Sources */,
+                               C0E345041C582ECB00E749C2 /* sscanf.c in Sources */,
+                               C0E345051C582ECB00E749C2 /* stdio.c in Sources */,
+                               C0E345061C582ECB00E749C2 /* swprintf.c in Sources */,
+                               C0E345071C582ECB00E749C2 /* swscanf.c in Sources */,
+                               C0E345081C582ECB00E749C2 /* tempnam.c in Sources */,
+                               C0E345091C582ECB00E749C2 /* tmpfile.c in Sources */,
+                               C0E3450A1C582ECB00E749C2 /* tmpnam.c in Sources */,
+                               C0E3450B1C582ECB00E749C2 /* ungetc.c in Sources */,
+                               C0E3450C1C582ECB00E749C2 /* ungetwc.c in Sources */,
+                               C0E3450D1C582ECB00E749C2 /* vasprintf.c in Sources */,
+                               C0E3450E1C582ECB00E749C2 /* vdprintf.c in Sources */,
+                               C0E3450F1C582ECB00E749C2 /* vfprintf.c in Sources */,
+                               C0E345101C582ECB00E749C2 /* vfscanf.c in Sources */,
+                               C0E345111C582ECB00E749C2 /* vfwprintf.c in Sources */,
+                               C0E345121C582ECB00E749C2 /* vfwscanf.c in Sources */,
+                               C0E345131C582ECB00E749C2 /* vprintf.c in Sources */,
+                               C0E345141C582ECB00E749C2 /* vscanf.c in Sources */,
+                               C0E345151C582ECB00E749C2 /* vsnprintf.c in Sources */,
+                               C0E345161C582ECB00E749C2 /* vsprintf.c in Sources */,
+                               C0E345171C582ECB00E749C2 /* vsscanf.c in Sources */,
+                               C0E345181C582ECB00E749C2 /* vswprintf.c in Sources */,
+                               C0E345191C582ECB00E749C2 /* vswscanf.c in Sources */,
+                               C0E3451A1C582ECB00E749C2 /* vwprintf.c in Sources */,
+                               C0E3451B1C582ECB00E749C2 /* vwscanf.c in Sources */,
+                               C0E3451C1C582ECB00E749C2 /* wbuf.c in Sources */,
+                               C0E3451D1C582ECB00E749C2 /* wprintf.c in Sources */,
+                               C0E3451E1C582ECB00E749C2 /* wscanf.c in Sources */,
+                               C0E3451F1C582ECB00E749C2 /* wsetup.c in Sources */,
+                               C0E345201C582ECB00E749C2 /* a64l.c in Sources */,
+                               C0E345211C582ECB00E749C2 /* _Exit_.c in Sources */,
+                               C0E345221C582ECB00E749C2 /* abort.c in Sources */,
+                               C0E345231C582ECB00E749C2 /* abs.c in Sources */,
+                               C0E345241C582ECB00E749C2 /* atexit.c in Sources */,
+                               C0E345251C582ECB00E749C2 /* atof.c in Sources */,
+                               C0E345261C582ECB00E749C2 /* atoi.c in Sources */,
+                               C0E345271C582ECB00E749C2 /* atol.c in Sources */,
+                               C0E345281C582ECB00E749C2 /* atoll.c in Sources */,
+                               C0E345291C582ECB00E749C2 /* bsearch.c in Sources */,
+                               C0E3452A1C582ECB00E749C2 /* div.c in Sources */,
+                               C0E3452B1C582ECB00E749C2 /* exit.c in Sources */,
+                               C0E3452C1C582ECB00E749C2 /* getenv.c in Sources */,
+                               C0E3452D1C582ECB00E749C2 /* getopt.c in Sources */,
+                               C0E3452E1C582ECB00E749C2 /* getopt_long.c in Sources */,
+                               C0E3452F1C582ECB00E749C2 /* getsubopt.c in Sources */,
+                               C0E345301C582ECB00E749C2 /* hcreate.c in Sources */,
+                               C0E345311C582ECB00E749C2 /* heapsort.c in Sources */,
+                               C0E345321C582ECB00E749C2 /* heapsort_b.c in Sources */,
+                               C0E345331C582ECB00E749C2 /* heapsort_r.c in Sources */,
+                               C0E345341C582ECB00E749C2 /* imaxabs.c in Sources */,
+                               C0E345351C582ECB00E749C2 /* imaxdiv.c in Sources */,
+                               C0E345361C582ECB00E749C2 /* insque.c in Sources */,
+                               C0E345371C582ECB00E749C2 /* labs.c in Sources */,
+                               C0E345381C582ECB00E749C2 /* ldiv.c in Sources */,
+                               C0E345391C582ECB00E749C2 /* llabs.c in Sources */,
+                               C0E3453A1C582ECB00E749C2 /* lldiv.c in Sources */,
+                               C0E3453B1C582ECB00E749C2 /* lsearch.c in Sources */,
+                               C0E3453C1C582ECB00E749C2 /* merge.c in Sources */,
+                               C0E3453D1C582ECB00E749C2 /* putenv.c in Sources */,
+                               C0E3453E1C582ECB00E749C2 /* qsort.c in Sources */,
+                               C0E3453F1C582ECB00E749C2 /* qsort_r.c in Sources */,
+                               C0E345401C582ECB00E749C2 /* radixsort.c in Sources */,
+                               C0E345411C582ECB00E749C2 /* rand.c in Sources */,
+                               C0E345421C582ECB00E749C2 /* random.c in Sources */,
+                               C0E345431C582ECB00E749C2 /* reallocf.c in Sources */,
+                               C0E345441C582ECB00E749C2 /* realpath.c in Sources */,
+                               C0E345451C582ECB00E749C2 /* remque.c in Sources */,
+                               C0E345461C582ECB00E749C2 /* setenv.c in Sources */,
+                               C0E345471C582ECB00E749C2 /* strhash.c in Sources */,
+                               C0E345481C582ECB00E749C2 /* strtoimax.c in Sources */,
+                               C0E345491C582ECB00E749C2 /* strtol.c in Sources */,
+                               C0E3454A1C582ECB00E749C2 /* strtoll.c in Sources */,
+                               C0E3454B1C582ECB00E749C2 /* strtoq.c in Sources */,
+                               C0E3454C1C582ECB00E749C2 /* strtoul.c in Sources */,
+                               C0E3454D1C582ECB00E749C2 /* strtoull.c in Sources */,
+                               C0E3454E1C582ECB00E749C2 /* strtoumax.c in Sources */,
+                               C0E3454F1C582ECB00E749C2 /* strtouq.c in Sources */,
+                               C0E345501C582ECB00E749C2 /* system.c in Sources */,
+                               C0E345511C582ECB00E749C2 /* tdelete.c in Sources */,
+                               C0E345521C582ECB00E749C2 /* tfind.c in Sources */,
+                               C0E345531C582ECB00E749C2 /* tsearch.c in Sources */,
+                               C0E345541C582ECB00E749C2 /* twalk.c in Sources */,
+                               C0E345551C582ECB00E749C2 /* grantpt.c in Sources */,
+                               C0E345561C582ECB00E749C2 /* l64a.c in Sources */,
+                               C0E345571C582ECB00E749C2 /* strfmon.c in Sources */,
+                               C0E345581C582ECB00E749C2 /* ecvt.c in Sources */,
+                               C0E345591C582ECB00E749C2 /* gcvt.c in Sources */,
+                               C0E3455A1C582ECB00E749C2 /* qsort_b-fbsd.c in Sources */,
+                               C0E3455B1C582ECB00E749C2 /* asctime.c in Sources */,
+                               C0E3455C1C582ECB00E749C2 /* difftime.c in Sources */,
+                               C0E3455D1C582ECB00E749C2 /* ftime.c in Sources */,
+                               C0E3455E1C582ECB00E749C2 /* localtime.c in Sources */,
+                               C0E3455F1C582ECB00E749C2 /* strftime.c in Sources */,
+                               C0E345601C582ECB00E749C2 /* strptime.c in Sources */,
+                               C0E345611C582ECB00E749C2 /* time32.c in Sources */,
+                               C0E345621C582ECB00E749C2 /* timelocal.c in Sources */,
+                               C0E345631C582ECB00E749C2 /* getdate.c in Sources */,
+                               C0E345641C582ECB00E749C2 /* timezone_unix03.c in Sources */,
+                               C0E345651C582ECB00E749C2 /* index.c in Sources */,
+                               C0E345661C582ECB00E749C2 /* memmem.c in Sources */,
+                               C0E345671C582ECB00E749C2 /* rindex.c in Sources */,
+                               C0E345681C582ECB00E749C2 /* strcasecmp.c in Sources */,
+                               C0E345691C582ECB00E749C2 /* strcasestr.c in Sources */,
+                               C0E3456A1C582ECB00E749C2 /* strcoll.c in Sources */,
+                               C0E3456B1C582ECB00E749C2 /* strcspn.c in Sources */,
+                               C0E3456C1C582ECB00E749C2 /* strdup.c in Sources */,
+                               C0E3456D1C582ECB00E749C2 /* strerror.c in Sources */,
+                               C0E3456E1C582ECB00E749C2 /* strlen.c in Sources */,
+                               C0E3456F1C582ECB00E749C2 /* strmode.c in Sources */,
+                               C0E345701C582ECB00E749C2 /* strndup.c in Sources */,
+                               C0E345711C582ECB00E749C2 /* strnlen.c in Sources */,
+                               C0E345721C582ECB00E749C2 /* strnstr.c in Sources */,
+                               C0E345731C582ECB00E749C2 /* strpbrk.c in Sources */,
+                               C0E345741C582ECB00E749C2 /* strrchr.c in Sources */,
+                               C0E345751C582ECB00E749C2 /* strsep.c in Sources */,
+                               C0E345761C582ECB00E749C2 /* strsignal.c in Sources */,
+                               C0E345771C582ECB00E749C2 /* strspn.c in Sources */,
+                               C0E345781C582ECB00E749C2 /* strstr.c in Sources */,
+                               C0E345791C582ECB00E749C2 /* strtok.c in Sources */,
+                               C0E3457A1C582ECB00E749C2 /* strxfrm.c in Sources */,
+                               C0E3457B1C582ECB00E749C2 /* swab.c in Sources */,
+                               C0E3457C1C582ECB00E749C2 /* wcpcpy.c in Sources */,
+                               C0E3457D1C582ECB00E749C2 /* wcpncpy.c in Sources */,
+                               C0E3457E1C582ECB00E749C2 /* wcscasecmp.c in Sources */,
+                               C0E3457F1C582ECB00E749C2 /* wcscat.c in Sources */,
+                               C0E345801C582ECB00E749C2 /* wcschr.c in Sources */,
+                               C0E345811C582ECB00E749C2 /* wcscmp.c in Sources */,
+                               C0E345821C582ECB00E749C2 /* wcscoll.c in Sources */,
+                               C0E345831C582ECB00E749C2 /* wcscpy.c in Sources */,
+                               C0E345841C582ECB00E749C2 /* wcscspn.c in Sources */,
+                               C0E345851C582ECB00E749C2 /* wcsdup.c in Sources */,
+                               C0E345861C582ECB00E749C2 /* wcslcat.c in Sources */,
+                               C0E345871C582ECB00E749C2 /* wcslcpy.c in Sources */,
+                               C0E345881C582ECB00E749C2 /* wcslen.c in Sources */,
+                               C0E345891C582ECB00E749C2 /* wcsncasecmp.c in Sources */,
+                               C0E3458A1C582ECB00E749C2 /* wcsncat.c in Sources */,
+                               C0E3458B1C582ECB00E749C2 /* wcsncmp.c in Sources */,
+                               C0E3458C1C582ECB00E749C2 /* wcsncpy.c in Sources */,
+                               C0E3458D1C582ECB00E749C2 /* wcsnlen.c in Sources */,
+                               C0E3458E1C582ECB00E749C2 /* wcspbrk.c in Sources */,
+                               C0E3458F1C582ECB00E749C2 /* wcsrchr.c in Sources */,
+                               C0E345901C582ECB00E749C2 /* wcsspn.c in Sources */,
+                               C0E345911C582ECB00E749C2 /* wcsstr.c in Sources */,
+                               C0E345921C582ECB00E749C2 /* wcstok.c in Sources */,
+                               C0E345931C582ECB00E749C2 /* wcswidth.c in Sources */,
+                               C0E345941C582ECB00E749C2 /* wcsxfrm.c in Sources */,
+                               C0E345951C582ECB00E749C2 /* wmemchr.c in Sources */,
+                               C0E345961C582ECB00E749C2 /* wmemcmp.c in Sources */,
+                               C0E345971C582ECB00E749C2 /* wmemcpy.c in Sources */,
+                               C0E345981C582ECB00E749C2 /* wmemmove.c in Sources */,
+                               C0E345991C582ECB00E749C2 /* wmemset.c in Sources */,
+                               C0E3459A1C582ECB00E749C2 /* _libc_init.c in Sources */,
+                               C0E3459B1C582ECB00E749C2 /* _libc_fork_child.c in Sources */,
+                               C0E3459C1C582ECB00E749C2 /* chmodx_np.c in Sources */,
+                               C0E3459D1C582ECB00E749C2 /* crt_externs.c in Sources */,
+                               C0E3459E1C582ECB00E749C2 /* fork.c in Sources */,
+                               C0E3459F1C582ECB00E749C2 /* getgroups.c in Sources */,
+                               C0E345A01C582ECB00E749C2 /* gettimeofday.c in Sources */,
+                               C0E345A11C582ECB00E749C2 /* msgctl.c in Sources */,
+                               C0E345A21C582ECB00E749C2 /* stack_protector.c in Sources */,
+                               C0E345A31C582ECB00E749C2 /* openx_np.c in Sources */,
+                               C0E345A41C582ECB00E749C2 /* OSMemoryNotification.c in Sources */,
+                               C0E345A51C582ECB00E749C2 /* OSThermalNotification.c in Sources */,
+                               C0E345A61C582ECB00E749C2 /* posix_spawn.c in Sources */,
+                               C0E345A71C582ECB00E749C2 /* semctl.c in Sources */,
+                               C0E345A81C582ECB00E749C2 /* settimeofday.c in Sources */,
+                               C0E345A91C582ECB00E749C2 /* shmctl.c in Sources */,
+                               C0E345AA1C582ECB00E749C2 /* sigaction.c in Sources */,
+                               C0E345AB1C582ECB00E749C2 /* (null) in Sources */,
+                               C0E345AC1C582ECB00E749C2 /* statx_np.c in Sources */,
+                               C0E345AD1C582ECB00E749C2 /* umaskx_np.c in Sources */,
+                               C0E345AE1C582ECB00E749C2 /* fparseln.c in Sources */,
+                               C0E345AF1C582ECB00E749C2 /* login.c in Sources */,
+                               C0E345B01C582ECB00E749C2 /* login_tty.c in Sources */,
+                               C0E345B11C582ECB00E749C2 /* logout.c in Sources */,
+                               C0E345B21C582ECB00E749C2 /* logwtmp.c in Sources */,
+                               C0E345B31C582ECB00E749C2 /* mkpath_np.c in Sources */,
+                               C0E345B41C582ECB00E749C2 /* opendev.c in Sources */,
+                               C0E345B51C582ECB00E749C2 /* pty.c in Sources */,
+                               C0E345B61C582ECB00E749C2 /* clear.c in Sources */,
+                               C0E345B71C582ECB00E749C2 /* compare.c in Sources */,
+                               C0E345B81C582ECB00E749C2 /* copy.c in Sources */,
+                               C0E345B91C582ECB00E749C2 /* gen_uuid.c in Sources */,
+                               C0E345BA1C582ECB00E749C2 /* isnull.c in Sources */,
+                               C0E345BB1C582ECB00E749C2 /* pack.c in Sources */,
+                               C0E345BC1C582ECB00E749C2 /* parse.c in Sources */,
+                               C0E345BD1C582ECB00E749C2 /* unpack.c in Sources */,
+                               C0E345BE1C582ECB00E749C2 /* unparse.c in Sources */,
+                               C0E345BF1C582ECB00E749C2 /* (null) in Sources */,
+                               C0E345C01C582ECB00E749C2 /* (null) in Sources */,
+                               C0E345C11C582ECB00E749C2 /* (null) in Sources */,
+                               C0E345C21C582ECB00E749C2 /* (null) in Sources */,
+                               C0E345C31C582ECB00E749C2 /* scandir_b.c in Sources */,
+                               C0E345C41C582ECB00E749C2 /* init_cpu_capabilities.c in Sources */,
+                               C0E345C51C582ECB00E749C2 /* pthread_getspecific.s in Sources */,
+                               C0E345C61C582ECB00E749C2 /* pthread_self.s in Sources */,
+                               C0E345C71C582ECB00E749C2 /* pthread_set_self.s in Sources */,
+                               C0E345C81C582ECB00E749C2 /* start_wqthread.s in Sources */,
+                               C0E345C91C582ECB00E749C2 /* thread_start.s in Sources */,
+                               C0E345CA1C582ECB00E749C2 /* strcpy.c in Sources */,
+                               C0E345CB1C582ECB00E749C2 /* strlcpy.c in Sources */,
+                               C0E345CC1C582ECB00E749C2 /* strncpy.c in Sources */,
+                               C0E345CD1C582ECB00E749C2 /* stpcpy.c in Sources */,
+                               C0E345CE1C582ECB00E749C2 /* stpncpy.c in Sources */,
+                               C0E345CF1C582ECB00E749C2 /* strcat.c in Sources */,
+                               C0E345D01C582ECB00E749C2 /* strncat.c in Sources */,
+                               C0E345D11C582ECB00E749C2 /* strlcat.c in Sources */,
+                               C0E345D21C582ECB00E749C2 /* sync_volume_np.c in Sources */,
+                               C0E345D31C582ECB00E749C2 /* dirfd.c in Sources */,
+                               C0E345D41C582ECB00E749C2 /* eos_stubs.c in Sources */,
+                               C0E345D51C582ECB00E749C2 /* strnlen.s in Sources */,
+                               C0E345D61C582ECB00E749C2 /* assumes.c in Sources */,
+                               C0E345D71C582ECB00E749C2 /* inet_ntop.c in Sources */,
+                               C0E345D81C582ECB00E749C2 /* inet_pton.c in Sources */,
+                               C0E345D91C582ECB00E749C2 /* memccpy_chk.c in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                C9257ECC138E1B5000B3107C /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                                C9257F34138E1C8200B3107C /* pause.c in Sources */,
                                C9257F35138E1C8200B3107C /* popen.c in Sources */,
                                C9257F37138E1C8200B3107C /* psignal.c in Sources */,
-                               C9257F38138E1C8200B3107C /* raise.c in Sources */,
                                C9257F39138E1C8200B3107C /* readdir.c in Sources */,
                                C9257F3A138E1C8200B3107C /* readpassphrase.c in Sources */,
                                C9257F3B138E1C8200B3107C /* rewinddir.c in Sources */,
                                C94210EE13900C8A004BA536 /* getvfsbyname.c in Sources */,
                                C94210F313900C8A004BA536 /* nanosleep.c in Sources */,
                                C94210F413900C8A004BA536 /* utmpx.c in Sources */,
+                               147CDFD91B7C232100831EC6 /* clock_gettime.c in Sources */,
                                C94210F513900C8A004BA536 /* nftw.c in Sources */,
                                C94210F613900C8A004BA536 /* nlist.c in Sources */,
                                C94210F813900C8A004BA536 /* oldsyslog.c in Sources */,
                                C95B7F44138F3C55004311DA /* disklabel.c in Sources */,
                                C95B7F45138F3C55004311DA /* errlst.c in Sources */,
                                C95B7F46138F3C55004311DA /* filesec.c in Sources */,
+                               147CDFDD1B7C233000831EC6 /* clock_gettime.c in Sources */,
                                C95B7F47138F3C55004311DA /* _rand48.c in Sources */,
                                C95B7F48138F3C55004311DA /* alarm.c in Sources */,
                                C95B7F49138F3C55004311DA /* arc4random.c in Sources */,
                                C95B81EF138F52B0004311DA /* disklabel.c in Sources */,
                                C95B81F0138F52B0004311DA /* errlst.c in Sources */,
                                C95B81F1138F52B0004311DA /* filesec.c in Sources */,
+                               147CDFDE1B7C233100831EC6 /* clock_gettime.c in Sources */,
                                C95B81F2138F52B0004311DA /* _rand48.c in Sources */,
                                C95B81F3138F52B0004311DA /* alarm.c in Sources */,
                                C95B81F4138F52B0004311DA /* arc4random.c in Sources */,
                                C95B8495138F53DB004311DA /* disklabel.c in Sources */,
                                C95B8496138F53DB004311DA /* errlst.c in Sources */,
                                C95B8497138F53DB004311DA /* filesec.c in Sources */,
+                               147CDFDF1B7C233100831EC6 /* clock_gettime.c in Sources */,
                                C95B8498138F53DB004311DA /* _rand48.c in Sources */,
                                C95B8499138F53DB004311DA /* alarm.c in Sources */,
                                C95B849A138F53DB004311DA /* arc4random.c in Sources */,
                                C97A713C1517AF53005E1998 /* wbuf.c in Sources */,
                                C97A713D1517AF53005E1998 /* wprintf.c in Sources */,
                                C97A713E1517AF53005E1998 /* wscanf.c in Sources */,
+                               147CDFDA1B7C232900831EC6 /* clock_gettime.c in Sources */,
                                C97A713F1517AF53005E1998 /* wsetup.c in Sources */,
                                C97A71401517AF53005E1998 /* a64l.c in Sources */,
                                C97A71411517AF53005E1998 /* _Exit_.c in Sources */,
                        files = (
                                C9C2A959138E025700287F00 /* sigaltstk.c in Sources */,
                                C9C2A95A138E025700287F00 /* sigcompat.c in Sources */,
+                               147CDFDB1B7C232A00831EC6 /* clock_gettime.c in Sources */,
                                C9C2A97D138E058200287F00 /* brk.c in Sources */,
                                C9C2A97E138E058200287F00 /* bsd_signal.c in Sources */,
                                C9C2A97F138E058200287F00 /* lchflags.c in Sources */,
                                C9A12978138E10C40003880A /* login_tty.c in Sources */,
                                C9A12979138E10C40003880A /* logwtmp.c in Sources */,
                                3F76864713E91CBC00C94D25 /* mkpath_np.c in Sources */,
+                               3F34A15D1C4AA80B000D4A82 /* raise.c in Sources */,
                                C9A1297A138E10C40003880A /* opendev.c in Sources */,
                                C9A1297B138E10C40003880A /* pty.c in Sources */,
                                C9A1297C138E10FB0003880A /* clear.c in Sources */,
                        buildActionMask = 2147483647;
                        files = (
                                C9D94333138DB75B00FB7ACC /* forceLibcToBuild.c in Sources */,
-                               C965CBF2143BBEC7003912CE /* deps.c in Sources */,
+                               92ABC7E91D375FC2000DF880 /* compatibility_hacks.c in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                C9765F19138EC61900741512 /* disklabel.c in Sources */,
                                C9765F1A138EC61900741512 /* errlst.c in Sources */,
                                C9765F1B138EC61900741512 /* filesec.c in Sources */,
+                               147CDFDC1B7C232F00831EC6 /* clock_gettime.c in Sources */,
                                C9765F1C138EC61900741512 /* _rand48.c in Sources */,
                                C9765F1D138EC61900741512 /* alarm.c in Sources */,
                                C9765F1E138EC61900741512 /* arc4random.c in Sources */,
                                C9EB314B138F6D880075BB52 /* fgetwln.c in Sources */,
                                C9EB314C138F6D880075BB52 /* fgetws.c in Sources */,
                                C9EB314D138F6D880075BB52 /* fileno.c in Sources */,
+                               147CDFE01B7C233200831EC6 /* clock_gettime.c in Sources */,
                                C9EB314E138F6D880075BB52 /* findfp.c in Sources */,
                                C9EB314F138F6D880075BB52 /* flags.c in Sources */,
                                C9EB3150138F6D880075BB52 /* fopen.c in Sources */,
                                C9EB33F2138F75580075BB52 /* fgetwln.c in Sources */,
                                C9EB33F3138F75580075BB52 /* fgetws.c in Sources */,
                                C9EB33F4138F75580075BB52 /* fileno.c in Sources */,
+                               147CDFE11B7C233300831EC6 /* clock_gettime.c in Sources */,
                                C9EB33F5138F75580075BB52 /* findfp.c in Sources */,
                                C9EB33F6138F75580075BB52 /* flags.c in Sources */,
                                C9EB33F7138F75580075BB52 /* fopen.c in Sources */,
                        target = 3F51206A16C3174300AFB431 /* FortifySource */;
                        targetProxy = 3F51211616C318EB00AFB431 /* PBXContainerItemProxy */;
                };
-               925E7FFB19E8946700AC7889 /* PBXTargetDependency */ = {
+               928F25D51BEAD2AE007B13C7 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
-                       name = all;
-                       targetProxy = 925E7FFA19E8946700AC7889 /* PBXContainerItemProxy */;
+                       target = 928F25D01BEACED7007B13C7 /* darwintests */;
+                       targetProxy = 928F25D41BEAD2AE007B13C7 /* PBXContainerItemProxy */;
                };
                B122F2D91432BA8700AF95D0 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = B122F0E71432B8E600AF95D0 /* TRE */;
                        targetProxy = B122F2D81432BA8700AF95D0 /* PBXContainerItemProxy */;
                };
+               C0E343841C582ECB00E749C2 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = C9C2A94C138DFFD900287F00 /* Base */;
+                       targetProxy = C0E343851C582ECB00E749C2 /* PBXContainerItemProxy */;
+               };
+               C0E343861C582ECB00E749C2 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = C9257ECF138E1B5000B3107C /* FreeBSD */;
+                       targetProxy = C0E343871C582ECB00E749C2 /* PBXContainerItemProxy */;
+               };
+               C0E343881C582ECB00E749C2 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = B122F0E71432B8E600AF95D0 /* TRE */;
+                       targetProxy = C0E343891C582ECB00E749C2 /* PBXContainerItemProxy */;
+               };
+               C0E3438A1C582ECB00E749C2 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = C9D9435F138EC3E300FB7ACC /* Variant_Cancelable */;
+                       targetProxy = C0E3438B1C582ECB00E749C2 /* PBXContainerItemProxy */;
+               };
+               C0E3438C1C582ECB00E749C2 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = C95B7ED9138F3C55004311DA /* Variant_DarwinExtsn */;
+                       targetProxy = C0E3438D1C582ECB00E749C2 /* PBXContainerItemProxy */;
+               };
+               C0E345E61C58323000E749C2 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = C0E343831C582ECB00E749C2 /* libc_static */;
+                       targetProxy = C0E345E51C58323000E749C2 /* PBXContainerItemProxy */;
+               };
                C925D2011518FA5D003D315B /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = C95B7ED9138F3C55004311DA /* Variant_DarwinExtsn */;
                };
                C942130913901709004BA536 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
-                       target = C942102D13900C8A004BA536 /* libc.a */;
+                       target = C942102D13900C8A004BA536 /* libc_dyld */;
                        targetProxy = C942130813901709004BA536 /* PBXContainerItemProxy */;
                };
                C95B817D138F3F72004311DA /* PBXTargetDependency */ = {
                        };
                        name = Release;
                };
+               928F25D21BEACED7007B13C7 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                       };
+                       name = Debug;
+               };
+               928F25D31BEACED7007B13C7 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                       };
+                       name = Release;
+               };
                B122F2AB1432B8E600AF95D0 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                        };
                        name = Release;
                };
+               C0E345E01C582ECB00E749C2 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = C0E345E31C58300F00E749C2 /* libc_static.xcconfig */;
+                       buildSettings = {
+                               PRODUCT_NAME = "$(PRODUCT_NAME)";
+                       };
+                       name = Debug;
+               };
+               C0E345E11C582ECB00E749C2 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = C0E345E31C58300F00E749C2 /* libc_static.xcconfig */;
+                       buildSettings = {
+                               PRODUCT_NAME = "$(PRODUCT_NAME)";
+                       };
+                       name = Release;
+               };
                C9257ED1138E1B5000B3107C /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                EXECUTABLE_PREFIX = lib;
                                INCLUDED_SOURCE_FILE_NAMES = "$(VARIANT_INCLUDED_SOURCE_FILE_NAMES)";
                                INSTALL_PATH = /usr/local/lib/dyld;
-                               PRODUCT_NAME = c;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       /usr/lib/system,
+                               );
+                               PRODUCT_NAME = c_dyld;
                                SKIP_INSTALL = NO;
                                STRIP_INSTALLED_PRODUCT = NO;
                                VARIANT = DYLD;
                                EXECUTABLE_PREFIX = lib;
                                INCLUDED_SOURCE_FILE_NAMES = "$(VARIANT_INCLUDED_SOURCE_FILE_NAMES)";
                                INSTALL_PATH = /usr/local/lib/dyld;
-                               PRODUCT_NAME = c;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       /usr/lib/system,
+                               );
+                               PRODUCT_NAME = c_dyld;
                                SKIP_INSTALL = NO;
                                STRIP_INSTALLED_PRODUCT = NO;
                                VARIANT = DYLD;
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               928F25D11BEACED7007B13C7 /* Build configuration list for PBXLegacyTarget "darwintests" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               928F25D21BEACED7007B13C7 /* Debug */,
+                               928F25D31BEACED7007B13C7 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
                B122F2AA1432B8E600AF95D0 /* Build configuration list for PBXNativeTarget "TRE" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               C0E345DF1C582ECB00E749C2 /* Build configuration list for PBXNativeTarget "libc_static" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               C0E345E01C582ECB00E749C2 /* Debug */,
+                               C0E345E11C582ECB00E749C2 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
                C9257ED3138E1B5000B3107C /* Build configuration list for PBXNativeTarget "FreeBSD" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
-               C94212C913900C8A004BA536 /* Build configuration list for PBXNativeTarget "libc.a" */ = {
+               C94212C913900C8A004BA536 /* Build configuration list for PBXNativeTarget "libc_dyld" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                                C94212CA13900C8A004BA536 /* Debug */,
diff --git a/Platforms/bridgeos/Makefile.inc b/Platforms/bridgeos/Makefile.inc
new file mode 100644 (file)
index 0000000..dcb0cc6
--- /dev/null
@@ -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
diff --git a/darwin/compatibility_hacks.c b/darwin/compatibility_hacks.c
new file mode 100644 (file)
index 0000000..04a2dd8
--- /dev/null
@@ -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 */
index b0b8b04ede2f973a9e7e725404f2819f6d66af0c..1521ca21a825140563d9c910d0ccda4b32e139a7 100644 (file)
@@ -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;
index 44015afec2029a063b58d76787c17744db3e887a..d8d55026ace6d9df66c8a9ff7679163dcabe30eb 100644 (file)
@@ -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 <provos@physnet.uni-hamburg.de>
 .\" All rights reserved.
 .\"
 .\" 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 .
index e443335adc5a8a9a8e6e4282e8a7e60b3047e13e..e49f56b403fdc2496efa090bcf4b20f6e99676a2 100644 (file)
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/gen/arc4random.c,v 1.25 2008/09/09 09:46:36 ache Exp $");
 
-#include "namespace.h"
 #include <sys/types.h>
 #include <sys/time.h>
-#include <stdlib.h>
+#include <sys/param.h>
+#include <sys/random.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <pthread.h>
+#include <os/assumes.h>
+#include <os/lock.h>
 
+#include "string.h"
 #include "libc_private.h"
-#include "un-namespace.h"
+
+#define CACHE_LENGTH 64
+#define BUFFERSIZE 32
+
+#define INITIAL_COUNT 1600000
+#define MAX_BUF_COUNT 4096
+
+static os_unfair_lock arc4_lock = OS_UNFAIR_LOCK_INIT;
+static int arc4_count;
+
+uint64_t arc4random64(void);
+
+#define        RANDOMDEV       "/dev/random"
+
+static void
+_my_getentropy(uint8_t *buf, size_t size){
+    int fd;
+       ssize_t ret;
+       if (getentropy(buf, size) == 0) {
+               return;
+       }
+
+       // The above should never fail, but we'll try /dev/random anyway
+       fd = open(RANDOMDEV, O_RDONLY, 0);
+       if (fd == -1) {
+#if !defined(VARIANT_STATIC)
+               os_crash("arc4random: unable to open /dev/random");
+#else
+               abort();
+#endif
+       }
+shortread:
+       ret = read(fd, buf, size);
+       if (ret == -1) {
+#if !defined(VARIANT_STATIC)
+               os_crash("arc4random: unable to read from /dev/random");
+#else
+               abort();
+#endif
+       } else if ((size_t)ret < size) {
+               size -= (size_t)ret;
+               buf += ret;
+               goto shortread;
+       }
+       (void)close(fd);
+}
+
+#if defined(__APPLE__) && !defined(VARIANT_STATIC)
+#include <corecrypto/ccdrbg.h>
+#include <corecrypto/ccaes.h>
+
+static struct ccdrbg_info rng_info;
+static struct ccdrbg_nistctr_custom rng_custom;
+static struct ccdrbg_state *rng_state;
+
+static int cache_pos = CACHE_LENGTH;
+static uint32_t rand_buffer[CACHE_LENGTH];
+
+static void
+arc4_init(void)
+{
+       if (rng_state != NULL) return;
+
+       uint8_t entropy[BUFFERSIZE];
+       int ret;
+       rng_custom.ecb = ccaes_ecb_encrypt_mode();
+       rng_custom.keylen = 16;
+       rng_custom.strictFIPS = 0;
+       rng_custom.use_df = 1;
+       ccdrbg_factory_nistctr(&rng_info, &rng_custom);
+       rng_state = malloc(rng_info.size);
+       os_assert(rng_state != NULL);
+
+       _my_getentropy(entropy, BUFFERSIZE);
+
+       ret = ccdrbg_init(&rng_info, rng_state,
+                               sizeof(entropy), entropy,
+                               0, NULL, 0, NULL);
+       os_assert_zero(ret);
+
+       memset_s(entropy, sizeof(entropy), 0, sizeof(entropy));
+
+       arc4_count = INITIAL_COUNT;
+}
+
+static void
+arc4_stir(void)
+{
+       uint8_t entropy[BUFFERSIZE];
+       int ret;
+
+       arc4_init();
+
+       _my_getentropy(entropy, BUFFERSIZE);
+
+       ret = ccdrbg_reseed(&rng_info, rng_state,
+                               sizeof(entropy), entropy,
+                               0, NULL);
+       os_assert_zero(ret);
+
+       memset_s(entropy, sizeof(entropy), 0, sizeof(entropy));
+
+       arc4_count = INITIAL_COUNT;
+}
+
+void
+arc4random_addrandom(__unused u_char *dat, __unused int datlen)
+{
+    /* NOP - deprecated */
+}
+
+uint32_t
+arc4random(void)
+{
+       int ret;
+       os_unfair_lock_lock(&arc4_lock);
+       arc4_init();
+       if (arc4_count <= 0) {
+           arc4_stir();
+       }
+       if (cache_pos >= CACHE_LENGTH) {
+               ret = ccdrbg_generate(&rng_info, rng_state, sizeof(rand_buffer), rand_buffer, 0, NULL);
+               os_assert_zero(ret);
+               cache_pos = 0;
+       }
+       uint32_t rand = rand_buffer[cache_pos];
+       // Delete the current random number from buffer
+       memset_s(rand_buffer+cache_pos, sizeof(rand_buffer[cache_pos]), 0, sizeof(rand_buffer[cache_pos]));
+       arc4_count--;
+       cache_pos++;
+       os_unfair_lock_unlock(&arc4_lock);
+       return rand;
+}
+
+void
+arc4random_buf(void *_buf, size_t buf_size)
+{
+       uint8_t *buf = _buf;
+       os_unfair_lock_lock(&arc4_lock);
+       arc4_init();
+       while (buf_size > 0) {
+               if (arc4_count <= 0 ) {
+                       arc4_stir();
+               }
+               size_t n = MIN(buf_size, (size_t)MIN(MAX_BUF_COUNT, arc4_count) * sizeof(uint32_t));
+               int ret = ccdrbg_generate(&rng_info, rng_state, n, buf, 0, NULL);
+               os_assert_zero(ret);
+               buf_size -= n;
+               buf += n;
+               arc4_count -= n/sizeof(uint32_t);
+
+               if (buf_size > 0) {
+                       os_unfair_lock_unlock(&arc4_lock);
+                       // Give others a chance to get the lock
+                       os_unfair_lock_lock(&arc4_lock);
+               }
+       }
+       os_unfair_lock_unlock(&arc4_lock);
+}
+
+__private_extern__ void
+_arc4_fork_child(void)
+{
+       arc4_lock = OS_UNFAIR_LOCK_INIT;
+       cache_pos = CACHE_LENGTH;
+       if (rng_state != NULL) {
+               arc4_count = 0;
+               memset_s(rand_buffer, sizeof(rand_buffer), 0, sizeof(rand_buffer));
+               memset_s(rng_state, rng_info.size, 0, rng_info.size);
+               free(rng_state); rng_state = NULL;
+               bzero(&rng_info, sizeof(rng_info));
+               bzero(&rng_custom, sizeof(rng_custom));
+       }
+}
+
+#else /* __APPLE__ && !VARIANT_STATIC */
 
 struct arc4_stream {
        u_int8_t i;
@@ -52,23 +230,7 @@ struct arc4_stream {
        u_int8_t s[256];
 };
 
-static int lock = 0;
-extern void spin_lock(int*);
-extern void spin_unlock(int*);
-
-#define        RANDOMDEV       "/dev/random"
 #define KEYSIZE                128
-#define        THREAD_LOCK()                                           \
-       do {                                                    \
-               if (__isthreaded)                               \
-                       spin_lock(&lock);                       \
-       } while (0)
-
-#define        THREAD_UNLOCK()                                         \
-       do {                                                    \
-               if (__isthreaded)                               \
-                       spin_unlock(&lock);                     \
-       } while (0)
 
 static struct arc4_stream rs = {
        .i = 0,
@@ -93,7 +255,6 @@ static struct arc4_stream rs = {
        }
 };
 static int rs_stired;
-static int arc4_count;
 
 static inline u_int8_t arc4_getbyte(void);
 static void arc4_stir(void);
@@ -125,19 +286,7 @@ arc4_addrandom(u_char *dat, int datlen)
 static void
 arc4_fetch(void)
 {
-       int done, fd;
-       fd = _open(RANDOMDEV, O_RDONLY, 0);
-       done = 0;
-       if (fd >= 0) {
-               if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
-                       done = 1;
-               (void)_close(fd);
-       } 
-       if (!done) {
-               (void)gettimeofday(&rdat.tv, NULL);
-               rdat.pid = getpid();
-               /* We'll just take whatever was on the stack too... */
-       }
+       _my_getentropy((uint8_t*)&rdat, KEYSIZE);
 }
 
 static void
@@ -202,6 +351,7 @@ arc4_getword(void)
 __private_extern__ void
 _arc4_fork_child(void)
 {
+       arc4_lock = OS_UNFAIR_LOCK_INIT;
        rs_stired = 0;
        rs_data_available = 0;
 }
@@ -216,21 +366,13 @@ arc4_check_stir(void)
        return 0;
 }
 
-void
-arc4random_stir(void)
-{
-       THREAD_LOCK();
-       arc4_stir();
-       THREAD_UNLOCK();
-}
-
 void
 arc4random_addrandom(u_char *dat, int datlen)
 {
-       THREAD_LOCK();
+       os_unfair_lock_lock(&arc4_lock);
        arc4_check_stir();
        arc4_addrandom(dat, datlen);
-       THREAD_UNLOCK();
+       os_unfair_lock_unlock(&arc4_lock);
 }
 
 u_int32_t
@@ -238,13 +380,13 @@ arc4random(void)
 {
        u_int32_t rnd;
 
-       THREAD_LOCK();
+       os_unfair_lock_lock(&arc4_lock);
 
        int did_stir = arc4_check_stir();
        rnd = arc4_getword();
        arc4_count -= 4;
 
-       THREAD_UNLOCK();
+       os_unfair_lock_unlock(&arc4_lock);
        if (did_stir)
        {
                /* stirring used up our data pool, we need to read in new data outside of the lock */
@@ -262,7 +404,7 @@ arc4random_buf(void *_buf, size_t n)
        u_char *buf = (u_char *)_buf;
        int did_stir = 0;
 
-       THREAD_LOCK();
+       os_unfair_lock_lock(&arc4_lock);
 
        while (n--) {
                if (arc4_check_stir())
@@ -272,8 +414,8 @@ arc4random_buf(void *_buf, size_t n)
                buf[n] = arc4_getbyte();
                arc4_count--;
        }
-       
-       THREAD_UNLOCK();
+
+       os_unfair_lock_unlock(&arc4_lock);
        if (did_stir)
        {
                /* stirring used up our data pool, we need to read in new data outside of the lock */
@@ -283,68 +425,53 @@ arc4random_buf(void *_buf, size_t n)
        }
 }
 
+#endif /* __APPLE__ */
+
+void
+arc4random_stir(void)
+{
+       os_unfair_lock_lock(&arc4_lock);
+       arc4_stir();
+       os_unfair_lock_unlock(&arc4_lock);
+}
+
 /*
  * Calculate a uniformly distributed random number less than upper_bound
  * avoiding "modulo bias".
  *
- * Uniformity is achieved by generating new random numbers until the one
- * returned is outside the range [0, 2**32 % upper_bound).  This
- * guarantees the selected random number will be inside
- * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
- * after reduction modulo upper_bound.
+ * Uniformity is achieved by trying successive ranges of bits from the random
+ * value, each large enough to hold the desired upper bound, until a range
+ * holding a value less than the bound is found.
  */
-u_int32_t
-arc4random_uniform(u_int32_t upper_bound)
+uint32_t
+arc4random_uniform(uint32_t upper_bound)
 {
-       u_int32_t r, min;
-
        if (upper_bound < 2)
-               return (0);
-
-#if (ULONG_MAX > 0xffffffffUL)
-       min = 0x100000000UL % upper_bound;
-#else
-       /* Calculate (2**32 % upper_bound) avoiding 64-bit math */
-       if (upper_bound > 0x80000000)
-               min = 1 + ~upper_bound;         /* 2**32 - upper_bound */
-       else {
-               /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */
-               min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
-       }
-#endif
-
-       /*
-        * This could theoretically loop forever but each retry has
-        * p > 0.5 (worst case, usually far better) of selecting a
-        * number inside the range we need, so it should rarely need
-        * to re-roll.
-        */
-       for (;;) {
-               r = arc4random();
-               if (r >= min)
-                       break;
-       }
+               return 0;
 
-       return (r % upper_bound);
-}
+       // find smallest 2**n -1 >= upper_bound
+       int zeros = __builtin_clz(upper_bound);
+       int bits = CHAR_BIT * sizeof(uint32_t) - zeros;
+       uint32_t mask = 0xFFFFFFFFU >> zeros;
 
-#if 0
-/*-------- Test code for i386 --------*/
-#include <stdio.h>
-#include <machine/pctr.h>
-int
-main(int argc, char **argv)
-{
-       const int iter = 1000000;
-       int     i;
-       pctrval v;
+       do {
+               uint32_t value = arc4random();
 
-       v = rdtsc();
-       for (i = 0; i < iter; i++)
-               arc4random();
-       v = rdtsc() - v;
-       v /= iter;
+               // If low 2**n-1 bits satisfy the requested condition, return result
+               uint32_t result = value & mask;
+               if (result < upper_bound) {
+                       return result;
+               }
 
-       printf("%qd cycles\n", v);
+               // otherwise consume remaining bits of randomness looking for a satisfactory result.
+               int bits_left = zeros;
+               while (bits_left >= bits) {
+                       value >>= bits;
+                       result = value & mask;
+                       if (result < upper_bound) {
+                               return result;
+                       }
+                       bits_left -= bits;
+               }
+       } while (1);
 }
-#endif
index a9300b3e109034bfc2b32ca28b08b6898631d907..e37802c01b66c3b608bdb66d544d38811eedb409 100644 (file)
@@ -1,33 +1,22 @@
+.\" $OpenBSD: basename.3,v 1.20 2007/05/31 19:19:28 jmc Exp $
 .\"
 .\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
-.\" 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.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\"    derived from this software without specific prior written permission.
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
 .\"
-.\" THIS SOFTWARE IS PROVIDED ``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 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.
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.\" $OpenBSD: basename.3,v 1.12 2000/04/18 03:01:25 aaron Exp $
-.\" $FreeBSD: src/lib/libc/gen/basename.3,v 1.7 2004/07/02 23:52:10 ru Exp $
+.\" $FreeBSD$
 .\"
-.Dd August 17, 1997
+.Dd March 31, 2010
 .Dt BASENAME 3
 .Os
 .Sh NAME
 .Sh SYNOPSIS
 .In libgen.h
 .Ft char *
-.Fo basename
-.Fa "char *path"
-.Fc
+.Fn basename "char *path"
+.Ft char *
+.Fn basename_r "const char *path" "char *bname"
 .Sh DESCRIPTION
 The
 .Fn basename
-function
-returns the last component from the pathname pointed to by
+function returns the last component from the pathname pointed to by
 .Fa path ,
 deleting any trailing
 .Sq \&/
@@ -60,15 +48,30 @@ If
 is a null pointer or the empty string, a pointer to the string
 .Qq \&.
 is returned.
+.Pp
+The
+.Fn basename_r
+variation accepts a buffer of at least
+.Dv MAXPATHLEN
+bytes in which to store the resulting component.
+.Sh IMPLEMENTATION NOTES
+The
+.Fn basename
+function
+returns a pointer to internal storage space allocated on the first call
+that will be overwritten
+by subsequent calls.
+.Fn basename_r
+is therefore preferred for threaded applications.
 .Sh RETURN VALUES
 On successful completion,
 .Fn basename
-returns a pointer to the last component of
+and
+.Fn basename_r
+return pointers to the last component of
 .Fa path .
 .Pp
-If
-.Fn basename
-fails, a null pointer is returned and the global variable
+If they fail, a null pointer is returned and the global variable
 .Va errno
 is set to indicate the error.
 .Sh ERRORS
@@ -79,31 +82,10 @@ The following error codes may be set in
 The path component to be returned was larger than
 .Dv MAXPATHLEN .
 .El
-.Sh WARNINGS
-The
-.Fn basename
-function
-returns a pointer to internal static storage space
-that will be overwritten by subsequent calls.
-The function may modify the string pointed to by
-.Fa path .
-.Sh LEGACY SYNOPSIS
-.Fd #include <libgen.h>
-.Pp
-.Ft char *
-.br
-.Fo basename
-.Fa "const char *path"
-.Fc ;
-.Pp
-In legacy mode,
-.Fa path
-will not be changed.
 .Sh SEE ALSO
 .Xr basename 1 ,
 .Xr dirname 1 ,
-.Xr dirname 3 ,
-.Xr compat 5
+.Xr dirname 3
 .Sh STANDARDS
 The
 .Fn basename
@@ -116,5 +98,19 @@ function first appeared in
 .Ox 2.2
 and
 .Fx 4.2 .
+The
+.Fn basename_r
+function first appeared in OS X 10.12.
 .Sh AUTHORS
-.An "Todd C. Miller" Aq Todd.Miller@courtesan.com
+.An Todd C. Miller
+.Sh CAVEATS
+.Fn basename
+returns a pointer to internal static storage space that will be overwritten
+by subsequent calls.
+.Pp
+Other vendor implementations of
+.Fn basename
+may modify the contents of the string passed to
+.Fn basename ;
+this should be taken into account when writing code which calls this function
+if portability is desired.
index 3de44fb2927ec423112793ec1df1afa3ad260b2e..140ccbb6a08741be8f94aed7dfbb45da2fd12d40 100644 (file)
@@ -39,38 +39,29 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/basename.c,v 1.7 2002/12/30 01:41:14 marcel
 #include <string.h>
 #include <sys/param.h>
 
-#if __DARWIN_UNIX03
-#define const /**/
-#endif
-
 char *
-basename(path)
-       const char *path;
+basename_r(const char *path, char *bname)
 {
-       static char *bname = NULL;
        const char *endp, *startp;
-
-       if (bname == NULL) {
-               bname = (char *)malloc(MAXPATHLEN);
-               if (bname == NULL)
-                       return(NULL);
-       }
+       size_t len;
 
        /* Empty or NULL string gets treated as "." */
        if (path == NULL || *path == '\0') {
-               (void)strcpy(bname, ".");
-               return(bname);
+               bname[0] = '.';
+               bname[1] = '\0';
+               return (bname);
        }
 
-       /* Strip trailing slashes */
+       /* Strip any trailing slashes */
        endp = path + strlen(path) - 1;
        while (endp > path && *endp == '/')
                endp--;
 
        /* All slashes becomes "/" */
        if (endp == path && *endp == '/') {
-               (void)strcpy(bname, "/");
-               return(bname);
+               bname[0] = '/';
+               bname[1] = '\0';
+               return (bname);
        }
 
        /* Find the start of the base */
@@ -78,11 +69,29 @@ basename(path)
        while (startp > path && *(startp - 1) != '/')
                startp--;
 
-       if (endp - startp + 2 > MAXPATHLEN) {
+       len = endp - startp + 1;
+       if (len >= MAXPATHLEN) {
                errno = ENAMETOOLONG;
-               return(NULL);
+               return (NULL);
+       }
+       memcpy(bname, startp, len);
+       bname[len] = '\0';
+       return (bname);
+}
+
+#if __DARWIN_UNIX03
+#define const /**/
+#endif
+
+char *
+basename(const char *path)
+{
+       static char *bname = NULL;
+
+       if (bname == NULL) {
+               bname = (char *)malloc(MAXPATHLEN);
+               if (bname == NULL)
+                       return (NULL);
        }
-       (void)strncpy(bname, startp, endp - startp + 1);
-       bname[endp - startp + 1] = '\0';
-       return(bname);
+       return (basename_r(path, bname));
 }
index 1869d0992538febd6eb2a84233f599f8d28acc13..2b79771784e650326981e7a3112e0b11b51e734e 100644 (file)
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)clock.3    8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/gen/clock.3,v 1.12 2007/01/09 00:27:53 imp Exp $
+.\" $FreeBSD$
 .\"
 .Dd June 4, 1993
 .Dt CLOCK 3
@@ -58,8 +58,7 @@ The
 function returns the amount of time used unless an error occurs, in which
 case the return value is \-1.
 .Sh SEE ALSO
-.Xr getrusage 2 ,
-.Xr clocks 7
+.Xr getrusage 2
 .Sh STANDARDS
 The
 .Fn clock
index 2085245e5a14e65127a1f65d9bc4909d8fcb87da..c1ba2973790770cfefa43efe32066a0b48337c3c 100644 (file)
@@ -26,9 +26,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)ctermid.3  8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/gen/ctermid.3,v 1.12 2007/01/09 00:27:53 imp Exp $
+.\" $FreeBSD$
 .\"
-.Dd June 4, 1993
+.Dd October 1, 2011
 .Dt CTERMID 3
 .Os
 .Sh NAME
 .Sh SYNOPSIS
 .In stdio.h
 .Ft char *
-.Fn ctermid "char *s"
+.Fn ctermid "char *buf"
 .Ft char *
-.Fn ctermid_r "char *s"
+.Fn ctermid_r "char *buf"
 .Sh DESCRIPTION
 The
 .Fn ctermid
-function generates a string that, when used as a pathname, refers to
+function generates a string, that, when used as a pathname, refers to
 the current controlling terminal of the calling process.
 .Pp
 If
-.Fa s
+.Fa buf
 is the
 .Dv NULL
 pointer, a pointer to a static area is returned.
 Otherwise, the pathname is copied into the memory referenced by
-.Fa s .
+.Fa buf .
 The argument
-.Fa s
+.Fa buf
 is assumed to be at least
 .Dv L_ctermid
 (as defined in the include
@@ -69,9 +69,9 @@ The
 .Fn ctermid_r
 function
 provides the same functionality as
-.Fn ctermid ,
+.Fn ctermid
 except that if
-.Fa s
+.Fa buf
 is a
 .Dv NULL
 pointer,
@@ -81,14 +81,18 @@ is returned.
 The current implementation simply returns
 .Ql /dev/tty .
 .Sh RETURN VALUES
-Upon successful completion, a
-.Pf non- Dv NULL
-pointer is returned.
-Otherwise, a
-.Dv NULL
-pointer is returned and the global variable
-.Va errno
-is set to indicate the error.
+The
+.Fn ctermid
+function returns
+.Fa buf
+if it is
+.Pf non- Dv NULL ,
+otherwise it returns the address of a static buffer.
+The
+.Fn ctermid_r
+function always returns
+.Fa buf ,
+even if it is the NULL pointer.
 .Sh ERRORS
 The current implementation detects no error conditions.
 .Sh SEE ALSO
index 330b426402d01dec533ca088deb85456b6d502d2..9c9d7f10fef537a17c24ccf492551f840ba69178 100644 (file)
 .Fo dirname
 .Fa "char *path"
 .Fc
+.Ft char *
+.Fo dirname_r
+.Fa "const char *path" "char *dname"
+.Fc
 .Sh DESCRIPTION
 The
 .Fn dirname
@@ -55,6 +59,8 @@ function
 returns a pointer to internal storage space allocated on the first call
 that will be overwritten
 by subsequent calls.
+.Fn dirname_r
+is therefore preferred for threaded applications.
 .Pp
 Other vendor implementations of
 .Fn dirname
@@ -92,6 +98,10 @@ The following error codes may be set in
 .It Bq Er ENAMETOOLONG
 The path component to be returned was larger than
 .Dv MAXPATHLEN .
+.It Bq Er ENOMEM
+The static buffer used for storing the path in
+.Fn dirname
+could not be allocated.
 .El
 .Sh SEE ALSO
 .Xr basename 1 ,
@@ -110,5 +120,8 @@ function first appeared in
 .Ox 2.2
 and
 .Fx 4.2 .
+The
+.Fn dirname_r
+function first appeared in OS X 10.12.
 .Sh AUTHORS
 .An "Todd C. Miller"
index 5164e185d3223bb2e1b9a06ba36068969bb7fd4a..c291a0636a9523734bdd96fac9f45834d41c2b29 100644 (file)
@@ -25,22 +25,11 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/dirname.c,v 1.8 2008/11/03 05:19:45 delphij
 #include <string.h>
 #include <sys/param.h>
 
-#if __DARWIN_UNIX03
-#define const /**/
-#endif
-
 char *
-dirname(const char *path)
+dirname_r(const char *path, char *dname)
 {
-       static char *dname = NULL;
-       size_t len;
        const char *endp;
-
-       if (dname == NULL) {
-               dname = (char *)malloc(MAXPATHLEN);
-               if (dname == NULL)
-                       return(NULL);
-       }
+       size_t len;
 
        /* Empty or NULL string gets treated as "." */
        if (path == NULL || *path == '\0') {
@@ -79,3 +68,20 @@ dirname(const char *path)
        dname[len] = '\0';
        return (dname);
 }
+
+#if __DARWIN_UNIX03
+#define const /**/
+#endif
+
+char *
+dirname(const char *path)
+{
+       static char *dname = NULL;
+
+       if (dname == NULL) {
+               dname = (char *)malloc(MAXPATHLEN);
+               if (dname == NULL)
+                       return (NULL);
+       }
+       return (dirname_r(path, dname));
+}
index 39fac8a587bf27924882540de47a0b65a007d900..aec34223d4934a4d0e1f0249534c0c907f602666 100644 (file)
@@ -159,7 +159,7 @@ err_set_file(void *fp)
 void
 err_set_exit(void (*ef)(int))
 {
-       _e_err_exit.type = ERR_EXIT_FUNC;
+       _e_err_exit.type = ef ? ERR_EXIT_FUNC : ERR_EXIT_UNDEF;
        _e_err_exit.func = ef;
 }
 
@@ -167,7 +167,7 @@ err_set_exit(void (*ef)(int))
 void
 err_set_exit_b(void (^ef)(int))
 {
-       _e_err_exit.type = ERR_EXIT_BLOCK;
+       _e_err_exit.type = ef ? ERR_EXIT_BLOCK : ERR_EXIT_UNDEF;
        _e_err_exit.block = Block_copy(ef);
 }
 #endif /* __BLOCKS__ */
index 55d33485637a554c9db2984dc42788b8bac205ce..2caf5fe1cb77abf342220cbd9f0ec68bc31a2aa6 100644 (file)
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)getbsize.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/gen/getbsize.3,v 1.11 2007/01/09 00:27:53 imp Exp $
+.\" $FreeBSD$
 .\"
-.Dd June 4, 1993
+.Dd November 16, 2012
 .Dt GETBSIZE 3
 .Os
 .Sh NAME
 .Nm getbsize
-.Nd get user block size
+.Nd get preferred block size
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
 .Sh DESCRIPTION
 The
 .Fn getbsize
-function determines the user's preferred block size based on the value of the
-.Dq BLOCKSIZE
-environment variable; see
-.Xr environ 7
-for details on its use and format.
+function returns a preferred block size for reporting by system utilities
+.Xr df 1 ,
+.Xr du 1 ,
+.Xr ls 1
+and
+.Xr systat 1 ,
+based on the value of the
+.Ev BLOCKSIZE
+environment variable.
+.Ev BLOCKSIZE
+may be specified directly in bytes, or in multiples of a kilobyte by
+specifying a number followed by ``K'' or ``k'', in multiples of a
+megabyte by specifying a number followed by ``M'' or ``m'' or in
+multiples of a gigabyte by specifying a number followed by ``G'' or
+``g''.
+Multiples must be integers.
+.Pp
+Valid values of
+.Ev BLOCKSIZE
+are 512 bytes to 1 gigabyte.
+Sizes less than 512 bytes are rounded up to 512 bytes, and sizes
+greater than 1 GB are rounded down to 1 GB.
+In each case
+.Fn getbsize
+produces a warning message.
 .Pp
 The
 .Fn getbsize
@@ -61,10 +81,6 @@ terminating null).
 The memory referenced by
 .Fa blocksizep
 is filled in with block size, in bytes.
-.Pp
-If the user's block size is unreasonable, a warning message is
-written to standard error and the returned information reflects
-a block size of 512 bytes.
 .Sh SEE ALSO
 .Xr df 1 ,
 .Xr du 1 ,
index b213c37fb4965a0bde27614d956ed7a5918e34ec..bbf5b1e89686776a7151c98259c7486bfb2d713e 100644 (file)
@@ -31,7 +31,7 @@
 static char sccsid[] = "@(#)getbsize.c 8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/gen/getbsize.c,v 1.9 2008/08/04 06:53:13 cperciva Exp $");
+__FBSDID("$FreeBSD$");
 
 #include <err.h>
 #include <stdio.h>
@@ -39,9 +39,7 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/getbsize.c,v 1.9 2008/08/04 06:53:13 cperci
 #include <string.h>
 
 char *
-getbsize(headerlenp, blocksizep)
-       int *headerlenp;
-       long *blocksizep;
+getbsize(int *headerlenp, long *blocksizep)
 {
        static char header[20];
        long n, max, mul, blocksize;
index 5a9e943f5af998285bf87dbe11ea9ef948984d5f..ce4efc2fbc6665c5828723caef29823be7d214ed 100644 (file)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/getlogin.c,v 1.11 2009/12/05 19:04:21 ed Ex
 #include <errno.h>
 #include <pwd.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include "namespace.h"
diff --git a/gen/FreeBSD/raise.c b/gen/FreeBSD/raise.c
deleted file mode 100644 (file)
index e9665e8..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- *     The Regents of the University of California.  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.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)raise.c    8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/gen/raise.c,v 1.5 2007/01/09 00:27:55 imp Exp $");
-
-#include <signal.h>
-#include <unistd.h>
-
-__weak_reference(__raise, raise);
-__weak_reference(__raise, _raise);
-
-int
-__raise(s)
-       int s;
-{
-       return(kill(getpid(), s));
-}
index 3bd3617424690fb00c21a12cc773d4ccfe6c3f0b..9f74b2f4305afa6a05911a8525388c7f9aafd109 100644 (file)
@@ -1,33 +1,26 @@
-.\"    $OpenBSD: readpassphrase.3,v 1.7 2001/12/15 15:37:51 millert Exp $
+.\"    $OpenBSD: readpassphrase.3,v 1.17 2007/05/31 19:19:28 jmc Exp $
 .\"
-.\" Copyright (c) 2000 Todd C. Miller <Todd.Miller@courtesan.com>
-.\" All rights reserved.
+.\" Copyright (c) 2000, 2002 Todd C. Miller <Todd.Miller@courtesan.com>
 .\"
-.\" 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.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\"    derived from this software without specific prior written permission.
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
 .\"
-.\" THIS SOFTWARE IS PROVIDED ``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 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.
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.\" $FreeBSD: src/lib/libc/gen/readpassphrase.3,v 1.7 2005/01/20 09:17:02 ru Exp $
+.\" Sponsored in part by the Defense Advanced Research Projects
+.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
+.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
 .\"
-.Dd December 7, 2001
+.\" $FreeBSD$
+.\"
+.Dd May 31, 2007
 .Dt READPASSPHRASE 3
 .Os
 .Sh NAME
@@ -79,6 +72,8 @@ force input to lower case
 force input to upper case
 .It Dv RPP_SEVENBIT
 strip the high bit from input
+.It Dv RPP_STDIN
+force read of passphrase from stdin
 .El
 .Pp
 The calling process should zero the passphrase as soon as possible to
@@ -87,7 +82,7 @@ space.
 .Sh RETURN VALUES
 Upon successful completion,
 .Fn readpassphrase
-returns a pointer to the null-terminated passphrase.
+returns a pointer to the NUL-terminated passphrase.
 If an error is encountered, the terminal state is restored and
 a
 .Dv NULL
@@ -117,40 +112,6 @@ if (compare(transform(passbuf), epass) != 0)
 
 memset(passbuf, 0, sizeof(passbuf));
 .Ed
-.Sh SIGNALS
-The
-.Fn readpassphrase
-function
-will catch the following signals:
-.Pp
-.Bl -tag -compact
-.It Dv SIGINT
-.It Dv SIGHUP
-.It Dv SIGQUIT
-.It Dv SIGTERM
-.It Dv SIGTSTP
-.It Dv SIGTTIN
-.It Dv SIGTTOU
-.El
-.Pp
-When one of the above signals is intercepted, terminal echo will
-be restored if it had previously been turned off.
-If a signal handler was installed for the signal when
-.Fn readpassphrase
-was called that handler is then executed.
-If no handler was previously installed for the signal then the
-default action is taken as per
-.Xr sigaction 2 .
-.Pp
-The
-.Dv SIGTSTP , SIGTTIN ,
-and
-.Dv SIGTTOU
-signals (stop signal generated from keyboard or due to terminal I/O
-from a background process) are treated specially.
-When the process is resumed after it has been stopped,
-.Fn readpassphrase
-will reprint the prompt and the user may then enter a passphrase.
 .Sh ERRORS
 .Bl -tag -width Er
 .It Bq Er EINTR
@@ -159,14 +120,14 @@ The
 function was interrupted by a signal.
 .It Bq Er EINVAL
 The
-.Fa bufsiz
+.Ar bufsiz
 argument was zero.
 .It Bq Er EIO
 The process is a member of a background process attempting to read
 from its controlling terminal, the process is ignoring or blocking
 the
 .Dv SIGTTIN
-signal or the process group is orphaned.
+signal, or the process group is orphaned.
 .It Bq Er EMFILE
 The process has already reached its limit for open file descriptors.
 .It Bq Er ENFILE
@@ -176,6 +137,35 @@ There is no controlling terminal and the
 .Dv RPP_REQUIRE_TTY
 flag was specified.
 .El
+.Sh SIGNALS
+The
+.Fn readpassphrase
+function
+will catch the following signals:
+.Bd -literal -offset indent
+SIGALRM                SIGHUP          SIGINT
+SIGPIPE                SIGQUIT         SIGTERM
+SIGTSTP                SIGTTIN         SIGTTOU
+.Ed
+.Pp
+When one of the above signals is intercepted, terminal echo will
+be restored if it had previously been turned off.
+If a signal handler was installed for the signal when
+.Fn readpassphrase
+was called, that handler is then executed.
+If no handler was previously installed for the signal then the
+default action is taken as per
+.Xr sigaction 2 .
+.Pp
+The
+.Dv SIGTSTP , SIGTTIN
+and
+.Dv SIGTTOU
+signals (stop signals generated from keyboard or due to terminal I/O
+from a background process) are treated specially.
+When the process is resumed after it has been stopped,
+.Fn readpassphrase
+will reprint the prompt and the user may then enter a passphrase.
 .Sh SEE ALSO
 .Xr sigaction 2 ,
 .Xr getpass 3
@@ -189,3 +179,5 @@ The
 .Fn readpassphrase
 function first appeared in
 .Ox 2.9 .
+.Dv RPP_STDIN
+was introduced in OS X 10.12.
index 3bd6a6a5fa63ef2d00ca032bee166e32f9b27776..646a8c6d82dda32f256ae6622a17c739d9eb8630 100644 (file)
@@ -1,37 +1,27 @@
-/*     $OpenBSD: readpassphrase.c,v 1.12 2001/12/15 05:41:00 millert Exp $     */
+/*     $OpenBSD: readpassphrase.c,v 1.24 2013/11/24 23:51:29 deraadt Exp $     */
 
 /*
- * Copyright (c) 2000 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
+ * Copyright (c) 2000-2002, 2007, 2010
+ *     Todd C. Miller <Todd.Miller@courtesan.com>
  *
- * 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.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
  *
- * THIS SOFTWARE IS PROVIDED ``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 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.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.12 2001/12/15 05:41:00 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/gen/readpassphrase.c,v 1.6 2002/03/09 03:16:41 green Exp $");
 
 #include "xlocale_private.h"
 
@@ -47,8 +37,9 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/readpassphrase.c,v 1.6 2002/03/09 03:16:41
 #include <unistd.h>
 #include <readpassphrase.h>
 #include "un-namespace.h"
+#include "libc_private.h"
 
-static volatile sig_atomic_t signo;
+static volatile int signo[NSIG];
 
 static void handler(int);
 
@@ -56,11 +47,11 @@ char *
 readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
 {
        ssize_t nr;
-       int input, output, save_errno;
+       int input, output, save_errno, i, need_restart, input_is_tty;
        char ch, *p, *end;
        struct termios term, oterm;
-       struct sigaction sa, saveint, savehup, savequit, saveterm;
-       struct sigaction savetstp, savettin, savettou;
+       struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm;
+       struct sigaction savetstp, savettin, savettou, savepipe;
        locale_t loc = __current_locale();
 
        /* I suppose we could alloc on demand in this case (XXX). */
@@ -70,59 +61,83 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
        }
 
 restart:
+       for (i = 0; i < NSIG; i++)
+               signo[i] = 0;
+       nr = -1;
+       save_errno = 0;
+       need_restart = 0;
        /*
         * Read and write to /dev/tty if available.  If not, read from
         * stdin and write to stderr unless a tty is required.
         */
-       if ((input = output = _open(_PATH_TTY, O_RDWR)) == -1) {
-               if (flags & RPP_REQUIRE_TTY) {
-                       errno = ENOTTY;
-                       return(NULL);
+       input_is_tty = 0;
+       if (!(flags & RPP_STDIN)) {
+               input = output = _open(_PATH_TTY, O_RDWR | O_CLOEXEC);
+               if (input == -1) {
+                       if (flags & RPP_REQUIRE_TTY) {
+                               errno = ENOTTY;
+                               return(NULL);
+                       }
+                       input = STDIN_FILENO;
+                       output = STDERR_FILENO;
+               } else {
+                       input_is_tty = 1;
                }
+       } else {
                input = STDIN_FILENO;
                output = STDERR_FILENO;
        }
 
+       /*
+        * Turn off echo if possible.
+        * If we are using a tty but are not the foreground pgrp this will
+        * generate SIGTTOU, so do it *before* installing the signal handlers.
+        */
+       if (input_is_tty && tcgetattr(input, &oterm) == 0) {
+               memcpy(&term, &oterm, sizeof(term));
+               if (!(flags & RPP_ECHO_ON))
+                       term.c_lflag &= ~(ECHO | ECHONL);
+               if (term.c_cc[VSTATUS] != _POSIX_VDISABLE)
+                       term.c_cc[VSTATUS] = _POSIX_VDISABLE;
+               (void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &term);
+       } else {
+               memset(&term, 0, sizeof(term));
+               term.c_lflag |= ECHO;
+               memset(&oterm, 0, sizeof(oterm));
+               oterm.c_lflag |= ECHO;
+       }
+
        /*
         * Catch signals that would otherwise cause the user to end
         * up with echo turned off in the shell.  Don't worry about
-        * things like SIGALRM and SIGPIPE for now.
+        * things like SIGXCPU and SIGVTALRM for now.
         */
        sigemptyset(&sa.sa_mask);
        sa.sa_flags = 0;                /* don't restart system calls */
        sa.sa_handler = handler;
-       (void)_sigaction(SIGINT, &sa, &saveint);
+       (void)_sigaction(SIGALRM, &sa, &savealrm);
        (void)_sigaction(SIGHUP, &sa, &savehup);
+       (void)_sigaction(SIGINT, &sa, &saveint);
+       (void)_sigaction(SIGPIPE, &sa, &savepipe);
        (void)_sigaction(SIGQUIT, &sa, &savequit);
        (void)_sigaction(SIGTERM, &sa, &saveterm);
        (void)_sigaction(SIGTSTP, &sa, &savetstp);
        (void)_sigaction(SIGTTIN, &sa, &savettin);
        (void)_sigaction(SIGTTOU, &sa, &savettou);
 
-       /* Turn off echo if possible. */
-       if (tcgetattr(input, &oterm) == 0) {
-               memcpy(&term, &oterm, sizeof(term));
-               if (!(flags & RPP_ECHO_ON))
-                       term.c_lflag &= ~(ECHO | ECHONL);
-               if (term.c_cc[VSTATUS] != _POSIX_VDISABLE)
-                       term.c_cc[VSTATUS] = _POSIX_VDISABLE;
-               (void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &term);
-       } else {
-               memset(&term, 0, sizeof(term));
-               memset(&oterm, 0, sizeof(oterm));
-       }
-
-       (void)_write(output, prompt, strlen(prompt));
+       if (!(flags & RPP_STDIN))
+               (void)_write(output, prompt, strlen(prompt));
        end = buf + bufsiz - 1;
-       for (p = buf; (nr = _read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r';) {
+       p = buf;
+       while ((nr = _read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r') {
                if (p < end) {
                        if ((flags & RPP_SEVENBIT))
                                ch &= 0x7f;
                        if (isalpha_l(ch, loc)) {
                                if ((flags & RPP_FORCELOWER))
-                                       ch = tolower_l(ch, loc);
+                                       ch = (char)tolower_l(ch, loc);
                                if ((flags & RPP_FORCEUPPER))
-                                       ch = toupper_l(ch, loc);
+                                       ch = (char)toupper_l(ch, loc);
                        }
                        *p++ = ch;
                }
@@ -133,34 +148,43 @@ restart:
                (void)_write(output, "\n", 1);
 
        /* Restore old terminal settings and signals. */
-       if (memcmp(&term, &oterm, sizeof(term)) != 0)
-               (void)tcsetattr(input, TCSANOW|TCSASOFT, &oterm);
-       (void)_sigaction(SIGINT, &saveint, NULL);
+       if (memcmp(&term, &oterm, sizeof(term)) != 0) {
+               while (tcsetattr(input, TCSAFLUSH|TCSASOFT, &oterm) == -1 &&
+                   errno == EINTR && !signo[SIGTTOU])
+                       continue;
+       }
+       (void)_sigaction(SIGALRM, &savealrm, NULL);
        (void)_sigaction(SIGHUP, &savehup, NULL);
+       (void)_sigaction(SIGINT, &saveint, NULL);
        (void)_sigaction(SIGQUIT, &savequit, NULL);
+       (void)_sigaction(SIGPIPE, &savepipe, NULL);
        (void)_sigaction(SIGTERM, &saveterm, NULL);
        (void)_sigaction(SIGTSTP, &savetstp, NULL);
        (void)_sigaction(SIGTTIN, &savettin, NULL);
        (void)_sigaction(SIGTTOU, &savettou, NULL);
-       if (input != STDIN_FILENO)
+       if (input_is_tty)
                (void)_close(input);
 
        /*
         * If we were interrupted by a signal, resend it to ourselves
         * now that we have restored the signal handlers.
         */
-       if (signo) {
-               kill(getpid(), signo); 
-               switch (signo) {
-               case SIGTSTP:
-               case SIGTTIN:
-               case SIGTTOU:
-                       signo = 0;
-                       goto restart;
+       for (i = 0; i < NSIG; i++) {
+               if (signo[i]) {
+                       kill(getpid(), i);
+                       switch (i) {
+                       case SIGTSTP:
+                       case SIGTTIN:
+                       case SIGTTOU:
+                               need_restart = 1;
+                       }
                }
        }
+       if (need_restart)
+               goto restart;
 
-       errno = save_errno;
+       if (save_errno)
+               errno = save_errno;
        return(nr == -1 ? NULL : buf);
 }
 
@@ -185,6 +209,5 @@ getpass(const char *prompt)
 
 static void handler(int s)
 {
-
-       signo = s;
+       signo[s] = 1;
 }
index 7205820f6882a422b37593f3b500d2e723e969c4..c890aae011ac529b2e043c7d8b1de390dec4e1c6 100644 (file)
@@ -47,11 +47,8 @@ extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
     void *newp, size_t newlen);
 
 int
-sysctl(name, namelen, oldp, oldlenp, newp, newlen)
-       int *name;
-       u_int namelen;
-       void *oldp, *newp;
-       size_t *oldlenp, newlen;
+sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+__attribute__((disable_tail_calls))
 {
        if (name[0] != CTL_USER) {
                if (namelen == 2 && name[0] == CTL_KERN && name[1] == KERN_EXEC) {
index f8e5f01d09ebb604763ed8ac6b9614176c732907..261c1aebc1aa360472bc390b9677d8715a82057d 100644 (file)
@@ -9,10 +9,6 @@
 .\" 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.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"    This product includes software developed by the University of
-.\"    California, Berkeley and its contributors.
 .\" 4. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
@@ -30,9 +26,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)times.3    8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/gen/times.3,v 1.10 2001/10/01 16:08:51 ru Exp $
+.\" $FreeBSD$
 .\"
-.Dd June 4, 1993
+.Dd December 1, 2008
 .Dt TIMES 3
 .Os
 .Sh NAME
@@ -43,9 +39,7 @@
 .Sh SYNOPSIS
 .In sys/times.h
 .Ft clock_t
-.Fo times
-.Fa "struct tms *buffer"
-.Fc
+.Fn times "struct tms *tp"
 .Sh DESCRIPTION
 .Bf -symbolic
 This interface is obsoleted by
@@ -63,7 +57,7 @@ of a second since
 Time.
 .Pp
 It also fills in the structure pointed to by
-.Fa buffer
+.Fa tp
 with time-accounting information.
 .Pp
 The
@@ -136,8 +130,7 @@ and
 .Xr time 1 ,
 .Xr getrusage 2 ,
 .Xr gettimeofday 2 ,
-.Xr wait 2 ,
-.Xr clocks 7
+.Xr wait 2
 .Sh STANDARDS
 The
 .Fn times
index cee1e61b83893d14619762ac1604028b8d9140b0..73b91da6087e27792318a1b775c29c1dd25ee4df 100644 (file)
@@ -1,3 +1,6 @@
+.\"    $NetBSD: unvis.3,v 1.27 2012/12/15 07:34:36 wiz Exp $
+.\"    $FreeBSD$
+.\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
@@ -9,7 +12,7 @@
 .\" 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.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
@@ -26,9 +29,8 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)unvis.3    8.2 (Berkeley) 12/11/93
-.\" $FreeBSD: src/lib/libc/gen/unvis.3,v 1.18 2007/01/09 00:27:56 imp Exp $
 .\"
-.Dd December 11, 1993
+.Dd March 12, 2011
 .Dt UNVIS 3
 .Os
 .Sh NAME
 .Ft int
 .Fn strunvis "char *dst" "const char *src"
 .Ft int
+.Fn strnunvis "char *dst" "size_t dlen" "const char *src"
+.Ft int
 .Fn strunvisx "char *dst" "const char *src" "int flag"
+.Ft int
+.Fn strnunvisx "char *dst" "size_t dlen" "const char *src" "int flag"
 .Sh DESCRIPTION
 The
 .Fn unvis ,
@@ -57,37 +63,37 @@ by the
 .Xr vis 3
 function, back into
 the original form.
-Unvis is called with successive characters in
-.Fa c
-until a valid
-sequence is recognized, at which time the decoded character is
-available at the character pointed to by
-.Fa cp .
-Strunvis decodes the
-characters pointed to by
-.Fa src
-into the buffer pointed to by
-.Fa dst .
+.Pp
+The
+.Fn unvis
+function is called with successive characters in
+.Ar c
+until a valid sequence is recognized, at which time the decoded
+character is available at the character pointed to by
+.Ar cp .
 .Pp
 The
 .Fn strunvis
-function
-simply copies
-.Fa src
+function decodes the characters pointed to by
+.Ar src
+into the buffer pointed to by
+.Ar dst .
+The
+.Fn strunvis
+function simply copies
+.Ar src
 to
-.Fa dst ,
+.Ar dst ,
 decoding any escape sequences along the way,
 and returns the number of characters placed into
-.Fa dst ,
+.Ar dst ,
 or \-1 if an
 invalid escape sequence was detected.
 The size of
-.Fa dst
-should be
-equal to the size of
-.Fa src
-(that is, no expansion takes place during
-decoding).
+.Ar dst
+should be equal to the size of
+.Ar src
+(that is, no expansion takes place during decoding).
 .Pp
 The
 .Fn strunvisx
@@ -95,58 +101,53 @@ function does the same as the
 .Fn strunvis
 function,
 but it allows you to add a flag that specifies the style the string
-.Fa src
+.Ar src
 is encoded with.
-Currently, the only supported flag is
-.Dv VIS_HTTPSTYLE .
+Currently, the supported flags are:
+.Dv VIS_HTTPSTYLE
+and
+.Dv VIS_MIMESTYLE .
 .Pp
 The
 .Fn unvis
-function
-implements a state machine that can be used to decode an arbitrary
-stream of bytes.
-All state associated with the bytes being decoded
-is stored outside the
+function implements a state machine that can be used to decode an
+arbitrary stream of bytes.
+All state associated with the bytes being decoded is stored outside the
 .Fn unvis
 function (that is, a pointer to the state is passed in), so
 calls decoding different streams can be freely intermixed.
-To
-start decoding a stream of bytes, first initialize an integer
-to zero.
+To start decoding a stream of bytes, first initialize an integer to zero.
 Call
 .Fn unvis
 with each successive byte, along with a pointer
 to this integer, and a pointer to a destination character.
 The
 .Fn unvis
-function
-has several return codes that must be handled properly.
+function has several return codes that must be handled properly.
 They are:
 .Bl -tag -width UNVIS_VALIDPUSH
-.It Li \&0 (zero)
+.It Li \&0 No (zero)
 Another character is necessary; nothing has been recognized yet.
 .It Dv UNVIS_VALID
 A valid character has been recognized and is available at the location
-pointed to by cp.
+pointed to by
+.Fa cp .
 .It Dv UNVIS_VALIDPUSH
 A valid character has been recognized and is available at the location
-pointed to by cp; however, the character currently passed in should
-be passed in again.
+pointed to by
+.Fa cp ;
+however, the character currently passed in should be passed in again.
 .It Dv UNVIS_NOCHAR
 A valid sequence was detected, but no character was produced.
-This
-return code is necessary to indicate a logical break between characters.
+This return code is necessary to indicate a logical break between characters.
 .It Dv UNVIS_SYNBAD
-An invalid escape sequence was detected, or the decoder is in an
-unknown state.
+An invalid escape sequence was detected, or the decoder is in an unknown state.
 The decoder is placed into the starting state.
 .El
 .Pp
 When all bytes in the stream have been processed, call
 .Fn unvis
-one more time with
-.Fa flag
-set to
+one more time with flag set to
 .Dv UNVIS_END
 to extract any remaining character (the character passed in is ignored).
 .Pp
@@ -154,9 +155,26 @@ The
 .Fa flag
 argument is also used to specify the encoding style of the source.
 If set to
-.Dv VIS_HTTPSTYLE ,
+.Dv VIS_HTTPSTYLE
+or
+.Dv VIS_HTTP1808 ,
 .Fn unvis
 will decode URI strings as specified in RFC 1808.
+If set to
+.Dv VIS_HTTP1866 ,
+.Fn unvis
+will decode entity references and numeric character references
+as specified in RFC 1866.
+If set to
+.Dv VIS_MIMESTYLE ,
+.Fn unvis
+will decode MIME Quoted-Printable strings as specified in RFC 2045.
+If set to
+.Dv VIS_NOESCAPE ,
+.Fn unvis
+will not decode
+.Ql \e
+quoted characters.
 .Pp
 The following code fragment illustrates a proper use of
 .Fn unvis .
@@ -166,25 +184,51 @@ char out;
 
 while ((ch = getchar()) != EOF) {
 again:
-       switch(unvis(&out, ch, &state, 0)) {
+       switch(unvis(\*[Am]out, ch, \*[Am]state, 0)) {
        case 0:
        case UNVIS_NOCHAR:
                break;
        case UNVIS_VALID:
-               (void) putchar(out);
+               (void)putchar(out);
                break;
        case UNVIS_VALIDPUSH:
-               (void) putchar(out);
+               (void)putchar(out);
                goto again;
        case UNVIS_SYNBAD:
-               (void)fprintf(stderr, "bad sequence!\en");
-       exit(1);
+               errx(EXIT_FAILURE, "Bad character sequence!");
        }
 }
-if (unvis(&out, (char)0, &state, UNVIS_END) == UNVIS_VALID)
-       (void) putchar(out);
+if (unvis(\*[Am]out, '\e0', \*[Am]state, UNVIS_END) == UNVIS_VALID)
+       (void)putchar(out);
 .Ed
+.Sh ERRORS
+The functions
+.Fn strunvis ,
+.Fn strnunvis ,
+.Fn strunvisx ,
+and
+.Fn strnunvisx
+will return \-1 on error and set
+.Va errno
+to:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+An invalid escape sequence was detected, or the decoder is in an unknown state.
+.El
+.Pp
+In addition the functions
+.Fn strnunvis
+and
+.Fn strnunvisx
+will can also set
+.Va errno
+on error to:
+.Bl -tag -width Er
+.It Bq Er ENOSPC
+Not enough space to perform the conversion.
+.El
 .Sh SEE ALSO
+.Xr unvis 1 ,
 .Xr vis 1 ,
 .Xr vis 3
 .Rs
@@ -198,3 +242,18 @@ The
 function
 first appeared in
 .Bx 4.4 .
+The
+.Fn strnunvis
+and
+.Fn strnunvisx
+functions appeared in OS X 10.12.
+.Sh BUGS
+The names
+.Dv VIS_HTTP1808
+and
+.Dv VIS_HTTP1866
+are wrong.
+Percent-encoding was defined in RFC 1738, the original RFC for URL.
+RFC 1866 defines HTML 2.0, an application of SGML, from which it
+inherits concepts of numeric character references and entity
+references.
index da2efbf306237e90c74d4a48d96bdfef041020fa..f8ff22b69c0240fbaaaf6fe8c2840b1e770f9d96 100644 (file)
@@ -1,3 +1,5 @@
+/*     $NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $  */
+
 /*-
  * Copyright (c) 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -10,7 +12,7 @@
  * 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.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
+#if 0
 static char sccsid[] = "@(#)unvis.c    8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $");
+#endif
 #endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/gen/unvis.c,v 1.10 2007/01/09 00:27:56 imp Exp $");
-
 #include "xlocale_private.h"
 
 #include <sys/types.h>
+
+#include <assert.h>
 #include <ctype.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <errno.h>
 #include <vis.h>
 
+#define        _DIAGASSERT(x)  assert(x)
+
+/*
+ * Return the number of elements in a statically-allocated array,
+ * __x.
+ */
+#define        __arraycount(__x)       (sizeof(__x) / sizeof(__x[0]))
+
+#if !HAVE_VIS
 /*
  * decode driven by state machine
  */
@@ -49,12 +67,128 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/unvis.c,v 1.10 2007/01/09 00:27:56 imp Exp
 #define        S_CTRL          4       /* control char started (^) */
 #define        S_OCTAL2        5       /* octal digit 2 */
 #define        S_OCTAL3        6       /* octal digit 3 */
-#define        S_HEX2          7       /* hex digit 2 */
-
-#define        S_HTTP          0x080   /* %HEXHEX escape */
+#define        S_HEX           7       /* mandatory hex digit */
+#define        S_HEX1          8       /* http hex digit */
+#define        S_HEX2          9       /* http hex digit 2 */
+#define        S_MIME1         10      /* mime hex digit 1 */
+#define        S_MIME2         11      /* mime hex digit 2 */
+#define        S_EATCRNL       12      /* mime eating CRNL */
+#define        S_AMP           13      /* seen & */
+#define        S_NUMBER        14      /* collecting number */
+#define        S_STRING        15      /* collecting string */
 
 #define        isoctal(c)      (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#define        ishex(c)        ((((u_char)(c)) >= '0' && ((u_char)(c)) <= '9') || (((u_char)(c)) >= 'a' && ((u_char)(c)) <= 'f'))
+#define        xtod(c)         (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
+#define        XTOD(c)         (isdigit(c) ? (c - '0') : ((c - 'A') + 10))
+
+/*
+ * RFC 1866
+ */
+static const struct nv {
+       char name[7];
+       uint8_t value;
+} nv[] = {
+       { "AElig",      198 }, /* capital AE diphthong (ligature)  */
+       { "Aacute",     193 }, /* capital A, acute accent  */
+       { "Acirc",      194 }, /* capital A, circumflex accent  */
+       { "Agrave",     192 }, /* capital A, grave accent  */
+       { "Aring",      197 }, /* capital A, ring  */
+       { "Atilde",     195 }, /* capital A, tilde  */
+       { "Auml",       196 }, /* capital A, dieresis or umlaut mark  */
+       { "Ccedil",     199 }, /* capital C, cedilla  */
+       { "ETH",        208 }, /* capital Eth, Icelandic  */
+       { "Eacute",     201 }, /* capital E, acute accent  */
+       { "Ecirc",      202 }, /* capital E, circumflex accent  */
+       { "Egrave",     200 }, /* capital E, grave accent  */
+       { "Euml",       203 }, /* capital E, dieresis or umlaut mark  */
+       { "Iacute",     205 }, /* capital I, acute accent  */
+       { "Icirc",      206 }, /* capital I, circumflex accent  */
+       { "Igrave",     204 }, /* capital I, grave accent  */
+       { "Iuml",       207 }, /* capital I, dieresis or umlaut mark  */
+       { "Ntilde",     209 }, /* capital N, tilde  */
+       { "Oacute",     211 }, /* capital O, acute accent  */
+       { "Ocirc",      212 }, /* capital O, circumflex accent  */
+       { "Ograve",     210 }, /* capital O, grave accent  */
+       { "Oslash",     216 }, /* capital O, slash  */
+       { "Otilde",     213 }, /* capital O, tilde  */
+       { "Ouml",       214 }, /* capital O, dieresis or umlaut mark  */
+       { "THORN",      222 }, /* capital THORN, Icelandic  */
+       { "Uacute",     218 }, /* capital U, acute accent  */
+       { "Ucirc",      219 }, /* capital U, circumflex accent  */
+       { "Ugrave",     217 }, /* capital U, grave accent  */
+       { "Uuml",       220 }, /* capital U, dieresis or umlaut mark  */
+       { "Yacute",     221 }, /* capital Y, acute accent  */
+       { "aacute",     225 }, /* small a, acute accent  */
+       { "acirc",      226 }, /* small a, circumflex accent  */
+       { "acute",      180 }, /* acute accent  */
+       { "aelig",      230 }, /* small ae diphthong (ligature)  */
+       { "agrave",     224 }, /* small a, grave accent  */
+       { "amp",         38 }, /* ampersand  */
+       { "aring",      229 }, /* small a, ring  */
+       { "atilde",     227 }, /* small a, tilde  */
+       { "auml",       228 }, /* small a, dieresis or umlaut mark  */
+       { "brvbar",     166 }, /* broken (vertical) bar  */
+       { "ccedil",     231 }, /* small c, cedilla  */
+       { "cedil",      184 }, /* cedilla  */
+       { "cent",       162 }, /* cent sign  */
+       { "copy",       169 }, /* copyright sign  */
+       { "curren",     164 }, /* general currency sign  */
+       { "deg",        176 }, /* degree sign  */
+       { "divide",     247 }, /* divide sign  */
+       { "eacute",     233 }, /* small e, acute accent  */
+       { "ecirc",      234 }, /* small e, circumflex accent  */
+       { "egrave",     232 }, /* small e, grave accent  */
+       { "eth",        240 }, /* small eth, Icelandic  */
+       { "euml",       235 }, /* small e, dieresis or umlaut mark  */
+       { "frac12",     189 }, /* fraction one-half  */
+       { "frac14",     188 }, /* fraction one-quarter  */
+       { "frac34",     190 }, /* fraction three-quarters  */
+       { "gt",          62 }, /* greater than  */
+       { "iacute",     237 }, /* small i, acute accent  */
+       { "icirc",      238 }, /* small i, circumflex accent  */
+       { "iexcl",      161 }, /* inverted exclamation mark  */
+       { "igrave",     236 }, /* small i, grave accent  */
+       { "iquest",     191 }, /* inverted question mark  */
+       { "iuml",       239 }, /* small i, dieresis or umlaut mark  */
+       { "laquo",      171 }, /* angle quotation mark, left  */
+       { "lt",          60 }, /* less than  */
+       { "macr",       175 }, /* macron  */
+       { "micro",      181 }, /* micro sign  */
+       { "middot",     183 }, /* middle dot  */
+       { "nbsp",       160 }, /* no-break space  */
+       { "not",        172 }, /* not sign  */
+       { "ntilde",     241 }, /* small n, tilde  */
+       { "oacute",     243 }, /* small o, acute accent  */
+       { "ocirc",      244 }, /* small o, circumflex accent  */
+       { "ograve",     242 }, /* small o, grave accent  */
+       { "ordf",       170 }, /* ordinal indicator, feminine  */
+       { "ordm",       186 }, /* ordinal indicator, masculine  */
+       { "oslash",     248 }, /* small o, slash  */
+       { "otilde",     245 }, /* small o, tilde  */
+       { "ouml",       246 }, /* small o, dieresis or umlaut mark  */
+       { "para",       182 }, /* pilcrow (paragraph sign)  */
+       { "plusmn",     177 }, /* plus-or-minus sign  */
+       { "pound",      163 }, /* pound sterling sign  */
+       { "quot",        34 }, /* double quote  */
+       { "raquo",      187 }, /* angle quotation mark, right  */
+       { "reg",        174 }, /* registered sign  */
+       { "sect",       167 }, /* section sign  */
+       { "shy",        173 }, /* soft hyphen  */
+       { "sup1",       185 }, /* superscript one  */
+       { "sup2",       178 }, /* superscript two  */
+       { "sup3",       179 }, /* superscript three  */
+       { "szlig",      223 }, /* small sharp s, German (sz ligature)  */
+       { "thorn",      254 }, /* small thorn, Icelandic  */
+       { "times",      215 }, /* multiply sign  */
+       { "uacute",     250 }, /* small u, acute accent  */
+       { "ucirc",      251 }, /* small u, circumflex accent  */
+       { "ugrave",     249 }, /* small u, grave accent  */
+       { "uml",        168 }, /* umlaut (dieresis)  */
+       { "uuml",       252 }, /* small u, dieresis or umlaut mark  */
+       { "yacute",     253 }, /* small y, acute accent  */
+       { "yen",        165 }, /* yen sign  */
+       { "yuml",       255 }, /* small y, dieresis or umlaut mark  */
+};
 
 /*
  * unvis - decode characters previously encoded by vis
@@ -62,235 +196,362 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/unvis.c,v 1.10 2007/01/09 00:27:56 imp Exp
 int
 unvis(char *cp, int c, int *astate, int flag)
 {
-       locale_t loc = __current_locale();
+       unsigned char uc = (unsigned char)c;
+       unsigned char st, ia, is, lc;
+
+/*
+ * Bottom 8 bits of astate hold the state machine state.
+ * Top 8 bits hold the current character in the http 1866 nv string decoding
+ */
+#define GS(a)          ((a) & 0xff)
+#define SS(a, b)       (((uint32_t)(a) << 24) | (b))
+#define GI(a)          ((uint32_t)(a) >> 24)
+
+       _DIAGASSERT(cp != NULL);
+       _DIAGASSERT(astate != NULL);
+       st = GS(*astate);
 
        if (flag & UNVIS_END) {
-               if (*astate == S_OCTAL2 || *astate == S_OCTAL3) {
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+               switch (st) {
+               case S_OCTAL2:
+               case S_OCTAL3:
+               case S_HEX2:
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
+               case S_GROUND:
+                       return UNVIS_NOCHAR;
+               default:
+                       return UNVIS_SYNBAD;
                }
-               return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
        }
 
-       switch (*astate & ~S_HTTP) {
+       switch (st) {
 
        case S_GROUND:
                *cp = 0;
-               if (c == '\\') {
-                       *astate = S_START;
-                       return (0);
+               if ((flag & VIS_NOESCAPE) == 0 && c == '\\') {
+                       *astate = SS(0, S_START);
+                       return UNVIS_NOCHAR;
+               }
+               if ((flag & VIS_HTTP1808) && c == '%') {
+                       *astate = SS(0, S_HEX1);
+                       return UNVIS_NOCHAR;
+               }
+               if ((flag & VIS_HTTP1866) && c == '&') {
+                       *astate = SS(0, S_AMP);
+                       return UNVIS_NOCHAR;
                }
-               if (flag & VIS_HTTPSTYLE && c == '%') {
-                       *astate = S_START | S_HTTP;
-                       return (0);
+               if ((flag & VIS_MIMESTYLE) && c == '=') {
+                       *astate = SS(0, S_MIME1);
+                       return UNVIS_NOCHAR;
                }
                *cp = c;
-               return (UNVIS_VALID);
+               return UNVIS_VALID;
 
        case S_START:
-               if (*astate & S_HTTP) {
-                   if (ishex(tolower_l(c, loc))) {
-                       *cp = isdigit_l(c, loc) ? (c - '0') : (tolower_l(c, loc) - 'a');
-                       *astate = S_HEX2;
-                       return (0);
-                   }
-               }
                switch(c) {
                case '\\':
                        *cp = c;
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case '0': case '1': case '2': case '3':
                case '4': case '5': case '6': case '7':
                        *cp = (c - '0');
-                       *astate = S_OCTAL2;
-                       return (0);
+                       *astate = SS(0, S_OCTAL2);
+                       return UNVIS_NOCHAR;
                case 'M':
-                       *cp = 0200;
-                       *astate = S_META;
-                       return (0);
+                       *cp = (char)0200;
+                       *astate = SS(0, S_META);
+                       return UNVIS_NOCHAR;
                case '^':
-                       *astate = S_CTRL;
-                       return (0);
+                       *astate = SS(0, S_CTRL);
+                       return UNVIS_NOCHAR;
                case 'n':
                        *cp = '\n';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case 'r':
                        *cp = '\r';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case 'b':
                        *cp = '\b';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case 'a':
                        *cp = '\007';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case 'v':
                        *cp = '\v';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case 't':
                        *cp = '\t';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case 'f':
                        *cp = '\f';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case 's':
                        *cp = ' ';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
                case 'E':
                        *cp = '\033';
-                       *astate = S_GROUND;
-                       return (UNVIS_VALID);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
+               case 'x':
+                       *astate = SS(0, S_HEX);
+                       return UNVIS_NOCHAR;
                case '\n':
                        /*
                         * hidden newline
                         */
-                       *astate = S_GROUND;
-                       return (UNVIS_NOCHAR);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_NOCHAR;
                case '$':
                        /*
                         * hidden marker
                         */
-                       *astate = S_GROUND;
-                       return (UNVIS_NOCHAR);
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_NOCHAR;
                }
-               *astate = S_GROUND;
-               return (UNVIS_SYNBAD);
+               goto bad;
 
        case S_META:
                if (c == '-')
-                       *astate = S_META1;
+                       *astate = SS(0, S_META1);
                else if (c == '^')
-                       *astate = S_CTRL;
-               else {
-                       *astate = S_GROUND;
-                       return (UNVIS_SYNBAD);
-               }
-               return (0);
+                       *astate = SS(0, S_CTRL);
+               else 
+                       goto bad;
+               return UNVIS_NOCHAR;
 
        case S_META1:
-               *astate = S_GROUND;
+               *astate = SS(0, S_GROUND);
                *cp |= c;
-               return (UNVIS_VALID);
+               return UNVIS_VALID;
 
        case S_CTRL:
                if (c == '?')
                        *cp |= 0177;
                else
                        *cp |= c & 037;
-               *astate = S_GROUND;
-               return (UNVIS_VALID);
+               *astate = SS(0, S_GROUND);
+               return UNVIS_VALID;
 
        case S_OCTAL2:  /* second possible octal digit */
-               if (isoctal(c)) {
+               if (isoctal(uc)) {
                        /*
                         * yes - and maybe a third
                         */
                        *cp = (*cp << 3) + (c - '0');
-                       *astate = S_OCTAL3;
-                       return (0);
+                       *astate = SS(0, S_OCTAL3);
+                       return UNVIS_NOCHAR;
                }
                /*
                 * no - done with current sequence, push back passed char
                 */
-               *astate = S_GROUND;
-               return (UNVIS_VALIDPUSH);
+               *astate = SS(0, S_GROUND);
+               return UNVIS_VALIDPUSH;
 
        case S_OCTAL3:  /* third possible octal digit */
-               *astate = S_GROUND;
-               if (isoctal(c)) {
+               *astate = SS(0, S_GROUND);
+               if (isoctal(uc)) {
                        *cp = (*cp << 3) + (c - '0');
-                       return (UNVIS_VALID);
+                       return UNVIS_VALID;
                }
                /*
                 * we were done, push back passed char
                 */
-               return (UNVIS_VALIDPUSH);
+               return UNVIS_VALIDPUSH;
 
-       case S_HEX2:    /* second mandatory hex digit */
-               if (ishex(tolower_l(c, loc))) {
-                       *cp = (isdigit_l(c, loc) ? (*cp << 4) + (c - '0') : (*cp << 4) + (tolower_l(c, loc) - 'a' + 10));
+       case S_HEX:
+               if (!isxdigit(uc))
+                       goto bad;
+               /*FALLTHROUGH*/
+       case S_HEX1:
+               if (isxdigit(uc)) {
+                       *cp = xtod(uc);
+                       *astate = SS(0, S_HEX2);
+                       return UNVIS_NOCHAR;
                }
+               /*
+                * no - done with current sequence, push back passed char
+                */
+               *astate = SS(0, S_GROUND);
+               return UNVIS_VALIDPUSH;
+
+       case S_HEX2:
                *astate = S_GROUND;
-               return (UNVIS_VALID);
+               if (isxdigit(uc)) {
+                       *cp = xtod(uc) | (*cp << 4);
+                       return UNVIS_VALID;
+               }
+               return UNVIS_VALIDPUSH;
+
+       case S_MIME1:
+               if (uc == '\n' || uc == '\r') {
+                       *astate = SS(0, S_EATCRNL);
+                       return UNVIS_NOCHAR;
+               }
+               if (isxdigit(uc) && (isdigit(uc) || isupper(uc))) {
+                       *cp = XTOD(uc);
+                       *astate = SS(0, S_MIME2);
+                       return UNVIS_NOCHAR;
+               }
+               goto bad;
+
+       case S_MIME2:
+               if (isxdigit(uc) && (isdigit(uc) || isupper(uc))) {
+                       *astate = SS(0, S_GROUND);
+                       *cp = XTOD(uc) | (*cp << 4);
+                       return UNVIS_VALID;
+               }
+               goto bad;
+
+       case S_EATCRNL:
+               switch (uc) {
+               case '\r':
+               case '\n':
+                       return UNVIS_NOCHAR;
+               case '=':
+                       *astate = SS(0, S_MIME1);
+                       return UNVIS_NOCHAR;
+               default:
+                       *cp = uc;
+                       *astate = SS(0, S_GROUND);
+                       return UNVIS_VALID;
+               }
+
+       case S_AMP:
+               *cp = 0;
+               if (uc == '#') {
+                       *astate = SS(0, S_NUMBER);
+                       return UNVIS_NOCHAR;
+               }
+               *astate = SS(0, S_STRING);
+               /*FALLTHROUGH*/
+
+       case S_STRING:
+               ia = *cp;               /* index in the array */
+               is = GI(*astate);       /* index in the string */
+               lc = is == 0 ? 0 : nv[ia].name[is - 1]; /* last character */
+
+               if (uc == ';')
+                       uc = '\0';
+
+               for (; ia < __arraycount(nv); ia++) {
+                       if (is != 0 && nv[ia].name[is - 1] != lc)
+                               goto bad;
+                       if (nv[ia].name[is] == uc)
+                               break;
+               }
+
+               if (ia == __arraycount(nv))
+                       goto bad;
+
+               if (uc != 0) {
+                       *cp = ia;
+                       *astate = SS(is + 1, S_STRING);
+                       return UNVIS_NOCHAR;
+               }
+
+               *cp = nv[ia].value;
+               *astate = SS(0, S_GROUND);
+               return UNVIS_VALID;
+
+       case S_NUMBER:
+               if (uc == ';')
+                       return UNVIS_VALID;
+               if (!isdigit(uc))
+                       goto bad;
+               *cp += (*cp * 10) + uc - '0';
+               return UNVIS_NOCHAR;
 
        default:
+       bad:
                /*
                 * decoder in unknown state - (probably uninitialized)
                 */
-               *astate = S_GROUND;
-               return (UNVIS_SYNBAD);
+               *astate = SS(0, S_GROUND);
+               return UNVIS_SYNBAD;
        }
 }
 
 /*
- * strunvis - decode src into dst
+ * strnunvisx - decode src into dst
  *
  *     Number of chars decoded into dst is returned, -1 on error.
  *     Dst is null terminated.
  */
 
 int
-strunvis(char *dst, const char *src)
+strnunvisx(char *dst, size_t dlen, const char *src, int flag)
 {
        char c;
-       char *start = dst;
+       char t = '\0', *start = dst;
        int state = 0;
 
-       while ( (c = *src++) ) {
-       again:
-               switch (unvis(dst, c, &state, 0)) {
+       _DIAGASSERT(src != NULL);
+       _DIAGASSERT(dst != NULL);
+#define CHECKSPACE() \
+       do { \
+               if (dlen-- == 0) { \
+                       errno = ENOSPC; \
+                       return -1; \
+               } \
+       } while (/*CONSTCOND*/0)
+
+       while ((c = *src++) != '\0') {
+ again:
+               switch (unvis(&t, c, &state, flag)) {
                case UNVIS_VALID:
-                       dst++;
+                       CHECKSPACE();
+                       *dst++ = t;
                        break;
                case UNVIS_VALIDPUSH:
-                       dst++;
+                       CHECKSPACE();
+                       *dst++ = t;
                        goto again;
                case 0:
                case UNVIS_NOCHAR:
                        break;
+               case UNVIS_SYNBAD:
+                       errno = EINVAL;
+                       return -1;
                default:
-                       return (-1);
+                       _DIAGASSERT(/*CONSTCOND*/0);
+                       errno = EINVAL;
+                       return -1;
                }
        }
-       if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
-               dst++;
+       if (unvis(&t, c, &state, UNVIS_END) == UNVIS_VALID) {
+               CHECKSPACE();
+               *dst++ = t;
+       }
+       CHECKSPACE();
        *dst = '\0';
-       return (dst - start);
+       return (int)(dst - start);
 }
 
 int
 strunvisx(char *dst, const char *src, int flag)
 {
-       char c;
-       char *start = dst;
-       int state = 0;
-    
-       while ( (c = *src++) ) {
-       again:
-               switch (unvis(dst, c, &state, flag)) {
-               case UNVIS_VALID:
-                       dst++;
-                       break;
-               case UNVIS_VALIDPUSH:
-                       dst++;
-                       goto again;
-               case 0:
-               case UNVIS_NOCHAR:
-                       break;
-               default:
-                       return (-1);
-               }
-       }
-       if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
-               dst++;
-       *dst = '\0';
-       return (dst - start);
+       return strnunvisx(dst, (size_t)~0, src, flag);
+}
+
+int
+strunvis(char *dst, const char *src)
+{
+       return strnunvisx(dst, (size_t)~0, src, 0);
+}
+
+int
+strnunvis(char *dst, size_t dlen, const char *src)
+{
+       return strnunvisx(dst, dlen, src, 0);
 }
+#endif
index e99b773da51ff826173c0670a2b0794b02468ba1..12b9274672474be307175560813566e63e8ea103 100644 (file)
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)usleep.3   8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/gen/usleep.3,v 1.19 2007/01/09 00:27:56 imp Exp $
+.\" $FreeBSD$
 .\"
 .Dd February 13, 1998
 .Dt USLEEP 3
 .Sh SYNOPSIS
 .In unistd.h
 .Ft int
-.Fo usleep
-.Fa "useconds_t useconds"
-.Fc
+.Fn usleep "useconds_t microseconds"
 .Sh DESCRIPTION
 The
 .Fn usleep
 function suspends execution of the calling thread until either
-.Fa useconds
-microseconds have elapsed
-or a signal is delivered to the thread whose action
-is to invoke a signal-catching function
-or to terminate the thread or process.
-The actual time slept may be longer, due to system latencies
-and possible limitations in the timer resolution of the hardware.
+.Fa microseconds
+microseconds have elapsed or a signal is delivered to the thread and its
+action is to invoke a signal-catching function or to terminate the
+process.
+System activity or limitations may lengthen the sleep by an indeterminate amount.
 .Pp
-This function is implemented, using
-.Xr nanosleep 2 ,
+This function is implemented using
+.Xr nanosleep 2
 by pausing for
-.Fa useconds
+.Fa microseconds
 microseconds or until a signal occurs.
 Consequently, in this implementation,
-sleeping has no effect on the state of process timers
+sleeping has no effect on the state of process timers,
 and there is no special handling for SIGALRM.
+Also, this implementation does not put a limit on the value of
+.Fa microseconds
+(other than that limited by the size of the
+.Ft useconds_t
+type); some other platforms require it to be less than one million.
+.Sh NOTE
+The
+.Fn usleep
+function is obsolescent.
+Use
+.Xr nanosleep 2
+instead.
 .Sh RETURN VALUES
 .Rv -std usleep
 .Sh ERRORS
index 2fa771c335237b1f1a3e8cbfcf2b9f4276d887e7..7ad956271bf7c9fa47e92646810f2af49014e8fb 100644 (file)
@@ -1,3 +1,6 @@
+.\"    $NetBSD: vis.3,v 1.39 2013/02/20 20:05:26 christos Exp $
+.\"    $FreeBSD$
+.\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
@@ -9,7 +12,7 @@
 .\" 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.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"     From: @(#)vis.3        8.1 (Berkeley) 6/9/93
-.\" $FreeBSD: src/lib/libc/gen/vis.3,v 1.30 2007/01/09 00:27:56 imp Exp $
+.\"     @(#)vis.3      8.1 (Berkeley) 6/9/93
 .\"
-.Dd April 9, 2006
+.Dd February 19, 2013
 .Dt VIS 3
 .Os
 .Sh NAME
-.Nm vis
+.Nm vis ,
+.Nm nvis ,
+.Nm strvis ,
+.Nm strnvis ,
+.Nm strvisx ,
+.Nm strnvisx ,
+.Nm strenvisx ,
+.Nm svis ,
+.Nm snvis ,
+.Nm strsvis ,
+.Nm strsnvis ,
+.Nm strsvisx ,
+.Nm strsnvisx ,
+.Nm strsenvisx
 .Nd visually encode characters
 .Sh LIBRARY
 .Lb libc
 .In vis.h
 .Ft char *
 .Fn vis "char *dst" "int c" "int flag" "int nextc"
+.Ft char *
+.Fn nvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc"
 .Ft int
 .Fn strvis "char *dst" "const char *src" "int flag"
 .Ft int
+.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag"
+.Ft int
 .Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
+.Ft int
+.Fn strnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag"
+.Ft int
+.Fn strenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "int *cerr_ptr"
+.Ft char *
+.Fn svis "char *dst" "int c" "int flag" "int nextc" "const char *extra"
+.Ft char *
+.Fn snvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc" "const char *extra"
+.Ft int
+.Fn strsvis "char *dst" "const char *src" "int flag" "const char *extra"
+.Ft int
+.Fn strsnvis "char *dst" "size_t dlen" "const char *src" "int flag" "const char *extra"
+.Ft int
+.Fn strsvisx "char *dst" "const char *src" "size_t len" "int flag" "const char *extra"
+.Ft int
+.Fn strsnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra"
+.Ft int
+.Fn strsenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra" "int *cerr_ptr"
 .Sh DESCRIPTION
 The
 .Fn vis
@@ -55,19 +92,16 @@ a string which represents the character
 If
 .Fa c
 needs no encoding, it is copied in unaltered.
-The string is
-null terminated, and a pointer to the end of the string is
+The string is null terminated, and a pointer to the end of the string is
 returned.
 The maximum length of any encoding is four
-characters (not including the trailing
+bytes (not including the trailing
 .Dv NUL ) ;
 thus, when
 encoding a set of characters into a buffer, the size of the buffer should
-be four times the number of characters encoded, plus one for the trailing
+be four times the number of bytes encoded, plus one for the trailing
 .Dv NUL .
-The
-.Fa flag
-argument is used for altering the default range of
+The flag parameter is used for altering the default range of
 characters considered for encoding and for altering the visual
 representation.
 The additional character,
@@ -77,9 +111,11 @@ is only used when selecting the
 encoding format (explained below).
 .Pp
 The
-.Fn strvis
+.Fn strvis ,
+.Fn strnvis ,
+.Fn strvisx ,
 and
-.Fn strvisx
+.Fn strnvisx
 functions copy into
 .Fa dst
 a visual representation of
@@ -87,14 +123,18 @@ the string
 .Fa src .
 The
 .Fn strvis
-function encodes characters from
+and
+.Fn strnvis
+functions encode characters from
 .Fa src
 up to the
 first
 .Dv NUL .
 The
 .Fn strvisx
-function encodes exactly
+and
+.Fn strnvisx
+functions encode exactly
 .Fa len
 characters from
 .Fa src
@@ -108,35 +148,96 @@ terminate
 The size of
 .Fa dst
 must be four times the number
-of characters encoded from
+of bytes encoded from
 .Fa src
 (plus one for the
 .Dv NUL ) .
 Both
-forms return the number of characters in dst (not including
-the trailing
+forms return the number of characters in
+.Fa dst
+(not including the trailing
 .Dv NUL ) .
+The
+.Dq Nm n
+versions of the functions also take an additional argument
+.Fa dlen
+that indicates the length of the
+.Fa dst
+buffer.
+If
+.Fa dlen
+is not large enough to fit the converted string then the
+.Fn strnvis
+and
+.Fn strnvisx
+functions return \-1 and set
+.Va errno
+to
+.Dv ENOSPC .
+The
+.Fn strenvisx
+function takes an additional argument,
+.Fa cerr_ptr ,
+that is used to pass in and out a multibyte conversion error flag.
+This is useful when processing single characters at a time when
+it is possible that the locale may be set to something other
+than the locale of the characters in the input data.
+.Pp
+The functions
+.Fn svis ,
+.Fn snvis ,
+.Fn strsvis ,
+.Fn strsnvis ,
+.Fn strsvisx ,
+.Fn strsnvisx ,
+and
+.Fn strsenvisx
+correspond to
+.Fn vis ,
+.Fn nvis ,
+.Fn strvis ,
+.Fn strnvis ,
+.Fn strvisx ,
+.Fn strnvisx ,
+and
+.Fn strenvisx
+but have an additional argument
+.Fa extra ,
+pointing to a
+.Dv NUL
+terminated list of characters.
+These characters will be copied encoded or backslash-escaped into
+.Fa dst .
+These functions are useful e.g. to remove the special meaning
+of certain characters to shells.
 .Pp
 The encoding is a unique, invertible representation composed entirely of
 graphic characters; it can be decoded back into the original form using
 the
-.Xr unvis 3
-or
+.Xr unvis 3 ,
 .Xr strunvis 3
+or
+.Xr strnunvis 3
 functions.
 .Pp
 There are two parameters that can be controlled: the range of
-characters that are encoded, and the type
-of representation used.
-By default, all non-graphic characters
-except space, tab, and newline are encoded.
-(See
-.Xr isgraph 3 . )
+characters that are encoded (applies only to
+.Fn vis ,
+.Fn nvis ,
+.Fn strvis ,
+.Fn strnvis ,
+.Fn strvisx ,
+and
+.Fn strnvisx ) ,
+and the type of representation used.
+By default, all non-graphic characters,
+except space, tab, and newline are encoded (see
+.Xr isgraph 3 ) .
 The following flags
 alter this:
 .Bl -tag -width VIS_WHITEX
 .It Dv VIS_GLOB
-Also encode magic characters
+Also encode the magic characters
 .Ql ( * ,
 .Ql \&? ,
 .Ql \&[
@@ -158,30 +259,54 @@ Synonym for
 \&|
 .Dv VIS_NL .
 .It Dv VIS_SAFE
-Only encode "unsafe" characters.
-Unsafe means control
-characters which may cause common terminals to perform
+Only encode
+.Dq unsafe
+characters.
+Unsafe means control characters which may cause common terminals to perform
 unexpected functions.
-Currently this form allows space,
-tab, newline, backspace, bell, and return - in addition
-to all graphic characters - unencoded.
+Currently this form allows space, tab, newline, backspace, bell, and
+return \(em in addition to all graphic characters \(em unencoded.
 .El
 .Pp
+(The above flags have no effect for
+.Fn svis ,
+.Fn snvis ,
+.Fn strsvis ,
+.Fn strsnvis ,
+.Fn strsvisx ,
+and
+.Fn strsnvisx .
+When using these functions, place all graphic characters to be
+encoded in an array pointed to by
+.Fa extra .
+In general, the backslash character should be included in this array, see the
+warning on the use of the
+.Dv VIS_NOSLASH
+flag below).
+.Pp
 There are four forms of encoding.
-Most forms use the backslash character
+All forms use the backslash character
 .Ql \e
 to introduce a special
-sequence; two backslashes are used to represent a real backslash.
+sequence; two backslashes are used to represent a real backslash,
+except
+.Dv VIS_HTTPSTYLE
+that uses
+.Ql % ,
+or
+.Dv VIS_MIMESTYLE
+that uses
+.Ql = .
 These are the visual formats:
-.Bl -tag -width VIS_HTTPSTYLE
+.Bl -tag -width VIS_CSTYLE
 .It (default)
 Use an
 .Ql M
 to represent meta characters (characters with the 8th
 bit set), and use caret
 .Ql ^
-to represent control characters see
-.Pf ( Xr iscntrl 3 ) .
+to represent control characters (see
+.Xr iscntrl 3 ) .
 The following formats are used:
 .Bl -tag -width xxxxx
 .It Dv \e^C
@@ -227,32 +352,21 @@ Represents Meta-space.
 Use C-style backslash sequences to represent standard non-printable
 characters.
 The following sequences are used to represent the indicated characters:
-.Pp
-.Bl -tag -width ".Li \e0" -offset indent -compact
-.It Li \ea
-.Dv BEL No (007)
-.It Li \eb
-.Dv BS No (010)
-.It Li \ef
-.Dv NP No (014)
-.It Li \en
-.Dv NL No (012)
-.It Li \er
-.Dv CR No (015)
-.It Li \es
-.Dv SP No (040)
-.It Li \et
-.Dv HT No (011)
-.It Li \ev
-.Dv VT No (013)
-.It Li \e0
-.Dv NUL No (000)
-.El
+.Bd -unfilled -offset indent
+.Li \ea Tn  \(em BEL No (007)
+.Li \eb Tn  \(em BS No (010)
+.Li \ef Tn  \(em NP No (014)
+.Li \en Tn  \(em NL No (012)
+.Li \er Tn  \(em CR No (015)
+.Li \es Tn  \(em SP No (040)
+.Li \et Tn  \(em HT No (011)
+.Li \ev Tn  \(em VT No (013)
+.Li \e0 Tn  \(em NUL No (000)
+.Ed
 .Pp
 When using this format, the
 .Fa nextc
-argument is looked at to determine
-if a
+parameter is looked at to determine if a
 .Dv NUL
 character can be encoded as
 .Ql \e0
@@ -262,20 +376,28 @@ If
 .Fa nextc
 is an octal digit, the latter representation is used to
 avoid ambiguity.
-.It Dv VIS_HTTPSTYLE
-Use URI encoding as described in RFC 1808.
-The form is
-.Ql %dd
-where
-.Ar d
-represents a hexadecimal digit.
 .It Dv VIS_OCTAL
 Use a three digit octal sequence.
 The form is
 .Ql \eddd
 where
-.Ar d
+.Em d
 represents an octal digit.
+.It Dv VIS_HTTPSTYLE
+Use URI encoding as described in RFC 1738.
+The form is
+.Ql %xx
+where
+.Em x
+represents a lower case hexadecimal digit.
+.It Dv VIS_MIMESTYLE
+Use MIME Quoted-Printable encoding as described in RFC 2045, only don't
+break lines and don't handle CRLF.
+The form is
+.Ql =XX
+where
+.Em X
+represents an upper case hexadecimal digit.
 .El
 .Pp
 There is one additional flag,
@@ -289,20 +411,96 @@ meta characters as
 .Ql M-C ) .
 With this flag set, the encoding is
 ambiguous and non-invertible.
+.Sh MULTIBYTE CHARACTER SUPPORT
+These functions support multibyte character input.
+The encoding conversion is influenced by the setting of the
+.Ev LC_CTYPE
+environment variable which defines the set of characters
+that can be copied without encoding.
+.Pp
+When 8-bit data is present in the input,
+.Ev LC_CTYPE
+must be set to the correct locale or to the C locale.
+If the locales of the data and the conversion are mismatched,
+multibyte character recognition may fail and encoding will be performed
+byte-by-byte instead.
+.Pp
+As noted above,
+.Fa dst
+must be four times the number of bytes processed from
+.Fa src .
+But note that each multibyte character can be up to
+.Dv MB_LEN_MAX
+bytes
+.\" (see
+.\" .Xr multibyte 3 )
+so in terms of multibyte characters,
+.Fa dst
+must be four times
+.Dv MB_LEN_MAX
+times the number of characters processed from
+.Fa src .
+.Sh ENVIRONMENT
+.Bl -tag -width ".Ev LC_CTYPE"
+.It Ev LC_CTYPE
+Specify the locale of the input data.
+Set to C if the input data locale is unknown.
+.El
+.Sh ERRORS
+The functions
+.Fn nvis
+and
+.Fn snvis
+will return
+.Dv NULL
+and the functions
+.Fn strnvis ,
+.Fn strnvisx ,
+.Fn strsnvis ,
+and
+.Fn strsnvisx ,
+will return \-1 when the
+.Fa dlen
+destination buffer size is not enough to perform the conversion while
+setting
+.Va errno
+to:
+.Bl -tag -width ".Bq Er ENOSPC"
+.It Bq Er ENOSPC
+The destination buffer size is not large enough to perform the conversion.
+.El
 .Sh SEE ALSO
 .Xr unvis 1 ,
+.Xr vis 1 ,
+.Xr glob 3 ,
+.\" .Xr multibyte 3 ,
 .Xr unvis 3
 .Rs
-.%A R. Fielding
-.%T Relative Uniform Resource Locators
-.%O RFC1808
+.%A T. Berners-Lee
+.%T Uniform Resource Locators (URL)
+.%O "RFC 1738"
+.Re
+.Rs
+.%T "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
+.%O "RFC 2045"
 .Re
 .Sh HISTORY
-These functions first appeared in
+The
+.Fn vis ,
+.Fn strvis ,
+and
+.Fn strvisx
+functions first appeared in
 .Bx 4.4 .
-.Sh BUGS
 The
-.Nm
-family of functions do not recognize multibyte characters, and thus
-may consider them to be non-printable when they are in fact printable
-(and vice versa.)
+.Fn svis ,
+.Fn strsvis ,
+.Fn strsvisx
+.Fn nvis ,
+.Fn strnvis ,
+.Fn strnvisx ,
+.Fn snvis ,
+.Fn strsnvis
+and
+.Fn strsnvisx
+functions as well as multibyte character support were added in OS X 10.12.
index 3a4b67c4ca24faaf9a8db6de70f9d313265931e7..f48f1730309843c0c09525b7fa0ad03c220f1c89 100644 (file)
@@ -1,3 +1,5 @@
+/*     $NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $        */
+
 /*-
  * Copyright (c) 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -10,7 +12,7 @@
  * 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.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
  * SUCH DAMAGE.
  */
 
+/*-
+ * Copyright (c) 1999, 2005 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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>
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vis.c      8.1 (Berkeley) 7/19/93";
+__RCSID("$NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/gen/vis.c,v 1.14 2007/01/09 00:27:56 imp Exp $");
-
-#include "xlocale_private.h"
+#ifdef __FBSDID
+__FBSDID("$FreeBSD$");
+#define        _DIAGASSERT(x)  assert(x)
+#endif
 
 #include <sys/types.h>
-#include <limits.h>
+#include <sys/param.h>
+
+#include <assert.h>
+#include <vis.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+#if !HAVE_VIS || !HAVE_SVIS
 #include <ctype.h>
+#include <limits.h>
 #include <stdio.h>
-#include <vis.h>
+#include <string.h>
 
-#define        isoctal(c)      (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
+/*
+ * The reason for going through the trouble to deal with character encodings
+ * in vis(3), is that we use this to safe encode output of commands. This
+ * safe encoding varies depending on the character set. For example if we
+ * display ps output in French, we don't want to display French characters
+ * as M-foo.
+ */
+
+static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
+
+#undef BELL
+#define BELL L'\a'
+
+#define iswoctal(c)    (((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7')
+#define iswwhite(c)    (c == L' ' || c == L'\t' || c == L'\n')
+#define iswsafe(c)     (c == L'\b' || c == BELL || c == L'\r')
+#define xtoa(c)                L"0123456789abcdef"[c]
+#define XTOA(c)                L"0123456789ABCDEF"[c]
+
+#define MAXEXTRAS      10
+
+_Static_assert(MB_LEN_MAX <= sizeof(uint64_t));
 
 /*
- * vis - visually encode characters
+ * This is do_hvis, for HTTP style (RFC 1808)
  */
-char *
-vis(dst, c, flag, nextc)
-       char *dst;
-       int c, nextc;
-       int flag;
-{
-       locale_t loc = __current_locale();
-
-       c = (unsigned char)c;
-
-       if (flag & VIS_HTTPSTYLE) {
-               /* Described in RFC 1808 */
-               if (!(isalnum_l(c, loc) /* alpha-numeric */
-                   /* safe */
-                   || c == '$' || c == '-' || c == '_' || c == '.' || c == '+'
-                   /* extra */
-                   || c == '!' || c == '*' || c == '\'' || c == '('
-                   || c == ')' || c == ',')) {
-                       *dst++ = '%';
-                       snprintf_l(dst, 4, loc, (c < 16 ? "0%X" : "%X"), c);
-                       dst += 2;
-                       goto done;
+static wchar_t *
+do_hvis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
+{
+       if (iswalnum(c)
+           /* safe */
+           || c == L'$' || c == L'-' || c == L'_' || c == L'.' || c == L'+'
+           /* extra */
+           || c == L'!' || c == L'*' || c == L'\'' || c == L'(' || c == L')'
+           || c == L',')
+               dst = do_svis(dst, c, flags, nextc, extra);
+       else {
+               *dst++ = L'%';
+               *dst++ = xtoa(((unsigned int)c >> 4) & 0xf);
+               *dst++ = xtoa((unsigned int)c & 0xf);
+       }
+
+       return dst;
+}
+
+/*
+ * This is do_mvis, for Quoted-Printable MIME (RFC 2045)
+ * NB: No handling of long lines or CRLF.
+ */
+static wchar_t *
+do_mvis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
+{
+       if ((c != L'\n') &&
+           /* Space at the end of the line */
+           ((iswspace(c) && (nextc == L'\r' || nextc == L'\n')) ||
+           /* Out of range */
+           (!iswspace(c) && (c < 33 || (c > 60 && c < 62) || c > 126)) ||
+           /* Specific char to be escaped */
+           wcschr(L"#$@[\\]^`{|}~", c) != NULL)) {
+               *dst++ = L'=';
+               *dst++ = XTOA(((unsigned int)c >> 4) & 0xf);
+               *dst++ = XTOA((unsigned int)c & 0xf);
+       } else
+               dst = do_svis(dst, c, flags, nextc, extra);
+       return dst;
+}
+
+/*
+ * Output single byte of multibyte character.
+ */
+static wchar_t *
+do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra)
+{
+       if (flags & VIS_CSTYLE) {
+               switch (c) {
+               case L'\n':
+                       *dst++ = L'\\'; *dst++ = L'n';
+                       return dst;
+               case L'\r':
+                       *dst++ = L'\\'; *dst++ = L'r';
+                       return dst;
+               case L'\b':
+                       *dst++ = L'\\'; *dst++ = L'b';
+                       return dst;
+               case BELL:
+                       *dst++ = L'\\'; *dst++ = L'a';
+                       return dst;
+               case L'\v':
+                       *dst++ = L'\\'; *dst++ = L'v';
+                       return dst;
+               case L'\t':
+                       *dst++ = L'\\'; *dst++ = L't';
+                       return dst;
+               case L'\f':
+                       *dst++ = L'\\'; *dst++ = L'f';
+                       return dst;
+               case L' ':
+                       *dst++ = L'\\'; *dst++ = L's';
+                       return dst;
+               case L'\0':
+                       *dst++ = L'\\'; *dst++ = L'0';
+                       if (iswoctal(nextc)) {
+                               *dst++ = L'0';
+                               *dst++ = L'0';
+                       }
+                       return dst;
+               default:
+                       if (iswgraph(c)) {
+                               *dst++ = L'\\';
+                               *dst++ = c;
+                               return dst;
+                       }
+               }
+       }
+       if (iswextra || ((c & 0177) == L' ') || (flags & VIS_OCTAL)) {
+               *dst++ = L'\\';
+               *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + L'0';
+               *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + L'0';
+               *dst++ =                             (c       & 07) + L'0';
+       } else {
+               if ((flags & VIS_NOSLASH) == 0)
+                       *dst++ = L'\\';
+
+               if (c & 0200) {
+                       c &= 0177;
+                       *dst++ = L'M';
+               }
+
+               if (iswcntrl(c)) {
+                       *dst++ = L'^';
+                       if (c == 0177)
+                               *dst++ = L'?';
+                       else
+                               *dst++ = c + L'@';
+               } else {
+                       *dst++ = L'-';
+                       *dst++ = c;
                }
        }
 
-       if ((flag & VIS_GLOB) &&
-           (c == '*' || c == '?' || c == '[' || c == '#'))
-               ;
-       else if (isgraph_l(c, loc) ||
-          ((flag & VIS_SP) == 0 && c == ' ') ||
-          ((flag & VIS_TAB) == 0 && c == '\t') ||
-          ((flag & VIS_NL) == 0 && c == '\n') ||
-          ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) {
+       return dst;
+}
+
+/*
+ * This is do_vis, the central code of vis.
+ * dst:              Pointer to the destination buffer
+ * c:        Character to encode
+ * flags:     Flags word
+ * nextc:     The character following 'c'
+ * extra:     Pointer to the list of extra characters to be
+ *           backslash-protected.
+ */
+static wchar_t *
+do_svis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
+{
+       int iswextra, i, shft;
+       uint64_t bmsk, wmsk;
+
+       iswextra = wcschr(extra, c) != NULL;
+       if (!iswextra && (iswgraph(c) || iswwhite(c) ||
+           ((flags & VIS_SAFE) && iswsafe(c)))) {
                *dst++ = c;
-               if (c == '\\' && (flag & VIS_NOSLASH) == 0)
-                       *dst++ = '\\';
-               *dst = '\0';
-               return (dst);
+               return dst;
        }
 
-       if (flag & VIS_CSTYLE) {
-               switch(c) {
-               case '\n':
-                       *dst++ = '\\';
-                       *dst++ = 'n';
-                       goto done;
-               case '\r':
-                       *dst++ = '\\';
-                       *dst++ = 'r';
-                       goto done;
-               case '\b':
-                       *dst++ = '\\';
-                       *dst++ = 'b';
-                       goto done;
-               case '\a':
-                       *dst++ = '\\';
-                       *dst++ = 'a';
-                       goto done;
-               case '\v':
-                       *dst++ = '\\';
-                       *dst++ = 'v';
-                       goto done;
-               case '\t':
-                       *dst++ = '\\';
-                       *dst++ = 't';
-                       goto done;
-               case '\f':
-                       *dst++ = '\\';
-                       *dst++ = 'f';
-                       goto done;
-               case ' ':
-                       *dst++ = '\\';
-                       *dst++ = 's';
-                       goto done;
-               case '\0':
-                       *dst++ = '\\';
-                       *dst++ = '0';
-                       if (isoctal(nextc)) {
-                               *dst++ = '0';
-                               *dst++ = '0';
-                       }
-                       goto done;
+       /* See comment in istrsenvisx() output loop, below. */
+       wmsk = 0;
+       for (i = sizeof(wmsk) - 1; i >= 0; i--) {
+               shft = i * NBBY;
+               bmsk = (uint64_t)0xffLL << shft;
+               wmsk |= bmsk;
+               if ((c & wmsk) || i == 0)
+                       dst = do_mbyte(dst, (wint_t)(
+                           (uint64_t)(c & bmsk) >> shft),
+                           flags, nextc, iswextra);
+       }
+
+       return dst;
+}
+
+typedef wchar_t *(*visfun_t)(wchar_t *, wint_t, int, wint_t, const wchar_t *);
+
+/*
+ * Return the appropriate encoding function depending on the flags given.
+ */
+static visfun_t
+getvisfun(int flags)
+{
+       if (flags & VIS_HTTPSTYLE)
+               return do_hvis;
+       if (flags & VIS_MIMESTYLE)
+               return do_mvis;
+       return do_svis;
+}
+
+/*
+ * Expand list of extra characters to not visually encode.
+ */
+static wchar_t *
+makeextralist(int flags, const char *src)
+{
+       wchar_t *dst, *d;
+       size_t len;
+
+       len = strlen(src);
+       if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL)
+               return NULL;
+
+       if (mbstowcs(dst, src, len) == (size_t)-1) {
+               size_t i;
+               for (i = 0; i < len; i++)
+                       dst[i] = (wint_t)(u_char)src[i];
+               d = dst + len;
+       } else
+               d = dst + wcslen(dst);
+
+       if (flags & VIS_GLOB) {
+               *d++ = L'*';
+               *d++ = L'?';
+               *d++ = L'[';
+               *d++ = L'#';
+       }
+
+       if (flags & VIS_SP) *d++ = L' ';
+       if (flags & VIS_TAB) *d++ = L'\t';
+       if (flags & VIS_NL) *d++ = L'\n';
+       if ((flags & VIS_NOSLASH) == 0) *d++ = L'\\';
+       *d = L'\0';
+
+       return dst;
+}
+
+/*
+ * istrsenvisx()
+ *     The main internal function.
+ *     All user-visible functions call this one.
+ */
+static int
+istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
+    int flags, const char *mbextra, int *cerr_ptr)
+{
+       wchar_t *dst, *src, *pdst, *psrc, *start, *extra;
+       size_t len, olen;
+       uint64_t bmsk, wmsk;
+       wint_t c;
+       visfun_t f;
+       int clen = 0, cerr = 0, error = -1, i, shft;
+       ssize_t mbslength, maxolen;
+
+       _DIAGASSERT(mbdst != NULL);
+       _DIAGASSERT(mbsrc != NULL || mblength == 0);
+       _DIAGASSERT(mbextra != NULL);
+
+       /*
+        * Input (mbsrc) is a char string considered to be multibyte
+        * characters.  The input loop will read this string pulling
+        * one character, possibly multiple bytes, from mbsrc and
+        * converting each to wchar_t in src.
+        *
+        * The vis conversion will be done using the wide char
+        * wchar_t string.
+        *
+        * This will then be converted back to a multibyte string to
+        * return to the caller.
+        */
+
+       /* Allocate space for the wide char strings */
+       psrc = pdst = extra = NULL;
+       if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
+               return -1;
+       if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
+               goto out;
+       dst = pdst;
+       src = psrc;
+
+       /* Use caller's multibyte conversion error flag. */
+       if (cerr_ptr)
+               cerr = *cerr_ptr;
+
+       /*
+        * Input loop.
+        * Handle up to mblength characters (not bytes).  We do not
+        * stop at NULs because we may be processing a block of data
+        * that includes NULs.
+        */
+       mbslength = (ssize_t)mblength;
+       /*
+        * When inputing a single character, must also read in the
+        * next character for nextc, the look-ahead character.
+        */
+       if (mbslength == 1)
+               mbslength++;
+       while (mbslength > 0) {
+               /* Convert one multibyte character to wchar_t. */
+               if (!cerr)
+                       clen = mbtowc(src, mbsrc, MB_LEN_MAX);
+               if (cerr || clen < 0) {
+                       /* Conversion error, process as a byte instead. */
+                       *src = (wint_t)(u_char)*mbsrc;
+                       clen = 1;
+                       cerr = 1;
                }
+               if (clen == 0)
+                       /*
+                        * NUL in input gives 0 return value. process
+                        * as single NUL byte and keep going.
+                        */
+                       clen = 1;
+               /* Advance buffer character pointer. */
+               src++;
+               /* Advance input pointer by number of bytes read. */
+               mbsrc += clen;
+               /* Decrement input byte count. */
+               mbslength -= clen;
        }
-       if (((c & 0177) == ' ') || isgraph_l(c, loc) || (flag & VIS_OCTAL)) {
-               *dst++ = '\\';
-               *dst++ = ((u_char)c >> 6 & 07) + '0';
-               *dst++ = ((u_char)c >> 3 & 07) + '0';
-               *dst++ = ((u_char)c & 07) + '0';
-               goto done;
+       len = src - psrc;
+       src = psrc;
+       /*
+        * In the single character input case, we will have actually
+        * processed two characters, c and nextc.  Reset len back to
+        * just a single character.
+        */
+       if (mblength < len)
+               len = mblength;
+
+       /* Convert extra argument to list of characters for this mode. */
+       extra = makeextralist(flags, mbextra);
+       if (!extra) {
+               if (dlen && *dlen == 0) {
+                       errno = ENOSPC;
+                       goto out;
+               }
+               *mbdst = '\0';          /* can't create extra, return "" */
+               error = 0;
+               goto out;
        }
-       if ((flag & VIS_NOSLASH) == 0)
-               *dst++ = '\\';
-       if (c & 0200) {
-               c &= 0177;
-               *dst++ = 'M';
+
+       /* Look up which processing function to call. */
+       f = getvisfun(flags);
+
+       /*
+        * Main processing loop.
+        * Call do_Xvis processing function one character at a time
+        * with next character available for look-ahead.
+        */
+       for (start = dst; len > 0; len--) {
+               c = *src++;
+               dst = (*f)(dst, c, flags, len >= 1 ? *src : L'\0', extra);
+               if (dst == NULL) {
+                       errno = ENOSPC;
+                       goto out;
+               }
        }
-       if (iscntrl_l(c, loc)) {
-               *dst++ = '^';
-               if (c == 0177)
-                       *dst++ = '?';
-               else
-                       *dst++ = c + '@';
-       } else {
-               *dst++ = '-';
-               *dst++ = c;
+
+       /* Terminate the string in the buffer. */
+       *dst = L'\0';
+
+       /*
+        * Output loop.
+        * Convert wchar_t string back to multibyte output string.
+        * If we have hit a multi-byte conversion error on input,
+        * output byte-by-byte here.  Else use wctomb().
+        */
+       len = wcslen(start);
+       maxolen = dlen ? *dlen : (wcslen(start) * MB_LEN_MAX + 1);
+       olen = 0;
+       for (dst = start; len > 0; len--) {
+               if (!cerr)
+                       clen = wctomb(mbdst, *dst);
+               if (cerr || clen < 0) {
+                       /*
+                        * Conversion error, process as a byte(s) instead.
+                        * Examine each byte and higher-order bytes for
+                        * data.  E.g.,
+                        *      0x000000000000a264 -> a2 64
+                        *      0x000000001f00a264 -> 1f 00 a2 64
+                        */
+                       clen = 0;
+                       wmsk = 0;
+                       for (i = sizeof(wmsk) - 1; i >= 0; i--) {
+                               shft = i * NBBY;
+                               bmsk = (uint64_t)0xffLL << shft;
+                               wmsk |= bmsk;
+                               if ((*dst & wmsk) || i == 0)
+                                       mbdst[clen++] = (char)(
+                                           (uint64_t)(*dst & bmsk) >>
+                                           shft);
+                       }
+                       cerr = 1;
+               }
+               /* If this character would exceed our output limit, stop. */
+               if (olen + clen > (size_t)maxolen)
+                       break;
+               /* Advance output pointer by number of bytes written. */
+               mbdst += clen;
+               /* Advance buffer character pointer. */
+               dst++;
+               /* Incrment output character count. */
+               olen += clen;
        }
-done:
-       *dst = '\0';
-       return (dst);
+
+       /* Terminate the output string. */
+       *mbdst = '\0';
+
+       /* Pass conversion error flag out. */
+       if (cerr_ptr)
+               *cerr_ptr = cerr;
+
+       free(extra);
+       free(pdst);
+       free(psrc);
+
+       return (int)olen;
+out:
+       free(extra);
+       free(pdst);
+       free(psrc);
+       return error;
+}
+
+static int
+istrsenvisxl(char *mbdst, size_t *dlen, const char *mbsrc,
+    int flags, const char *mbextra, int *cerr_ptr)
+{
+       return istrsenvisx(mbdst, dlen, mbsrc,
+           mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr);
+}
+
+#endif
+
+#if !HAVE_SVIS
+/*
+ *     The "svis" variants all take an "extra" arg that is a pointer
+ *     to a NUL-terminated list of characters to be encoded, too.
+ *     These functions are useful e. g. to encode strings in such a
+ *     way so that they are not interpreted by a shell.
+ */
+
+char *
+svis(char *mbdst, int c, int flags, int nextc, const char *mbextra)
+{
+       char cc[2];
+       int ret;
+
+       cc[0] = c;
+       cc[1] = nextc;
+
+       ret = istrsenvisx(mbdst, NULL, cc, 1, flags, mbextra, NULL);
+       if (ret < 0)
+               return NULL;
+       return mbdst + ret;
+}
+
+char *
+snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra)
+{
+       char cc[2];
+       int ret;
+
+       cc[0] = c;
+       cc[1] = nextc;
+
+       ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, mbextra, NULL);
+       if (ret < 0)
+               return NULL;
+       return mbdst + ret;
+}
+
+int
+strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
+{
+       return istrsenvisxl(mbdst, NULL, mbsrc, flags, mbextra, NULL);
+}
+
+int
+strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
+{
+       return istrsenvisxl(mbdst, &dlen, mbsrc, flags, mbextra, NULL);
+}
+
+int
+strsvisx(char *mbdst, const char *mbsrc, size_t len, int flags, const char *mbextra)
+{
+       return istrsenvisx(mbdst, NULL, mbsrc, len, flags, mbextra, NULL);
+}
+
+int
+strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
+    const char *mbextra)
+{
+       return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
+}
+
+int
+strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
+    const char *mbextra, int *cerr_ptr)
+{
+       return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr);
+}
+#endif
+
+#if !HAVE_VIS
+/*
+ * vis - visually encode characters
+ */
+char *
+vis(char *mbdst, int c, int flags, int nextc)
+{
+       char cc[2];
+       int ret;
+
+       cc[0] = c;
+       cc[1] = nextc;
+
+       ret = istrsenvisx(mbdst, NULL, cc, 1, flags, "", NULL);
+       if (ret < 0)
+               return NULL;
+       return mbdst + ret;
+}
+
+char *
+nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
+{
+       char cc[2];
+       int ret;
+
+       cc[0] = c;
+       cc[1] = nextc;
+
+       ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, "", NULL);
+       if (ret < 0)
+               return NULL;
+       return mbdst + ret;
 }
 
 /*
- * strvis, strvisx - visually encode characters from src into dst
+ * strvis - visually encode characters from src into dst
  *
  *     Dst must be 4 times the size of src to account for possible
- *     expansion.  The length of dst, not including the trailing NUL,
+ *     expansion.  The length of dst, not including the trailing NULL,
  *     is returned.
- *
- *     Strvisx encodes exactly len bytes from src into dst.
- *     This is useful for encoding a block of data.
  */
+
 int
-strvis(dst, src, flag)
-       char *dst;
-       const char *src;
-       int flag;
+strvis(char *mbdst, const char *mbsrc, int flags)
 {
-       char c;
-       char *start;
+       return istrsenvisxl(mbdst, NULL, mbsrc, flags, "", NULL);
+}
 
-       for (start = dst; (c = *src); )
-               dst = vis(dst, c, flag, *++src);
-       *dst = '\0';
-       return (dst - start);
+int
+strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
+{
+       return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
 }
 
+/*
+ * strvisx - visually encode characters from src into dst
+ *
+ *     Dst must be 4 times the size of src to account for possible
+ *     expansion.  The length of dst, not including the trailing NULL,
+ *     is returned.
+ *
+ *     Strvisx encodes exactly len characters from src into dst.
+ *     This is useful for encoding a block of data.
+ */
+
 int
-strvisx(dst, src, len, flag)
-       char *dst;
-       const char *src;
-       size_t len;
-       int flag;
+strvisx(char *mbdst, const char *mbsrc, size_t len, int flags)
 {
-       int c;
-       char *start;
+       return istrsenvisx(mbdst, NULL, mbsrc, len, flags, "", NULL);
+}
 
-       for (start = dst; len > 1; len--) {
-               c = *src;
-               dst = vis(dst, c, flag, *++src);
-       }
-       if (len)
-               dst = vis(dst, *src, flag, '\0');
-       *dst = '\0';
+int
+strnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags)
+{
+       return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", NULL);
+}
 
-       return (dst - start);
+int
+strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
+    int *cerr_ptr)
+{
+       return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
 }
+#endif
diff --git a/gen/assumes.h b/gen/assumes.h
deleted file mode 100644 (file)
index 6734325..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef __OSX_ASSUMES_H__
-#define __OSX_ASSUMES_H__
-
-/* The interfaces in this file have been replaced by those in os/assumes.h.
- * Use the os_*() variants instead of these. The posix_assumes_*() macros have
- * moved to os/assumes.h.
- */
-#include <os/assumes.h>
-
-__BEGIN_DECLS
-
-#define osx_fastpath(x) os_fastpath(x)
-#define osx_slowpath(x) os_slowpath(x)
-#define osx_constant(x) os_constant(x)
-#define osx_hardware_trap() os_hardware_trap()
-#define __OSX_COMPILETIME_ASSERT__(e) __OS_COMPILETIME_ASSERT__((e))
-
-typedef os_redirect_t osx_redirect_t;
-typedef os_log_callout_t osx_log_callout_t;
-
-#define osx_set_crash_message(arg) os_set_crash_message(arg)
-
-#define osx_assumes(e) os_assumes((e))
-#define osx_assumes_zero(e) os_assumes_zero((e))
-
-#define osx_assert(e) os_assert((e))
-#define osx_assert_zero(e) os_assert_zero((e))
-
-#define osx_assumes_ctx(f, ctx, e) os_assumes_ctx((f), (ctx), (e))
-#define osx_assumes_zero_ctx(f, ctx, e) os_assumes_zero_ctx((f), (ctx), (e))
-
-#define osx_assert_ctx(f, ctx, e) os_assert_ctx((f), (ctx), (e))
-#define osx_assert_zero_ctx(f, ctx, e) os_assert_zero_ctx((f), (ctx), (e))
-
-__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)
-extern void
-_osx_assumes_log(uint64_t code);
-
-__OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0)
-extern char *
-_osx_assert_log(uint64_t code);
-
-__OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0)
-extern void
-_osx_assumes_log_ctx(osx_log_callout_t callout, void *ctx, uint64_t code);
-
-__OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0)
-extern char *
-_osx_assert_log_ctx(osx_log_callout_t callout, void *ctx, uint64_t code);
-
-__OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0)
-extern void
-_osx_avoid_tail_call(void);
-
-__END_DECLS
-
-#endif /* __OSX_ASSUMES_H__ */
diff --git a/gen/clock_gettime.3 b/gen/clock_gettime.3
new file mode 100644 (file)
index 0000000..e340b64
--- /dev/null
@@ -0,0 +1,186 @@
+.\"
+.\" Copyright (c) 1980, 1991, 1993
+.\" The Regents of the University of California.  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.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+.\"
+.Dd January 26, 2016
+.Dt CLOCK_GETTIME 3
+.Os
+.Sh NAME
+.Nm clock_gettime ,
+.Nm clock_settime ,
+.Nm clock_getres ,
+.Nm clock_gettime_nsec_np
+.Nd get/set date and time
+.Sh SYNOPSIS
+.Fd #include <time.h>
+.Ft int
+.Fn clock_gettime "clockid_t clock_id" "struct timespec *tp"
+.Ft int
+.Fn clock_settime "clockid_t clock_id" "const struct timespec *tp"
+.Ft int
+.Fn clock_getres "clockid_t clock_id" "struct timespec *tp"
+.Ft uint64_t
+.Fn clock_gettime_nsec_np "clockid_t clock_id"
+.Sh DESCRIPTION
+The
+.Fn clock_gettime
+and
+.Fn clock_settime
+functions
+allow the calling process to retrieve or set the value used by a clock
+which is specified by
+.Fa clock_id .
+.Pp
+.Fa clock_id
+can be a value from
+one of 5 predefined values:
+.Bl -tag -width Er
+.It Dv CLOCK_REALTIME
+the system's real time (i.e. wall time) clock, expressed as the amount of time
+since the Epoch.
+This is the same as the value returned by
+.Xr gettimeofday 2 .
+.It Dv CLOCK_MONOTONIC
+clock that increments monotonically, tracking the time since an arbitrary
+point, and will continue to increment while the system is asleep.
+.It Dv CLOCK_MONOTONIC_RAW
+clock that increments monotonically, tracking the time since an arbitrary point
+like CLOCK_MONOTONIC.  However, this clock is unaffected by frequency or time
+adjustments.  It should not be compared to other system time sources.
+.It Dv CLOCK_MONOTONIC_RAW_APPROX
+like CLOCK_MONOTONIC_RAW, but reads a value cached by the system at context
+switch.  This can be read faster, but at a loss of accuracy as it may return
+values that are milliseconds old.
+.It Dv CLOCK_UPTIME_RAW
+clock that increments monotonically, in the same manner as
+.Dv CLOCK_MONOTONIC_RAW,
+but that does not increment while the system is asleep.
+The returned value is identical to the result of
+.Fn mach_absolute_time
+after the appropriate mach_timebase conversion is applied.
+.It Dv CLOCK_UPTIME_RAW_APPROX
+like CLOCK_UPTIME_RAW, but reads a value cached by the system at context
+switch.  This can be read faster, but at a loss of accuracy as it may return
+values that are milliseconds old.
+.It Dv CLOCK_PROCESS_CPUTIME_ID
+clock that tracks the amount of CPU (in user- or kernel-mode) used by the
+calling process.
+.It Dv CLOCK_THREAD_CPUTIME_ID
+clock that tracks the amount of CPU (in user- or kernel-mode) used by the
+calling thread.
+.El
+.Pp
+The structure pointed to by
+.Fa tp
+is defined in
+.In sys/time.h
+as:
+.Bd -literal -offset indent
+struct timespec {
+    time_t  tv_sec;     /* seconds */
+    long    tv_nsec;    /* and nanoseconds */
+};
+.Ed
+.Pp
+Only the
+.Dv CLOCK_REALTIME
+clock can be set, and only the superuser may do so.
+.Pp
+The resolution of a clock is returned by the
+.Fn clock_getres
+call.
+This value is placed in a (non-null)
+.Fa *tp .
+This value may be smaller than the actual precision of the underlying clock,
+but represents a lower bound on the resolution.
+.Pp
+As a non-portable extension, the
+.Fn clock_gettime_nsec_np
+function will return the clock value in 64-bit nanoseconds.
+.Sh RETURN VALUES
+A 0 return value indicates that the call succeeded.
+A \-1 return value indicates an error occurred, and in this
+case an error code is stored into the global variable
+.Va errno .
+For
+.Fn clock_gettime_nsec_np
+a return value of non-0 indicates success.  A 0 return value indicates an error
+occurred and an error code is stored in
+.Va errno .
+.Sh ERRORS
+.Fn clock_gettime ,
+.Fn clock_settime ,
+.Fn clock_getres ,
+and
+.Fn clock_gettime_nsec_np
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+.Fa clock_id
+is not a valid value.
+.It Bq Er EFAULT
+The
+.Fa tp
+argument address referenced invalid memory.
+.El
+.Pp
+In addition,
+.Fn clock_settime
+may return the following errors:
+.Bl -tag -width Er
+.It Bq Er EPERM
+A user other than the superuser attempted to set the time.
+.It Bq Er EINVAL
+.Fa clock_id
+specifies a clock that isn't settable,
+.Fa tp
+specifies a nanosecond value less than zero or greater than 1000 million,
+or a value outside the range of the specified clock.
+.El
+.Sh SEE ALSO
+.Xr date 1 ,
+.Xr getitimer 2 ,
+.Xr gettimeofday 2 ,
+.Sh HISTORY
+These functions first appeared
+in
+Mac OSX 10.12
+.Sh STANDARDS
+The
+.Fn clock_gettime ,
+.Fn clock_settime ,
+and
+.Fn clock_getres
+system calls conform to
+.St -p1003.1b-93 .
+.Fn cleck_gettime_nsec_np
+is a non-portable Darwin extension.
+The clock IDs
+.Fa CLOCK_MONOTONIC_RAW
+and
+.Fa CLOCK_UPTIME_RAW
+are extensions to the POSIX interface.
diff --git a/gen/clock_gettime.c b/gen/clock_gettime.c
new file mode 100644 (file)
index 0000000..7be0ad7
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2016 Apple Inc. All rights reserved.
+ *
+ * @APPLE_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. 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_LICENSE_HEADER_END@
+ */
+
+#include <errno.h>
+#include <stdatomic.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <mach/mach_error.h>
+#include <mach/mach_time.h>
+#include <os/base_private.h>
+
+extern uint64_t __thread_selfusage(void);
+
+#define timeval2nsec(tv) (tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * NSEC_PER_USEC)
+
+static uint64_t
+_boottime_fallback_usec(void)
+{
+    struct timeval tv;
+    size_t len = sizeof(tv);
+    int ret = sysctlbyname("kern.boottime", &tv, &len, NULL, 0);
+    if (ret == -1) return 0;
+    return (uint64_t)tv.tv_sec * USEC_PER_SEC + (uint64_t)tv.tv_usec;
+}
+
+static int
+_mach_boottime_usec(uint64_t *boottime, struct timeval *realtime)
+{
+    uint64_t bt1 = 0, bt2 = 0;
+    int ret;
+    do {
+        bt1 = mach_boottime_usec();
+        if (os_slowpath(bt1 == 0)) bt1 = _boottime_fallback_usec();
+
+        atomic_thread_fence(memory_order_seq_cst);
+
+        ret = gettimeofday(realtime, NULL);
+        if (ret != 0) return ret;
+
+        atomic_thread_fence(memory_order_seq_cst);
+
+        bt2 = mach_boottime_usec();
+        if (os_slowpath(bt2 == 0)) bt2 = _boottime_fallback_usec();
+    } while (os_slowpath(bt1 != bt2));
+    *boottime = bt1;
+    return 0;
+}
+
+uint64_t
+clock_gettime_nsec_np(clockid_t clock_id)
+{
+    switch(clock_id){
+    case CLOCK_REALTIME: {
+        struct timeval tv;
+        int ret = gettimeofday(&tv, NULL);
+        if (ret) return 0;
+        return timeval2nsec(tv);
+    }
+    case CLOCK_MONOTONIC: {
+        struct timeval tv;
+        uint64_t boottime;
+        int ret = _mach_boottime_usec(&boottime, &tv);
+        if (ret) return 0;
+        boottime *= NSEC_PER_USEC;
+        return timeval2nsec(tv) - boottime;
+    }
+    case CLOCK_PROCESS_CPUTIME_ID: {
+        struct rusage ru;
+        int ret = getrusage(RUSAGE_SELF, &ru);
+        if (ret) return 0;
+        return timeval2nsec(ru.ru_utime) + timeval2nsec(ru.ru_stime);
+    }
+    default:
+        // calls that use mach_absolute_time units fall through into a common path
+        break;
+    }
+
+    // Mach Absolute Time unit-based calls
+    mach_timebase_info_data_t tb_info;
+    if (mach_timebase_info(&tb_info)) return 0;
+    uint64_t mach_time;
+
+    switch(clock_id){
+    case CLOCK_MONOTONIC_RAW:
+        mach_time = mach_continuous_time();
+        break;
+    case CLOCK_MONOTONIC_RAW_APPROX:
+        mach_time = mach_continuous_approximate_time();
+        break;
+    case CLOCK_UPTIME_RAW:
+        mach_time = mach_absolute_time();
+        break;
+    case CLOCK_UPTIME_RAW_APPROX:
+        mach_time = mach_approximate_time();
+        break;
+    case CLOCK_THREAD_CPUTIME_ID:
+        mach_time = __thread_selfusage();
+        break;
+    default:
+        errno = EINVAL;
+        return 0;
+    }
+
+    return (mach_time * tb_info.numer) / tb_info.denom;
+}
+
+int
+clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+    switch(clk_id){
+    case CLOCK_REALTIME: {
+        struct timeval tv;
+        int ret = gettimeofday(&tv, NULL);
+        TIMEVAL_TO_TIMESPEC(&tv, tp);
+        return ret;
+    }
+    case CLOCK_MONOTONIC: {
+        struct timeval tv;
+        uint64_t boottime_usec;
+        int ret = _mach_boottime_usec(&boottime_usec, &tv);
+        struct timeval boottime = {
+            .tv_sec = boottime_usec / USEC_PER_SEC,
+            .tv_usec = boottime_usec % USEC_PER_SEC
+        };
+        timersub(&tv, &boottime, &tv);
+        TIMEVAL_TO_TIMESPEC(&tv, tp);
+        return ret;
+    }
+    case CLOCK_PROCESS_CPUTIME_ID: {
+        struct rusage ru;
+        int ret = getrusage(RUSAGE_SELF, &ru);
+        timeradd(&ru.ru_utime, &ru.ru_stime, &ru.ru_utime);
+        TIMEVAL_TO_TIMESPEC(&ru.ru_utime, tp);
+        return ret;
+    }
+    case CLOCK_MONOTONIC_RAW:
+    case CLOCK_MONOTONIC_RAW_APPROX:
+    case CLOCK_UPTIME_RAW:
+    case CLOCK_UPTIME_RAW_APPROX:
+    case CLOCK_THREAD_CPUTIME_ID: {
+        uint64_t ns = clock_gettime_nsec_np(clk_id);
+        if (!ns) return -1;
+
+        tp->tv_sec = ns/NSEC_PER_SEC;
+        tp->tv_nsec = ns % NSEC_PER_SEC;
+        return 0;
+    }
+    default:
+        errno = EINVAL;
+        return -1;
+    }
+}
+
+int
+clock_getres(clockid_t clk_id, struct timespec *res)
+{
+    switch(clk_id){
+    case CLOCK_REALTIME:
+    case CLOCK_MONOTONIC:
+    case CLOCK_PROCESS_CPUTIME_ID:
+        res->tv_nsec = NSEC_PER_USEC;
+        res->tv_sec = 0;
+        return 0;
+
+    case CLOCK_MONOTONIC_RAW:
+    case CLOCK_MONOTONIC_RAW_APPROX:
+    case CLOCK_UPTIME_RAW:
+    case CLOCK_UPTIME_RAW_APPROX:
+    case CLOCK_THREAD_CPUTIME_ID: {
+        mach_timebase_info_data_t tb_info;
+        if (mach_timebase_info(&tb_info)){
+            return -1;
+        }
+        res->tv_nsec = tb_info.numer / tb_info.denom + (tb_info.numer % tb_info.denom != 0);
+        res->tv_sec = 0;
+        return 0;
+    }
+
+    default:
+        errno = EINVAL;
+        return -1;
+    }
+}
+
+int
+clock_settime(clockid_t clk_id, const struct timespec *tp)
+{
+    switch(clk_id){
+    case CLOCK_REALTIME: {
+        struct timeval tv;
+        TIMESPEC_TO_TIMEVAL(&tv,tp)
+        return settimeofday(&tv, NULL);
+    }
+    default:
+        errno = EINVAL;
+        return -1;
+    }
+}
index 1bd602528ee165082458f862afce037e831a61f7..729ec79349f46210d687d04b1fde86f9d45cc324 100644 (file)
--- a/gen/fts.c
+++ b/gen/fts.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2000, 2003, 2005, 2008, 2012 Apple Inc. All rights reserved.
+ * Copyright (c) 1999, 2000, 2003, 2005, 2008, 2012, 2016 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
  * SUCH DAMAGE.
  */
 
+/*     $OpenBSD: fts.c,v 1.51 2015/09/12 13:32:24 guenther Exp $       */
 
 #include <sys/param.h>
 #include <sys/stat.h>
 
+#include <assert.h>
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <fts.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <stdbool.h>
+#include <sys/vnode.h>
+#include <sys/attr.h>
+
 #ifdef __BLOCKS__
 #include <Block.h>
 #endif /* __BLOCKS__ */
+#include <malloc_private.h>
 
 static FTSENT  *fts_alloc(FTS *, char *, int);
 static FTSENT  *fts_build(FTS *, int);
 static void     fts_lfree(FTSENT *);
 static void     fts_load(FTS *, FTSENT *);
 static size_t   fts_maxarglen(char * const *);
-static void     fts_padjust(FTS *, void *);
+static void     fts_padjust(FTS *, FTSENT *);
 static int      fts_palloc(FTS *, size_t);
 static FTSENT  *fts_sort(FTS *, FTSENT *, int);
-static u_short  fts_stat(FTS *, FTSENT *, int);
+static u_short  fts_stat(FTS *, FTSENT *, int, int);
+static u_short   fts_stat2(FTS *, FTSENT *, int, int, struct stat *);
+static int      fts_safe_changedir(FTS *, FTSENT *, int, char *);
 
-#define        ISDOT(a)        (a[0] == '.' && (!a[1] || a[1] == '.' && !a[2]))
+#define        ISDOT(a)        (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
 
-#define        ISSET(opt)      (sp->fts_options & opt)
-#define        SET(opt)        (sp->fts_options |= opt)
+#define        CLR(opt)        (sp->fts_options &= ~(opt))
+#define        ISSET(opt)      (sp->fts_options & (opt))
+#define        SET(opt)        (sp->fts_options |= (opt))
 
-#define        CHDIR(sp, path) (!ISSET(FTS_NOCHDIR) && chdir(path))
 #define        FCHDIR(sp, fd)  (!ISSET(FTS_NOCHDIR) && fchdir(fd))
 
 /* fts_build flags */
@@ -130,13 +136,11 @@ static u_short     fts_stat(FTS *, FTSENT *, int);
 #define F_D_TYPESYM    (5 << F_SHIFT)  /* only stat directories and symlinks but use d_type */
 
 static FTS *
-__fts_open(argv, sp)
-       char * const *argv;
-       register FTS *sp;
+__fts_open(char * const *argv, FTS *sp)
 {
-       register FTSENT *p, *root;
-       register int nitems;
-       FTSENT *parent, *tmp = NULL;
+       FTSENT *p, *root;
+       int nitems;
+       FTSENT *parent, *tmp;
        int len;
 
        /* Logical walks turn on NOCHDIR; symbolic links are too hard. */
@@ -147,7 +151,7 @@ __fts_open(argv, sp)
         * Start out with 1K of path space, and enough, in any case,
         * to hold the user's paths.
         */
-       if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN)))
+       if (fts_palloc(sp, MAX(fts_maxarglen(argv), PATH_MAX)))
                goto mem1;
 
        /* Allocate/initialize root's parent. */
@@ -163,11 +167,12 @@ __fts_open(argv, sp)
                        goto mem3;
                }
 
-               p = fts_alloc(sp, *argv, len);
+               if ((p = fts_alloc(sp, *argv, len)) == NULL)
+                       goto mem3;
                p->fts_level = FTS_ROOTLEVEL;
                p->fts_parent = parent;
                p->fts_accpath = p->fts_name;
-               p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOWDIR) ? -1 : ISSET(FTS_COMFOLLOW));
+               p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOWDIR) ? -1 : ISSET(FTS_COMFOLLOW), -1);
 
                /* Command-line "." and ".." are real directories. */
                if (p->fts_info == FTS_DOT)
@@ -204,15 +209,19 @@ __fts_open(argv, sp)
        sp->fts_cur->fts_info = FTS_INIT;
 
        /*
-        * If using chdir(2), grab a file descriptor pointing to dot to insure
+        * If using chdir(2), grab a file descriptor pointing to dot to ensure
         * that we can get back here; this could be avoided for some paths,
         * but almost certainly not worth the effort.  Slashes, symbolic links,
         * and ".." are all fairly nasty problems.  Note, if we can't get the
         * descriptor we run anyway, just more slowly.
         */
-       if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = open(".", O_RDONLY, 0)) < 0)
+       if (!ISSET(FTS_NOCHDIR) &&
+           (sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC)) < 0)
                SET(FTS_NOCHDIR);
 
+       if (nitems == 0)
+               free(parent);
+
        return (sp);
 
 mem3:  fts_lfree(root);
@@ -223,12 +232,9 @@ mem1:      free(sp);
 }
 
 FTS *
-fts_open(argv, options, compar)
-       char * const *argv;
-       int options;
-       int (*compar)();
+fts_open(char * const *argv, int options, int (*compar)())
 {
-       register FTS *sp;
+       FTS *sp;
 
        /* Options check. */
        if (options & ~FTS_OPTIONMASK) {
@@ -238,9 +244,8 @@ fts_open(argv, options, compar)
        if (options & FTS_NOSTAT_TYPE) options |= FTS_NOSTAT;
 
        /* Allocate/initialize the stream */
-       if ((sp = malloc((u_int)sizeof(FTS))) == NULL)
+       if ((sp = calloc(1, sizeof(FTS))) == NULL)
                return (NULL);
-       memset(sp, 0, sizeof(FTS));
        sp->fts_compar = compar;
        sp->fts_options = options;
 
@@ -249,12 +254,9 @@ fts_open(argv, options, compar)
 
 #ifdef __BLOCKS__
 FTS *
-fts_open_b(argv, options, compar)
-       char * const *argv;
-       int options;
-       int (^compar)(const FTSENT **, const FTSENT **);
+fts_open_b(char * const *argv, int options, int (^compar)(const FTSENT **, const FTSENT **))
 {
-       register FTS *sp;
+       FTS *sp;
 
        /* Options check. */
        if (options & ~FTS_OPTIONMASK) {
@@ -264,9 +266,8 @@ fts_open_b(argv, options, compar)
        if (options & FTS_NOSTAT_TYPE) options |= FTS_NOSTAT;
 
        /* Allocate/initialize the stream */
-       if ((sp = malloc((u_int)sizeof(FTS))) == NULL)
+       if ((sp = calloc(1, sizeof(FTS))) == NULL)
                return (NULL);
-       memset(sp, 0, sizeof(FTS));
        sp->fts_compar_b = (int (^)())Block_copy(compar);
        sp->fts_options = options | FTS_BLOCK_COMPAR;
 
@@ -275,12 +276,10 @@ fts_open_b(argv, options, compar)
 #endif /* __BLOCKS__ */
 
 static void
-fts_load(sp, p)
-       FTS *sp;
-       register FTSENT *p;
+fts_load(FTS *sp, FTSENT *p)
 {
-       register int len;
-       register char *cp;
+       int len;
+       char *cp;
 
        /*
         * Load the stream structure for the next traversal.  Since we don't
@@ -301,11 +300,10 @@ fts_load(sp, p)
 }
 
 int
-fts_close(sp)
-       FTS *sp;
+fts_close(FTS *sp)
 {
-       register FTSENT *freep, *p;
-       int saved_errno = 0;
+       FTSENT *freep, *p;
+       int rfd, error = 0;
 
        /*
         * This still works if we haven't read anything -- the dummy structure
@@ -321,20 +319,15 @@ fts_close(sp)
                free(p);
        }
 
-       /* Free up child linked list, sort array, path buffer. */
-       if (sp->fts_child)
+       /* Stash the original directory fd if needed. */
+       rfd = ISSET(FTS_NOCHDIR) ? -1 : sp->fts_rfd;
+
+       /* Free up child linked list, sort array, path buffer, stream ptr.*/
+       if (sp->fts_child){
                fts_lfree(sp->fts_child);
-       if (sp->fts_array)
-               free(sp->fts_array);
-       free(sp->fts_path);
-
-       /* Return to original directory, save errno if necessary. */
-       if (!ISSET(FTS_NOCHDIR)) {
-            if (fchdir(sp->fts_rfd)) {
-                saved_errno = errno;
-            }
-            (void)close(sp->fts_rfd);
        }
+       free(sp->fts_array); sp->fts_array = NULL;
+       free(sp->fts_path); sp->fts_path = NULL;
 
 #ifdef __BLOCKS__
        /* Free up any block pointer. */
@@ -345,12 +338,21 @@ fts_close(sp)
        /* Free up the stream pointer. */
        free(sp);
 
-       /* Set errno and return. */
-       if (saved_errno) {
+       /* Return to original directory, checking for error. */
+       if (rfd != -1) {
+               int saved_errno = errno;
+               if (fchdir(rfd) != 0){
+                       error = -1;
+                       saved_errno = errno;
+               }
+               if (close(rfd) != 0){
+                       error = -1;
+                       saved_errno = errno;
+               }
                errno = saved_errno;
-               return (-1);
        }
-       return (0);
+
+       return (error);
 }
 
 /*
@@ -362,12 +364,11 @@ fts_close(sp)
            p->fts_path[0] == '/' ? 0 : p->fts_pathlen)
 
 FTSENT *
-fts_read(sp)
-       register FTS *sp;
+fts_read(FTS *sp)
 {
-       register FTSENT *p, *tmp;
-       register int instr;
-       register char *t;
+       FTSENT *p, *tmp;
+       int instr;
+       char *t;
        int saved_errno;
 
        /* If finished or unrecoverable error, return NULL. */
@@ -383,7 +384,7 @@ fts_read(sp)
 
        /* Any type of file may be re-visited; re-stat and re-turn. */
        if (instr == FTS_AGAIN) {
-               p->fts_info = fts_stat(sp, p, 0);
+               p->fts_info = fts_stat(sp, p, 0, -1);
                return (p);
        }
 
@@ -395,9 +396,10 @@ fts_read(sp)
         */
        if (instr == FTS_FOLLOW &&
            (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
-               p->fts_info = fts_stat(sp, p, 1);
+               p->fts_info = fts_stat(sp, p, 1, -1);
                if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
-                       if ((p->fts_symfd = open(".", O_RDONLY, 0)) < 0) {
+                       if ((p->fts_symfd =
+                           open(".", O_RDONLY | O_CLOEXEC)) < 0) {
                                p->fts_errno = errno;
                                p->fts_info = FTS_ERR;
                        } else {
@@ -423,8 +425,8 @@ fts_read(sp)
                }
 
                /* Rebuild if only read the names and now traversing. */
-               if (sp->fts_child && sp->fts_options & FTS_NAMEONLY) {
-                       sp->fts_options &= ~FTS_NAMEONLY;
+               if (sp->fts_child && ISSET(FTS_NAMEONLY)) {
+                       CLR(FTS_NAMEONLY);
                        fts_lfree(sp->fts_child);
                        sp->fts_child = NULL;
                }
@@ -442,7 +444,7 @@ fts_read(sp)
                 * FTS_STOP or the fts_info field of the node.
                 */
                if (sp->fts_child) {
-                       if (CHDIR(sp, p->fts_accpath)) {
+                       if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) {
                                p->fts_errno = errno;
                                p->fts_flags |= FTS_DONTCHDIR;
                                for (p = sp->fts_child; p; p = p->fts_link)
@@ -462,17 +464,18 @@ fts_read(sp)
        /* Move to the next node on this level. */
 next:  tmp = p;
        if ((p = p->fts_link)) {
+               free(tmp);
+
                /*
-                * If reached the top, return to the original directory, and
-                * load the paths for the next root.
+                * If reached the top, return to the original directory (or
+                * the root of the tree), and load the paths for the next root.
                 */
                if (p->fts_level == FTS_ROOTLEVEL) {
-                       if (!ISSET(FTS_NOCHDIR) && FCHDIR(sp, sp->fts_rfd)) {
+                       if (FCHDIR(sp, sp->fts_rfd)) {
                                SET(FTS_STOP);
                                return (NULL);
                        }
                        fts_load(sp, p);
-                       free(tmp);
                        return (sp->fts_cur = p);
                }
 
@@ -482,14 +485,13 @@ next:     tmp = p;
                 * get back if necessary.
                 */
                if (p->fts_instr == FTS_SKIP) {
-                       free(tmp);
                        goto next;
                }
                if (p->fts_instr == FTS_FOLLOW) {
-                       p->fts_info = fts_stat(sp, p, 1);
+                       p->fts_info = fts_stat(sp, p, 1, -1);
                        if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
                                if ((p->fts_symfd =
-                                   open(".", O_RDONLY, 0)) < 0) {
+                                   open(".", O_RDONLY | O_CLOEXEC, 0)) < 0) {
                                        p->fts_errno = errno;
                                        p->fts_info = FTS_ERR;
                                } else {
@@ -499,7 +501,6 @@ next:       tmp = p;
                        p->fts_instr = FTS_NOINSTR;
                }
 
-               free(tmp);
 name:          t = sp->fts_path + NAPPEND(p->fts_parent);
                *t++ = '/';
                memmove(t, p->fts_name, p->fts_namelen + 1);
@@ -508,19 +509,19 @@ name:             t = sp->fts_path + NAPPEND(p->fts_parent);
 
        /* Move up to the parent node. */
        p = tmp->fts_parent;
+       free(tmp);
 
        if (p->fts_level == FTS_ROOTPARENTLEVEL) {
                /*
                 * Done; free everything up and set errno to 0 so the user
                 * can distinguish between error and EOF.
                 */
-               free(tmp);
                free(p);
                errno = 0;
                return (sp->fts_cur = NULL);
        }
 
-       /* Nul terminate the pathname. */
+       /* NUL terminate the pathname. */
        sp->fts_path[p->fts_pathlen] = '\0';
 
        /*
@@ -529,8 +530,9 @@ name:               t = sp->fts_path + NAPPEND(p->fts_parent);
         * one directory.
         */
        if (p->fts_level == FTS_ROOTLEVEL) {
-               if (!ISSET(FTS_NOCHDIR) && FCHDIR(sp, sp->fts_rfd)) {
+               if (FCHDIR(sp, sp->fts_rfd)) {
                        SET(FTS_STOP);
+                       sp->fts_cur = p;
                        return (NULL);
                }
        } else if (p->fts_flags & FTS_SYMFOLLOW) {
@@ -539,16 +541,16 @@ name:             t = sp->fts_path + NAPPEND(p->fts_parent);
                        (void)close(p->fts_symfd);
                        errno = saved_errno;
                        SET(FTS_STOP);
+                       sp->fts_cur = p;
                        return (NULL);
                }
                (void)close(p->fts_symfd);
-       } else if (!(p->fts_flags & FTS_DONTCHDIR)) {
-               if (CHDIR(sp, "..")) {
-                       SET(FTS_STOP);
-                       return (NULL);
-               }
+       } else if (!(p->fts_flags & FTS_DONTCHDIR) &&
+           fts_safe_changedir(sp, p->fts_parent, -1, "..")) {
+               SET(FTS_STOP);
+               sp->fts_cur = p;
+               return (NULL);
        }
-       free(tmp);
        p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
        return (sp->fts_cur = p);
 }
@@ -561,10 +563,7 @@ name:              t = sp->fts_path + NAPPEND(p->fts_parent);
  */
 /* ARGSUSED */
 int
-fts_set(sp, p, instr)
-       FTS *sp;
-       FTSENT *p;
-       int instr;
+fts_set(FTS __unused *sp, FTSENT *p, int instr)
 {
        if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
            instr != FTS_NOINSTR && instr != FTS_SKIP) {
@@ -576,11 +575,9 @@ fts_set(sp, p, instr)
 }
 
 FTSENT *
-fts_children(sp, instr)
-       register FTS *sp;
-       int instr;
+fts_children(FTS *sp, int instr)
 {
-       register FTSENT *p;
+       FTSENT *p;
        int fd;
 
        if (instr && instr != FTS_NAMEONLY) {
@@ -618,9 +615,9 @@ fts_children(sp, instr)
                fts_lfree(sp->fts_child);
 
        if (instr == FTS_NAMEONLY) {
-               sp->fts_options |= FTS_NAMEONLY;
+               SET(FTS_NAMEONLY);
                instr = BNAMES;
-       } else 
+       } else
                instr = BCHILD;
 
        /*
@@ -634,15 +631,341 @@ fts_children(sp, instr)
            ISSET(FTS_NOCHDIR))
                return (sp->fts_child = fts_build(sp, instr));
 
-       if ((fd = open(".", O_RDONLY, 0)) < 0)
+       if ((fd = open(".", O_RDONLY | O_CLOEXEC, 0)) < 0)
                return (NULL);
        sp->fts_child = fts_build(sp, instr);
-       if (fchdir(fd))
+       if (fchdir(fd)) {
+               (void)close(fd);
                return (NULL);
+       }
        (void)close(fd);
        return (sp->fts_child);
 }
 
+typedef struct __attribute__((packed)) {
+       uint32_t length;
+
+       /* common attributes */
+       attribute_set_t attrset;
+       attrreference_t name;
+       dev_t st_dev;
+       fsobj_type_t objtype;
+       struct timespec st_birthtimespec;
+       struct timespec st_mtimespec;
+       struct timespec st_ctimespec;
+       struct timespec st_atimespec;
+       uid_t st_uid;
+       gid_t st_gid;
+       uint32_t accessmask;
+       uint32_t st_flags;
+       uint64_t st_ino;
+
+       /* non-directory attributes */
+       uint32_t st_nlink;
+       off_t allocsize;
+       uint32_t st_blksize;
+       uint32_t st_rdev;
+       off_t st_size;
+} attrListAttributes;
+
+typedef struct __attribute__((packed)) {
+       uint32_t length;
+
+       /* common attributes */
+       attribute_set_t attrset;
+       attrreference_t name;
+       dev_t st_dev;
+       fsobj_type_t objtype;
+       uint64_t st_ino;
+
+       /* non-directory attributes */
+       uint32_t st_nlink;
+       uint32_t st_rdev;
+} attrListAttributes_nostat;
+
+#define ATTR_BUF_SIZE (32*1024)
+
+typedef struct {
+       DIR *dirp;
+
+       struct attrlist requested_attrs;
+       void *attrbuf;
+       union {
+               attrListAttributes *curattr;
+               attrListAttributes_nostat *curattr_nostat;
+       };
+       int dirfd;
+       bool done;
+       bool nostat;
+       bool needs_dot;
+       bool needs_dotdot;
+
+       int entry_count;
+       int cur_entry;
+} dir_handle;
+
+typedef struct {
+       char *d_name;
+       size_t d_namlen;
+       struct stat sb;
+       int d_type;
+       bool stat_valid;
+} dir_entry;
+
+static bool
+advance_directory(dir_handle *handle)
+{
+       if (handle->done) return true;
+
+       assert(handle->dirfd != -1);
+       handle->entry_count = getattrlistbulk(handle->dirfd, &handle->requested_attrs,
+                       handle->attrbuf, ATTR_BUF_SIZE, FSOPT_PACK_INVAL_ATTRS);
+       if (handle->entry_count == -1) {
+               goto error;
+       } else if (handle->entry_count == 0) {
+               /* No more entries. */
+               handle->done = true;
+       }
+       handle->cur_entry = 0;
+       handle->curattr = handle->attrbuf;
+       return true;
+
+error: {
+               int saved_errno = errno;
+               close(handle->dirfd);
+               handle->dirfd = -1;
+               errno = saved_errno;
+               return false;
+       }
+}
+
+static bool
+open_directory(FTS *sp, dir_handle *handle, const char *path)
+{
+       memset(handle, 0, sizeof(*handle));
+
+       handle->nostat = ISSET(FTS_NOSTAT);
+       handle->needs_dot = handle->needs_dotdot = ISSET(FTS_SEEDOT);
+
+       handle->dirfd = open(path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC);
+       if (handle->dirfd == -1) goto fallback;
+
+       handle->attrbuf = malloc(ATTR_BUF_SIZE);
+       if (!handle->attrbuf) goto fallback;
+
+       handle->requested_attrs.bitmapcount = ATTR_BIT_MAP_COUNT;
+       if (!handle->nostat) {
+               handle->requested_attrs.commonattr =
+                               ATTR_CMN_RETURNED_ATTRS|
+                               ATTR_CMN_NAME|ATTR_CMN_DEVID|ATTR_CMN_OBJTYPE|
+                               ATTR_CMN_CRTIME|ATTR_CMN_MODTIME|ATTR_CMN_CHGTIME|ATTR_CMN_ACCTIME|
+                               ATTR_CMN_OWNERID|ATTR_CMN_GRPID|ATTR_CMN_ACCESSMASK|ATTR_CMN_FLAGS|
+                               ATTR_CMN_FILEID;
+               handle->requested_attrs.fileattr = ATTR_FILE_LINKCOUNT|ATTR_FILE_ALLOCSIZE|
+                               ATTR_FILE_IOBLOCKSIZE|ATTR_FILE_DEVTYPE|ATTR_FILE_DATALENGTH;
+       } else {
+               handle->requested_attrs.commonattr = ATTR_CMN_RETURNED_ATTRS|
+                               ATTR_CMN_NAME|ATTR_CMN_DEVID|ATTR_CMN_OBJTYPE|
+                               ATTR_CMN_FILEID;
+               handle->requested_attrs.fileattr = ATTR_FILE_LINKCOUNT;
+       }
+
+       if (advance_directory(handle)) {
+               /*
+                * We successfully read the first attribute buffer,
+                * so we'll use getdirentriesattr/getattrlistbulk.
+                */
+               return true;
+       }
+
+fallback:
+       if (handle->dirfd != -1) close(handle->dirfd);
+       handle->dirfd = -1;
+       free(handle->attrbuf);
+       handle->attrbuf = NULL;
+       handle->dirp = opendir(path);
+       return (handle->dirp != NULL);
+}
+
+static bool
+read_dirent(dir_handle *handle, dir_entry *entry)
+{
+       if (handle->dirp) {
+               struct dirent *de = readdir(handle->dirp);
+               if (de == NULL) return false;
+               entry->d_name = de->d_name;
+               entry->d_namlen = de->d_namlen;
+               entry->d_type = de->d_type;
+               entry->stat_valid = false;
+               return true;
+       }
+
+       /*
+        * There are three states that our dir_handle can be in:
+        *   - real getattrlistbulk use (entry_count >= 0) - the rest of this function
+        *   - fallback - handled above with dirp
+        *   - closed fallback (dirp == NULL) - handled with this check
+        */
+       if (handle->dirfd == -1) {
+               return false;
+       }
+
+       if (handle->needs_dot) {
+               handle->needs_dot = false;
+               entry->d_name = ".";
+               entry->d_namlen = strlen(".");
+               entry->d_type = DT_DIR;
+               entry->stat_valid = false;
+               return true;
+       } else if (handle->needs_dotdot) {
+               handle->needs_dotdot = false;
+               entry->d_name = "..";
+               entry->d_namlen = strlen("..");
+               entry->d_type = DT_DIR;
+               entry->stat_valid = false;
+               return true;
+       }
+
+       if (handle->cur_entry == handle->entry_count) {
+               if (handle->done) return false;                /* Already done with the directory. */
+               if (!advance_directory(handle)) return false;  /* Reading the next buffer failed. */
+               if (handle->done) return false;                /* We're now done with the directory. */
+       }
+
+       bzero(entry, sizeof(*entry));
+
+       attrListAttributes *curattr_stat = NULL;
+       attrListAttributes_nostat *curattr_nostat = NULL;
+       if (!handle->nostat) {
+               curattr_stat = handle->curattr;
+               handle->cur_entry++;
+               handle->curattr = (attrListAttributes*)(((char*)curattr_stat) + curattr_stat->length);
+
+               entry->d_name = ((char*)&curattr_stat->name) + curattr_stat->name.attr_dataoffset;
+               /* attr_length includes the null terminator, but readdir's d_namlen doesn't. */
+               entry->d_namlen = curattr_stat->name.attr_length - 1;
+       } else {
+               curattr_nostat = handle->curattr_nostat;
+               handle->cur_entry++;
+               handle->curattr_nostat = (attrListAttributes_nostat*)(((char*)curattr_nostat) + curattr_nostat->length);
+
+               entry->d_name = ((char*)&curattr_nostat->name) + curattr_nostat->name.attr_dataoffset;
+               /* attr_length includes the null terminator, but readdir's d_namlen doesn't. */
+               entry->d_namlen = curattr_nostat->name.attr_length - 1;
+       }
+
+       int stat_type = 0;
+
+       switch (handle->nostat ? curattr_nostat->objtype : curattr_stat->objtype) {
+       case VREG:
+               entry->d_type = DT_REG;
+               stat_type = S_IFREG;
+               break;
+       case VDIR:
+               entry->d_type = DT_DIR;
+               /* Force a stat call so we don't have to guess on st_size, st_blocks, etc. */
+               // stat_type = S_IFDIR;
+               break;
+       case VBLK:
+               entry->d_type = DT_BLK;
+               stat_type = S_IFBLK;
+               break;
+       case VCHR:
+               entry->d_type = DT_CHR;
+               stat_type = S_IFCHR;
+               break;
+       case VLNK:
+               entry->d_type = DT_LNK;
+               stat_type = S_IFLNK;
+               break;
+       case VSOCK:
+               entry->d_type = DT_SOCK;
+               stat_type = S_IFSOCK;
+               break;
+       case VFIFO:
+               entry->d_type = DT_FIFO;
+               stat_type = S_IFIFO;
+               break;
+       default:
+               entry->d_type = DT_UNKNOWN;
+               break;
+       }
+
+       if (!handle->nostat && stat_type) {
+               entry->stat_valid = true;
+
+               /*
+                * Make sure we got all the attributes we need to fill out a stat structure.
+                */
+
+               attrgroup_t requiredCommon = handle->requested_attrs.commonattr;
+               attrgroup_t requiredFile = handle->requested_attrs.fileattr;
+
+               if ((entry->d_type != DT_BLK) && (entry->d_type != DT_CHR)) {
+                       /* It's okay for ATTR_FILE_DEVTYPE to be missing if the entry isn't a block or character device. */
+                       curattr_stat->st_rdev = 0;
+                       requiredFile &= ~ATTR_FILE_DEVTYPE;
+               }
+
+               if ((curattr_stat->attrset.commonattr & requiredCommon) != requiredCommon ||
+                               (curattr_stat->attrset.fileattr & requiredFile) != requiredFile) {
+                       /* Some of our required attributes are missing. */
+                       entry->stat_valid = false;
+               }
+       } else {
+               entry->stat_valid = false;
+       }
+
+       if (entry->stat_valid) {
+
+#define COPY_FIELD(fld) entry->sb.fld = curattr_stat->fld
+               COPY_FIELD(st_dev);
+               /* COPY_FIELD(st_mode);      Handled below. */
+               COPY_FIELD(st_nlink);
+               COPY_FIELD(st_ino);
+               COPY_FIELD(st_uid);
+               COPY_FIELD(st_gid);
+               COPY_FIELD(st_rdev);
+               COPY_FIELD(st_atimespec);
+               COPY_FIELD(st_mtimespec);
+               COPY_FIELD(st_ctimespec);
+#if __DARWIN_64_BIT_INO_T
+               COPY_FIELD(st_birthtimespec);
+#endif /* __DARWIN_64_BIT_INO_T */
+               COPY_FIELD(st_size);
+               /* COPY_FIELD(st_blocks);    Handled below. */
+               COPY_FIELD(st_blksize);
+               COPY_FIELD(st_flags);
+#undef COPY_FIELD
+
+               /* We have to handle some fields specially. */
+               entry->sb.st_mode = (curattr_stat->accessmask & ~S_IFMT) | stat_type;
+               entry->sb.st_blocks = howmany(curattr_stat->allocsize, 512); /* Matches vn_stat implementation in xnu. */
+       }
+       return true;
+}
+
+static int
+dir_fd(dir_handle *handle)
+{
+       return handle->dirp ? dirfd(handle->dirp) : handle->dirfd;
+}
+
+static void
+close_directory(dir_handle *handle)
+{
+       if (handle->dirp) {
+               closedir(handle->dirp);
+               handle->dirp = NULL;
+       }
+       if (handle->dirfd != -1) {
+               close(handle->dirfd);
+               handle->dirfd = -1;
+       }
+       free(handle->attrbuf);
+       handle->attrbuf = NULL;
+}
+
 /*
  * This is the tricky part -- do not casually change *anything* in here.  The
  * idea is to build the linked list of entries that are used by fts_children
@@ -654,18 +977,19 @@ fts_children(sp, instr)
  * types.  This cuts the number of stat calls significantly.
  */
 static FTSENT *
-fts_build(sp, type)
-       register FTS *sp;
-       int type;
+fts_build(FTS *sp, int type)
 {
-       register struct dirent *dp;
-       register FTSENT *p, *head;
-       register int nitems;
+       dir_entry de = { 0 };
+       dir_entry *dp = &de;
+       FTSENT *p, *head;
+       int nitems;
        FTSENT *cur, *tail;
-       DIR *dirp;
-       void *adjaddr;
-       int cderrno, descend, len, level, maxlen, dostat, oflag, saved_errno;
-       char *cp = NULL;
+       dir_handle dirp;
+       void *oldaddr;
+       int len, maxlen;
+       int cderrno, descend, level, dostat, doadjust;
+       int saved_errno;
+       char *cp;
 
        /* Set current node pointer. */
        cur = sp->fts_cur;
@@ -674,15 +998,7 @@ fts_build(sp, type)
         * Open the directory for reading.  If this fails, we're done.
         * If being called from fts_read, set the fts_info field.
         */
-#ifdef FTS_WHITEOUT
-       if (ISSET(FTS_WHITEOUT))
-               oflag = DTF_NODUP|DTF_REWIND;
-       else
-               oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND;
-#else
-#define __opendir2(path, flag) opendir(path)
-#endif
-       if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) {
+       if (!open_directory(sp, &dirp, cur->fts_accpath)) {
                if (type == BREAD) {
                        cur->fts_info = FTS_DNR;
                        cur->fts_errno = errno;
@@ -720,17 +1036,21 @@ fts_build(sp, type)
         * checking FTS_NS on the returned nodes.
         */
        cderrno = 0;
-       if (dostat || type == BREAD)
-               if (FCHDIR(sp, dirfd(dirp))) {
-                       if (dostat && type == BREAD)
+       if (dostat || type == BREAD) {
+               if (fts_safe_changedir(sp, cur, dir_fd(&dirp), NULL)) {
+                       if (dostat && type == BREAD) {
                                cur->fts_errno = errno;
+                       }
                        cur->fts_flags |= FTS_DONTCHDIR;
                        descend = 0;
                        cderrno = errno;
-               } else
+                       close_directory(&dirp);
+               } else {
                        descend = 1;
-       else
+               }
+       } else {
                descend = 0;
+       }
 
        /*
         * Figure out the max file name length that can be stored in the
@@ -750,46 +1070,67 @@ fts_build(sp, type)
        len++;
        maxlen = sp->fts_pathlen - len;
 
-       level = cur->fts_level + 1;
+       /*
+        * fts_level is signed so we must prevent it from wrapping
+        * around to FTS_ROOTLEVEL and FTS_ROOTPARENTLEVEL.
+        */
+       level = cur->fts_level;
+       if (level < FTS_MAXLEVEL)
+           level++;
 
        /* Read the directory, attaching each entry to the `link' pointer. */
-       adjaddr = NULL;
-       for (head = tail = NULL, nitems = 0; (dp = readdir(dirp)) ; ) {
+       doadjust = 0;
+       for (head = tail = NULL, nitems = 0; read_dirent(&dirp, dp) ; ) {
                if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
                        continue;
 
                if ((p = fts_alloc(sp, dp->d_name, (int)dp->d_namlen)) == NULL)
                        goto mem1;
-               if (dp->d_namlen >= maxlen) {   /* include space for NUL */
-                       if (fts_palloc(sp, (size_t)dp->d_namlen)) {
+               if (dp->d_namlen >= (size_t)maxlen) {   /* include space for NUL */
+                       oldaddr = sp->fts_path;
+                       if (fts_palloc(sp, dp->d_namlen +len + 1)) {
                                /*
                                 * No more memory for path or structures.  Save
                                 * errno, free up the current structure and the
                                 * structures already allocated.
                                 */
 mem1:                          saved_errno = errno;
-                               if (p)
-                                       free(p);
+                               free(p);
                                fts_lfree(head);
-                               (void)closedir(dirp);
+                               close_directory(&dirp);
                                cur->fts_info = FTS_ERR;
                                SET(FTS_STOP);
                                errno = saved_errno;
                                return (NULL);
                        }
-                       adjaddr = sp->fts_path;
-                       maxlen = sp->fts_pathlen - sp->fts_cur->fts_pathlen - 1;
+                       /* Did realloc() change the pointer? */
+                       if (oldaddr != sp->fts_path) {
+                               doadjust = 1;
+                               if (ISSET(FTS_NOCHDIR))
+                                       cp = sp->fts_path + len;
+                       }
+                       maxlen = sp->fts_pathlen - len;
                }
 
+               if (len + dp->d_namlen >= USHRT_MAX) {
+                       /*
+                        * In an FTSENT, fts_pathlen is a u_short so it is
+                        * possible to wraparound here.  If we do, free up
+                        * the current structure and the structures already
+                        * allocated, then error out with ENAMETOOLONG.
+                        */
+                       free(p);
+                       fts_lfree(head);
+                       close_directory(&dirp);
+                       cur->fts_info = FTS_ERR;
+                       SET(FTS_STOP);
+                       errno = ENAMETOOLONG;
+                       return (NULL);
+               }
                p->fts_level = level;
                p->fts_parent = sp->fts_cur;
                p->fts_pathlen = len + dp->d_namlen;
 
-#ifdef FTS_WHITEOUT
-               if (dp->d_type == DT_WHT)
-                       p->fts_flags |= FTS_ISW;
-#endif
-
                if (cderrno) {
                        if (dostat) {
                                p->fts_info = FTS_NS;
@@ -827,10 +1168,11 @@ mem1:                            saved_errno = errno;
                                if (ISSET(FTS_NOCHDIR)) {
                                        p->fts_accpath = p->fts_path;
                                        memmove(cp, p->fts_name, p->fts_namelen + 1);
-                               } else
+                                       p->fts_info = fts_stat2(sp, p, 0, dir_fd(&dirp), dp->stat_valid ? &dp->sb : NULL);
+                               } else {
                                        p->fts_accpath = p->fts_name;
-                               /* Stat it. */
-                               p->fts_info = fts_stat(sp, p, 0);
+                                       p->fts_info = fts_stat2(sp, p, 0, -1, dp->stat_valid ? &dp->sb : NULL);
+                               }
                                break;
                        case (F_D_TYPE | DT_FIFO):
                        case (F_D_TYPE | DT_CHR):
@@ -873,21 +1215,21 @@ common_no_stat:
                }
                ++nitems;
        }
-       (void)closedir(dirp);
+       close_directory(&dirp);
 
        /*
-        * If had to realloc the path, adjust the addresses for the rest
-        * of the tree.
+        * If realloc() changed the address of the path, adjust the
+        * addresses for the rest of the tree and the dir list.
         */
-       if (adjaddr)
-               fts_padjust(sp, adjaddr);
+       if (doadjust)
+               fts_padjust(sp, head);
 
        /*
         * If not changing directories, reset the path back to original
         * state.
         */
        if (ISSET(FTS_NOCHDIR)) {
-               if (cp - 1 > sp->fts_path)
+               if (len == sp->fts_pathlen || nitems == 0)
                        --cp;
                *cp = '\0';
        }
@@ -900,8 +1242,8 @@ common_no_stat:
         * can't get back, we're done.
         */
        if (descend && (type == BCHILD || !nitems) &&
-           (cur->fts_level == FTS_ROOTLEVEL ?
-           FCHDIR(sp, sp->fts_rfd) : CHDIR(sp, ".."))) {
+           (cur->fts_level == FTS_ROOTLEVEL ? FCHDIR(sp, sp->fts_rfd) :
+           fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) {
                cur->fts_info = FTS_ERR;
                SET(FTS_STOP);
                return (NULL);
@@ -921,45 +1263,58 @@ common_no_stat:
 }
 
 static u_short
-fts_stat(sp, p, follow)
-       FTS *sp;
-       register FTSENT *p;
-       int follow;
+fts_stat(FTS *sp, FTSENT *p, int follow, int dfd)
+{
+       return fts_stat2(sp, p, follow, dfd, NULL);
+}
+
+static u_short
+fts_stat2(FTS *sp, FTSENT *p, int follow, int dfd, struct stat *insb)
 {
-       register FTSENT *t;
-       register dev_t dev;
-       register ino_t ino;
+       FTSENT *t;
+       dev_t dev;
+       ino_t ino;
        struct stat *sbp, sb;
        int saved_errno;
+       const char *path;
+
+       if (dfd == -1) {
+               path = p->fts_accpath;
+               dfd = AT_FDCWD;
+       } else {
+               path = p->fts_name;
+       }
 
        /* If user needs stat info, stat buffer already allocated. */
        sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp;
 
-#ifdef FTS_WHITEOUT
-       /* check for whiteout */
-       if (p->fts_flags & FTS_ISW) {
-               if (sbp != &sb) {
-                       memset(sbp, '\0', sizeof (*sbp));
-                       sbp->st_mode = S_IFWHT;
-               }
-               return (FTS_W);
-       }
-#endif
-       
        /*
-        * If doing a logical walk, or application requested FTS_FOLLOW, do
-        * a stat(2).  If that fails, check for a non-existent symlink.  If
-        * fail, set the errno from the stat call.
+        * getattrlistbulk always returns information about the link, not its
+        * destination, so if we are doing a logical walk we need to detect links
+        * and do a stat anyway.
         */
-       if (ISSET(FTS_LOGICAL) || follow) {
-               if (stat(p->fts_accpath, sbp)) {
+       if (follow) {
+               insb = NULL;
+       } else if (insb && ISSET(FTS_LOGICAL) && ((insb->st_mode & S_IFLNK) == S_IFLNK)) {
+               insb = NULL;
+       }
+
+       if (insb) {
+               memcpy(sbp, insb, sizeof(*insb));
+       } else if (ISSET(FTS_LOGICAL) || follow) {
+               /*
+                * If doing a logical walk, or application requested FTS_FOLLOW, do
+                * a stat(2).  If that fails, check for a non-existent symlink.  If
+                * fail, set the errno from the stat call.
+                */
+               if (fstatat(dfd, path, sbp, 0)) {
                        saved_errno = errno;
-                       if (!lstat(p->fts_accpath, sbp)) {
+                       if (!fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
                                if (saved_errno == ELOOP)
                                        p->fts_errno = ELOOP;
                                errno = 0;
                                return (FTS_SLNONE);
-                       } 
+                       }
                        p->fts_errno = saved_errno;
                        goto err;
                }
@@ -968,12 +1323,12 @@ fts_stat(sp, p, follow)
                 * a directory
                 */
                if (follow == -1 && !S_ISDIR(sbp->st_mode)) {
-                       if (lstat(p->fts_accpath, sbp)) {
+                       if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
                                p->fts_errno = errno;
                                goto err;
                        }
                }
-       } else if (lstat(p->fts_accpath, sbp)) {
+       } else if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
                p->fts_errno = errno;
 err:           memset(sbp, 0, sizeof(struct stat));
                return (FTS_NS);
@@ -1016,12 +1371,9 @@ err:             memset(sbp, 0, sizeof(struct stat));
 }
 
 static FTSENT *
-fts_sort(sp, head, nitems)
-       FTS *sp;
-       FTSENT *head;
-       register int nitems;
+fts_sort(FTS *sp, FTSENT *head, int nitems)
 {
-       register FTSENT **ap, *p;
+       FTSENT **ap, *p;
 
        /*
         * Construct an array of pointers to the structures and call qsort(3).
@@ -1031,12 +1383,17 @@ fts_sort(sp, head, nitems)
         * 40 so don't realloc one entry at a time.
         */
        if (nitems > sp->fts_nitems) {
+               struct _ftsent **a;
+
                sp->fts_nitems = nitems + 40;
-               if ((sp->fts_array = realloc(sp->fts_array,
-                   (size_t)(sp->fts_nitems * sizeof(FTSENT *)))) == NULL) {
+               if ((a = reallocarray(sp->fts_array,
+                   sp->fts_nitems, sizeof(FTSENT *))) == NULL) {
+                       free(sp->fts_array);
+                       sp->fts_array = NULL;
                        sp->fts_nitems = 0;
                        return (head);
                }
+               sp->fts_array = a;
        }
        for (ap = sp->fts_array, p = head; p; p = p->fts_link)
                *ap++ = p;
@@ -1053,12 +1410,9 @@ fts_sort(sp, head, nitems)
 }
 
 static FTSENT *
-fts_alloc(sp, name, namelen)
-       FTS *sp;
-       char *name;
-       register int namelen;
+fts_alloc(FTS *sp, char *name, int namelen)
 {
-       register FTSENT *p;
+       FTSENT *p;
        size_t len;
 
        /*
@@ -1072,29 +1426,23 @@ fts_alloc(sp, name, namelen)
        len = sizeof(FTSENT) + namelen;
        if (!ISSET(FTS_NOSTAT))
                len += sizeof(struct stat) + ALIGNBYTES;
-       if ((p = malloc(len)) == NULL)
+       if ((p = calloc(1, len)) == NULL)
                return (NULL);
 
-       /* Copy the name plus the trailing NULL. */
-       memmove(p->fts_name, name, namelen + 1);
-
-       if (!ISSET(FTS_NOSTAT))
-               p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
-       p->fts_namelen = namelen;
        p->fts_path = sp->fts_path;
-       p->fts_errno = 0;
-       p->fts_flags = 0;
+       p->fts_namelen = namelen;
        p->fts_instr = FTS_NOINSTR;
-       p->fts_number = 0;
-       p->fts_pointer = NULL;
+       if (!ISSET(FTS_NOSTAT))
+               p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
+       memcpy(p->fts_name, name, namelen);
+
        return (p);
 }
 
 static void
-fts_lfree(head)
-       register FTSENT *head;
+fts_lfree(FTSENT *head)
 {
-       register FTSENT *p;
+       FTSENT *p;
 
        /* Free a linked list of structures. */
        while ((p = head)) {
@@ -1105,18 +1453,35 @@ fts_lfree(head)
 
 /*
  * Allow essentially unlimited paths; find, rm, ls should all work on any tree.
- * Most systems will allow creation of paths much longer than MAXPATHLEN, even
+ * Most systems will allow creation of paths much longer than PATH_MAX, even
  * though the kernel won't resolve them.  Add the size (not just what's needed)
  * plus 256 bytes so don't realloc the path 2 bytes at a time.
  */
 static int
-fts_palloc(sp, more)
-       FTS *sp;
-       size_t more;
+fts_palloc(FTS *sp, size_t more)
 {
+       char *p;
+
        sp->fts_pathlen += more + 256;
-       sp->fts_path = realloc(sp->fts_path, (size_t)sp->fts_pathlen);
-       return (sp->fts_path == NULL);
+       /*
+        * Check for possible wraparound.  In an FTS, fts_pathlen is
+        * a signed int but in an FTSENT it is an unsigned short.
+        * We limit fts_pathlen to USHRT_MAX to be safe in both cases.
+        */
+       if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) {
+               free(sp->fts_path);
+               sp->fts_path = NULL;
+               errno = ENAMETOOLONG;
+               return (1);
+       }
+       p = realloc(sp->fts_path, sp->fts_pathlen);
+       if (p == NULL) {
+               free(sp->fts_path);
+               sp->fts_path = NULL;
+               return (1);
+       }
+       sp->fts_path = p;
+       return (0);
 }
 
 /*
@@ -1124,31 +1489,31 @@ fts_palloc(sp, more)
  * already returned.
  */
 static void
-fts_padjust(FTS *sp, void *addr)
+fts_padjust(FTS *sp, FTSENT *head)
 {
        FTSENT *p;
+       char *addr = sp->fts_path;
 
-#define        ADJUST(p) do {                                                  \
+#define        ADJUST(p) {                                                     \
        if ((p)->fts_accpath != (p)->fts_name) {                        \
                (p)->fts_accpath =                                      \
                    (char *)addr + ((p)->fts_accpath - (p)->fts_path);  \
        }                                                               \
        (p)->fts_path = addr;                                           \
-} while (0)
+}
        /* Adjust the current set of children. */
        for (p = sp->fts_child; p; p = p->fts_link)
                ADJUST(p);
 
-       /* Adjust the rest of the tree. */
-       for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
+       /* Adjust the rest of the tree, including the current level. */
+       for (p = head; p->fts_level >= FTS_ROOTLEVEL;) {
                ADJUST(p);
                p = p->fts_link ? p->fts_link : p->fts_parent;
        }
 }
 
 static size_t
-fts_maxarglen(argv)
-       char * const *argv;
+fts_maxarglen(char * const *argv)
 {
        size_t len, max;
 
@@ -1157,3 +1522,37 @@ fts_maxarglen(argv)
                        max = len;
        return (max + 1);
 }
+
+/*
+ * Change to dir specified by fd or p->fts_accpath without getting
+ * tricked by someone changing the world out from underneath us.
+ * Assumes p->fts_dev and p->fts_ino are filled in.
+ */
+static int
+fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
+{
+       int ret, oerrno, newfd;
+       struct stat sb;
+
+       newfd = fd;
+       if (ISSET(FTS_NOCHDIR))
+               return (0);
+       if (fd < 0 && (newfd = open(path, O_RDONLY|O_DIRECTORY|O_CLOEXEC)) < 0)
+               return (-1);
+       if (fstat(newfd, &sb)) {
+               ret = -1;
+               goto bail;
+       }
+       if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) {
+               errno = ENOENT;         /* disinformation */
+               ret = -1;
+               goto bail;
+       }
+       ret = fchdir(newfd);
+bail:
+       oerrno = errno;
+       if (fd < 0)
+               (void)close(newfd);
+       errno = oerrno;
+       return (ret);
+}
diff --git a/gen/raise.c b/gen/raise.c
new file mode 100644 (file)
index 0000000..430e5da
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Apple, Inc. All rights reserved.
+ *
+ * @APPLE_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. 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_LICENSE_HEADER_END@
+ */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <unistd.h>
+
+int raise(int sig) {
+    int error = pthread_kill(pthread_self(), sig);
+    switch (error) {
+        case 0:
+            return 0;
+        case ENOTSUP:
+            return kill(getpid(), sig);
+        default:
+            errno = error;
+            return -1;
+    }
+}
index b4b77b36224d2cea12c5aee96fed8afd94201d23..0edbad1a845a14b90d5f5776e25990d289b20e80 100644 (file)
@@ -205,7 +205,7 @@ with the particular file descriptor.
 .Pp
 The
 .Fn cfmakeraw
-function sets the flags stored in the termios structure to a state disabling
+function modifies the flags stored in the termios structure to a state disabling
 all input and output processing, giving a
 .Dq raw I/O path .
 It should be noted that there is no function to reverse this effect.
index ff2f4edc43aeadba15e1efee2b62f2455d6ce0f3..1ba417166aa7cc9e4ca14674c0c0a5c5523d90fe 100644 (file)
@@ -137,28 +137,6 @@ extern void monreset(
 extern void monoutput(
     const char *filename);
 
-static char profiling = -1;    /* tas (test and set) location for NeXT */
-static char init = 0;          /* set while moninit() is being serviced */
-
-static unsigned long order = 0;        /* call order */
-
-typedef struct {
-    /* the address range and size this mon struct refers to */
-    char               *lowpc;
-    char               *highpc;
-    unsigned long      textsize;
-    /* the data structures to support the arc's and their counts */
-    unsigned short     *froms; /* froms is unsigned shorts indexing into tos */
-    tostruct_t         *tos;
-    long               tolimit;
-    /* the pc-sample buffer, it's size and scale */
-    char               *sbuf;
-    long               ssiz;   /* includes the gmonhdr_t */
-    long               scale;
-} mon_t;
-static mon_t *mon = NULL;
-static unsigned long nmon = 0;
-
 void
 moninit(
 void)
index ee4eae99d552771c9b8403b7942e9fcfdb242bfb..6a531763b24d81c8afdb3df0d640aafe5fbbcb0d 100644 (file)
@@ -83,9 +83,9 @@ void  vwarnc(int, const char *, __darwin_va_list) __printflike(2, 0);
 void   warnx(const char *, ...) __printflike(1, 2);
 void   vwarnx(const char *, __darwin_va_list) __printflike(1, 0);
 void   err_set_file(void *);
-void   err_set_exit(void (*)(int));
+void   err_set_exit(void (* _Nullable)(int));
 #ifdef __BLOCKS__
-void   err_set_exit_b(void (^)(int)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+void   err_set_exit_b(void (^ _Nullable)(int)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
 #endif /* __BLOCKS__ */
 
 __END_DECLS
index a3ee69f6f17a78182293af1dc8ebc71f98d6ab6b..c91b09900c33be9b4f422791163b83971cb8a60f 100644 (file)
@@ -90,7 +90,7 @@ typedef struct {
 #define        FTS_PHYSICAL    0x010           /* physical walk */
 #define        FTS_SEEDOT      0x020           /* return dot and dot-dot */
 #define        FTS_XDEV        0x040           /* don't cross devices */
-#define        FTS_WHITEOUT    0x080           /* return whiteout information */
+#define        FTS_WHITEOUT    0x080           /* (no longer supported) return whiteout information */
 #define        FTS_COMFOLLOWDIR 0x400          /* (non-std) follow command line symlinks for directories only */
 #if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1090) || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 70000)
 #define        FTS_OPTIONMASK  0x4ff           /* valid user option mask */
@@ -126,6 +126,7 @@ typedef struct _ftsent {
 
 #define        FTS_ROOTPARENTLEVEL     -1
 #define        FTS_ROOTLEVEL            0
+#define        FTS_MAXLEVEL             0x7fffffff
        short fts_level;                /* depth (-1 to N) */
 
 #define        FTS_D            1              /* preorder directory */
index 06184d81c41d924fc42051290f5954d2da0676f3..4200fc6c400f4124814eeb069f8989ff1243a8bc 100644 (file)
@@ -47,6 +47,17 @@ char *dirname(const char *);
 
 #endif /* __DARWIN_UNIX_03 */
 
+#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
+#include <Availability.h>
+char   *basename_r(const char *, char *)
+               __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
+               __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
+
+char   *dirname_r(const char *, char *)
+               __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
+               __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
+#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
+
 __END_DECLS
 
 #endif /* _LIBGEN_H_ */
index 2f9385d420a39a3b30ce11ef613a6152208c31c3..6f4669093cf5047cf485f28b9a28b980aa4b958a 100644 (file)
 
 #define PTHREAD_DESTRUCTOR_ITERATIONS  4
 #define PTHREAD_KEYS_MAX               512
+#if defined(__arm__) 
+#define PTHREAD_STACK_MIN              16384
+#else
 #define PTHREAD_STACK_MIN              8192
+#endif
 #endif /* __DARWIN_C_LEVEL >= 199506L */
 
 #if __DARWIN_C_LEVEL >= 200112
index 097385bfe538fbf4e1f514afbcb441bbbe68dd1c..76316cc2a21d945a0a24eaf00301ac2ee9fbbcd5 100644 (file)
@@ -1,31 +1,21 @@
-/*     $OpenBSD: /usr/local/www/cvsroot/OpenBSD/src/include/readpassphrase.h,v 1.2 2002/02/16 21:27:17 millert Exp $   */
-/*     $FreeBSD: /repoman/r/ncvs/src/include/readpassphrase.h,v 1.2 2002/03/08 20:52:52 green Exp $    */
-
 /*
- * Copyright (c) 2000 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
+ * Copyright (c) 2000, 2002 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
  *
- * 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.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * THIS SOFTWARE IS PROVIDED ``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 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.
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
  */
 
 #ifndef _READPASSPHRASE_H_
@@ -37,6 +27,7 @@
 #define RPP_FORCELOWER  0x04           /* Force input to lower case. */
 #define RPP_FORCEUPPER  0x08           /* Force input to upper case. */
 #define RPP_SEVENBIT    0x10           /* Strip the high bit from input. */
+#define RPP_STDIN       0x20           /* Read from stdin, not /dev/tty */
 
 #include <_types.h>
 #include <sys/_types/_size_t.h>
index 39dc6e044c64248096374d230784f2c9f0b7fb26..a07abff19c67f3ea2678261f8fe5aaa31190b904 100644 (file)
@@ -76,7 +76,7 @@ __END_DECLS
 
 #ifndef        _ANSI_SOURCE
 __BEGIN_DECLS
-void   (*bsd_signal(int, void (*)(int)))(int);
+void   (* _Nullable bsd_signal(int, void (* _Nullable)(int)))(int);
 //Begin-Libc
 #ifndef LIBC_ALIAS_KILL
 //End-Libc
@@ -136,7 +136,7 @@ int sigpause(int) LIBC_ALIAS_C(sigpause);
 int    sigpending(sigset_t *);
 int    sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
 int    sigrelse(int);
-void    (*sigset(int, void (*)(int)))(int);
+void    (* _Nullable sigset(int, void (* _Nullable)(int)))(int);
 //Begin-Libc
 #ifndef LIBC_ALIAS_SIGSUSPEND
 //End-Libc
index adc59ed82af251a6f2ae4187c04527ca3f7bdf7c..d0cf7a50c15029ba0b3e3cf4ef7900e11a469879 100644 (file)
@@ -130,10 +130,10 @@ typedef   struct __sFILE {
 
        /* operations */
        void    *_cookie;       /* cookie passed to io functions */
-       int     (*_close)(void *);
-       int     (*_read) (void *, char *, int);
-       fpos_t  (*_seek) (void *, fpos_t, int);
-       int     (*_write)(void *, const char *, int);
+       int     (* _Nullable _close)(void *);
+       int     (* _Nullable _read) (void *, char *, int);
+       fpos_t  (* _Nullable _seek) (void *, fpos_t, int);
+       int     (* _Nullable _write)(void *, const char *, int);
 
        /* separate buffer for long sequences of ungetc() */
        struct  __sbuf _ub;     /* ungetc buffer */
@@ -237,15 +237,15 @@ int        fgetc(FILE *);
 int     fgetpos(FILE * __restrict, fpos_t *);
 char   *fgets(char * __restrict, int, FILE *);
 #if defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE)
-FILE   *fopen(const char * __restrict, const char * __restrict) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(fopen));
+FILE   *fopen(const char * __restrict __filename, const char * __restrict __mode) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(fopen));
 #else /* !_DARWIN_UNLIMITED_STREAMS && !_DARWIN_C_SOURCE */
 //Begin-Libc
 #ifndef LIBC_ALIAS_FOPEN
 //End-Libc
-FILE   *fopen(const char * __restrict, const char * __restrict) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fopen));
+FILE   *fopen(const char * __restrict __filename, const char * __restrict __mode) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fopen));
 //Begin-Libc
 #else /* LIBC_ALIAS_FOPEN */
-FILE   *fopen(const char * __restrict, const char * __restrict) LIBC_ALIAS(fopen);
+FILE   *fopen(const char * __restrict __filename, const char * __restrict __mode) LIBC_ALIAS(fopen);
 #endif /* !LIBC_ALIAS_FOPEN */
 //End-Libc
 #endif /* (DARWIN_UNLIMITED_STREAMS || _DARWIN_C_SOURCE) */
@@ -260,7 +260,7 @@ int  fputs(const char * __restrict, FILE * __restrict) __DARWIN_ALIAS(fputs);
 int     fputs(const char * __restrict, FILE * __restrict) LIBC_ALIAS(fputs);
 #endif /* !LIBC_ALIAS_FPUTS */
 //End-Libc
-size_t  fread(void * __restrict, size_t, size_t, FILE * __restrict);
+size_t  fread(void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream);
 //Begin-Libc
 #ifndef LIBC_ALIAS_FREOPEN
 //End-Libc
@@ -279,10 +279,10 @@ long       ftell(FILE *);
 //Begin-Libc
 #ifndef LIBC_ALIAS_FWRITE
 //End-Libc
-size_t  fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) __DARWIN_ALIAS(fwrite);
+size_t  fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) __DARWIN_ALIAS(fwrite);
 //Begin-Libc
 #else /* LIBC_ALIAS_FWRITE */
-size_t  fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) LIBC_ALIAS(fwrite);
+size_t  fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) LIBC_ALIAS(fwrite);
 #endif /* !LIBC_ALIAS_FWRITE */
 //End-Libc
 int     getc(FILE *);
@@ -294,15 +294,16 @@ int        putc(int, FILE *);
 int     putchar(int);
 int     puts(const char *);
 int     remove(const char *);
-int     rename (const char *, const char *);
+int     rename (const char *__old, const char *__new);
 void    rewind(FILE *);
 int     scanf(const char * __restrict, ...) __scanflike(1, 2);
 void    setbuf(FILE * __restrict, char * __restrict);
 int     setvbuf(FILE * __restrict, char * __restrict, int, size_t);
-int     sprintf(char * __restrict, const char * __restrict, ...) __printflike(2, 3);
+int     sprintf(char * __restrict, const char * __restrict, ...) __printflike(2, 3) __swift_unavailable("Use snprintf instead.");
 int     sscanf(const char * __restrict, const char * __restrict, ...) __scanflike(2, 3);
 FILE   *tmpfile(void);
 
+__swift_unavailable("Use mkstemp(3) instead.")
 #if !defined(_POSIX_C_SOURCE)
 __deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.")
 #endif
@@ -310,7 +311,7 @@ char        *tmpnam(char *);
 int     ungetc(int, FILE *);
 int     vfprintf(FILE * __restrict, const char * __restrict, va_list) __printflike(2, 0);
 int     vprintf(const char * __restrict, va_list) __printflike(1, 0);
-int     vsprintf(char * __restrict, const char * __restrict, va_list) __printflike(2, 0);
+int     vsprintf(char * __restrict, const char * __restrict, va_list) __printflike(2, 0) __swift_unavailable("Use vsnprintf instead.");
 __END_DECLS
 
 
@@ -350,17 +351,22 @@ __END_DECLS
 /* Additional functionality provided by:
  * POSIX.2-1992 C Language Binding Option
  */
+#if TARGET_OS_EMBEDDED
+#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
+#else
+#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg)
+#endif
 
 #if __DARWIN_C_LEVEL >= 199209L
 __BEGIN_DECLS
-int     pclose(FILE *);
+int     pclose(FILE *) __swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable.");
 #if defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE)
-FILE   *popen(const char *, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(popen));
+FILE   *popen(const char *, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(popen)) __swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable.");
 #else /* !_DARWIN_UNLIMITED_STREAMS && !_DARWIN_C_SOURCE */
 //Begin-Libc
 #ifndef LIBC_ALIAS_POPEN
 //End-Libc
-FILE   *popen(const char *, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(popen));
+FILE   *popen(const char *, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(popen)) __swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable.");
 //Begin-Libc
 #else /* LIBC_ALIAS_POPEN */
 FILE   *popen(const char *, const char *) LIBC_ALIAS(popen);
@@ -370,8 +376,7 @@ FILE        *popen(const char *, const char *) LIBC_ALIAS(popen);
 __END_DECLS
 #endif /* __DARWIN_C_LEVEL >= 199209L */
 
-
-
+#undef __swift_unavailable_on
 
 /* Additional functionality provided by:
  * POSIX.1c-1995,
@@ -434,16 +439,17 @@ int        getw(FILE *);
 int     putw(int, FILE *);
 #endif
 
+__swift_unavailable("Use mkstemp(3) instead.")
 #if !defined(_POSIX_C_SOURCE)
 __deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead.")
 #endif
 //Begin-Libc
 #ifndef LIBC_ALIAS_TEMPNAM
 //End-Libc
-char   *tempnam(const char *, const char *) __DARWIN_ALIAS(tempnam);
+char   *tempnam(const char *__dir, const char *__prefix) __DARWIN_ALIAS(tempnam);
 //Begin-Libc
 #else /* LIBC_ALIAS_TEMPNAM */
-char   *tempnam(const char *, const char *) LIBC_ALIAS(tempnam);
+char   *tempnam(const char *__dir, const char *__prefix) LIBC_ALIAS(tempnam);
 #endif /* !LIBC_ALIAS_TEMPNAM */
 //End-Libc
 __END_DECLS
@@ -468,18 +474,18 @@ __END_DECLS
 #include <sys/_types/_off_t.h>
 
 __BEGIN_DECLS
-int     fseeko(FILE *, off_t, int);
-off_t   ftello(FILE *);
+int     fseeko(FILE * __stream, off_t __offset, int __whence);
+off_t   ftello(FILE * __stream);
 __END_DECLS
 #endif /* __DARWIN_C_LEVEL >= 200112L */
 
 #if __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus)
 __BEGIN_DECLS
-int     snprintf(char * __restrict, size_t, const char * __restrict, ...) __printflike(3, 4);
-int     vfscanf(FILE * __restrict, const char * __restrict, va_list) __scanflike(2, 0);
-int     vscanf(const char * __restrict, va_list) __scanflike(1, 0);
-int     vsnprintf(char * __restrict, size_t, const char * __restrict, va_list) __printflike(3, 0);
-int     vsscanf(const char * __restrict, const char * __restrict, va_list) __scanflike(2, 0);
+int     snprintf(char * __restrict __str, size_t __size, const char * __restrict __format, ...) __printflike(3, 4);
+int     vfscanf(FILE * __restrict __stream, const char * __restrict __format, va_list) __scanflike(2, 0);
+int     vscanf(const char * __restrict __format, va_list) __scanflike(1, 0);
+int     vsnprintf(char * __restrict __str, size_t __size, const char * __restrict __format, va_list) __printflike(3, 0);
+int     vsscanf(const char * __restrict __str, const char * __restrict __format, va_list) __scanflike(2, 0);
 __END_DECLS
 #endif /* __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus) */
 
@@ -495,8 +501,8 @@ __END_DECLS
 __BEGIN_DECLS
 int    dprintf(int, const char * __restrict, ...) __printflike(2, 3) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
 int    vdprintf(int, const char * __restrict, va_list) __printflike(2, 0) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
-ssize_t getdelim(char ** __restrict, size_t * __restrict, int, FILE * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
-ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+ssize_t getdelim(char ** __restrict __linep, size_t * __restrict __linecapp, int __delimiter, FILE * __restrict __stream) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+ssize_t getline(char ** __restrict __linep, size_t * __restrict __linecapp, FILE * __restrict __stream) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
 __END_DECLS
 #endif /* __DARWIN_C_LEVEL >= 200809L */
 
@@ -524,10 +530,10 @@ FILE      *zopen(const char *, const char *, int);
  * Stdio function-access interface.
  */
 FILE   *funopen(const void *,
-                 int (*)(void *, char *, int),
-                 int (*)(void *, const char *, int),
-                 fpos_t (*)(void *, fpos_t, int),
-                 int (*)(void *));
+                 int (* _Nullable)(void *, char *, int),
+                 int (* _Nullable)(void *, const char *, int),
+                 fpos_t (* _Nullable)(void *, fpos_t, int),
+                 int (* _Nullable)(void *));
 __END_DECLS
 #define        fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
 #define        fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
index c1a3f7cb26711066824534418a6db9d0179185fb..c04d3a7edb5c99eb0d008b190a1b0e2a2fa7f346 100644 (file)
@@ -132,7 +132,7 @@ extern int __mb_cur_max;
 __BEGIN_DECLS
 void    abort(void) __dead2;
 int     abs(int) __pure2;
-int     atexit(void (*)(void));
+int     atexit(void (* _Nonnull)(void));
 double  atof(const char *);
 int     atoi(const char *);
 long    atol(const char *);
@@ -140,9 +140,9 @@ long         atol(const char *);
 long long
         atoll(const char *);
 #endif /* !__DARWIN_NO_LONG_LONG */
-void   *bsearch(const void *, const void *, size_t,
-           size_t, int (*)(const void *, const void *));
-void   *calloc(size_t, size_t);
+void   *bsearch(const void *__key, const void *__base, size_t __nel,
+           size_t __width, int (* _Nonnull __compar)(const void *, const void *));
+void   *calloc(size_t __count, size_t __size) __result_use_check;
 div_t   div(int, int) __pure2;
 void    exit(int) __dead2;
 void    free(void *);
@@ -154,40 +154,53 @@ long long
         llabs(long long);
 lldiv_t         lldiv(long long, long long);
 #endif /* !__DARWIN_NO_LONG_LONG */
-void   *malloc(size_t);
-int     mblen(const char *, size_t);
+void   *malloc(size_t __size) __result_use_check;
+int     mblen(const char *__s, size_t __n);
 size_t  mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
 int     mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
-int     posix_memalign(void **, size_t, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);
-void    qsort(void *, size_t, size_t,
-           int (*)(const void *, const void *));
-int     rand(void);
-void   *realloc(void *, size_t);
-void    srand(unsigned);
+int     posix_memalign(void **__memptr, size_t __alignment, size_t __size) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);
+void    qsort(void *__base, size_t __nel, size_t __width,
+           int (* _Nonnull __compar)(const void *, const void *));
+int     rand(void) __swift_unavailable("Use arc4random instead.");
+void   *realloc(void *__ptr, size_t __size) __result_use_check;
+void    srand(unsigned) __swift_unavailable("Use arc4random instead.");
 double  strtod(const char *, char **) __DARWIN_ALIAS(strtod);
 float   strtof(const char *, char **) __DARWIN_ALIAS(strtof);
-long    strtol(const char *, char **, int);
+long    strtol(const char *__str, char **__endptr, int __base);
 long double
         strtold(const char *, char **);
 #if !__DARWIN_NO_LONG_LONG
 long long 
-        strtoll(const char *, char **, int);
+        strtoll(const char *__str, char **__endptr, int __base);
 #endif /* !__DARWIN_NO_LONG_LONG */
 unsigned long
-        strtoul(const char *, char **, int);
+        strtoul(const char *__str, char **__endptr, int __base);
 #if !__DARWIN_NO_LONG_LONG
 unsigned long long
-        strtoull(const char *, char **, int);
+        strtoull(const char *__str, char **__endptr, int __base);
 #endif /* !__DARWIN_NO_LONG_LONG */
 //Begin-Libc
 #ifndef LIBC_ALIAS_SYSTEM
 //End-Libc
-int     system(const char *) __DARWIN_ALIAS_C(system) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0,__MAC_NA,__IPHONE_2_0,__IPHONE_8_0, "Use posix_spawn APIs instead.") __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
+
+#if TARGET_OS_EMBEDDED
+#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
+#else
+#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg)
+#endif
+
+__swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable")
+__OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0,__MAC_NA,__IPHONE_2_0,__IPHONE_8_0, "Use posix_spawn APIs instead.")
+__WATCHOS_PROHIBITED __TVOS_PROHIBITED
+int     system(const char *) __DARWIN_ALIAS_C(system);
 //Begin-Libc
 #else /* LIBC_ALIAS_SYSTEM */
 int     system(const char *) LIBC_ALIAS_C(system);
 #endif /* !LIBC_ALIAS_SYSTEM */
 //End-Libc
+
+#undef __swift_unavailable_on
+
 size_t  wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
 int     wctomb(char *, wchar_t);
 
@@ -196,7 +209,7 @@ void        _Exit(int) __dead2;
 long    a64l(const char *);
 double  drand48(void);
 char   *ecvt(double, int, int *__restrict, int *__restrict); /* LEGACY */
-double  erand48(unsigned short[3]); 
+double  erand48(unsigned short[3]);
 char   *fcvt(double, int, int *__restrict, int *__restrict); /* LEGACY */
 char   *gcvt(double, int, char *); /* LEGACY */
 int     getsubopt(char **, char * const *, char **);
@@ -206,14 +219,14 @@ char      *initstate(unsigned, char *, size_t); /* no  __DARWIN_ALIAS needed */
 #else /* !__DARWIN_UNIX03 */
 char   *initstate(unsigned long, char *, long);
 #endif /* __DARWIN_UNIX03 */
-long    jrand48(unsigned short[3]);
+long    jrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead.");
 char   *l64a(long);
 void    lcong48(unsigned short[7]);
-long    lrand48(void);
+long    lrand48(void) __swift_unavailable("Use arc4random instead.");
 char   *mktemp(char *);
 int     mkstemp(char *);
-long    mrand48(void)
-long    nrand48(unsigned short[3]);
+long    mrand48(void) __swift_unavailable("Use arc4random instead.");
+long    nrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead.");
 int     posix_openpt(int);
 char   *ptsname(int);
 //Begin-Libc
@@ -225,8 +238,8 @@ int  putenv(char *) __DARWIN_ALIAS(putenv);
 int     putenv(char *) LIBC_ALIAS(putenv);
 #endif /* !LIBC_ALIAS_PUTENV */
 //End-Libc
-long    random(void);
-int     rand_r(unsigned *);
+long    random(void) __swift_unavailable("Use arc4random instead.");
+int     rand_r(unsigned *) __swift_unavailable("Use arc4random instead.");
 //Begin-Libc
 #ifdef __LIBC__
 #ifndef LIBC_ALIAS_REALPATH
@@ -253,10 +266,10 @@ unsigned short
 //Begin-Libc
 #ifndef LIBC_ALIAS_SETENV
 //End-Libc
-int     setenv(const char *, const char *, int) __DARWIN_ALIAS(setenv);
+int     setenv(const char * __name, const char * __value, int __overwrite) __DARWIN_ALIAS(setenv);
 //Begin-Libc
 #else /* LIBC_ALIAS_SETENV */
-int     setenv(const char *, const char *, int) LIBC_ALIAS(setenv);
+int     setenv(const char * __name, const char * __value, int __overwrite) LIBC_ALIAS(setenv);
 #endif /* !LIBC_ALIAS_SETENV */
 //End-Libc
 #if __DARWIN_UNIX03
@@ -300,17 +313,22 @@ void       unsetenv(const char *);
 
 #include <sys/_types/_dev_t.h>
 #include <sys/_types/_mode_t.h>
+#include <_types/_uint32_t.h>
 
-u_int32_t      arc4random(void);
-void    arc4random_addrandom(unsigned char * /*dat*/, int /*datlen*/);
-void    arc4random_buf(void * /*buf*/, size_t /*nbytes*/) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+uint32_t arc4random(void);
+void    arc4random_addrandom(unsigned char * /*dat*/, int /*datlen*/)
+    __OSX_DEPRECATED(10.0, 10.12, "use arc4random_stir")
+    __IOS_DEPRECATED(2.0, 10.0, "use arc4random_stir")
+    __TVOS_DEPRECATED(2.0, 10.0, "use arc4random_stir")
+    __WATCHOS_DEPRECATED(1.0, 3.0, "use arc4random_stir");
+void    arc4random_buf(void * __buf, size_t __nbytes) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
 void    arc4random_stir(void);
-u_int32_t
-        arc4random_uniform(u_int32_t /*upper_bound*/) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+uint32_t
+        arc4random_uniform(uint32_t __upper_bound) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
 #ifdef __BLOCKS__
-int     atexit_b(void (^)(void)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
-void   *bsearch_b(const void *, const void *, size_t,
-           size_t, int (^)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+int     atexit_b(void (^ _Nonnull)(void)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+void   *bsearch_b(const void *__key, const void *__base, size_t __nel,
+           size_t __width, int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
 #endif /* __BLOCKS__ */
 
         /* getcap(3) functions */
@@ -333,45 +351,45 @@ int        getloadavg(double [], int);
 const char
        *getprogname(void);
 
-int     heapsort(void *, size_t, size_t,
-           int (*)(const void *, const void *));
+int     heapsort(void *__base, size_t __nel, size_t __width,
+           int (* _Nonnull __compar)(const void *, const void *));
 #ifdef __BLOCKS__
-int     heapsort_b(void *, size_t, size_t,
-           int (^)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+int     heapsort_b(void *__base, size_t __nel, size_t __width,
+           int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
 #endif /* __BLOCKS__ */
-int     mergesort(void *, size_t, size_t,
-           int (*)(const void *, const void *));
+int     mergesort(void *__base, size_t __nel, size_t __width,
+           int (* _Nonnull __compar)(const void *, const void *));
 #ifdef __BLOCKS__
-int     mergesort_b(void *, size_t, size_t,
-           int (^)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+int     mergesort_b(void *__base, size_t __nel, size_t __width,
+           int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
 #endif /* __BLOCKS__ */
-void    psort(void *, size_t, size_t,
-           int (*)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+void    psort(void *__base, size_t __nel, size_t __width,
+           int (* _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
 #ifdef __BLOCKS__
-void    psort_b(void *, size_t, size_t,
-           int (^)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+void    psort_b(void *__base, size_t __nel, size_t __width,
+           int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
 #endif /* __BLOCKS__ */
-void    psort_r(void *, size_t, size_t, void *,
-           int (*)(void *, const void *, const void *))  __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+void    psort_r(void *__base, size_t __nel, size_t __width, void *,
+           int (* _Nonnull __compar)(void *, const void *, const void *))  __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
 #ifdef __BLOCKS__
-void    qsort_b(void *, size_t, size_t,
-           int (^)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
+void    qsort_b(void *__base, size_t __nel, size_t __width,
+           int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
 #endif /* __BLOCKS__ */
-void    qsort_r(void *, size_t, size_t, void *,
-           int (*)(void *, const void *, const void *));
-int     radixsort(const unsigned char **, int, const unsigned char *,
-           unsigned);
+void    qsort_r(void *__base, size_t __nel, size_t __width, void *,
+           int (* _Nonnull __compar)(void *, const void *, const void *));
+int     radixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
+           unsigned __endbyte);
 void    setprogname(const char *);
-int     sradixsort(const unsigned char **, int, const unsigned char *,
-           unsigned);
+int     sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
+           unsigned __endbyte);
 void    sranddev(void);
 void    srandomdev(void);
-void   *reallocf(void *, size_t);
+void   *reallocf(void *__ptr, size_t __size);
 #if !__DARWIN_NO_LONG_LONG
 long long
-        strtoq(const char *, char **, int);
+        strtoq(const char *__str, char **__endptr, int __base);
 unsigned long long
-        strtouq(const char *, char **, int);
+        strtouq(const char *__str, char **__endptr, int __base);
 #endif /* !__DARWIN_NO_LONG_LONG */
 extern char *suboptarg;                /* getsubopt(3) external variable */
 void   *valloc(size_t);
index 3585d91213e4910f1d4e95d12b09dcd396713986..b06848e97b33442cff958bea70bae31bfce48c7c 100644 (file)
 /* ANSI-C */
 
 __BEGIN_DECLS
-void   *memchr(const void *, int, size_t);
-int     memcmp(const void *, const void *, size_t);
-void   *memcpy(void *, const void *, size_t);
-void   *memmove(void *, const void *, size_t);
-void   *memset(void *, int, size_t);
-char   *strcat(char *, const char *);
-char   *strchr(const char *, int);
-int     strcmp(const char *, const char *);
-int     strcoll(const char *, const char *);
-char   *strcpy(char *, const char *);
-size_t  strcspn(const char *, const char *);
+void   *memchr(const void *__s, int __c, size_t __n);
+int     memcmp(const void *__s1, const void *__s2, size_t __n);
+void   *memcpy(void *__dst, const void *__src, size_t __n);
+void   *memmove(void *__dst, const void *__src, size_t __len);
+void   *memset(void *__b, int __c, size_t __len);
+char   *strcat(char *__s1, const char *__s2);
+char   *strchr(const char *__s, int __c);
+int     strcmp(const char *__s1, const char *__s2);
+int     strcoll(const char *__s1, const char *__s2);
+char   *strcpy(char *__dst, const char *__src);
+size_t  strcspn(const char *__s, const char *__charset);
 //Begin-Libc
 #ifndef LIBC_ALIAS_STRERROR
 //End-Libc
-char   *strerror(int) __DARWIN_ALIAS(strerror);
+char   *strerror(int __errnum) __DARWIN_ALIAS(strerror);
 //Begin-Libc
 #else /* LIBC_ALIAS_STRERROR */
-char   *strerror(int) LIBC_ALIAS(strerror);
+char   *strerror(int __errnum) LIBC_ALIAS(strerror);
 #endif /* !LIBC_ALIAS_STRERROR */
 //End-Libc
-size_t  strlen(const char *);
-char   *strncat(char *, const char *, size_t);
-int     strncmp(const char *, const char *, size_t);
-char   *strncpy(char *, const char *, size_t);
-char   *strpbrk(const char *, const char *);
-char   *strrchr(const char *, int);
-size_t  strspn(const char *, const char *);
-char   *strstr(const char *, const char *);
-char   *strtok(char *, const char *);
-size_t  strxfrm(char *, const char *, size_t);
+size_t  strlen(const char *__s);
+char   *strncat(char *__s1, const char *__s2, size_t __n);
+int     strncmp(const char *__s1, const char *__s2, size_t __n);
+char   *strncpy(char *__dst, const char *__src, size_t __n);
+char   *strpbrk(const char *__s, const char *__charset);
+char   *strrchr(const char *__s, int __c);
+size_t  strspn(const char *__s, const char *__charset);
+char   *strstr(const char *__big, const char *__little);
+char   *strtok(char *__str, const char *__sep);
+size_t  strxfrm(char *__s1, const char *__s2, size_t __n);
 __END_DECLS
 
 
@@ -109,7 +109,7 @@ __END_DECLS
 
 #if __DARWIN_C_LEVEL >= 199506L
 __BEGIN_DECLS
-char   *strtok_r(char *, const char *, char **);
+char   *strtok_r(char *__str, const char *__sep, char **__lasts);
 __END_DECLS
 #endif /* __DARWIN_C_LEVEL >= 199506L */
 
@@ -121,9 +121,9 @@ __END_DECLS
 
 #if __DARWIN_C_LEVEL >= 200112L
 __BEGIN_DECLS
-int     strerror_r(int, char *, size_t);
-char   *strdup(const char *);
-void   *memccpy(void *, const void *, int, size_t);
+int     strerror_r(int __errnum, char *__strerrbuf, size_t __buflen);
+char   *strdup(const char *__s1);
+void   *memccpy(void *__dst, const void *__src, int __c, size_t __n);
 __END_DECLS
 #endif /* __DARWIN_C_LEVEL >= 200112L */
 
@@ -135,11 +135,11 @@ __END_DECLS
 
 #if __DARWIN_C_LEVEL >= 200809L
 __BEGIN_DECLS
-char   *stpcpy(char *, const char *);
-char    *stpncpy(char *, const char *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
-char   *strndup(const char *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
-size_t   strnlen(const char *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
-char   *strsignal(int sig);
+char   *stpcpy(char *__dst, const char *__src);
+char    *stpncpy(char *__dst, const char *__src, size_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+char   *strndup(const char *__s1, size_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+size_t   strnlen(const char *__s1, size_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+char   *strsignal(int __sig);
 __END_DECLS
 #endif /* __DARWIN_C_LEVEL >= 200809L */
 
@@ -150,7 +150,7 @@ __END_DECLS
 #include <sys/_types/_errno_t.h>
 
 __BEGIN_DECLS
-errno_t        memset_s(void *, rsize_t, int, rsize_t) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
+errno_t        memset_s(void *__s, rsize_t __smax, int __c, rsize_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
 __END_DECLS
 #endif
 
@@ -160,17 +160,17 @@ __END_DECLS
 #include <sys/_types/_ssize_t.h>
 
 __BEGIN_DECLS
-void   *memmem(const void *, size_t, const void *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
-void     memset_pattern4(void *, const void *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0);
-void     memset_pattern8(void *, const void *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0);
-void     memset_pattern16(void *, const void *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0);
-
-char   *strcasestr(const char *, const char *);
-char   *strnstr(const char *, const char *, size_t);
-size_t  strlcat(char *, const char *, size_t);
-size_t  strlcpy(char *, const char *, size_t);
-void    strmode(int, char *);
-char   *strsep(char **, const char *);
+void   *memmem(const void *__big, size_t __big_len, const void *__little, size_t __little_len) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+void     memset_pattern4(void *__b, const void *__pattern4, size_t __len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0);
+void     memset_pattern8(void *__b, const void *__pattern8, size_t __len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0);
+void     memset_pattern16(void *__b, const void *__pattern16, size_t __len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0);
+
+char   *strcasestr(const char *__big, const char *__little);
+char   *strnstr(const char *__big, const char *__little, size_t __len);
+size_t  strlcat(char *__dst, const char *__source, size_t __size);
+size_t  strlcpy(char *__dst, const char *__source, size_t __size);
+void    strmode(int __mode, char *__bp);
+char   *strsep(char **__stringp, const char *__delim);
 
 /* SUS places swab() in unistd.h.  It is listed here for source compatibility */
 void    swab(const void * __restrict, void * __restrict, ssize_t);
index 7636571067119e1c94cd9257cf5c735a8c60400f..cf18a94775ba74607b0da240c4866df6a1e1751d 100644 (file)
@@ -117,10 +117,11 @@ extern int pthread_key_init_np(int, void (*)(void *));
  * Libc pthread key assignments
  */
 #define __LIBC_PTHREAD_KEY_XLOCALE     __LIBC_PTHREAD_KEY(0)
-#define __LIBC_PTHREAD_KEY_TTYNAME     __LIBC_PTHREAD_KEY(1)
+//#define __LIBC_PTHREAD_KEY_RESERVED_WIN64    __LIBC_PTHREAD_KEY(1)
 #define __LIBC_PTHREAD_KEY_LOCALTIME   __LIBC_PTHREAD_KEY(2)
 #define __LIBC_PTHREAD_KEY_GMTIME      __LIBC_PTHREAD_KEY(3)
 #define __LIBC_PTHREAD_KEY_GDTOA_BIGINT        __LIBC_PTHREAD_KEY(4)
 #define __LIBC_PTHREAD_KEY_PARSEFLOAT  __LIBC_PTHREAD_KEY(5)
+#define __LIBC_PTHREAD_KEY_TTYNAME     __LIBC_PTHREAD_KEY(6)
 
 #endif /* _LIBC_SYS_CDEFS_H_ */
index a97ae7a62d9933a0810ef1b7b1e4dafdc75b20ea..dedea0b79fcc4b11629c724d4b523caff6c19d28 100644 (file)
@@ -64,6 +64,7 @@
 #define        _TIME_H_
 
 #include <_types.h>
+#include <Availability.h>
 #include <sys/_types/_clock_t.h>
 #include <sys/_types/_null.h>
 #include <sys/_types/_size_t.h>
@@ -180,13 +181,62 @@ time_t timegm(struct tm * const);
 //Begin-Libc
 #ifndef LIBC_ALIAS_NANOSLEEP
 //End-Libc
-int nanosleep(const struct timespec *, struct timespec *) __DARWIN_ALIAS_C(nanosleep);
+int nanosleep(const struct timespec *__rqtp, struct timespec *__rmtp) __DARWIN_ALIAS_C(nanosleep);
 //Begin-Libc
 #else /* LIBC_ALIAS_NANOSLEEP */
-int nanosleep(const struct timespec *, struct timespec *) LIBC_ALIAS_C(nanosleep);
+int nanosleep(const struct timespec *__rqtp, struct timespec *__rmtp) LIBC_ALIAS_C(nanosleep);
 #endif /* !LIBC_ALIAS_NANOSLEEP */
 //End-Libc
 #endif
+
+#if !defined(_DARWIN_FEATURE_CLOCK_GETTIME) || _DARWIN_FEATURE_CLOCK_GETTIME != 0
+#if __DARWIN_C_LEVEL >= 199309L
+#if __has_feature(enumerator_attributes)
+#define __CLOCK_AVAILABILITY __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
+#else
+#define __CLOCK_AVAILABILITY
+#endif
+
+typedef enum {
+_CLOCK_REALTIME __CLOCK_AVAILABILITY = 0,
+#define CLOCK_REALTIME _CLOCK_REALTIME
+_CLOCK_MONOTONIC __CLOCK_AVAILABILITY = 6,
+#define CLOCK_MONOTONIC _CLOCK_MONOTONIC
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+_CLOCK_MONOTONIC_RAW __CLOCK_AVAILABILITY = 4,
+#define CLOCK_MONOTONIC_RAW _CLOCK_MONOTONIC_RAW
+_CLOCK_MONOTONIC_RAW_APPROX __CLOCK_AVAILABILITY = 5,
+#define CLOCK_MONOTONIC_RAW_APPROX _CLOCK_MONOTONIC_RAW_APPROX
+_CLOCK_UPTIME_RAW __CLOCK_AVAILABILITY = 8,
+#define CLOCK_UPTIME_RAW _CLOCK_UPTIME_RAW
+_CLOCK_UPTIME_RAW_APPROX __CLOCK_AVAILABILITY = 9,
+#define CLOCK_UPTIME_RAW_APPROX _CLOCK_UPTIME_RAW_APPROX
+#endif
+_CLOCK_PROCESS_CPUTIME_ID __CLOCK_AVAILABILITY = 12,
+#define CLOCK_PROCESS_CPUTIME_ID _CLOCK_PROCESS_CPUTIME_ID
+_CLOCK_THREAD_CPUTIME_ID __CLOCK_AVAILABILITY = 16
+#define CLOCK_THREAD_CPUTIME_ID _CLOCK_THREAD_CPUTIME_ID
+} clockid_t;
+
+__CLOCK_AVAILABILITY
+int clock_getres(clockid_t __clock_id, struct timespec *__res);
+
+__CLOCK_AVAILABILITY
+int clock_gettime(clockid_t __clock_id, struct timespec *__tp);
+
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+__CLOCK_AVAILABILITY
+__uint64_t clock_gettime_nsec_np(clockid_t __clock_id);
+#endif
+
+__OSX_AVAILABLE(10.12) __IOS_PROHIBITED
+__TVOS_PROHIBITED __WATCHOS_PROHIBITED
+int clock_settime(clockid_t __clock_id, const struct timespec *__tp);
+
+#undef __CLOCK_AVAILABILITY
+#endif /* __DARWIN_C_LEVEL */
+#endif /* _DARWIN_FEATURE_CLOCK_GETTIME */
+
 __END_DECLS
 
 #ifdef _USE_EXTENDED_LOCALES_
index 6cfeedf854cc2fc983b49bcb6da934ab7b84bc7b..43842478b1198b3bc363cd39c019a70299787f57 100644 (file)
@@ -445,12 +445,12 @@ int        close(int) LIBC_ALIAS_C(close);
 
 int     dup(int);
 int     dup2(int, int);
-int     execl(const char *, const char *, ...) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
-int     execle(const char *, const char *, ...) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
-int     execlp(const char *, const char *, ...) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
-int     execv(const char *, char * const *) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
-int     execve(const char *, char * const *, char * const *) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
-int     execvp(const char *, char * const *) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
+int     execl(const char * __path, const char * __arg0, ...) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
+int     execle(const char * __path, const char * __arg0, ...) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
+int     execlp(const char * __file, const char * __arg0, ...) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
+int     execv(const char * __path, char * const * __argv) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
+int     execve(const char * __file, char * const * __argv, char * const * __envp) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
+int     execvp(const char * __file, char * const * __argv) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
 pid_t   fork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
 long    fpathconf(int, int);
 char   *getcwd(char *, size_t);
@@ -536,10 +536,10 @@ int        unlink(const char *);
 //Begin-Libc
 #ifndef LIBC_ALIAS_WRITE
 //End-Libc
-ssize_t         write(int, const void *, size_t) __DARWIN_ALIAS_C(write);
+ssize_t         write(int __fd, const void * __buf, size_t __nbyte) __DARWIN_ALIAS_C(write);
 //Begin-Libc
 #else /* LIBC_ALIAS_WRITE */
-ssize_t         write(int, const void *, size_t) LIBC_ALIAS_C(write);
+ssize_t         write(int __fd, const void * __buf, size_t __nbyte) LIBC_ALIAS_C(write);
 #endif /* !LIBC_ALIAS_WRITE */
 //End-Libc
 __END_DECLS
@@ -673,20 +673,20 @@ int        nice(int) LIBC_ALIAS(nice);
 //Begin-Libc
 #ifndef LIBC_ALIAS_PREAD
 //End-Libc
-ssize_t         pread(int, void *, size_t, off_t) __DARWIN_ALIAS_C(pread);
+ssize_t         pread(int __fd, void * __buf, size_t __nbyte, off_t __offset) __DARWIN_ALIAS_C(pread);
 //Begin-Libc
 #else /* LIBC_ALIAS_PREAD */
-ssize_t         pread(int, void *, size_t, off_t) LIBC_ALIAS_C(pread);
+ssize_t         pread(int __fd, void * __buf, size_t __nbyte, off_t __offset) LIBC_ALIAS_C(pread);
 #endif /* !LIBC_ALIAS_PREAD */
 //End-Libc
 
 //Begin-Libc
 #ifndef LIBC_ALIAS_PWRITE
 //End-Libc
-ssize_t         pwrite(int, const void *, size_t, off_t) __DARWIN_ALIAS_C(pwrite);
+ssize_t         pwrite(int __fd, const void * __buf, size_t __nbyte, off_t __offset) __DARWIN_ALIAS_C(pwrite);
 //Begin-Libc
 #else /* LIBC_ALIAS_PWRITE */
-ssize_t         pwrite(int, const void *, size_t, off_t) LIBC_ALIAS_C(pwrite);
+ssize_t         pwrite(int __fd, const void * __buf, size_t __nbyte, off_t __offset) LIBC_ALIAS_C(pwrite);
 #endif /* !LIBC_ALIAS_PWRITE */
 //End-Libc
 
@@ -800,7 +800,7 @@ int  accessx_np(const struct accessx_descriptor *, size_t, int *, uid_t);
 int     acct(const char *);
 int     add_profil(char *, size_t, unsigned long, unsigned int) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
 void    endusershell(void);
-int     execvP(const char *, const char *, char * const *)  __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
+int     execvP(const char * __file, const char * __searchpath, char * const * __argv)  __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
 char   *fflagstostr(unsigned long);
 int     getdomainname(char *, int);
 int     getgrouplist(const char *, int, int *, int *);
@@ -819,27 +819,42 @@ int        getsgroups_np(int *, uuid_t);
 char   *getusershell(void);
 int     getwgroups_np(int *, uuid_t);
 int     initgroups(const char *, int);
-int     iruserok(unsigned long, int, const char *, const char *);
-int     iruserok_sa(const void *, int, int, const char *, const char *);
 int     issetugid(void);
 char   *mkdtemp(char *);
 int     mknod(const char *, mode_t, dev_t);
 int     mkpath_np(const char *path, mode_t omode) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); /* returns errno */
+int     mkpathat_np(int dfd, const char *path, mode_t omode) /* returns errno */
+               __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
+               __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
 int     mkstemp(char *);
 int     mkstemps(char *, int);
 char   *mktemp(char *);
+int     mkostemp(char *path, int oflags)
+               __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
+               __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
+int     mkostemps(char *path, int slen, int oflags)
+               __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
+               __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
+/* Non-portable mkstemp that uses open_dprotected_np */
+int     mkstemp_dprotected_np(char *path, int dpclass, int dpflags)
+               __OSX_UNAVAILABLE __IOS_AVAILABLE(10.0)
+               __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
 int     nfssvc(int, void *);
 int     profil(char *, size_t, unsigned long, unsigned int);
 int     pthread_setugid_np(uid_t, gid_t);
 int     pthread_getugid_np( uid_t *, gid_t *);
-int     rcmd(char **, int, const char *, const char *, const char *, int *);
-int     rcmd_af(char **, int, const char *, const char *, const char *, int *,
-               int);
 int     reboot(int);
 int     revoke(const char *);
-int     rresvport(int *);
-int     rresvport_af(int *, int);
-int     ruserok(const char *, int, const char *, const char *);
+
+__deprecated int        rcmd(char **, int, const char *, const char *, const char *, int *);
+__deprecated int        rcmd_af(char **, int, const char *, const char *, const char *, int *,
+               int);
+__deprecated int        rresvport(int *);
+__deprecated int        rresvport_af(int *, int);
+__deprecated int        iruserok(unsigned long, int, const char *, const char *);
+__deprecated int        iruserok_sa(const void *, int, int, const char *, const char *);
+__deprecated int        ruserok(const char *, int, const char *, const char *);
+
 int     setdomainname(const char *, int);
 int     setgroups(int, const gid_t *);
 void    sethostid(long);
@@ -874,12 +889,18 @@ void       setusershell(void);
 int     setwgroups_np(int, const uuid_t);
 int     strtofflags(char **, unsigned long *, unsigned long *);
 int     swapon(const char *);
-int     syscall(int, ...) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
 int     ttyslot(void);
 int     undelete(const char *);
 int     unwhiteout(const char *);
 void   *valloc(size_t);                        
 
+__WATCHOS_PROHIBITED __TVOS_PROHIBITED
+__OS_AVAILABILITY_MSG(ios,deprecated=10.0,"syscall(2) is unsupported; "
+    "please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost().")
+__OS_AVAILABILITY_MSG(macosx,deprecated=10.12,"syscall(2) is unsupported; "
+    "please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost().")
+int     syscall(int, ...);
+
 extern char *suboptarg;                        /* getsubopt(3) external variable */
 int     getsubopt(char **, char * const *, char **);
 
index 739ee417e914be0c07a54133fb30d6de9ed79e33..d0001cc37d4dd6c639d026f069992e394700f095 100644 (file)
@@ -20,6 +20,9 @@
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
+/*     $NetBSD: vis.h,v 1.21 2013/02/20 17:01:15 christos Exp $        */
+/*     $FreeBSD$       */
+
 /*-
  * Copyright (c) 1990, 1993
  *     The Regents of the University of California.  All rights reserved.
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
 /*
  * to select alternate encoding format
  */
-#define        VIS_OCTAL       0x01    /* use octal \ddd format */
-#define        VIS_CSTYLE      0x02    /* use \[nrft0..] where appropriate */
+#define        VIS_OCTAL       0x0001  /* use octal \ddd format */
+#define        VIS_CSTYLE      0x0002  /* use \[nrft0..] where appropiate */
 
 /*
  * to alter set of characters encoded (default is to encode all
  * non-graphic except space, tab, and newline).
  */
-#define        VIS_SP          0x04    /* also encode space */
-#define        VIS_TAB         0x08    /* also encode tab */
-#define        VIS_NL          0x10    /* also encode newline */
+#define        VIS_SP          0x0004  /* also encode space */
+#define        VIS_TAB         0x0008  /* also encode tab */
+#define        VIS_NL          0x0010  /* also encode newline */
 #define        VIS_WHITE       (VIS_SP | VIS_TAB | VIS_NL)
-#define        VIS_SAFE        0x20    /* only encode "unsafe" characters */
+#define        VIS_SAFE        0x0020  /* only encode "unsafe" characters */
 
 /*
  * other
  */
-#define        VIS_NOSLASH     0x40    /* inhibit printing '\' */
-#define        VIS_HTTPSTYLE   0x80    /* http-style escape % HEX HEX */
-#define        VIS_GLOB        0x100   /* encode glob(3) magics */
+#define        VIS_NOSLASH     0x0040  /* inhibit printing '\' */
+#define        VIS_HTTP1808    0x0080  /* http-style escape % hex hex */
+#define        VIS_HTTPSTYLE   0x0080  /* http-style escape % hex hex */
+#define        VIS_GLOB        0x0100  /* encode glob(3) magic characters */
+#define        VIS_MIMESTYLE   0x0200  /* mime-style escape = HEX HEX */
+#define        VIS_HTTP1866    0x0400  /* http-style &#num; or &string; */
+#define        VIS_NOESCAPE    0x0800  /* don't decode `\' */
+#define        _VIS_END        0x1000  /* for unvis */
 
 /*
  * unvis return codes
 /*
  * unvis flags
  */
-#define        UNVIS_END       1       /* no more characters */
+#define        UNVIS_END       _VIS_END        /* no more characters */
 
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
 char   *vis(char *, int, int, int);
+char   *nvis(char *, size_t, int, int, int);
+
+char   *svis(char *, int, int, int, const char *);
+char   *snvis(char *, size_t, int, int, int, const char *);
+
 int    strvis(char *, const char *, int);
+int    strnvis(char *, size_t, const char *, int);
+
+int    strsvis(char *, const char *, int, const char *);
+int    strsnvis(char *, size_t, const char *, int, const char *);
+
 int    strvisx(char *, const char *, size_t, int);
+int    strnvisx(char *, size_t, const char *, size_t, int);
+int    strenvisx(char *, size_t, const char *, size_t, int, int *);
+
+int    strsvisx(char *, const char *, size_t, int, const char *);
+int    strsnvisx(char *, size_t, const char *, size_t, int, const char *);
+int    strsenvisx(char *, size_t, const char *, size_t , int, const char *,
+    int *);
+
 int    strunvis(char *, const char *);
+int    strnunvis(char *, size_t, const char *);
+
 int    strunvisx(char *, const char *, int);
+int    strnunvisx(char *, size_t, const char *, int);
+
 int    unvis(char *, int, int *, int);
 __END_DECLS
 
index 0ad40f87f9ad961ac9e676b9aa44f8e30c39a539..c48f7632a1e151a3c305ec34a667c15c6bd62990 100644 (file)
@@ -35,7 +35,7 @@ int    printf_l(locale_t __restrict, const char * __restrict, ...)
 int     scanf_l(locale_t __restrict, const char * __restrict, ...)
         __scanflike(2, 3);
 int     sprintf_l(char * __restrict, locale_t __restrict, const char * __restrict, ...)
-        __printflike(3, 4);
+        __printflike(3, 4) __swift_unavailable("Use snprintf_l instead.");
 int     sscanf_l(const char * __restrict, locale_t __restrict, const char * __restrict, ...) 
         __scanflike(3, 4);
 int     vfprintf_l(FILE * __restrict, locale_t __restrict, const char * __restrict, va_list)
@@ -43,7 +43,7 @@ int    vfprintf_l(FILE * __restrict, locale_t __restrict, const char * __restrict,
 int     vprintf_l(locale_t __restrict, const char * __restrict, va_list)
         __printflike(2, 0);
 int     vsprintf_l(char * __restrict, locale_t __restrict, const char * __restrict, va_list)
-        __printflike(3, 0);
+        __printflike(3, 0) __swift_unavailable("Use vsnprintf_l instead.");
 
 #if __DARWIN_C_LEVEL >= 200112L || defined(__cplusplus)
 int     snprintf_l(char * __restrict, size_t, locale_t __restrict, const char * __restrict, ...)
index e4f1489129a085ccc57fa6973a52cd2f3f645e20..4c910ea720345e6d0577ebc2d901708ab283f558 100644 (file)
@@ -6,6 +6,11 @@
  * This code is derived from software contributed to Berkeley by
  * Paul Borman at Krystal Technologies.
  *
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -32,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/locale/ascii.c,v 1.1 2008/01/21 23:48:12 ache Exp $");
+__FBSDID("$FreeBSD$");
 
 #include <errno.h>
 #include <limits.h>
@@ -137,6 +142,7 @@ _ascii_mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src,
        nchr = 0;
        while (len-- > 0 && nms-- > 0) {
                if (*s & 0x80) {
+                       *src = s;
                        errno = EILSEQ;
                        return ((size_t)-1);
                }
@@ -171,6 +177,7 @@ _ascii_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src,
        nchr = 0;
        while (len-- > 0 && nwc-- > 0) {
                if (*s < 0 || *s > 127) {
+                       *src = s;
                        errno = EILSEQ;
                        return ((size_t)-1);
                }
index 268db3f6ff82c341b167704dbe3b350c474c49e3..d468783ae4c1d7190e004cd5b60f411504cab4e3 100644 (file)
@@ -109,12 +109,11 @@ __collate_load_tables(const char *encoding, locale_t loc)
 
        /* 'PathLocale' must be already set & checked. */
        /* Range checking not needed, encoding has fixed size */
-       (void)strcpy(buf, _PathLocale);
-       (void)strcat(buf, "/");
-       (void)strcat(buf, encoding);
+       (void)strcpy(buf, encoding);
        (void)strcat(buf, "/LC_COLLATE");
-       if ((fp = fopen(buf, "r")) == NULL)
+       if ((fp = fdopen(__open_path_locale(buf), "r")) == NULL) {
                return (_LDP_ERROR);
+       }
 
        if (fread(strbuf, sizeof(strbuf), 1, fp) != 1) {
                saverr = errno;
index 0a0ab37e26c485721b81f9d02a0d56adfd5828c7..dc18f3aae86ec779b3ab1989221547c7d6d8863e 100644 (file)
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/lib/libc/locale/isspecial.3,v 1.3 2009/09/04 07:44:58 des Exp $
+.\" $FreeBSD$
 .\"
 .Dd March 30, 2004
 .Dt ISSPECIAL 3
@@ -41,6 +41,9 @@
 The
 .Fn isspecial
 function tests for a special character.
+Special characters are locale dependent, and not necessarily consistent between
+different locales.
+Examples might include fractions and numbers inside circles.
 .Sh RETURN VALUES
 The
 .Fn isspecial
index 6a08e150f05fd5b4583aa5bfa8bdf6883581df56..10172af826a71dc12f23ca0e85ff92c5b20d2823 100644 (file)
@@ -70,12 +70,10 @@ __part_load_locale(const char *name,
        /* 'PathLocale' must be already set & checked. */
 
        /* Range checking not needed, 'name' size is limited */
-       strcpy(filename, _PathLocale);
-       strcat(filename, "/");
-       strcat(filename, name);
+       strcpy(filename, name);
        strcat(filename, "/");
        strcat(filename, category_filename);
-       if ((fd = _open(filename, O_RDONLY)) < 0)
+       if ((fd = __open_path_locale(filename)) < 0)
                return (_LDP_ERROR);
        if (_fstat(fd, &st) != 0)
                goto bad_locale;
index 11c2cb09814df8479ac1df6767ae2b19d03b886f..b6a346dc3badd678e8b6c319806227898560984e 100644 (file)
@@ -1,4 +1,6 @@
 /*-
+ * Copyright 2013 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
  * Copyright (c) 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -6,6 +8,11 @@
  * This code is derived from software contributed to Berkeley by
  * Paul Borman at Krystal Technologies.
  *
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -35,7 +42,7 @@
 static char sccsid[] = "@(#)none.c     8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/locale/none.c,v 1.15 2007/10/13 16:28:22 ache Exp $");
+__FBSDID("$FreeBSD$");
 
 #include "xlocale_private.h"
 
@@ -157,6 +164,7 @@ _none_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src,
        nchr = 0;
        while (len-- > 0 && nwc-- > 0) {
                if (*s < 0 || *s > UCHAR_MAX) {
+                       *src = s;
                        errno = EILSEQ;
                        return ((size_t)-1);
                }
index 6d3be0354b924d59900528eb9bff31f061a8eec9..8c263b9c36c8317a0d3cdb0a9bc691a25ebc132a 100644 (file)
@@ -29,7 +29,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"    @(#)setlocale.3 8.1 (Berkeley) 6/9/93
-.\" $FreeBSD: src/lib/libc/locale/setlocale.3,v 1.35 2007/01/09 00:28:00 imp Exp $
+.\" $FreeBSD$
 .\"
 .Dd November 21, 2003
 .Dt SETLOCALE 3
@@ -60,7 +60,6 @@ The
 .Fn setlocale
 function recognizes several categories of routines.
 These are the categories and the sets of routines they select:
-.Pp
 .Bl -tag -width LC_MONETARY
 .It Dv LC_ALL
 Set the entire locale generically.
@@ -106,21 +105,25 @@ function.
 .Pp
 Only three locales are defined by default:
 the empty string
-.Li "\&""\|""
+.Li \&"\|"
 (which denotes the native environment) and the
-.Li "\&""C""
+.Li \&"C"
 and
-.Li "\&""POSIX""
-locales (which denote the C-language environment).
+.Li \&"POSIX"
+locales (which denote the C language environment).
 A
 .Fa locale
 argument of
 .Dv NULL
 causes
 .Fn setlocale
-to return the current locale.
+to return the current locale.  An argument of
+.Li \&"\|"
+will determine the name of the new locale taking into account the environment
+variables LANG and LC_*.  If these environment variables yield a locale that is
+invalid, NULL will be returned and the current locale will remain unchanged.
 By default, C programs start in the
-.Li "\&""C""
+.Li \&"C"
 locale.
 The only function in the library that sets the locale is
 .Fn setlocale ;
@@ -150,6 +153,11 @@ locale file for the locale
 .Em locale
 and the category
 .Em category .
+.It Pa /usr/local/share/locale/ Ns Em locale/category
+locale file for the locale
+.Em locale
+and the category
+.Em category .
 .El
 .Sh ERRORS
 No errors are defined.
index c65d189188a08702b9836742446b93eb81fd1e18..11b259e974d3302953c2148a565bdc2932dc259b 100644 (file)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/setlocale.c,v 1.51 2007/01/09 00:28:00 i
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <fcntl.h>
 #include "collate.h"
 #include "lmonetary.h" /* for __monetary_load_locale() */
 #include "lnumeric.h"  /* for __numeric_load_locale() */
@@ -362,3 +363,31 @@ __detect_path_locale(void)
        return (0);
 }
 
+__private_extern__ int
+__open_path_locale(const char *subpath)
+{
+       char filename[PATH_MAX];
+       int fd;
+
+       strcpy(filename, _PathLocale);
+       strcat(filename, "/");
+       strcat(filename, subpath);
+       fd = _open(filename, O_RDONLY);
+       if (fd >= 0) {
+               return fd;
+       }
+
+       strcpy(filename, _PATH_LOCALE);
+       strcat(filename, "/");
+       strcat(filename, subpath);
+       fd = _open(filename, O_RDONLY);
+       if (fd >= 0) {
+               return fd;
+       }
+
+       strcpy(filename, "/usr/local/share/locale");
+       strcat(filename, "/");
+       strcat(filename, subpath);
+       return _open(filename, O_RDONLY);
+}
+
index b21f6f71a3a3fd7c048c47bfa21bb56a5fbbaf57..fd002f267c6e6d7c9cdfc0d9bf38af94e5dce74f 100644 (file)
@@ -38,5 +38,6 @@ extern char *_PathLocale;
 
 int    __detect_path_locale(void);
 int    __wrap_setrunelocale(const char *, locale_t);
+int    __open_path_locale(const char *);
 
 #endif /* !_SETLOCALE_H_ */
index fbb2275349c51696a8fe816746f5cc18bed80731..213a62b9d4eaf8cb73dd9b50424fb0c3d8a0bc8e 100644 (file)
@@ -107,12 +107,10 @@ __setrunelocale(const char *encoding, locale_t loc)
         */
 
        /* Range checking not needed, encoding length already checked before */
-       (void) strcpy(name, _PathLocale);
-       (void) strcat(name, "/");
-       (void) strcat(name, encoding);
+       (void) strcpy(name, encoding);
        (void) strcat(name, "/LC_CTYPE");
 
-       if ((fp = fopen(name, "r")) == NULL)
+       if ((fp = fdopen(__open_path_locale(name), "r")) == NULL)
                return (errno == 0 ? ENOENT : errno);
 
        if ((xrl = _Read_RuneMagi(fp)) == NULL) {
index 2d5ddb72dec4dd8d3945f925296e41bb1403c9ff..c34654eafaed10680ef34c3991553991e168e378 100644 (file)
@@ -263,6 +263,9 @@ as a multibyte string.
 .It Pa /usr/share/locale/ Ns Em locale Ns /LC_CTYPE
 binary LC_CTYPE file for the locale
 .Em locale .
+.It Pa /usr/local/share/locale/ Ns Em locale Ns /LC_CTYPE
+binary LC_CTYPE file for the locale
+.Em locale .
 .El
 .Sh SEE ALSO
 .Xr mbrune 3 ,
index 337fa4a721eec2129a6ac8f5ef28828a8cde415d..1e1c443d8c014e31793707e3f6ff8ac33b48d5bd 100644 (file)
@@ -480,7 +480,8 @@ ___mb_cur_max_l(locale_t loc)
 static void
 __xlocale_release(void *loc)
 {
-       XL_RELEASE((locale_t)loc);
+       locale_t l = loc;
+       XL_RELEASE(l);
 }
 
 /*
index 52a4fb8fcf05bacc4a47afc1546340ee4df1d5cb..2301aa0ff2feeb3307a4dfb1a8af223d3c1954f4 100644 (file)
@@ -180,6 +180,7 @@ struct _xlocale {
                                if ((x)->__free_extra) \
                                        (*(x)->__free_extra)((x)); \
                                free((x)); \
+                               (x) = NULL; \
                        }
 #define        XL_RETAIN(x)    if ((x) && (x)->__free_extra != XPERMANENT) { OSAtomicIncrement32Barrier(&(x)->__refcount); }
 #define XL_UNLOCK(x)   UNLOCK((x)->__lock);
diff --git a/man/FreeBSD/environ.7 b/man/FreeBSD/environ.7
new file mode 100644 (file)
index 0000000..901f7eb
--- /dev/null
@@ -0,0 +1,291 @@
+.\" Copyright (c) 1983, 1990, 1993
+.\"    The Regents of the University of California.  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.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+.\"
+.\"    @(#)environ.7   8.3 (Berkeley) 4/19/94
+.\" $FreeBSD$
+.\"
+.Dd April 12, 2003
+.Dt ENVIRON 7
+.Os
+.Sh NAME
+.Nm environ
+.Nd user environment
+.Sh SYNOPSIS
+.Ar extern char **environ ;
+.Sh DESCRIPTION
+An array of strings called the
+.Ar environment
+is made available by
+.Xr execve 2
+when a process begins.
+By convention these strings have the form
+.Dq Ar name=value .
+The following names are used by various commands:
+.Bl -tag -width LC_MONETARY
+.It Ev BLOCKSIZE
+The size of the block units used by several commands, most notably
+.Xr df 1 ,
+.Xr du 1
+and
+.Xr ls 1 .
+This variable is processed by the
+.Xr getbsize 3
+function.
+.It Ev COLUMNS
+The user's preferred width in column positions for the terminal.
+Utilities such as
+.Xr ls 1
+and
+.Xr who 1
+use this to format output into columns.
+If unset or empty, utilities will use an
+.Xr ioctl 2
+call to ask the terminal driver for the width.
+.It Ev EDITOR
+Default editor name.
+.It Ev EXINIT
+A startup list of commands read by
+.Xr ex 1
+and
+.Xr vi 1 .
+.It Ev HOME
+A user's login directory, set by
+.Xr login 1
+from the password file
+.Xr passwd 5 .
+.It Ev LANG
+This variable configures all programs which use
+.Xr setlocale 3
+to use the specified locale unless the
+.Ev LC_*
+variables are set.
+.It Ev LC_ALL
+Overrides the values of
+.Ev LC_COLLATE ,
+.Ev LC_CTYPE ,
+.Ev LC_MESSAGES ,
+.Ev LC_MONETARY ,
+.Ev LC_NUMERIC ,
+.Ev LC_TIME
+and
+.Ev LANG .
+.It Ev LC_COLLATE
+Locale to be used for ordering of strings.
+.It Ev LC_CTYPE
+Locale to be used for character classification
+(letter, space, digit, etc.) and for interpreting byte sequences as
+multibyte characters.
+.It Ev LC_MESSAGES
+Locale to be used for diagnostic messages.
+.It Ev LC_MONETARY
+Locale to be used for interpreting monetary input
+and formatting output.
+.It Ev LC_NUMERIC
+Locale to be used for interpreting numeric input and
+formatting output.
+.It Ev LC_TIME
+Locale to be used for interpreting dates input and
+for formatting output.
+.It Ev MAIL
+The location of the user's
+mailbox instead of the default in /var/mail,
+used by
+.Xr mail 1 ,
+.Xr sh 1 ,
+and many other mail clients.
+.It Ev NLSPATH
+List of directories to be searched for the message catalog referred to by
+.Ev LC_MESSAGES .
+See
+.Xr catopen 3 .
+.It Ev PAGER
+Default paginator program.
+The program specified by this variable is used by
+.Xr mail 1 ,
+.Xr man 1 ,
+.Xr ftp 1 ,
+etc, to display information which is longer than the current display.
+.It Ev PATH
+The sequence of directories, separated by colons, searched by
+.Xr csh 1 ,
+.Xr sh 1 ,
+.Xr system 3 ,
+.Xr execvp 3 ,
+etc, when looking for an executable file.
+.Ev PATH
+is set to ``/usr/bin:/bin'' initially by
+.Xr login 1 .
+.It Ev PRINTER
+The name of the default printer to be used by
+.Xr lpr 1 ,
+.Xr lpq 1 ,
+and
+.Xr lprm 1 .
+.It Ev PWD
+The current directory pathname.
+.It Ev SHELL
+The full pathname of the user's login shell.
+.It Ev TERM
+The kind of terminal for which output is to be prepared.
+This information is used by commands, such as
+.Xr nroff 1
+or
+.Xr plot 1
+which may exploit special terminal capabilities.
+See
+.Pa /usr/share/misc/termcap
+.Pq Xr termcap 5
+for a list of terminal types.
+.It Ev TERMCAP
+The string describing the terminal in
+.Ev TERM ,
+or, if
+it begins with a '/', the name of the termcap file.
+See
+.Ev TERMPATH
+below, and
+.Xr termcap 5 .
+.It Ev TERMPATH
+A sequence of pathnames of termcap files, separated by colons or spaces,
+which are searched for terminal descriptions in the order listed.
+Having
+no
+.Ev TERMPATH
+is equivalent to a
+.Ev TERMPATH
+of
+.Dq Pa $HOME/.termcap:/etc/termcap .
+.Ev TERMPATH
+is ignored if
+.Ev TERMCAP
+contains a full pathname.
+.It Ev TMPDIR
+The directory in which to store temporary files.
+Most applications use either
+.Dq /tmp
+or
+.Dq /var/tmp .
+Setting this variable will make them use another directory.
+.It Ev TZ
+The timezone to use when displaying dates.
+The normal format is a pathname relative to
+.Dq Pa /usr/share/zoneinfo .
+For example, the command
+.Dq env TZ=America/Los_Angeles date
+displays the current time in California.
+See
+.Xr tzset 3
+for more information.
+.It Ev USER
+The login name of the user.
+.El
+.Pp
+Further names may be placed in the environment by the
+.Ic export
+command and
+.Ar name=value
+arguments in
+.Xr sh 1 ,
+or by the
+.Ic setenv
+command if you use
+.Xr csh 1 .
+It is unwise to change certain
+.Xr sh 1
+variables that are frequently exported by
+.Pa .profile
+files, such as
+.Ev MAIL ,
+.Ev PS1 ,
+.Ev PS2 ,
+and
+.Ev IFS ,
+unless you know what you are doing.
+.Pp
+The current environment variables can be printed with
+.Xr env 1 ,
+.Xr set 1
+or
+.Xr printenv 1
+in
+.Xr sh 1
+and
+.Xr env 1 ,
+.Xr printenv 1
+or the
+.Cm printenv
+built-in command in
+.Xr csh 1 .
+.Sh PROGRAMMING
+Programs can query and modify the environment, using the environment routines
+.Xr getenv 3 ,
+.Xr putenv 3 ,
+.Xr setenv 3
+and
+.Xr unsetenv 3 .
+Direct access can be made through the global variable
+.Va environ ,
+though it is recommended that changes to the enviroment still be made through
+the environment routines.
+.Pp
+Shared libraries and bundles don't have direct access to
+.Va environ ,
+which is only available to the loader
+.Xr ld 1
+when a complete program is being linked.
+The environment routines can still be used, but if direct access to
+.Va environ
+is needed, the
+.Fn _NSGetEnviron
+routine, defined in
+.In crt_externs.h ,
+can be used to retrieve the address of
+.Va environ
+at runtime.
+.Sh SEE ALSO
+.Xr cd 1 ,
+.Xr csh 1 ,
+.Xr env 1 ,
+.Xr ex 1 ,
+.Xr login 1 ,
+.Xr printenv 1 ,
+.Xr sh 1 ,
+.Xr execve 2 ,
+.Xr execle 3 ,
+.Xr getenv 3 ,
+.Xr putenv 3 ,
+.Xr setenv 3 ,
+.Xr unsetenv 3 ,
+.Xr setlocale 3 ,
+.Xr system 3 ,
+.Xr termcap 3 ,
+.Xr termcap 5
+.Sh HISTORY
+The
+.Nm
+manual page appeared in
+.Bx 4.2 .
diff --git a/man/environ.7 b/man/environ.7
deleted file mode 100644 (file)
index 827b487..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-.\"    $NetBSD: environ.7,v 1.4 1995/07/03 19:45:07 jtc Exp $
-.\"
-.\" Copyright (c) 1983, 1990, 1993
-.\"    The Regents of the University of California.  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.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"    This product includes software developed by the University of
-.\"    California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
-.\"
-.\"    @(#)environ.7   8.3 (Berkeley) 4/19/94
-.\"
-.Dd April 19, 1994
-.Dt ENVIRON 7
-.Os BSD 4.2
-.Sh NAME
-.Nm environ
-.Nd user environment
-.Sh SYNOPSIS
-.Ar extern char **environ ;
-.Sh DESCRIPTION
-An array of strings called the
-.Ar environment
-is made available by
-.Xr execve  2
-when a process begins.  By convention these strings have the form
-.Dq Ar name=value .
-The following names are used by various commands:
-.Bl -tag -width BLOCKSIZE
-.It Ev BLOCKSIZE
-The size of the block units used by several commands, most notably
-.Xr df 1 ,
-.Xr du 1
-and
-.Xr ls 1 .
-BLOCKSIZE may be specified in units of a byte by specifying a number, 
-in units of a kilobyte by specifying a number followed by ``K'' or
-``k'', in units of a megabyte by specifying a number followed by ``M''
-or ``m'' and in units of a gigabyte by specifying a number followed
-by ``G'' or ``g''.
-Sizes less than 512 bytes or greater than a gigabyte are ignored.
-.It Ev EXINIT
-A startup list of commands read by
-.Xr ex  1
-and
-.Xr vi  1  .
-.It Ev HOME
-A user's login directory, set by
-.Xr login  1
-from the password file
-.Xr passwd  5  .
-.It Ev PATH
-The sequence of directories, separated by colons, searched by
-.Xr csh  1  ,
-.Xr sh  1 ,
-.Xr system  3  ,
-.Xr execvp  3 ,
-etc, when looking for an executable file.
-PATH is set to ``/usr/bin:/bin'' initially by
-.Xr login  1  .
-.It Ev PRINTER
-The name of the default printer to be used by
-.Xr lpr  1  ,
-.Xr lpq  1 ,
-and
-.Xr lprm  1  .
-.It Ev SHELL
-The full pathname of the user's login shell.
-.It Ev TERM
-The kind of terminal for which output is to be prepared.
-This information is used by commands, such as
-.Xr nroff  1
-which may exploit special terminal capabilities.  See
-.Xr termcap 3
-and
-.Xr terminfo 5 .
-.It Ev TMPDIR
-The directory in which to store temporary files.
-Most applications use either
-.Dq /tmp
-or
-.Dq /var/tmp .
-Setting this variable will make them use another directory.
-.It Ev TZ
-The timezone to use when displaying dates.
-The normal format is a pathname relative to
-.Dq /usr/share/zoneinfo .
-For example, the command
-.Dq env TZ=US/Pacific date
-displays the current time in California.
-See
-.Xr tzset 3
-for more information.
-.It Ev LOGNAME
-The login name of the user.
-.It Ev USER
-Deprecated synonym of
-.Ev LOGNAME
-(for backwards compatibility).
-.El
-.Pp
-Further names may be placed in the environment by the
-.Xr export
-command and
-.Ar name=value
-arguments in
-.Xr sh  1  ,
-or by the
-.Xr setenv
-command if you use
-.Xr csh  1  .
-It is unwise to change certain
-.Xr sh  1
-variables that are frequently exported by
-.Pa .profile
-files, such as
-.Ev MAIL ,
-.Ev PS1 ,
-.Ev PS2 ,
-and
-.Ev IFS ,
-unless you know what you are doing.
-.Sh PROGRAMMING
-Programs can query and modify the environment, using the environment routines
-.Xr getenv 3 ,
-.Xr putenv 3 ,
-.Xr setenv 3
-and
-.Xr unsetenv 3 .
-Direct access can be made through the global variable
-.Va environ ,
-though it is recommended that changes to the enviroment still be made through
-the environment routines.
-.Pp
-Shared libraries and bundles don't have direct access to
-.Va environ ,
-which is only available to the loader
-.Xr ld 1
-when a complete program is being linked.
-The environment routines can still be used, but if direct access to
-.Va environ
-is needed, the
-.Fn _NSGetEnviron
-routine, defined in
-.In crt_externs.h ,
-can be used to retrieve the address of
-.Va environ
-at runtime.
-.Sh SEE ALSO
-.Xr csh 1 ,
-.Xr ex 1 ,
-.Xr login 1 ,
-.Xr sh 1 ,
-.Xr getenv 3 ,
-.Xr putenv 3 ,
-.Xr setenv 3 ,
-.Xr unsetenv 3 ,
-.Xr execve 2 ,
-.Xr execle 3 ,
-.Xr system 3 ,
-.Xr termcap 3 ,
-.Xr terminfo 5
-.Sh HISTORY
-The
-.Nm environ
-manual page appeared in
-.Bx 4.2 .
index 9c284c57fe74dbc3be9e91e2fe93c438b9c10b7d..418ae3084e5f16091b0afead6462f8c613873671 100644 (file)
@@ -57,7 +57,7 @@ atof.3 atof.3 atof_l.3
 atoi.3 atoi.3 atoi_l.3
 atol.3 atol.3 atol_l.3 atoll.3 atoll_l.3
 backtrace.3 backtrace.3 backtrace_symbols.3 backtrace_symbols_fd.3
-basename.3 basename.3
+basename.3 basename.3 basename_r.3
 bcmp.3 bcmp.3
 bcopy.3 bcopy.3
 bitstring.3 bitstring.3 bit_alloc.3 bit_clear.3 bit_decl.3 bit_ffs.3 bit_nclear.3 bit_nset.3 bit_set.3 bit_test.3 bitstr_size.3
@@ -72,6 +72,7 @@ catclose.3 catclose.3
 catgets.3 catgets.3
 catopen.3 catopen.3
 clock.3 clock.3
+clock_gettime.3 clock_gettime.3 clock_settime.3 clock_getres.3 clock_gettime_nsec_np.3
 confstr.3 confstr.3
 crypt.3 crypt.3 encrypt.3 setkey.3
 ctermid.3 ctermid.3 ctermid_r.3
@@ -84,7 +85,7 @@ dbopen.3 dbopen.3 db.3
 devname.3 devname.3 devname_r.3
 digittoint.3 digittoint.3 digittoint_l.3
 directory.3 directory.3 closedir.3 dirfd.3 fdopendir.3 opendir.3 readdir.3 readdir_r.3 rewinddir.3 seekdir.3 telldir.3
-dirname.3 dirname.3
+dirname.3 dirname.3 dirname_r.3
 div.3 div.3
 duplocale.3 duplocale.3
 ecvt.3 ecvt.3 fcvt.3 gcvt.3
@@ -233,7 +234,6 @@ rand.3 rand.3 rand_r.3 srand.3 sranddev.3
 rand48.3 rand48.3 _rand48.3 drand48.3 erand48.3 jrand48.3 lcong48.3 lrand48.3 mrand48.3 nrand48.3 seed48.3 srand48.3
 random.3 random.3 initstate.3 setstate.3 srandom.3 srandomdev.3
 rbtree.3 rbtree.3
-rcmdsh.3 rcmdsh.3
 readpassphrase.3 readpassphrase.3
 realpath.3 realpath.3
 recno.3 recno.3
@@ -264,7 +264,6 @@ strchr.3 strchr.3 strrchr.3
 strcmp.3 strcmp.3 strncmp.3
 strcoll.3 strcoll.3 strcoll_l.3
 strcpy.3 strcpy.3 stpcpy.3 stpncpy.3 strncpy.3
-strcspn.3 strcspn.3
 strdup.3 strdup.3 strndup.3
 strerror.3 strerror.3 perror.3 strerror_r.3 sys_errlist.3 sys_nerr.3
 strfmon.3 strfmon.3 strfmon_l.3
@@ -277,7 +276,7 @@ strmode.3 strmode.3
 strpbrk.3 strpbrk.3
 strptime.3 strptime.3 strptime_l.3
 strsep.3 strsep.3
-strspn.3 strspn.3
+strspn.3 strspn.3 strcspn.3
 strstr.3 strstr.3 strcasestr.3 strcasestr_l.3 strnstr.3
 strtod.3 strtod.3 strtof.3 strtold.3
 strtod_l.3 strtod_l.3 strtof_l.3 strtold_l.3
@@ -321,7 +320,7 @@ unvis.3 unvis.3 strunvis.3 strunvisx.3
 uselocale.3 uselocale.3
 usleep.3 usleep.3
 utime.3 utime.3
-vis.3 vis.3 strvis.3 strvisx.3
+vis.3 vis.3 nvis.3 strvis.3 strnvis.3 strvisx.3 strnvisx.3 strenvisx.3 svis.3 snvis.3 strsvis.3 strsnvis.3 strsvisx.3 strsnvisx.3 strsenvisx.3
 wcrtomb.3 wcrtomb.3 wcrtomb_l.3
 wcscoll.3 wcscoll.3 wcscoll_l.3
 wcsftime.3 wcsftime.3 wcsftime_l.3
index 946d17d22ff4254e8355870f65b08cd9446b3d02..a43ced3a3fa967c81cb608f98dc9221ebd5acc3b 100644 (file)
@@ -50,9 +50,7 @@ __FBSDID("$FreeBSD: src/lib/libc/net/linkaddr.c,v 1.4 2007/01/09 00:28:02 imp Ex
 #define LETTER (4*3)
 
 void
-link_addr(addr, sdl)
-       const char *addr;
-       struct sockaddr_dl *sdl;
+link_addr(const char *addr, struct sockaddr_dl *sdl)
 {
        char *cp = sdl->sdl_data;
        char *cplim = sdl->sdl_len + (char *)sdl;
@@ -121,8 +119,7 @@ link_addr(addr, sdl)
 static const char hexlist[] = "0123456789abcdef";
 
 char *
-link_ntoa(sdl)
-       const struct sockaddr_dl *sdl;
+link_ntoa(const struct sockaddr_dl *sdl)
 {
        static char obuf[64];
        char *out = obuf;
@@ -131,6 +128,18 @@ link_ntoa(sdl)
        u_char *inlim = in + sdl->sdl_alen;
        int firsttime = 1;
 
+       /*
+        * the length of the output string is length of network name (eg "le0")
+        * plus 3 * each byte (eg. "XX.") assuming the print representation is
+        * two bytes plus the period
+        *
+        * The ":" is accounted for as the last byte doesn't have a "." at the
+        * end
+        */
+       if (sdl->sdl_nlen + 3*sdl->sdl_alen >= sizeof(obuf)) {
+               goto exit;
+       }
+
        if (sdl->sdl_nlen) {
                bcopy(sdl->sdl_data, obuf, sdl->sdl_nlen);
                out += sdl->sdl_nlen;
@@ -148,9 +157,12 @@ link_ntoa(sdl)
                        i >>= 4;
                        out[0] = hexlist[i];
                        out += 2;
-               } else
+               } else {
                        *out++ = hexlist[i];
+               }
        }
+
+exit:
        *out = 0;
        return (obuf);
 }
index a4c977d736e14f2937da9dc69b7c2cb5699fe5ea..a5ad5c60f7c6f453c2f619bfbb2f7a9a842ce752 100644 (file)
@@ -1,3 +1,25 @@
+/*
+ * Copyright (c) 2003,2005,2006,2011,2012 Apple, Inc. All rights reserved.
+ *
+ * @APPLE_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. 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_LICENSE_HEADER_END@
+ */
 
 #include <sys/types.h>
 #include <netinet/in.h>
 
 static const char *hexchars = "0123456789abcdef";
 
+const char * inet_ntop6(const struct in6_addr *addr, char *dst, socklen_t size);
+const char * inet_ntop4(const struct in_addr *addr, char *dst, socklen_t size);
+
+const char *
+inet_ntop(int af, const void *addr, char *buf, socklen_t len)
+{
+       if (af == AF_INET6) return inet_ntop6(addr, buf, len);
+       if (af == AF_INET) return inet_ntop4(addr, buf, len);
+
+       errno = EAFNOSUPPORT;
+       return NULL;
+}
+
 const char *
 inet_ntop6(const struct in6_addr *addr, char *dst, socklen_t size)
 {
@@ -43,16 +78,26 @@ inet_ntop6(const struct in6_addr *addr, char *dst, socklen_t size)
        j = IN6_IS_ADDR_V4COMPAT(addr);
        if ((i != 0) || (j != 0))
        {
+               const char *prefix;
+               socklen_t prefix_len;
+               if (i != 0) {
+                       prefix = "::ffff:";
+                       prefix_len = 7;
+               } else {
+                       prefix = "::";
+                       prefix_len = 2;
+               }
                a4.s_addr = addr->__u6_addr.__u6_addr32[3];
-               sprintf(tmp, "::%s%s", (i != 0) ? "ffff:" : "", inet_ntoa(a4));
+               inet_ntop4(&a4, tmp, sizeof(tmp));
                len = strlen(tmp) + 1;
-               if (len > size)
+               if (prefix_len + len > size)
                {
                        errno = ENOSPC;
                        return NULL;
                }
 
-               memcpy(dst, tmp, len);
+               memcpy(dst, prefix, prefix_len);
+               memcpy(dst + prefix_len, tmp, len);
                return dst;
        }
 
@@ -194,13 +239,3 @@ inet_ntop4(const struct in_addr *addr, char *dst, socklen_t size)
        memcpy(dst, tmp, len);
        return dst;
 }
-
-const char *
-inet_ntop(int af, const void *addr, char *buf, socklen_t len)
-{
-       if (af == AF_INET6) return inet_ntop6(addr, buf, len);
-       if (af == AF_INET) return inet_ntop4(addr, buf, len);
-
-       errno = EAFNOSUPPORT;
-       return NULL;
-}
diff --git a/net/rcmdsh.3 b/net/rcmdsh.3
deleted file mode 100644 (file)
index 43e6a8d..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-.\"    $OpenBSD: rcmdsh.3,v 1.6 1999/07/05 04:41:00 aaron Exp $
-.\"
-.\" Copyright (c) 1983, 1991, 1993
-.\"    The Regents of the University of California.  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.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"    This product includes software developed by the University of
-.\"    California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
-.\"
-.\" $FreeBSD: src/lib/libc/net/rcmdsh.3,v 1.2 2001/11/09 15:19:25 ru Exp $
-.\"
-.Dd September 1, 1996
-.Dt RCMDSH 3
-.Os
-.Sh NAME
-.Nm rcmdsh
-.Nd return a stream to a remote command without superuser
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fo rcmdsh
-.Fa "char **ahost"
-.Fa "int inport"
-.Fa "const char *locuser"
-.Fa "const char *remuser"
-.Fa "const char *cmd"
-.Fa "const char *rshprog"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn rcmdsh
-function
-is used by normal users to execute a command on
-a remote machine using an authentication scheme based
-on reserved port numbers using
-.Xr rshd 8
-or the value of
-.Fa rshprog
-(if
-.No non- Ns Dv NULL ) .
-.Pp
-The
-.Fn rcmdsh
-function
-looks up the host
-.Fa *ahost
-using
-.Xr gethostbyname 3 ,
-returning \-1 if the host does not exist.
-Otherwise
-.Fa *ahost
-is set to the standard name of the host
-and a connection is established to a server
-residing at the well-known Internet port
-.Dq Li shell/tcp
-(or whatever port is used by
-.Fa rshprog ) .
-The parameter
-.Fa inport
-is ignored; it is only included to provide an interface similar to
-.Xr rcmd 3 .
-.Pp
-If the connection succeeds,
-a socket in the
-.Ux
-domain of type
-.Dv SOCK_STREAM
-is returned to the caller, and given to the remote
-command as stdin, stdout, and stderr.
-.Sh RETURN VALUES
-The
-.Fn rcmdsh
-function
-returns a valid socket descriptor on success.
-Otherwise, \-1 is returned
-and a diagnostic message is printed on the standard error.
-.Sh SEE ALSO
-.Xr rsh 1 ,
-.Xr socketpair 2 ,
-.Xr rcmd 3 ,
-.Xr rshd 8
-.Sh BUGS
-If
-.Xr rsh 1
-encounters an error, a file descriptor is still returned instead of \-1.
-.Sh HISTORY
-The
-.Fn rcmdsh
-function first appeared in
-.Ox 2.0 ,
-and made its way into
-.Fx 5.0 .
index da5ab00e400c21fe79e4fe7353f9a279d110c69b..e51d3995edfb4934a612d64ee73b7bae59a7bfea 100644 (file)
@@ -40,7 +40,6 @@
 #include <pthread.h>
 #include <string.h>
 #include "os/assumes.h"
-#include "gen/assumes.h"
 #include <os/debug_private.h>
 
 #define OSX_ASSUMES_LOG_REDIRECT_SECT_NAME "__osx_log_func"
@@ -383,34 +382,3 @@ _os_avoid_tail_call(void)
 {
        // no-op
 }
-
-#pragma mark Legacy
-void
-_osx_assumes_log(uint64_t code)
-{
-       _os_assumes_log(code);
-}
-
-char *
-_osx_assert_log(uint64_t code)
-{
-       return _os_assert_log_impl(code);
-}
-
-void
-_osx_assumes_log_ctx(osx_log_callout_t callout, void *ctx, uint64_t code)
-{
-       _os_assumes_log_ctx_impl(callout, ctx, code);
-}
-
-char *
-_osx_assert_log_ctx(osx_log_callout_t callout, void *ctx, uint64_t code)
-{
-       return _os_assert_log_ctx_impl(callout, ctx, code);
-}
-
-void
-_osx_avoid_tail_call(void)
-{
-       _os_avoid_tail_call();
-}
index c9189fa176f130307e25640bdc1bae35f8c45f9d..c120f4ec08f896bc8e17a4d703b71283ca0223c7 100644 (file)
@@ -122,7 +122,7 @@ typedef bool (*os_log_callout_t)(_SIMPLE_STRING asl_message, void *ctx, const ch
        __typeof__(e) _e = os_slowpath(e); \
        if (_e) { \
                if (os_constant(e)) { \
-                       __OS_COMPILETIME_ASSERT__(!e); \
+                       __OS_COMPILETIME_ASSERT__(!(e)); \
                } \
                _os_assumes_log((uint64_t)(uintptr_t)_e); \
                _os_avoid_tail_call(); \
@@ -165,7 +165,7 @@ typedef bool (*os_log_callout_t)(_SIMPLE_STRING asl_message, void *ctx, const ch
        __typeof__(e) _e = os_slowpath(e); \
        if (_e) { \
                if (os_constant(e)) { \
-                       __OS_COMPILETIME_ASSERT__(!e); \
+                       __OS_COMPILETIME_ASSERT__(!(e)); \
                } \
 \
                char *_fail_message = _os_assert_log((uint64_t)(uintptr_t)_e); \
@@ -203,7 +203,7 @@ typedef bool (*os_log_callout_t)(_SIMPLE_STRING asl_message, void *ctx, const ch
        __typeof__(e) _e = os_slowpath(e); \
        if (_e) { \
                if (os_constant(e)) { \
-                       __OS_COMPILETIME_ASSERT__(!e); \
+                       __OS_COMPILETIME_ASSERT__(!(e)); \
                } \
                _os_assumes_log_ctx((f), (ctx), (uintptr_t)_e); \
                _os_avoid_tail_call(); \
@@ -237,7 +237,7 @@ typedef bool (*os_log_callout_t)(_SIMPLE_STRING asl_message, void *ctx, const ch
        __typeof__(e) _e = os_slowpath(e); \
        if (_e) { \
                if (os_constant(e)) { \
-                       __OS_COMPILETIME_ASSERT__(!e); \
+                       __OS_COMPILETIME_ASSERT__(!(e)); \
                } \
 \
                char *_fail_message = _os_assert_log_ctx((f), (ctx), (uint64_t)(uintptr_t)_e); \
index 2a826b250145289a32d6363c9e89838b8bb9eafd..d38a9a20a56db65befac65e73c45868fa04fccd0 100644 (file)
@@ -254,7 +254,7 @@ static __attribute__((always_inline))
 void
 _os_debug_logv(int level, const char *msg, va_list ap)
 {
-       if (os_slowpath(os_debug_log_globals()->errors_only) && level > LOG_ERR) {
+       if (os_slowpath((bool)os_debug_log_globals()->errors_only) && level > LOG_ERR) {
                // more important = lower integer
                return;
        }
@@ -274,7 +274,7 @@ _os_debug_logv(int level, const char *msg, va_list ap)
        __OS_COMPILETIME_ASSERT__(pfxlen >= timelen);
 
        if (os_fastpath(len > pfxlen)) {
-               if (os_slowpath(os_debug_log_globals()->prepend_timestamp)) {
+               if (os_slowpath((bool)os_debug_log_globals()->prepend_timestamp)) {
                        char tmp = buf[timelen];
                        snprintf(buf, timelen + 1, "%16llu", _os_debug_log_ticks_since_start());
                        buf[timelen] = tmp; // snprintf's null
index 5eb434ee920dc3e5d471466aecc55050886b77b8..d7174a3fd97c0afb15e849363420fd86004662c1 100644 (file)
 #include "secure.h"
 
 size_t
-__strlcat_chk (char *restrict dest, char *restrict src,
-              size_t len, size_t dstlen)
+__strlcat_chk(char *restrict dest, char *restrict src,
+    size_t len, size_t dstlen)
 {
   size_t initial_srclen;
   size_t initial_dstlen;
 
-  if (__builtin_expect (dstlen < len, 0))
+  if (__builtin_expect (dstlen < len, 0)) {
     __chk_fail_overflow ();
+  }
 
   initial_srclen = strlen(src);
   initial_dstlen = strnlen(dest, len);
@@ -45,7 +46,7 @@ __strlcat_chk (char *restrict dest, char *restrict src,
     __chk_overlap(dest, initial_srclen + initial_dstlen + 1, src, initial_srclen + 1);
     memcpy(dest+initial_dstlen, src, initial_srclen + 1);
   } else {
-    __chk_overlap(dest, initial_srclen + initial_dstlen + 1, src, len - initial_dstlen - 1);
+    __chk_overlap(dest, len, src, len - initial_dstlen - 1);
     memcpy(dest+initial_dstlen, src, len - initial_dstlen - 1);
     dest[len-1] = '\0';
   }
index 2d87d6603c4fe3b1f2489dde7de96685c0c3d550..1f515abd01e3424970031925cb8f3f61cfa9968a 100644 (file)
@@ -159,8 +159,10 @@ __sfp(int count)
 
        if (count) {
                if (__scounted >= __stream_max) {
-                       errno = EMFILE;
-                       return NULL;
+                       if (__scounted >= (__stream_max = sysconf(_SC_STREAM_MAX))){
+                               errno = EMFILE;
+                               return NULL;
+                       }
                }
                OSAtomicIncrement32(&__scounted);
        }
index 8faa92d4a134d3dcbe70624ac3b5fe4b340571d4..02ff26dfecbbe41652d2fd07ff0c307ea9caa9e0 100644 (file)
@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD: src/lib/libc/stdio/getdelim.c,v 1.3 2009/10/04 19:43:36 das Exp $");
 
 #include "namespace.h"
+#include <os/overflow.h>
 #include <sys/param.h>
 #include <errno.h>
 #include <limits.h>
@@ -96,9 +97,16 @@ static int
 sappend(char ** __restrict dstp, size_t * __restrict dstlenp,
        size_t * __restrict dstcapp, char * __restrict src, size_t srclen)
 {
+       size_t tmp;
+
+       /* avoid overflowing the result length */
+       if (os_add3_overflow(srclen, *dstlenp, 1, &tmp)) {
+               errno = EOVERFLOW;
+               return (-1);
+       }
 
        /* ensure room for srclen + dstlen + terminating NUL */
-       if (expandtofit(dstp, srclen + *dstlenp + 1, dstcapp))
+       if (expandtofit(dstp, tmp, dstcapp))
                return (-1);
        memcpy(*dstp + *dstlenp, src, srclen);
        *dstlenp += srclen;
index f55ceef025a77c153c6f44d0fa0afde8895e8ead..d4072c63189e74570c9adcb7c04067d500482672 100644 (file)
@@ -9,7 +9,7 @@
 .\" 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.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)mktemp.3   8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdio/mktemp.3,v 1.22 2007/01/09 00:28:07 imp Exp $
 .\"
-.Dd February 11, 1998
+.Dd December 18, 2015
 .Dt MKTEMP 3
 .Os
 .Sh NAME
-.Nm mkdtemp ,
+.Nm mktemp ,
 .Nm mkstemp ,
+.Nm mkdtemp ,
 .Nm mkstemps ,
-.Nm mktemp
+.Nm mkostemp ,
+.Nm mkostemps
 .Nd make temporary file name (unique)
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
 .In unistd.h
 .Ft char *
+.Fo mktemp
+.Fa "char *template"
+.Fc
+.Ft int
+.Fo mkstemp
+.Fa "char *template"
+.Fc
+.Ft char *
 .Fo mkdtemp
 .Fa "char *template"
 .Fc
 .Fa "char *template"
 .Fa "int suffixlen"
 .Fc
-.In stdlib.h
 .Ft int
-.Fo mkstemp
+.Fo mkostemp
 .Fa "char *template"
+.Fa "int oflags"
 .Fc
-.Ft char *
-.Fo mktemp
+.Ft int
+.Fo mkostemps
 .Fa "char *template"
+.Fa "int suffixlen"
+.Fa "int oflags"
 .Fc
 .Sh DESCRIPTION
 The
@@ -97,22 +108,45 @@ This avoids the race between testing for a file's existence and opening it
 for use.
 .Pp
 The
+.Fn mkdtemp
+function makes the same replacement to the template as in
+.Fn mktemp
+and creates the template directory, mode 0700.
+.Pp
+The
+.Fn mkostemp
+function
+is like
+.Fn mkstemp
+but allows specifying additional
+.Xr open 2
+flags (defined in
+.In fcntl.h ) .
+The permitted flags are
+.Dv O_APPEND ,
+.Dv O_SHLOCK ,
+.Dv O_EXLOCK
+and
+.Dv O_CLOEXEC .
+.Pp
+The
 .Fn mkstemps
-function acts the same as
-.Fn mkstemp ,
-except it permits a suffix to exist in the template.
+and
+.Fn mkostemps
+functions act the same as
+.Fn mkstemp
+and
+.Fn mkostemp
+respectively,
+except they permit a suffix to exist in the template.
 The template should be of the form
 .Pa /tmp/tmpXXXXXXsuffix .
 The
 .Fn mkstemps
-function
-is told the length of the suffix string.
-.Pp
-The
-.Fn mkdtemp
-function makes the same replacement to the template as in
-.Fn mktemp
-and creates the template directory, mode 0700.
+and
+.Fn mkostemps
+functions
+are told the length of the suffix string.
 .Sh RETURN VALUES
 The
 .Fn mktemp
@@ -122,9 +156,11 @@ functions return a pointer to the template on success and
 .Dv NULL
 on failure.
 The
-.Fn mkstemp
-and
+.Fn mkstemp ,
+.Fn mkostemp ,
 .Fn mkstemps
+and
+.Fn mkostemps
 functions
 return \-1 if no suitable file could be created.
 If either call fails an error code is placed in the global variable
@@ -132,7 +168,9 @@ If either call fails an error code is placed in the global variable
 .Sh ERRORS
 The
 .Fn mkstemp ,
-.Fn mkstemps
+.Fn mkostemp ,
+.Fn mkstemps ,
+.Fn mkostemps ,
 and
 .Fn mkdtemp
 functions
@@ -145,8 +183,25 @@ The pathname portion of the template is not an existing directory.
 .El
 .Pp
 The
+.Fn mkostemp
+and
+.Fn mkostemps
+functions
+may also set
+.Va errno
+to the following value:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa oflags
+argument is invalid.
+.El
+.Pp
+The
 .Fn mkstemp ,
+.Fn mkostemp ,
 .Fn mkstemps ,
+.Fn mkostemps 
 and
 .Fn mkdtemp
 functions
@@ -157,9 +212,11 @@ to any value specified by the
 function.
 .Pp
 The
-.Fn mkstemp
-and
+.Fn mkstemp ,
+.Fn mkostemp ,
 .Fn mkstemps
+and
+.Fn mkostemps 
 functions
 may also set
 .Va errno
@@ -180,7 +237,7 @@ A common problem that results in a core dump is that the programmer
 passes in a read-only string to
 .Fn mktemp ,
 .Fn mkstemp ,
-.Fn mkstemps ,
+.Fn mkstemps
 or
 .Fn mkdtemp .
 This is common with programs that were developed before
@@ -193,12 +250,6 @@ with an argument of
 will result in a core dump due to
 .Fn mkstemp
 attempting to modify the string constant that was given.
-If the program in question makes heavy use of that type
-of function call, you do have the option of compiling the program
-so that it will store string constants in a writable segment of memory.
-See
-.Xr gcc 1
-for more information.
 .Sh LEGACY SYNOPSIS
 .Fd #include <unistd.h>
 .Pp
@@ -212,6 +263,25 @@ is necessary and sufficient for all functions.
 .Xr open 2 ,
 .Xr stat 2 ,
 .Xr compat 5
+.Sh STANDARDS
+The
+.Fn mkstemp
+and
+.Fn mkdtemp
+functions are expected to conform to
+.St -p1003.1-2008 .
+The
+.Fn mktemp
+function is expected to conform to
+.St -p1003.1-2001
+and is not specified by
+.St -p1003.1-2008 .
+The
+.Fn mkostemp ,
+.Fn mkstemps
+and
+.Fn mkostemps
+functions do not conform to any standard.
 .Sh HISTORY
 A
 .Fn mktemp
@@ -233,6 +303,11 @@ function first appeared in
 .Ox 2.4 ,
 and later in
 .Fx 3.4 .
+The
+.Fn mkostemp
+and
+.Fn mkostemps
+functions appeared in OS X 10.12.
 .Sh BUGS
 This family of functions produces filenames which can be guessed,
 though the risk is minimized when large numbers of
@@ -249,6 +324,8 @@ and opening it for use
 particularly dangerous from a security perspective.
 Whenever it is possible,
 .Fn mkstemp
+or
+.Fn mkostemp
 should be used instead, since it does not have the race condition.
 If
 .Fn mkstemp
index 30dc90113d88f0ab8a517745aaeebacfd27dc7cd..08b0aec4f0b11fdef236927d496c04e9f704f81a 100644 (file)
@@ -10,7 +10,7 @@
  * 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.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -31,7 +31,6 @@
 static char sccsid[] = "@(#)mktemp.c   8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/mktemp.c,v 1.32 2010/02/28 13:31:29 jh Exp $");
 
 #include "namespace.h"
 #include <sys/param.h>
@@ -45,62 +44,116 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/mktemp.c,v 1.32 2010/02/28 13:31:29 jh Ex
 #include <unistd.h>
 #include "un-namespace.h"
 
+#define ALLOWED_MKOSTEMP_FLAGS (O_APPEND | O_SHLOCK | O_EXLOCK | O_CLOEXEC)
+
 char *_mktemp(char *);
 
-static int _gettemp(char *, int *, int, int);
+typedef enum {
+       FTPP_DONE, FTPP_TRY_NEXT, FTPP_ERROR
+} find_temp_path_progress_t;
+
+/* A contract for actions that find_temp_path performs for every path from
+ * the template.
+ *
+ * If the desired path was found, set result and return FTPP_DONE.
+ * If an IO/FS error ocurred, set errno and return FTPP_ERROR.
+ * Otherwise return FTPP_TRY_NEXT.
+ */
+typedef find_temp_path_progress_t (*find_temp_path_action_t)(
+               char *path, void *ctx, void *result);
+
+static int find_temp_path(char *path, int slen, bool stat_base_dir,
+               find_temp_path_action_t action, void *action_ctx, void *action_result);
+
+static find_temp_path_progress_t _mkostemps_action(
+               char *path, void *ctx, void *result);
+static find_temp_path_progress_t _mktemp_action(
+               char *path, void *ctx, void *result);
+static find_temp_path_progress_t _mkdtemp_action(
+               char *path, void *ctx, void *result);
+static find_temp_path_progress_t _mkstemp_dprotected_np_action(
+               char *path, void *ctx, void *result);
 
 static const char padchar[] =
 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
 int
-mkstemps(path, slen)
-       char *path;
-       int slen;
+mkostemps(char *path, int slen, int oflags)
+{
+       int fd;
+       if (oflags & ~ALLOWED_MKOSTEMP_FLAGS) {
+               errno = EINVAL;
+               return -1;
+       }
+       return (find_temp_path(path, slen, TRUE, _mkostemps_action, &oflags, &fd) ? fd : -1);
+}
+
+int
+mkstemps(char *path, int slen)
 {
        int fd;
 
-       return (_gettemp(path, &fd, 0, slen) ? fd : -1);
+       return (find_temp_path(path, slen, TRUE, _mkostemps_action, NULL, &fd) ? fd : -1);
 }
 
 int
-mkstemp(path)
-       char *path;
+mkostemp(char *path, int oflags)
+{
+       int fd;
+       if (oflags & ~ALLOWED_MKOSTEMP_FLAGS) {
+               errno = EINVAL;
+               return -1;
+       }
+       return (find_temp_path(path, 0, TRUE, _mkostemps_action, &oflags, &fd) ? fd : -1);
+}
+
+int
+mkstemp(char *path)
 {
        int fd;
 
-       return (_gettemp(path, &fd, 0, 0) ? fd : -1);
+       return (find_temp_path(path, 0, TRUE, _mkostemps_action, NULL, &fd) ? fd : -1);
 }
 
 char *
-mkdtemp(path)
-       char *path;
+mkdtemp(char *path)
 {
-       return (_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL);
+       return (find_temp_path(path, 0, TRUE, _mkdtemp_action, NULL, NULL) ?
+                       path : (char *)NULL);
 }
 
 char *
-_mktemp(path)
-       char *path;
+_mktemp(char *path)
 {
-       return (_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL);
+       return (find_temp_path(path, 0, FALSE, _mktemp_action, NULL, NULL) ?
+                       path : (char *)NULL);
 }
 
 __warn_references(mktemp,
     "warning: mktemp() possibly used unsafely; consider using mkstemp()");
 
 char *
-mktemp(path)
-       char *path;
+mktemp(char *path)
 {
        return (_mktemp(path));
 }
 
+int
+mkstemp_dprotected_np(char *path, int class, int dpflags)
+{
+       int fd;
+       int ctx[2] = { class, dpflags };
+
+       return (find_temp_path(path, 0, TRUE, _mkstemp_dprotected_np_action, &ctx, &fd) ? fd : -1);
+}
+
+/* For every path matching a given template, invoke an action. Depending on
+ * the progress reported by action, stops or tries the next path.
+ * Returns 1 if succeeds, 0 and sets errno if fails.
+ */
 static int
-_gettemp(path, doopen, domkdir, slen)
-       char *path;
-       int *doopen;
-       int domkdir;
-       int slen;
+find_temp_path(char *path, int slen, bool stat_base_dir,
+               find_temp_path_action_t action, void *action_ctx, void *action_result)
 {
        char *start, *trv, *suffp, *carryp;
        char *pad;
@@ -109,7 +162,7 @@ _gettemp(path, doopen, domkdir, slen)
        uint32_t rand;
        char carrybuf[MAXPATHLEN];
 
-       if ((doopen != NULL && domkdir) || slen < 0) {
+       if (slen < 0) {
                errno = EINVAL;
                return (0);
        }
@@ -141,7 +194,7 @@ _gettemp(path, doopen, domkdir, slen)
        /*
         * check the target directory.
         */
-       if (doopen != NULL || domkdir) {
+       if (stat_base_dir) {
                for (; trv > path; --trv) {
                        if (*trv == '/') {
                                *trv = '\0';
@@ -159,25 +212,23 @@ _gettemp(path, doopen, domkdir, slen)
        }
 
        for (;;) {
-               if (doopen) {
-                       if ((*doopen =
-                           _open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
-                               return (1);
-                       if (errno != EEXIST)
-                               return (0);
-               } else if (domkdir) {
-                       if (mkdir(path, 0700) == 0)
-                               return (1);
-                       if (errno != EEXIST)
-                               return (0);
-               } else if (lstat(path, &sbuf))
-                       return (errno == ENOENT);
+               switch (action(path, action_ctx, action_result)) {
+               case FTPP_DONE:
+                       return (1);
+               case FTPP_ERROR:
+                       return (0); // errno must be set by the action
+               default:
+                       ; // FTPP_TRY_NEXT, fall-through
+               }
 
                /* If we have a collision, cycle through the space of filenames */
                for (trv = start, carryp = carrybuf;;) {
                        /* have we tried all possible permutations? */
-                       if (trv == suffp)
-                               return (0); /* yes - exit with EEXIST */
+                       if (trv == suffp) {
+                               /* yes - exit with EEXIST */
+                               errno = EEXIST;
+                               return (0);
+                       }
                        pad = strchr(padchar, *trv);
                        if (pad == NULL) {
                                /* this should never happen */
@@ -199,3 +250,57 @@ _gettemp(path, doopen, domkdir, slen)
        }
        /*NOTREACHED*/
 }
+
+static find_temp_path_progress_t
+_mkostemps_action(char *path, void *ctx, void *result)
+{
+       int oflags = (ctx != NULL) ? *((int *) ctx) : 0;
+       int fd = _open(path, O_CREAT|O_EXCL|O_RDWR|oflags, 0600);
+       if (fd >= 0) {
+               *((int *) result) = fd;
+               return FTPP_DONE;
+       }
+       return (errno == EEXIST) ?
+                       FTPP_TRY_NEXT :
+                       FTPP_ERROR; // errno is set already
+}
+
+static find_temp_path_progress_t
+_mktemp_action(char *path, void *ctx __unused, void *result __unused)
+{
+       struct stat sbuf;
+       if (lstat(path, &sbuf)) {
+               // stat failed
+               return (errno == ENOENT) ?
+                               FTPP_DONE : // path is vacant, done
+                               FTPP_ERROR; // errno is set already
+       }
+       return FTPP_TRY_NEXT;
+}
+
+static find_temp_path_progress_t
+_mkdtemp_action(char *path, void *ctx __unused, void *result __unused)
+{
+       if (mkdir(path, 0700) == 0)
+               return FTPP_DONE;
+       return (errno == EEXIST) ?
+                       FTPP_TRY_NEXT :
+                       FTPP_ERROR; // errno is set already
+}
+
+static find_temp_path_progress_t
+_mkstemp_dprotected_np_action(char *path, void *ctx, void *result)
+{
+       int class = ((int *) ctx)[0];
+       int dpflags = ((int *) ctx)[1];
+       int fd = open_dprotected_np(path, O_CREAT|O_EXCL|O_RDWR, class, dpflags, 0600);
+       if (fd >= 0) {
+               *((int *) result) = fd;
+               return FTPP_DONE;
+       }
+       return (errno == EEXIST) ?
+                       FTPP_TRY_NEXT :
+                       FTPP_ERROR; // errno is set already
+}
+
+
index 3f1679ff9bdee050517626e24ab9f4496270f217..1efbca7cf5b926b47512fa9417ccc0f41e9727d0 100644 (file)
@@ -13,7 +13,7 @@
  * 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.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/tmpfile.c,v 1.10 2007/01/09 00:28:07 imp
 #include "un-namespace.h"
 
 FILE *
-tmpfile()
+tmpfile(void)
 {
        sigset_t set, oset;
        FILE *fp;
@@ -63,6 +63,9 @@ tmpfile()
        if (tmpdir == NULL)
                tmpdir = _PATH_TMP;
 
+       if (*tmpdir == '\0')
+               return (NULL);
+
        (void)asprintf(&buf, "%s%s%s", tmpdir,
            (tmpdir[strlen(tmpdir) - 1] == '/') ? "" : "/", TRAILER);
        if (buf == NULL)
index 72dd5cc8e3256a7c5bf2b77feea088a84c7538d9..701e2ab9934963351c898254aaae52efe112127b 100644 (file)
@@ -890,11 +890,11 @@ fp_common:
                        if (flags & LONGINT) {
                                wchar_t *wcp;
 
-                               if (convbuf != NULL)
-                                       free(convbuf);
-                               if ((wcp = GETARG(wchar_t *)) == NULL)
+                               free(convbuf);
+                               if ((wcp = GETARG(wchar_t *)) == NULL) {
+                                       convbuf = NULL;
                                        cp = "(null)";
-                               else {
+                               else {
                                        convbuf = __wcsconv(wcp, prec, loc);
                                        if (convbuf == NULL) {
                                                fp->_flags |= __SERR;
@@ -1390,8 +1390,7 @@ error:
        if (dtoaresult != NULL)
                freedtoa(dtoaresult);
 #endif
-       if (convbuf != NULL)
-               free(convbuf);
+       free(convbuf);
        if (__sferror(fp))
                ret = EOF;
        if ((argtable != NULL) && (argtable != statargtable))
index 31764a9110e116d0cdd1f0fe36a75adebeb410c7..f623fff3e4e7dcda7fb15685173fe8d3e2041ce6 100644 (file)
@@ -771,8 +771,7 @@ reswitch:   switch (ch) {
                                prec = dtoaend - dtoaresult;
                        if (expt == INT_MAX)
                                ox[1] = '\0';
-                       if (convbuf != NULL)
-                               free(convbuf);
+                       free(convbuf);
                        ndig = dtoaend - dtoaresult;
                        cp = convbuf = __mbsconv(dtoaresult, -1, loc);
                        freedtoa(dtoaresult);
@@ -815,8 +814,7 @@ reswitch:   switch (ch) {
 fp_begin:
                        if (prec < 0)
                                prec = DEFPREC;
-                       if (convbuf != NULL)
-                               free(convbuf);
+                       free(convbuf);
                        if (flags & LONGDBL) {
                                fparg.ldbl = GETARG(long double);
                                dtoaresult =
@@ -955,11 +953,11 @@ fp_common:
                        } else {
                                char *mbp;
 
-                               if (convbuf != NULL)
-                                       free(convbuf);
-                               if ((mbp = GETARG(char *)) == NULL)
+                               free(convbuf);
+                               if ((mbp = GETARG(char *)) == NULL) {
+                                       convbuf = NULL;
                                        cp = L"(null)";
-                               else {
+                               else {
                                        convbuf = __mbsconv(mbp, prec, loc);
                                        if (convbuf == NULL) {
                                                fp->_flags |= __SERR;
@@ -1256,7 +1254,7 @@ number:                   if ((dprec = prec) >= 0)
                break;                                                  \
        }                                                               \
        ret += vlen;                                                    \
-       PRINT(vstr, vlen);                                              \
+       PRINT((const CHAR *) vstr, vlen);                               \
        free(vstr);                                                     \
 } while (0)
 #else /* !V64TYPE */
@@ -1285,7 +1283,7 @@ number:                   if ((dprec = prec) >= 0)
                break;                                                  \
        }                                                               \
        ret += vlen;                                                    \
-       PRINT(vstr, vlen);                                              \
+       PRINT((const CHAR *) vstr, vlen);                               \
        free(vstr);                                                     \
 } while (0)
 #endif /* V64TYPE */
@@ -1455,8 +1453,7 @@ done:
        FLUSH();
 error:
        va_end(orgap);
-       if (convbuf != NULL)
-               free(convbuf);
+       free(convbuf);
        if (__sferror(fp))
                ret = EOF;
        if ((argtable != NULL) && (argtable != statargtable))
index d1c34986dce9048df5deb5aeff93477c2dde13a2..12a3bea71af3a2904f0d45264e73ac952c202ef1 100644 (file)
 .\"
 .\"     @(#)printf.3   8.1 (Berkeley) 6/4/93
 .\" FreeBSD: src/lib/libc/stdio/printf.3,v 1.47 2002/09/06 11:23:55 tjr Exp
-.\" $FreeBSD: src/lib/libc/stdio/wprintf.3,v 1.6 2007/01/09 00:28:08 imp Exp $
+.\" $FreeBSD$
 .\"
 .Dd July 5, 2003
 .Dt WPRINTF 3
 .Os
 .Sh NAME
-.Nm fwprintf ,
-.Nm swprintf ,
-.Nm vfwprintf ,
-.Nm vswprintf ,
-.Nm vwprintf ,
-.Nm wprintf
+.Nm wprintf , fwprintf , swprintf ,
+.Nm vwprintf , vfwprintf , vswprintf
 .Nd formatted wide character output conversion
 .Sh LIBRARY
 .Lb libc
 .In stdio.h
 .In wchar.h
 .Ft int
-.Fo fwprintf
-.Fa "FILE *restrict stream"
-.Fa "const wchar_t *restrict format"
-.Fa ...
-.Fc
+.Fn fwprintf "FILE * restrict stream" "const wchar_t * restrict format" ...
 .Ft int
-.Fo swprintf
-.Fa "wchar_t *restrict ws"
-.Fa "size_t n"
-.Fa "const wchar_t *restrict format"
-.Fa ...
-.Fc
+.Fn swprintf "wchar_t * restrict ws" "size_t n" "const wchar_t * restrict format" ...
 .Ft int
-.Fo wprintf
-.Fa "const wchar_t *restrict format"
-.Fa ...
-.Fc
+.Fn wprintf "const wchar_t * restrict format" ...
 .In stdarg.h
-.In stdio.h
-.In wchar.h
 .Ft int
-.Fo vfwprintf
-.Fa "FILE *restrict stream"
-.Fa "const wchar_t *restrict format"
-.Fa "va_list arg"
-.Fc
+.Fn vfwprintf "FILE * restrict stream" "const wchar_t * restrict" "va_list ap"
 .Ft int
-.Fo vswprintf
-.Fa "wchar_t *restrict ws"
-.Fa "size_t n"
-.Fa "const wchar_t *restrict format"
-.Fa "va_list arg"
-.Fc
+.Fn vswprintf "wchar_t * restrict ws" "size_t n" "const wchar_t *restrict format" "va_list ap"
 .Ft int
-.Fo vwprintf
-.Fa "const wchar_t *restrict format"
-.Fa "va_list arg"
-.Fc
+.Fn vwprintf "const wchar_t * restrict format" "va_list ap"
 .Sh DESCRIPTION
 The
 .Fn wprintf
 family of functions produces output according to a
-.Fa format ,
+.Fa format
 as described below.
 The
 .Fn wprintf
@@ -135,9 +105,18 @@ The
 .Fn swprintf
 and
 .Fn vswprintf
-functions will fail if
+functions return the number of characters written (not including the terminating
+null wide character).
+These functions will fail (returning a negative value and setting
+.Va errno
+appropriately) if
 .Fa n
-or more wide characters were requested to be written,
+or more wide characters were requested to be written.
+.Pp
+The other functions return the number of wide characters printed on success, or
+a negative value on faiure, setting
+.Va errno
+to indicate the error.
 .Pp
 The format string is composed of zero or more directives:
 ordinary
@@ -412,7 +391,7 @@ The
 .Vt double
 argument is rounded and converted in the style
 .Sm off
-.Oo \- Oc Ar d Li \&. Ar ddd Li e \\*[Pm] Ar dd
+.Oo \- Oc Ar d Li \&. Ar ddd Li e \(+- Ar dd
 .Sm on
 where there is one digit before the
 decimal-point character
@@ -488,7 +467,7 @@ The
 .Vt double
 argument is converted to hexadecimal notation in the style
 .Sm off
-.Oo \- Oc Li 0x Ar h Li \&. Ar hhhp Oo \\*[Pm] Oc Ar d ,
+.Oo \- Oc Li 0x Ar h Li \&. Ar hhhp Oo \(+- Oc Ar d ,
 .Sm on
 where the number of digits after the hexadecimal-point character
 is equal to the precision specification.
@@ -627,6 +606,9 @@ field is expanded to contain the conversion result.
 .Sh SECURITY CONSIDERATIONS
 Refer to
 .Xr printf 3 .
+.Sh ERRORS
+Refer to
+.Xr printf 3 .
 .Sh SEE ALSO
 .Xr btowc 3 ,
 .Xr fputws 3 ,
@@ -647,7 +629,7 @@ the
 .Fn fwprintf ,
 .Fn swprintf ,
 .Fn vwprintf ,
-.Fn vfwprintf ,
+.Fn vfwprintf
 and
 .Fn vswprintf
 functions
index 6bcaa26dccf6962ec41dab631b10ed3516d78602..ebe5d2850e5bb979d6b7eb93f7837e62c4a7d461 100644 (file)
 .\" 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.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"    This product includes software developed by the University of
-.\"    California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
@@ -34,9 +30,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)getenv.3   8.2 (Berkeley) 12/11/93
-.\" $FreeBSD: src/lib/libc/stdlib/getenv.3,v 1.16 2004/07/07 19:57:13 ru Exp $
+.\" $FreeBSD$
 .\"
-.Dd December 11, 1993
+.Dd June 20, 2007
 .Dt GETENV 3
 .Os
 .Sh NAME
 .Sh SYNOPSIS
 .In stdlib.h
 .Ft char *
-.Fo getenv
-.Fa "const char *name"
-.Fc
+.Fn getenv "const char *name"
 .Ft int
-.Fo putenv
-.Fa "char *string"
-.Fc
+.Fn setenv "const char *name" "const char *value" "int overwrite"
 .Ft int
-.Fo setenv
-.Fa "const char *name"
-.Fa "const char *value"
-.Fa "int overwrite"
-.Fc
+.Fn putenv "char *string"
 .Ft int
-.Fo unsetenv
-.Fa "const char *name"
-.Fc
+.Fn unsetenv "const char *name"
 .Sh DESCRIPTION
 These functions set, unset and fetch environment variables from the
 host
 .Em environment list .
-For compatibility with differing environment conventions,
-the given arguments
-.Fa name
-and
-.Fa value
-may be appended and prepended,
-respectively,
-with an equal sign
-.Dq Li \&= .
-The behavior is undefined when an equal sign appears at any other location in
-.Fa name .
 .Pp
 The
 .Fn getenv
 function obtains the current value of the environment variable,
 .Fa name .
+The application should not modify the string pointed
+to by the
+.Fn getenv
+function.
 .Pp
 The
 .Fn setenv
@@ -102,8 +81,7 @@ If the variable does exist, the argument
 .Fa overwrite
 is tested; if
 .Fa overwrite
-is
-zero, the
+is zero, the
 variable is not reset, otherwise it is reset
 to the given
 .Fa value .
@@ -153,13 +131,33 @@ is returned.
 .Bl -tag -width Er
 .It Bq Er EINVAL
 The function
+.Fn getenv ,
+.Fn setenv
+or
 .Fn unsetenv
-failed because
+failed because the
 .Fa name
-was not found in the environment list.
+is a
+.Dv NULL
+pointer, points to an empty string, or points to a string containing an
+.Dq Li \&=
+character.
+.Pp
+The function
+.Fn putenv
+failed because
+.Fa string
+is a
+.Dv NULL
+pointer or
+.Fa string
+is without an
+.Dq Li \&=
+character.
 .It Bq Er ENOMEM
 The function
-.Fn setenv
+.Fn setenv ,
+.Fn unsetenv
 or
 .Fn putenv
 failed because it was unable to allocate memory for the environment.
@@ -208,33 +206,38 @@ The
 .Fn getenv
 function conforms to
 .St -isoC .
+The
+.Fn setenv ,
+.Fn putenv
+and
+.Fn unsetenv
+functions conforms to
+.St -p1003.1-2001 .
+.Sh HISTORY
+The functions
+.Fn setenv
+and
+.Fn unsetenv
+appeared in
+.At v7 .
+The
+.Fn putenv
+function appeared in
+.Bx 4.3 Reno .
 .Sh BUGS
 Successive calls to
 .Fn setenv
-or
-.Fn putenv
-assigning a differently sized
+that assign a larger-sized
 .Fa value
-to the same
+than any previous value to the same
 .Fa name
 will result in a memory leak.
 The
 .Fx
-semantics for these functions
+semantics for this function
 (namely, that the contents of
 .Fa value
 are copied and that old values remain accessible indefinitely) make this
 bug unavoidable.
 Future versions may eliminate one or both of these
 semantic guarantees in order to fix the bug.
-.Sh HISTORY
-The functions
-.Fn setenv
-and
-.Fn unsetenv
-appeared in
-.At v7 .
-The
-.Fn putenv
-function appeared in
-.Bx 4.3 Reno .
index 47b60dfab1c9f9a56de038c3c16c14bf1998b1ba..bde7421158357a1012895caa2aff28dcfe2054ca 100644 (file)
@@ -33,15 +33,18 @@ static char sccsid[] = "@(#)getenv.c        8.1 (Berkeley) 6/4/93";
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/stdlib/getenv.c,v 1.8 2007/05/01 16:02:41 ache Exp $");
 
+#include <os/lock_private.h>
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
 #include <crt_externs.h>
 
-__private_extern__ char *__findenv(const char *, int *, char **);
+__private_extern__ char *__findenv_locked(const char *, int *, char **);
+__private_extern__ void __environ_lock(void);
+__private_extern__ void __environ_unlock(void);
 
 /*
- * __findenv --
+ * __findenv_locked --
  *     Returns pointer to value associated with name, if any, else NULL.
  *     Sets offset to be the offset of the name/value combination in the
  *     environmental array, for use by setenv(3) and unsetenv(3).
@@ -50,7 +53,7 @@ __private_extern__ char *__findenv(const char *, int *, char **);
  *     This routine *should* be a static; don't use it.
  */
 __private_extern__ char *
-__findenv(name, offset, environ)
+__findenv_locked(name, offset, environ)
        const char *name;
        int *offset;
        char **environ;
@@ -76,6 +79,32 @@ __findenv(name, offset, environ)
        return (NULL);
 }
 
+static os_unfair_lock __environ_lock_obj = OS_UNFAIR_LOCK_INIT;
+__private_extern__ void
+__environ_lock(void)
+{
+#if TARGET_OS_IOS && !TARGET_OS_SIMULATOR
+       os_unfair_lock_lock_with_options_4Libc(
+                       &__environ_lock_obj, OS_UNFAIR_LOCK_DATA_SYNCHRONIZATION);
+#else // TARGET_OS_IOS && !TARGET_OS_SIMULATOR
+       os_unfair_lock_lock(&__environ_lock_obj);
+#endif // TARGET_OS_IOS && !TARGET_OS_SIMULATOR
+}
+__private_extern__ void
+__environ_unlock(void)
+{
+#if TARGET_OS_IOS && !TARGET_OS_SIMULATOR
+       os_unfair_lock_unlock_4Libc(&__environ_lock_obj);
+#else // TARGET_OS_IOS && !TARGET_OS_SIMULATOR
+       os_unfair_lock_unlock(&__environ_lock_obj);
+#endif // TARGET_OS_IOS && !TARGET_OS_SIMULATOR
+}
+__private_extern__ void
+__environ_lock_fork_child(void)
+{
+       __environ_lock_obj = OS_UNFAIR_LOCK_INIT;
+}
+
 /*
  * _getenvp -- SPI using an arbitrary pointer to string array (the array must
  * have been created with malloc) and an env state, created by _allocenvstate().
@@ -84,9 +113,12 @@ __findenv(name, offset, environ)
 char *
 _getenvp(const char *name, char ***envp, void *state __unused)
 {
+       // envp is passed as an argument, so the lock is not protecting everything
        int offset;
-
-       return (__findenv(name, &offset, *envp));
+       __environ_lock();
+       char *result = (__findenv_locked(name, &offset, *envp));
+       __environ_unlock();
+       return result;
 }
 
 /*
@@ -98,6 +130,8 @@ getenv(name)
        const char *name;
 {
        int offset;
-
-       return (__findenv(name, &offset, *_NSGetEnviron()));
+       __environ_lock();
+       char *result = __findenv_locked(name, &offset, *_NSGetEnviron());
+       __environ_unlock();
+       return result;
 }
index fd33cfca7617e42b4959a34a61aff8bf3e576fff..69047162c5567b70d6a333d51d3caa019b175f9d 100644 (file)
@@ -29,9 +29,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)getopt.3   8.5 (Berkeley) 4/27/95
-.\" $FreeBSD: src/lib/libc/stdlib/getopt_long.3,v 1.13 2005/01/20 09:17:04 ru Exp $
+.\" $FreeBSD$
 .\"
-.Dd April 1, 2000
+.Dd December 25, 2011
 .Dt GETOPT_LONG 3
 .Os
 .Sh NAME
@@ -130,11 +130,11 @@ field should be one of:
 .Pp
 .Bl -tag -width ".Dv optional_argument" -offset indent -compact
 .It Dv no_argument
-no argument to the option is expect
+no argument to the option is expected
 .It Dv required_argument
 an argument to the option is required
 .It Dv optional_argument
-an argument to the option may be presented.
+an argument to the option may be presented
 .El
 .Pp
 If
@@ -239,7 +239,7 @@ static struct option longopts[] = {
 };
 
 bflag = 0;
-while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1)
+while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) {
        switch (ch) {
        case 'b':
                bflag = 1;
@@ -256,6 +256,7 @@ while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1)
                break;
        default:
                usage();
+       }
 }
 argc -= optind;
 argv += optind;
@@ -469,9 +470,9 @@ The
 .Fn getopt_long
 and
 .Fn getopt_long_only
-functions first appeared in
+functions first appeared in the
 .Tn GNU
-libiberty.
+libiberty library.
 The first
 .Bx
 implementation of
index a2c53be35158b4a4a00c8d754180888537368740..6458d6306ee66b21b3d999ac07a31f84b9440f6d 100644 (file)
@@ -46,8 +46,10 @@ extern struct owned_ptr *__env_owned;
 extern char **_saved_environ;
 #endif /* LEGACY_CRT1_ENVIRON */
 
-__private_extern__ int __init__env_owned(int);
-__private_extern__ int __setenv(const char *, const char *, int, int, char ***, struct owned_ptr *);
+__private_extern__ int __init__env_owned_locked(int);
+__private_extern__ int __setenv_locked(const char *, const char *, int, int, char ***, struct owned_ptr *);
+__private_extern__ void __environ_lock(void);
+__private_extern__ void __environ_unlock(void);
 
 #ifndef BUILDING_VARIANT
 /*
@@ -58,8 +60,15 @@ __private_extern__ int __setenv(const char *, const char *, int, int, char ***,
 int
 _putenvp(char *str, char ***envp, void *state)
 {
-       if (__init__env_owned(1)) return (-1);
-       return (__setenv(str, NULL, 1, 0, envp, (state ? (struct owned_ptr *)state : __env_owned)));
+       __environ_lock();
+       if (__init__env_owned_locked(1)) {
+               __environ_unlock();
+               return (-1);
+       }
+       int ret = __setenv_locked(str, NULL, 1, 0, envp,
+                       (state ? (struct owned_ptr *)state : __env_owned));
+       __environ_unlock();
+       return ret;
 }
 #endif /* BUILDING_VARIANT */
 
@@ -67,9 +76,8 @@ int
 putenv(str)
        char *str;
 {
-#ifdef LEGACY_CRT1_ENVIRON
        int ret;
-#endif /* LEGACY_CRT1_ENVIRON */
+       int copy;
 
 #if __DARWIN_UNIX03
        if (str == NULL || *str == 0 || index(str, '=') == NULL) {
@@ -80,21 +88,22 @@ putenv(str)
        if (index(str, '=') == NULL)
                return (-1);
 #endif /* __DARWIN_UNIX03 */
-       if (__init__env_owned(1)) return (-1);
-#ifdef LEGACY_CRT1_ENVIRON
-       ret =
-#else /* !LEGACY_CRT1_ENVIRON */
-       return
-#endif /* !LEGACY_CRT1_ENVIRON */
-           __setenv(str, NULL, 1,
+
 #if __DARWIN_UNIX03
-               0,
+       copy = 0;
 #else /* !__DARWIN_UNIX03 */
-               -1,
+       copy = -1;
 #endif /* __DARWIN_UNIX03 */
-               _NSGetEnviron(), __env_owned);
+
+       __environ_lock();
+       if (__init__env_owned_locked(1)) {
+               __environ_unlock();
+               return (-1);
+       }
+       ret = __setenv_locked(str, NULL, 1, copy, _NSGetEnviron(), __env_owned);
 #ifdef LEGACY_CRT1_ENVIRON
        _saved_environ = *_NSGetEnviron();
-       return ret;
 #endif /* LEGACY_CRT1_ENVIRON */
+       __environ_unlock();
+       return ret;
 }
index 7a12cea3e41e3d7241eea07d22c856d8ab5b469d..75a5a0db9fb66a13c30d61799141e3b652f26c6b 100644 (file)
@@ -42,12 +42,15 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/setenv.c,v 1.14 2007/05/01 16:02:41 ache
 #include <fcntl.h>
 
 struct owned_ptr;
-__private_extern__ char *__findenv(const char *, int *, char **);
-__private_extern__ int __setenv(const char *, const char *, int, int, char ***, struct owned_ptr *);
-__private_extern__ void __unsetenv(const char *, char **, struct owned_ptr *);
+__private_extern__ char *__findenv_locked(const char *, int *, char **);
+__private_extern__ int __setenv_locked(const char *, const char *, int, int, char ***, struct owned_ptr *);
+__private_extern__ void __unsetenv_locked(const char *, char **, struct owned_ptr *);
+
+__private_extern__ void __environ_lock(void);
+__private_extern__ void __environ_unlock(void);
 
 __private_extern__ struct owned_ptr *__env_owned;
-__private_extern__ int __init__env_owned(int);
+__private_extern__ int __init__env_owned_locked(int);
 
 /*
  * _cthread_init_routine used to be called from crt1.o to initialize threads.
@@ -205,7 +208,7 @@ _owned_ptr_search(struct owned_ptr * __restrict owned, const void * __restrict p
  * Initialize the process's __env_owned structure
  */
 __private_extern__ int
-__init__env_owned(int should_set_errno)
+__init__env_owned_locked(int should_set_errno)
 {
        int save;
 
@@ -229,7 +232,7 @@ __init__env_owned(int should_set_errno)
  * -1 - like 0, except we copy of the name=value string in name
  */
 __private_extern__ int
-__setenv(name, value, rewrite, copy, environp, owned)
+__setenv_locked(name, value, rewrite, copy, environp, owned)
        const char *name;
        const char *value;
        int rewrite, copy;
@@ -240,7 +243,7 @@ __setenv(name, value, rewrite, copy, environp, owned)
        int offset;
        int oindex;
 
-       if ((c = __findenv(name, &offset, *environp))) { /* find if already exists */
+       if ((c = __findenv_locked(name, &offset, *environp))) { /* find if already exists */
                char *e;
                if (!rewrite)
                        return (0);
@@ -326,13 +329,13 @@ __setenv(name, value, rewrite, copy, environp, owned)
 }
 
 __private_extern__ void
-__unsetenv(const char *name, char **environ, struct owned_ptr *owned)
+__unsetenv_locked(const char *name, char **environ, struct owned_ptr *owned)
 {
        char **p;
        int offset;
        int oindex;
 
-       while (__findenv(name, &offset, environ)) { /* if set multiple times */
+       while (__findenv_locked(name, &offset, environ)) { /* if set multiple times */
                /* if we malloc-ed it, free it first */
                if (_owned_ptr_search(owned, environ[offset], &oindex) == 0) {
                        _owned_ptr_delete(owned, oindex);
@@ -358,7 +361,7 @@ _allocenvstate(void)
  * _copyenv -- SPI that copies a NULL-tereminated char * array in a newly
  * allocated buffer, compatible with the other SPI env routines.  If env
  * is NULL, a char * array composed of a single NULL is returned.  NULL
- * is returned on error.  (This isn't needed anymore, as __setenv will
+ * is returned on error.  (This isn't needed anymore, as __setenv_locked will
  * automatically make a copy.)
  */
 char **
@@ -407,8 +410,15 @@ _deallocenvstate(void *state)
 int
 _setenvp(const char *name, const char *value, int rewrite, char ***envp, void *state)
 {
-       if (__init__env_owned(1)) return (-1);
-       return (__setenv(name, value, rewrite, 1, envp, (state ? (struct owned_ptr *)state : __env_owned)));
+       __environ_lock();
+       if (__init__env_owned_locked(1)) {
+               __environ_unlock();
+               return (-1);
+       }
+       int ret = __setenv_locked(name, value, rewrite, 1, envp,
+                       (state ? (struct owned_ptr *)state : __env_owned));
+       __environ_unlock();
+       return ret;
 }
 
 /*
@@ -420,8 +430,13 @@ _setenvp(const char *name, const char *value, int rewrite, char ***envp, void *s
 int
 _unsetenvp(const char *name, char ***envp, void *state)
 {
-       if (__init__env_owned(1)) return (-1);
-       __unsetenv(name, *envp, (state ? (struct owned_ptr *)state : __env_owned));
+       __environ_lock();
+       if (__init__env_owned_locked(1)) {
+               __environ_unlock();
+               return (-1);
+       }
+       __unsetenv_locked(name, *envp, (state ? (struct owned_ptr *)state : __env_owned));
+       __environ_unlock();
        return 0;
 }
 
@@ -438,9 +453,7 @@ setenv(name, value, rewrite)
        const char *value;
        int rewrite;
 {
-#ifdef LEGACY_CRT1_ENVIRON
        int ret;
-#endif /* LEGACY_CRT1_ENVIRON */
 
        /* no null ptr or empty str */
        if(name == NULL || *name == 0) {
@@ -456,16 +469,31 @@ setenv(name, value, rewrite)
        }
 #endif /* __DARWIN_UNIX03 */
 
-       if (*value == '=')                      /* no `=' in value */
-               ++value;
-       if (__init__env_owned(1)) return (-1);
+       __environ_lock();
+       if (__init__env_owned_locked(1)) {
+               __environ_unlock();
+               return (-1);
+       }
+       ret = __setenv_locked(name, value, rewrite, 1, _NSGetEnviron(), __env_owned);
 #ifdef LEGACY_CRT1_ENVIRON
-       ret = __setenv(name, value, rewrite, 1, _NSGetEnviron(), __env_owned);
        _saved_environ = *_NSGetEnviron();
-       return ret;
-#else /* !LEGACY_CRT1_ENVIRON */
-       return (__setenv(name, value, rewrite, 1, _NSGetEnviron(), __env_owned));
 #endif /* !LEGACY_CRT1_ENVIRON */
+       __environ_unlock();
+
+       return ret;
+}
+
+static inline __attribute__((always_inline)) int
+_unsetenv(const char *name, int should_set_errno)
+{
+       __environ_lock();
+       if (__init__env_owned_locked(should_set_errno)) {
+               __environ_unlock();
+               return (-1);
+       }
+       __unsetenv_locked(name, *_NSGetEnviron(), __env_owned);
+       __environ_unlock();
+       return 0;
 }
 
 /*
@@ -474,13 +502,8 @@ setenv(name, value, rewrite)
  */
 #if __DARWIN_UNIX03
 int
-#else /* !__DARWIN_UNIX03 */
-void
-#endif /* __DARWIN_UNIX03 */
-unsetenv(name)
-       const char *name;
+unsetenv(const char *name)
 {
-#if __DARWIN_UNIX03
        /* no null ptr or empty str */
        if(name == NULL || *name == 0) {
                errno = EINVAL;
@@ -492,15 +515,15 @@ unsetenv(name)
                errno = EINVAL;
                return (-1);
        }
-       if (__init__env_owned(1)) return (-1);
+       return _unsetenv(name, 1);
+}
 #else /* !__DARWIN_UNIX03 */
+void
+unsetenv(const char *name)
+{
        /* no null ptr or empty str */
        if(name == NULL || *name == 0)
                return;
-       if (__init__env_owned(0)) return;
-#endif /* __DARWIN_UNIX03 */
-       __unsetenv(name, *_NSGetEnviron(), __env_owned);
-#if __DARWIN_UNIX03
-       return 0;
-#endif /* __DARWIN_UNIX03 */
+       _unsetenv(name, 0);
 }
+#endif /* __DARWIN_UNIX03 */
index a9c25f98db7c9c121e47ab60b680221b15b35ab3..eb8c16c1781938df1516c097973a8f42bf564e0f 100644 (file)
@@ -23,9 +23,9 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/lib/libc/stdtime/strptime.3,v 1.24 2005/01/20 09:17:04 ru Exp $
+.\" $FreeBSD$
 .\" "
-.Dd January 4, 2003
+.Dd October 2, 2014
 .Dt STRPTIME 3
 .Os
 .Sh NAME
 .In time.h
 .Ft char *
 .Fo strptime
-.Fa "const char *restrict buf"
-.Fa "const char *restrict format"
-.Fa "struct tm *restrict tm"
+.Fa "const char * restrict buf"
+.Fa "const char * restrict format"
+.Fa "struct tm * restrict timeptr"
 .Fc
 .In time.h
 .In xlocale.h
 .Ft char *
-.Fo strptime_l
-.Fa "const char *restrict buf"
-.Fa "const char *restrict format"
-.Fa "struct tm *restrict tm"
-.Fa "locale_t loc"
-.Fc
+.Fn strptime_l "const char * restrict buf" "const char * restrict format" "struct tm * restrict timeptr" "locale_t loc"
 .Sh DESCRIPTION
 The
 .Fn strptime
 function parses the string in the buffer
-.Fa buf ,
+.Fa buf
 according to the string pointed to by
 .Fa format ,
 and fills in the elements of the structure pointed to by
-.Fa tm .
+.Fa timeptr .
 The resulting values will be relative to the local time zone.
 Thus, it can be considered the reverse operation of
 .Xr strftime 3 .
+The
+.Fn strptime_l
+function does the same as
+.Fn strptime ,
+but takes an explicit locale rather than using the current locale.
 .Pp
 The
 .Fa format
@@ -81,6 +81,11 @@ and
 are now interpreted as beginning at 1969 per POSIX requirements.
 Years 69-00 are interpreted in the 20th century (1969-2000), years
 01-68 in the 21st century (2001-2068).
+The
+.Fa \&%U
+and
+.Fa %W
+format specifiers accept any value within the range 00 to 53.
 .Pp
 If the
 .Fa format
@@ -88,7 +93,7 @@ string does not contain enough conversion specifications to completely
 specify the resulting
 .Vt struct tm ,
 the unspecified members of
-.Va tm
+.Va timeptr
 are left untouched.
 For example, if
 .Fa format
@@ -101,17 +106,9 @@ and
 .Va tm_min
 will be modified.
 If time relative to today is desired, initialize the
-.Fa tm
+.Fa timeptr
 structure with today's date before passing it to
 .Fn strptime .
-.Pp
-While the
-.Fn strptime
-function uses the current locale, the
-.Fn strptime_l
-function may be passed a locale directly. See
-.Xr xlocale 3
-for more information.
 .Sh RETURN VALUES
 Upon successful completion,
 .Fn strptime
@@ -122,6 +119,9 @@ that has not been required to satisfy the specified conversions in
 It returns
 .Dv NULL
 if one of the conversions failed.
+.Fn strptime_l
+returns the same values as
+.Fn strptime .
 .Sh LEGACY DESCRIPTION
 In legacy mode, the
 .Fa %Y
@@ -173,14 +173,6 @@ and 12PM
 is taken as noon.
 .Pp
 The
-.Fa %U
-and
-.Fa %W
-format specifiers accept any value within the range 00 to 53
-without validating against other values supplied (like month
-or day of the year, for example).
-.Pp
-The
 .Fa %Z
 format specifier only accepts time zone abbreviations of the local time zone,
 or the value "GMT".
index 2cac16184cf92bd22cd63fa425331b7fe07b2af3..2220c5dac2626479f3d2869f50360c1b2d6cd62d 100644 (file)
@@ -1,27 +1,13 @@
-/*
- * Powerdog Industries kindly requests feedback from anyone modifying
- * this function:
- *
- * Date: Thu, 05 Jun 1997 23:17:17 -0400  
- * From: Kevin Ruddy <kevin.ruddy@powerdog.com>
- * To: James FitzGibbon <james@nexis.net>
- * Subject: Re: Use of your strptime(3) code (fwd)
- * 
- * The reason for the "no mod" clause was so that modifications would
- * come back and we could integrate them and reissue so that a wider 
- * audience could use it (thereby spreading the wealth).  This has   
- * made it possible to get strptime to work on many operating systems.
- * I'm not sure why that's "plain unacceptable" to the FreeBSD team.
- * 
- * Anyway, you can change it to "with or without modification" as
- * you see fit.  Enjoy.                                          
- * 
- * Kevin Ruddy
- * Powerdog Industries, Inc.
- */
-/*
+/*-
+ * Copyright (c) 2014 Gary Mills
+ * Copyright 2011, Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 1994 Powerdog Industries.  All rights reserved.
  *
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *    notice, this list of conditions and the following disclaimer
  *    in the documentation and/or other materials provided with the
  *    distribution.
- * 3. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgement:
- *      This product includes software developed by Powerdog Industries.
- * 4. The name of Powerdog Industries may not be used to endorse or
- *    promote products derived from this software without specific prior
- *    written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY POWERDOG INDUSTRIES ``AS IS'' AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * 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.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Powerdog Industries.
  */
 
 #include <sys/cdefs.h>
@@ -59,7 +43,7 @@ static char copyright[] __unused =
 static char sccsid[] __unused = "@(#)strptime.c        0.1 (Powerdog) 94/03/27";
 #endif /* !defined NOID */
 #endif /* not lint */
-__FBSDID("$FreeBSD: src/lib/libc/stdtime/strptime.c,v 1.37 2009/09/02 04:56:30 ache Exp $");
+__FBSDID("$FreeBSD$");
 
 #include "xlocale_private.h"
 
@@ -71,86 +55,69 @@ __FBSDID("$FreeBSD: src/lib/libc/stdtime/strptime.c,v 1.37 2009/09/02 04:56:30 a
 #include <stdlib.h>
 #include <string.h>
 #include <pthread.h>
-#include <stdint.h>
-#include <limits.h>
 #include "un-namespace.h"
 #include "libc_private.h"
 #include "timelocal.h"
+#include "tzfile.h"
 
 time_t _mktime(struct tm *, const char *);
 
-#define asizeof(a)     (sizeof (a) / sizeof ((a)[0]))
+#define        asizeof(a)      (sizeof(a) / sizeof((a)[0]))
 
 enum {CONVERT_NONE, CONVERT_GMT, CONVERT_ZONE};
+enum week_kind { WEEK_U = 'U', WEEK_V = 'V', WEEK_W = 'W'};
+
+#define _strptime(b,f,t,c,l)   _strptime0(b,f,t,c,l,FLAG_NONE,0,WEEK_U)
 
-#define _strptime(b,f,t,c,l)   _strptime0(b,f,t,c,l,-1,0,-1,-1,'U')
+#define        FLAG_NONE       0x01
+#define        FLAG_YEAR       0x02
+#define        FLAG_MONTH      0x04
+#define        FLAG_YDAY       0x08
+#define        FLAG_MDAY       0x10
+#define        FLAG_WDAY       0x20
+#define FLAG_WEEK      0x40
+#define FLAG_CENTURY 0x100
+#define FLAG_YEAR_IN_CENTURY 0x200
 
-#define WEEK_U 'U'
-#define WEEK_V 'V'
-#define WEEK_W 'W'
+/*
+ * Calculate the week day of the first day of a year. Valid for
+ * the Gregorian calendar, which began Sept 14, 1752 in the UK
+ * and its colonies. Ref:
+ * http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week
+ */
 
 static int
-calcweeknum(struct tm *tm, int weeknum, int wday, int year, int kind)
+first_wday_of(int year)
 {
-       struct tm t;
-       int off;
-
-       bzero(&t, sizeof(t));
-       t.tm_mday = kind == WEEK_V ? 4 : 1;
-       t.tm_hour = 12; /* avoid any DST effects */
-       t.tm_year = year;
-       if (mktime(&t) == (time_t)-1) return 0;
-       off = t.tm_wday;
-
-       bzero(&t, sizeof(t));
-       if (kind != WEEK_U) {
-               off = (off + 6) % 7;
-               wday = (wday + 6) % 7;
-       }
-       if (kind == WEEK_V) {
-               t.tm_mday = 7 * weeknum + wday - off - 3;
-       } else {
-               if(off == 0) off = 7;
-               t.tm_mday = 7 * weeknum + wday - off + 1;
-       }
-       t.tm_hour = 12; /* avoid any DST effects */
-       t.tm_year = year;
-       if (mktime(&t) == (time_t)-1) return 0;
-
-       tm->tm_mday = t.tm_mday;
-       tm->tm_mon = t.tm_mon;
-       tm->tm_yday = t.tm_yday;
-       return 1;
+       return (((2 * (3 - (year / 100) % 4)) + (year % 100) +
+               ((year % 100) / 4) + (isleap(year) ? 6 : 0) + 1) % 7);
 }
 
 static char *
-_strptime0(const char *buf, const char *fmt, struct tm *tm, int *convp, locale_t loc, int year, int yday, int wday, int weeknum, int weekkind)
+_strptime0(const char *buf, const char *fmt, struct tm *tm, int *convp, locale_t locale, int flags, int week_number, enum week_kind week_kind)
 {
        char    c;
        const char *ptr;
-       int     i,
-               len;
+       int wday_offset;
+       int     i, len;
        int Ealternative, Oalternative;
-       struct lc_time_T *tptr = __get_current_time_locale(loc);
+       const struct lc_time_T *tptr = __get_current_time_locale(locale);
+       static int start_of_month[2][13] = {
+               {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
+               {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
+       };
 
        ptr = fmt;
        while (*ptr != 0) {
-               if (*buf == 0) {
-                       fmt = ptr;
-                       while (isspace_l((unsigned char)*ptr, loc)) {
-                               ptr++;
-                       }
-                       return ((*ptr)==0) ? (char *)fmt : 0; /* trailing whitespace is ok */
-               }
-
                c = *ptr++;
 
                if (c != '%') {
-                       if (isspace_l((unsigned char)c, loc))
-                               while (*buf != 0 && isspace_l((unsigned char)*buf, loc))
+                       if (isspace_l((unsigned char)c, locale))
+                               while (*buf != 0 && 
+                                      isspace_l((unsigned char)*buf, locale))
                                        buf++;
                        else if (c != *buf++)
-                               return 0;
+                               return (NULL);
                        continue;
                }
 
@@ -159,133 +126,145 @@ _strptime0(const char *buf, const char *fmt, struct tm *tm, int *convp, locale_t
 label:
                c = *ptr++;
                switch (c) {
-               case 0:
                case '%':
                        if (*buf++ != '%')
-                               return 0;
+                               return (NULL);
                        break;
 
                case '+':
-                       buf = _strptime(buf, tptr->date_fmt, tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
+                       buf = _strptime(buf, tptr->date_fmt, tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
+                       flags |= FLAG_WDAY | FLAG_MONTH | FLAG_MDAY | FLAG_YEAR;
                        break;
 
                case 'C':
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
                        /* XXX This will break for 3-digit centuries. */
                        len = 2;
-                       for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
+                       for (i = 0; len && *buf != 0 &&
+                            isdigit_l((unsigned char)*buf, locale); buf++) {
                                i *= 10;
                                i += *buf - '0';
                                len--;
                        }
                        if (i < 19)
-                               return 0;
+                               return (NULL);
+
+                       if (flags & FLAG_YEAR_IN_CENTURY) {
+                               tm->tm_year = i * 100 + (tm->tm_year % 100) - TM_YEAR_BASE;
+                               flags &= ~FLAG_YEAR_IN_CENTURY;
+                       } else {
+                               tm->tm_year = i * 100 - TM_YEAR_BASE;
+                               flags |= FLAG_YEAR;
+                               flags |= FLAG_CENTURY;
+                       }
 
-                       if (year != -1)
-                               tm->tm_year = (year % 100) + i * 100 - 1900;
-                       else
-                       tm->tm_year = i * 100 - 1900;
-                       year = tm->tm_year;
                        break;
 
                case 'c':
-                       buf = _strptime(buf, tptr->c_fmt, tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
+                       buf = _strptime(buf, tptr->c_fmt, tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
+                       flags |= FLAG_WDAY | FLAG_MONTH | FLAG_MDAY | FLAG_YEAR;
+                       flags &= ~(FLAG_CENTURY | FLAG_YEAR_IN_CENTURY);
                        break;
 
                case 'D':
-                       buf = _strptime(buf, "%m/%d/%y", tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
+                       buf = _strptime(buf, "%m/%d/%y", tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
+                       flags |= FLAG_MONTH | FLAG_MDAY | FLAG_YEAR;
+                       flags &= ~(FLAG_CENTURY | FLAG_YEAR_IN_CENTURY);
                        break;
 
                case 'E':
                        if (Ealternative || Oalternative)
                                break;
                        Ealternative++;
+                       if (*ptr == '%') return (NULL);
                        goto label;
 
                case 'O':
                        if (Ealternative || Oalternative)
                                break;
                        Oalternative++;
+                       if (*ptr == '%') return (NULL);
                        goto label;
 
                case 'F':
-                       buf = _strptime(buf, "%Y-%m-%d", tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
+                       buf = _strptime(buf, "%Y-%m-%d", tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
+                       flags |= FLAG_MONTH | FLAG_MDAY | FLAG_YEAR;
+                       flags &= ~(FLAG_CENTURY | FLAG_YEAR_IN_CENTURY);
                        break;
 
                case 'R':
-                       buf = _strptime(buf, "%H:%M", tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
+                       buf = _strptime(buf, "%H:%M", tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
                        break;
 
                case 'r':
-                       buf = _strptime(buf, tptr->ampm_fmt, tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
-                       break;
-
-               case 'n':
-               case 't':
-                       if (!isspace((unsigned char)*buf))
-                               return 0;
-                       while (isspace((unsigned char)*buf))
-                               buf++;
+                       buf = _strptime(buf, tptr->ampm_fmt, tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
                        break;
 
                case 'T':
-                       buf = _strptime(buf, "%H:%M:%S", tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
+                       buf = _strptime(buf, "%H:%M:%S", tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
                        break;
 
                case 'X':
-                       buf = _strptime(buf, tptr->X_fmt, tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
+                       buf = _strptime(buf, tptr->X_fmt, tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
                        break;
 
                case 'x':
-                       buf = _strptime(buf, tptr->x_fmt, tm, convp, loc);
-                       if (buf == 0)
-                               return 0;
+                       buf = _strptime(buf, tptr->x_fmt, tm, convp, locale);
+                       if (buf == NULL)
+                               return (NULL);
+                       flags |= FLAG_MONTH | FLAG_MDAY | FLAG_YEAR;
+                       flags &= ~(FLAG_CENTURY | FLAG_YEAR_IN_CENTURY);
                        break;
 
                case 'j':
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
                        len = 3;
-                       for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
+                       for (i = 0; len && *buf != 0 &&
+                            isdigit_l((unsigned char)*buf, locale); buf++){
                                i *= 10;
                                i += *buf - '0';
                                len--;
                        }
                        if (i < 1 || i > 366)
-                               return 0;
+                               return (NULL);
+
+                       tm->tm_yday = i - 1;
+                       flags |= FLAG_YDAY;
 
-                       tm->tm_yday = yday = i - 1;
                        break;
 
                case 'M':
                case 'S':
-                       if (*buf == 0 || isspace_l((unsigned char)*buf, loc))
+                       if (*buf == 0 ||
+                               isspace_l((unsigned char)*buf, locale))
                                break;
 
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
                        len = 2;
-                       for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
+                       for (i = 0; len && *buf != 0 &&
+                               isdigit_l((unsigned char)*buf, locale); buf++){
                                i *= 10;
                                i += *buf - '0';
                                len--;
@@ -293,17 +272,14 @@ label:
 
                        if (c == 'M') {
                                if (i > 59)
-                                       return 0;
+                                       return (NULL);
                                tm->tm_min = i;
                        } else {
                                if (i > 60)
-                                       return 0;
+                                       return (NULL);
                                tm->tm_sec = i;
                        }
 
-                       if (*buf != 0 && isspace_l((unsigned char)*buf, loc))
-                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, loc) && *ptr != '%')
-                                       ptr++;
                        break;
 
                case 'H':
@@ -318,26 +294,24 @@ label:
                         * XXX The %l specifier may gobble one too many
                         * digits if used incorrectly.
                         */
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
                        len = 2;
-                       for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
+                       for (i = 0; len && *buf != 0 &&
+                            isdigit_l((unsigned char)*buf, locale); buf++) {
                                i *= 10;
                                i += *buf - '0';
                                len--;
                        }
                        if (c == 'H' || c == 'k') {
                                if (i > 23)
-                                       return 0;
+                                       return (NULL);
                        } else if (i > 12)
-                               return 0;
+                               return (NULL);
 
                        tm->tm_hour = i;
 
-                       if (*buf != 0 && isspace_l((unsigned char)*buf, loc))
-                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, loc) && *ptr != '%')
-                                       ptr++;
                        break;
 
                case 'p':
@@ -346,9 +320,9 @@ label:
                         * specifiers.
                         */
                        len = strlen(tptr->am);
-                       if (strncasecmp_l(buf, tptr->am, len, loc) == 0) {
+                       if (strncasecmp_l(buf, tptr->am, len, locale) == 0) {
                                if (tm->tm_hour > 12)
-                                       return 0;
+                                       return (NULL);
                                if (tm->tm_hour == 12)
                                        tm->tm_hour = 0;
                                buf += len;
@@ -356,93 +330,92 @@ label:
                        }
 
                        len = strlen(tptr->pm);
-                       if (strncasecmp_l(buf, tptr->pm, len, loc) == 0) {
+                       if (strncasecmp_l(buf, tptr->pm, len, locale) == 0) {
                                if (tm->tm_hour > 12)
-                                       return 0;
+                                       return (NULL);
                                if (tm->tm_hour != 12)
                                        tm->tm_hour += 12;
                                buf += len;
                                break;
                        }
 
-                       return 0;
+                       return (NULL);
 
                case 'A':
                case 'a':
                        for (i = 0; i < asizeof(tptr->weekday); i++) {
                                len = strlen(tptr->weekday[i]);
                                if (strncasecmp_l(buf, tptr->weekday[i],
-                                               len, loc) == 0)
+                                               len, locale) == 0)
                                        break;
                                len = strlen(tptr->wday[i]);
                                if (strncasecmp_l(buf, tptr->wday[i],
-                                               len, loc) == 0)
+                                               len, locale) == 0)
                                        break;
                        }
                        if (i == asizeof(tptr->weekday))
-                               return 0;
+                               return (NULL);
 
-                       tm->tm_wday = wday = i;
                        buf += len;
+                       tm->tm_wday = i;
+                       flags |= FLAG_WDAY;
                        break;
 
-               case 'U':       /* Sunday week */
-               case 'V':       /* ISO 8601 week */
-               case 'W':       /* Monday week */
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+               case 'U':       /* Sunday week */
+               case 'V':       /* ISO 8601 week */
+               case 'W':       /* Monday week */
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
                        len = 2;
-                       for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
+                       for (i = 0; len && *buf != 0 &&
+                            isdigit_l((unsigned char)*buf, locale); buf++) {
                                i *= 10;
                                i += *buf - '0';
                                len--;
                        }
                        if (i > 53)
-                               return 0;
-                       if (c == 'V' && i < 1)
-                               return 0;
+                               return (NULL);
+                       if (c == WEEK_V && i < 1)
+                               return (NULL);
 
-                       weeknum = i;
-                       weekkind = c;
+                       week_number = i;
+                       week_kind = c;
+                       flags |= FLAG_WEEK;
 
-                       /* Calculate mon/mday/yday if we have enough data */
-                       if ((year != -1) && (wday != -1)) {
-                               if (!calcweeknum(tm, weeknum, wday, year, weekkind)) return 0;
-                       }
-                       if (*buf != 0 && isspace_l((unsigned char)*buf, loc))
-                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, loc) && *ptr != '%')
-                                       ptr++;
                        break;
 
-               case 'u':       /* [1,7] */
-               case 'w':       /* [0,6] */
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+               case 'u':       /* [1,7] */
+               case 'w':       /* [0,6] */
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
                        i = *buf - '0';
                        if (i > 6 + (c == 'u'))
-                               return 0;
+                               return (NULL);
                        if (i == 7)
                                i = 0;
-                       tm->tm_wday = wday = i;
-
-                       /* Calculate mon/mday/yday if we have enough data */
-                       if ((year != -1) && (weeknum != -1)) {
-                               if (!calcweeknum(tm, weeknum, wday, year, weekkind)) return 0;
-                       }
 
+                       tm->tm_wday = i;
+                       flags |= FLAG_WDAY;
                        buf++;
-                       if (*buf != 0 && isspace_l((unsigned char)*buf, loc))
-                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, loc) && *ptr != '%')
-                                       ptr++;
+
                        break;
 
-               case 'd':
                case 'e':
                        /*
-                        * The %e specifier is explicitly documented as not
-                        * being zero-padded but there is no harm in allowing
+                        * With %e format, our strftime(3) adds a blank space
+                        * before single digits.
+                        */
+                       if (*buf != 0 &&
+                           isspace_l((unsigned char)*buf, locale))
+                              buf++;
+                       /* FALLTHROUGH */
+               case 'd':
+                       /*
+                        * The %e specifier was once explicitly documented as
+                        * not being zero-padded but was later changed to
+                        * equivalent to %d.  There is no harm in allowing
                         * such padding.
                         *
                         * XXX The %e specifier may gobble one too many
@@ -450,28 +423,27 @@ label:
                         */
                        /* Leading space is ok if date is single digit */
                        len = 2;
-                       if (isspace_l((unsigned char)buf[0], loc) &&
-                           isdigit_l((unsigned char)buf[1], loc) &&
-                           !isdigit_l((unsigned char)buf[2], loc)) {
+                       if (isspace_l((unsigned char)buf[0], locale) &&
+                               isdigit_l((unsigned char)buf[1], locale) &&
+                               !isdigit_l((unsigned char)buf[2], locale)) {
                                len = 1;
                                buf++;
                        }
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
-                       for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
+                       for (i = 0; len && *buf != 0 &&
+                            isdigit_l((unsigned char)*buf, locale); buf++) {
                                i *= 10;
                                i += *buf - '0';
                                len--;
                        }
                        if (i > 31)
-                               return 0;
+                               return (NULL);
 
                        tm->tm_mday = i;
+                       flags |= FLAG_MDAY;
 
-                       if (*buf != 0 && isspace_l((unsigned char)*buf, loc))
-                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, loc) && *ptr != '%')
-                                       ptr++;
                        break;
 
                case 'B':
@@ -483,45 +455,54 @@ label:
                                                len = strlen(tptr->alt_month[i]);
                                                if (strncasecmp_l(buf,
                                                                tptr->alt_month[i],
-                                                               len, loc) == 0)
+                                                               len, locale) == 0)
                                                        break;
                                        }
                                } else {
                                        len = strlen(tptr->month[i]);
                                        if (strncasecmp_l(buf, tptr->month[i],
-                                                       len, loc) == 0)
+                                                       len, locale) == 0)
                                                break;
+                               }
+                       }
+                       /*
+                        * Try the abbreviated month name if the full name
+                        * wasn't found and Oalternative was not requested.
+                        */
+                       if (i == asizeof(tptr->month) && !Oalternative) {
+                               for (i = 0; i < asizeof(tptr->month); i++) {
                                        len = strlen(tptr->mon[i]);
                                        if (strncasecmp_l(buf, tptr->mon[i],
-                                                       len, loc) == 0)
+                                                       len, locale) == 0)
                                                break;
                                }
                        }
                        if (i == asizeof(tptr->month))
-                               return 0;
+                               return (NULL);
 
                        tm->tm_mon = i;
                        buf += len;
+                       flags |= FLAG_MONTH;
+
                        break;
 
                case 'm':
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
                        len = 2;
-                       for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
+                       for (i = 0; len && *buf != 0 &&
+                            isdigit_l((unsigned char)*buf, locale); buf++) {
                                i *= 10;
                                i += *buf - '0';
                                len--;
                        }
                        if (i < 1 || i > 12)
-                               return 0;
+                               return (NULL);
 
                        tm->tm_mon = i - 1;
+                       flags |= FLAG_MONTH;
 
-                       if (*buf != 0 && isspace_l((unsigned char)*buf, loc))
-                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, loc) && *ptr != '%')
-                                       ptr++;
                        break;
 
                case 's':
@@ -533,25 +514,30 @@ label:
 
                        sverrno = errno;
                        errno = 0;
-                       n = strtol_l(buf, &cp, 10, loc);
+                       n = strtol_l(buf, &cp, 10, locale);
                        if (errno == ERANGE || (long)(t = n) != n) {
                                errno = sverrno;
-                               return 0;
+                               return (NULL);
                        }
                        errno = sverrno;
                        buf = cp;
-                       gmtime_r(&t, tm);
+                       if (gmtime_r(&t, tm) == NULL)
+                               return (NULL);
                        *convp = CONVERT_GMT;
+                       flags |= FLAG_YDAY | FLAG_WDAY | FLAG_MONTH |
+                           FLAG_MDAY | FLAG_YEAR;
+                       flags &= ~(FLAG_CENTURY | FLAG_YEAR_IN_CENTURY);
                        }
                        break;
 
                case 'Y':
                case 'y':
-                       if (*buf == 0 || isspace_l((unsigned char)*buf, loc))
+                       if (*buf == 0 ||
+                           isspace_l((unsigned char)*buf, locale))
                                break;
 
-                       if (!isdigit_l((unsigned char)*buf, loc))
-                               return 0;
+                       if (!isdigit_l((unsigned char)*buf, locale))
+                               return (NULL);
 
 #if __DARWIN_UNIX03
                        if (c == 'Y') {
@@ -560,7 +546,7 @@ label:
                                int64_t i64 = 0;
                                int overflow = 0;
 
-                               for (len = 0; *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
+                               for (len = 0; *buf != 0 && isdigit_l((unsigned char)*buf, locale); buf++) {
                                        i64 *= 10;
                                        i64 += *buf - '0';
                                        if (++len <= 4) {
@@ -592,10 +578,10 @@ label:
 
                                        tm->tm_year = i64 - 1900;
 
-                                       if (*buf != 0 && isspace_l((unsigned char)*buf, loc))
-                                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, loc) && *ptr != '%')
+                                       if (*buf != 0 && isspace_l((unsigned char)*buf, locale))
+                                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, locale) && *ptr != '%')
                                                        ptr++;
-                                       ret = _strptime0(buf, ptr, tm, convp, loc, tm->tm_year, yday, wday, weeknum, weekkind);
+                                       ret = _strptime0(buf, ptr, tm, convp, locale, flags, week_number, week_kind);
                                        if (ret) return ret;
                                        /* Failed, so try 4-digit year */
                                        *tm = savetm;
@@ -607,99 +593,186 @@ label:
                        } else {
                                len = 2;
 #else /* !__DARWIN_UNIX03 */
-                       len = (c == 'Y') ? 4 : 2;
+                               len = (c == 'Y') ? 4 : 2;
 #endif /* __DARWIN_UNIX03 */
-                       for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, loc); buf++) {
-                               i *= 10;
-                               i += *buf - '0';
-                               len--;
-                       }
+                       
+                               for (i = 0; len && *buf != 0 &&
+                                        isdigit_l((unsigned char)*buf, locale); buf++) {
+                                       i *= 10;
+                                       i += *buf - '0';
+                                       len--;
+                               }
 #if __DARWIN_UNIX03
                        }
 #endif /* __DARWIN_UNIX03 */
-                       if (c == 'Y')
-                               i -= 1900;
-                       if (c == 'y' && i < 69)
-                               i += 100;
-                       if (i < 0)
-                               return 0;
 
-                       tm->tm_year = year = i;
+                       if (i < 0)
+                               return (NULL);
+
+                       if (c == 'Y'){
+                               i -= TM_YEAR_BASE;
+                       } else if (c == 'y' && flags & FLAG_CENTURY) {
+                               i = tm->tm_year + (i % 100);
+                               flags &= ~FLAG_CENTURY;
+                       } else if (c == 'y'){
+                               if (i < 69) i += 100;
+                               flags |= FLAG_YEAR_IN_CENTURY;
+                       }
 
-                       /* Calculate mon/mday/yday if we have enough data */
-                       if ((weeknum != -1) && (wday != -1)) {
-                               if (!calcweeknum(tm, weeknum, wday, year, weekkind)) return 0;
+                       tm->tm_year = i;
+                       flags |= FLAG_YEAR;
+                       if (c == 'Y'){
+                               flags &= ~(FLAG_CENTURY | FLAG_YEAR_IN_CENTURY);
                        }
 
-                       if (*buf != 0 && isspace_l((unsigned char)*buf, loc))
-                               while (*ptr != 0 && !isspace_l((unsigned char)*ptr, loc) && *ptr != '%')
-                                       ptr++;
                        break;
 
                case 'Z':
                        {
-                       const char *cp;
-                       size_t tzlen, len;
+                               const char *cp;
+                               size_t tzlen, len;
 
-                       for (cp = buf; *cp && isupper((unsigned char)*cp); ++cp) {/*empty*/}
-                       len = cp - buf;
-                       if (len == 3 && strncmp(buf, "GMT", 3) == 0) {
-                               *convp = CONVERT_GMT;
-                               buf += len;
-                               break;
-                       }
-                       tzset();
-                       tzlen = strlen(tzname[0]);
-                       if (len == tzlen && strncmp(buf, tzname[0], tzlen) == 0) {
-                               tm->tm_isdst = 0;
-                               buf += len;
-                               break;
-                       }
-                       tzlen = strlen(tzname[1]);
-                       if (len == tzlen && strncmp(buf, tzname[1], tzlen) == 0) {
-                               tm->tm_isdst = 1;
-                               buf += len;
-                               break;
-                       }
-                       return 0;
+                               for (cp = buf; *cp &&
+                                        isupper_l((unsigned char)*cp, locale); ++cp) {
+                                       /*empty*/
+                               }
+                               len = cp - buf;
+                               if (len == 3 && strncmp(buf, "GMT", 3) == 0) {
+                                       *convp = CONVERT_GMT;
+                                       buf += len;
+                                       break;
+                               }
+
+                               tzset();
+                               tzlen = strlen(tzname[0]);
+                               if (len == tzlen && strncmp(buf, tzname[0], tzlen) == 0) {
+                                       tm->tm_isdst = 0;
+                                       buf += len;
+                                       break;
+                               }
+                               tzlen = strlen(tzname[1]);
+                               if (len == tzlen && strncmp(buf, tzname[1], tzlen) == 0) {
+                                       tm->tm_isdst = 1;
+                                       buf += len;
+                                       break;
+                               }
+                               return (NULL);
                        }
 
                case 'z':
                        {
-                       int sign = 1;
-
-                       if (*buf != '+') {
-                               if (*buf == '-')
-                                       sign = -1;
-                               else
+                               char sign;
+                               int hr, min;
+                               if ((buf[0] != '+' && buf[0] != '-')
+                                       || !isdigit_l((unsigned char)buf[1], locale)
+                                       || !isdigit_l((unsigned char)buf[2], locale)
+                                       || !isdigit_l((unsigned char)buf[3], locale)
+                                       || !isdigit_l((unsigned char)buf[4], locale))
                                        return 0;
+                               sscanf(buf, "%c%2d%2d", &sign, &hr, &min);
+                               *convp = CONVERT_ZONE;
+                               tm->tm_gmtoff = 60 * (60 * hr + min);
+                               if (sign == '-')
+                                       tm->tm_gmtoff = -tm->tm_gmtoff;
+                               buf += 5;
                        }
+                       break;
 
-                       buf++;
-                       i = 0;
-                       for (len = 4; len > 0; len--) {
-                               if (isdigit_l((unsigned char)*buf, loc)) {
-                                       i *= 10;
-                                       i += *buf - '0';
-                                       buf++;
-                               } else
-                                       return 0;
+               case 'n':
+               case 't':
+                       if (!isspace((unsigned char)*buf))
+                               return 0;
+                       while (isspace_l((unsigned char)*buf, locale))
+                               buf++;
+                       break;
+
+               default:
+                       return (NULL);
+               }
+       }
+
+       if (!(flags & FLAG_YDAY) && (flags & FLAG_YEAR)) {
+               if ((flags & (FLAG_MONTH | FLAG_MDAY)) ==
+                   (FLAG_MONTH | FLAG_MDAY)) {
+                       tm->tm_yday = start_of_month[isleap(tm->tm_year +
+                           TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1);
+                       flags |= FLAG_YDAY;
+               } else if (flags & FLAG_WEEK){
+                       if (!(flags & FLAG_WDAY)) {
+                               tm->tm_wday = week_kind == WEEK_U ? TM_SUNDAY : TM_MONDAY;
+                               flags |= FLAG_WDAY;
                        }
 
-                       tm->tm_hour -= sign * (i / 100);
-                       tm->tm_min  -= sign * (i % 100);
-                       *convp = CONVERT_GMT;
+                       struct tm t = {0};
+                       t.tm_mday = week_kind == WEEK_V ? 4 : 1;
+                       t.tm_hour = 12; /* avoid any DST effects */
+                       t.tm_year = tm->tm_year;
+                       if (timegm(&t) == (time_t)-1) return 0;
+
+                       int off = t.tm_wday;
+                       int wday = tm->tm_wday;
+
+                       if (week_kind != WEEK_U) {
+                               off = (off + 6) % 7;
+                               wday = (wday + 6) % 7;
                        }
-                       break;
+
+                       if (week_kind == WEEK_V) {
+                               t.tm_mday = 7 * week_number + wday - off - 3;
+                       } else {
+                               if(off == 0) off = 7;
+                               t.tm_mday = 7 * week_number + wday - off + 1;
+                       }
+                       if (timegm(&t) == (time_t)-1) return 0;
+
+                       tm->tm_yday = t.tm_yday;
+
+                       flags |= FLAG_YDAY;
                }
        }
-       return (char *)buf;
+
+       if ((flags & (FLAG_YEAR | FLAG_YDAY)) == (FLAG_YEAR | FLAG_YDAY)) {
+               if (!(flags & FLAG_MONTH)) {
+                       i = 0;
+                       while (tm->tm_yday >=
+                           start_of_month[isleap(tm->tm_year +
+                           TM_YEAR_BASE)][i])
+                               i++;
+                       if (i > 12) {
+                               i = 1;
+                               tm->tm_yday -=
+                                   start_of_month[isleap(tm->tm_year +
+                                   TM_YEAR_BASE)][12];
+                               tm->tm_year++;
+                       }
+                       tm->tm_mon = i - 1;
+                       flags |= FLAG_MONTH;
+               }
+               if (!(flags & FLAG_MDAY)) {
+                       tm->tm_mday = tm->tm_yday -
+                           start_of_month[isleap(tm->tm_year + TM_YEAR_BASE)]
+                           [tm->tm_mon] + 1;
+                       flags |= FLAG_MDAY;
+               }
+               if (!(flags & FLAG_WDAY)) {
+                       i = 0;
+                       wday_offset = first_wday_of(tm->tm_year);
+                       while (i++ <= tm->tm_yday) {
+                               if (wday_offset++ >= 6)
+                                       wday_offset = 0;
+                       }
+                       tm->tm_wday = wday_offset;
+                       flags |= FLAG_WDAY;
+               }
+       }
+
+       return ((char *)buf);
 }
 
 
 char *
 strptime(const char * __restrict buf, const char * __restrict fmt,
-    struct tm * __restrict tm)
+                struct tm * __restrict tm)
 {
        return strptime_l(buf, fmt, tm, __current_locale());
 }
index 7e3bc79fff1c95eb224a5d5a9abf5b2aaef1cf75..e8e1ff571a8eb613edf64c6b502e64cb7efe28b3 100644 (file)
@@ -242,14 +242,17 @@ getdate(const char *str)
                        getdate_err = INVALID_DATE;
                        break;
                }
-               if(wday_set != UNDEFINED) {
+               if(wday_set != UNDEFINED &&
+                       (dateset != (TM_YEAR_SET | TM_MON_SET | TM_MDAY_SET))) {
+                   /*
+                    * We got back a week day, but not enough information to resolve it
+                    * to a specific day, so we need to push forward the time to the
+                    * correct wday.  <rdar://problem/27439823>
+                    */
                    int delta = wday_set - tm.tm_wday;
-                   if(delta && (dateset & TM_MDAY_SET)) {
-                       getdate_err = INVALID_DATE;
-                       break;
-                   }
-                   if(delta < 0)
+                   if(delta < 0) {
                        delta += 7;
+                   }
                    tm.tm_mday += delta;
                    if(mktime(&tm) == (time_t)-1) {
                        getdate_err = INVALID_DATE;
index f48f5d4c640ad24b2415b278651b7e6d501b4a91..892efbe5056f3330c2d3f5a260916ba92cab4af4 100644 (file)
@@ -13,7 +13,7 @@
 .\" 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.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)memcmp.3   8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/string/memcmp.3,v 1.10 2009/04/07 13:42:53 trasz Exp $
+.\" $FreeBSD$
 .\"
 .Dd June 4, 1993
 .Dt MEMCMP 3
@@ -65,12 +65,16 @@ The
 function
 returns zero if the two strings are identical,
 otherwise returns the difference between the first two differing bytes
-(treated as unsigned char values, so that
+(treated as
+.Vt "unsigned char"
+values, so that
 .Sq Li \e200
 is greater than
 .Sq Li \&\e0 ,
 for example).
 Zero-length strings are always identical.
+This behavior is not required by C and portable code should only depend on the
+sign of the returned value.
 .Sh SEE ALSO
 .Xr bcmp 3 ,
 .Xr strcasecmp 3 ,
diff --git a/string/FreeBSD/strcspn.3 b/string/FreeBSD/strcspn.3
deleted file mode 100644 (file)
index 938f80b..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-.\" Copyright (c) 1990, 1991, 1993
-.\"    The Regents of the University of California.  All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Chris Torek and the American National Standards Committee X3,
-.\" on Information Processing Systems.
-.\"
-.\" 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.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
-.\"
-.\"     @(#)strcspn.3  8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/string/strcspn.3,v 1.9 2007/01/09 00:28:12 imp Exp $
-.\"
-.Dd June 4, 1993
-.Dt STRCSPN 3
-.Os
-.Sh NAME
-.Nm strcspn
-.Nd span the complement of a string
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In string.h
-.Ft size_t
-.Fo strcspn
-.Fa "const char *s1"
-.Fa "const char *s2"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn strcspn
-function
-spans the initial part of the null-terminated string
-.Fa s1 ,
-as long as the characters from
-.Fa s1
-do not occur in string
-.Fa s2
-(it
-spans the
-.Em complement
-of
-.Fa s2 ) .
-In other words, it computes the string array index in
-.Fa s1
-of the first character of
-.Fa s1
-which is also in
-.Fa s2 ,
-else the index of the first null character.
-.Sh RETURN VALUES
-The
-.Fn strcspn
-function
-returns the number of characters spanned.
-.Sh SEE ALSO
-.Xr memchr 3 ,
-.Xr strchr 3 ,
-.Xr strpbrk 3 ,
-.Xr strrchr 3 ,
-.Xr strsep 3 ,
-.Xr strspn 3 ,
-.Xr strstr 3 ,
-.Xr strtok 3
-.Sh STANDARDS
-The
-.Fn strcspn
-function
-conforms to
-.St -isoC .
index 30db8c21dff57c44153d9cda2876de58f23b55e4..bfa50990a71d648cac4b4017fc06a3a86f8ce235 100644 (file)
@@ -13,7 +13,7 @@
 .\" 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.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)strpbrk.3  8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/string/strpbrk.3,v 1.9 2009/04/07 13:42:53 trasz Exp $
+.\" $FreeBSD$
 .\"
 .Dd June 4, 1993
 .Dt STRPBRK 3
 .Sh SYNOPSIS
 .In string.h
 .Ft char *
-.Fo strpbrk
-.Fa "const char *s1"
-.Fa "const char *s2"
-.Fc
+.Fn strpbrk "const char *s" "const char *charset"
 .Sh DESCRIPTION
 The
 .Fn strpbrk
 function
 locates in the null-terminated string
-.Fa s1
+.Fa s
 the first occurrence of any character in the string
-.Fa s2 ,
-returning a pointer to this character.
+.Fa charset
+and returns a pointer to this character.
 If no characters from
-.Fa s2
+.Fa charset
 occur anywhere in
-.Fa s1 ,
+.Fa s
 .Fn strpbrk
 returns NULL.
 .Sh SEE ALSO
index fcd199c1f1eacb069a8bacdb58879a50e113fe93..4a8e3f40ce59cc4111dfc9f7f087e839905b3201 100644 (file)
@@ -13,7 +13,7 @@
 .\" 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.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)strspn.3   8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/string/strspn.3,v 1.11 2009/04/07 13:42:53 trasz Exp $
+.\" $FreeBSD$
 .\"
-.Dd June 4, 1993
+.Dd May 24, 2014
 .Dt STRSPN 3
 .Os
 .Sh NAME
-.Nm strspn
+.Nm strspn ,
+.Nm strcspn
 .Nd span a string
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
 .In string.h
 .Ft size_t
-.Fo strspn
-.Fa "const char *s1"
-.Fa "const char *s2"
-.Fc
+.Fn strspn "const char *s" "const char *charset"
+.Ft size_t
+.Fn strcspn "const char *s" "const char *charset"
 .Sh DESCRIPTION
 The
 .Fn strspn
 function
 spans the initial part of the null-terminated string
-.Fa s1 ,
+.Fa s
 as long as the characters from
-.Fa s1
+.Fa s
 occur in the null-terminated string
-.Fa s2 .
-In other words, it computes the string array index in
-.Fa s1
+.Fa charset .
+In other words, it computes the string array index
 of the first character of
-.Fa s1
+.Fa s
 which is not in
-.Fa s2 ,
+.Fa charset ,
+else the index of the first null character.
+.Pp
+The
+.Fn strcspn
+function
+spans the initial part of the null-terminated string
+.Fa s
+as long as the characters from
+.Fa s
+.Sy do not
+occur in the null-terminated string
+.Fa charset
+.Po it spans the
+.Sy complement
+of
+.Fa charset
+.Pc .
+In other words, it computes the string array index
+of the first character of
+.Fa s
+which is also in
+.Fa charset ,
 else the index of the first null character.
 .Sh RETURN VALUES
 The
 .Fn strspn
-function
-returns the number of characters spanned.
+and
+.Fn strcspn
+functions
+return the number of characters spanned.
 .Sh SEE ALSO
 .Xr memchr 3 ,
 .Xr strchr 3 ,
-.Xr strcspn 3 ,
 .Xr strpbrk 3 ,
 .Xr strrchr 3 ,
 .Xr strsep 3 ,
@@ -82,6 +104,8 @@ returns the number of characters spanned.
 .Sh STANDARDS
 The
 .Fn strspn
-function
-conforms to
+and
+.Fn strcspn
+functions
+conform to
 .St -isoC .
index f02ab438c3203b3c9416a2d7f6ec0136c5101c19..a87044f39dfc8ab30ace8491eeae7aa4923d0700 100644 (file)
 .Sh SYNOPSIS
 .In string.h
 .Ft char *
-.Fn strstr "const char *big" "const char *little"
+.Fn strstr "const char *haystack" "const char *needle"
 .Ft char *
-.Fn strcasestr "const char *big" "const char *little"
+.Fn strcasestr "const char *haystack" "const char *needle"
 .Ft char *
-.Fn strnstr "const char *big" "const char *little" "size_t len"
+.Fn strnstr "const char *haystack" "const char *needle" "size_t len"
 .In string.h
 .In xlocale.h
 .Ft char *
-.Fn strcasestr_l "const char *big" "const char *little" "locale_t loc"
+.Fn strcasestr_l "const char *haystack" "const char *needle" "locale_t loc"
 .Sh DESCRIPTION
 The
 .Fn strstr
 function
 locates the first occurrence of the null-terminated string
-.Fa little
+.Fa needle
 in the null-terminated string
-.Fa big .
+.Fa haystack .
 .Pp
 The
 .Fn strcasestr
@@ -72,9 +72,9 @@ The
 .Fn strnstr
 function
 locates the first occurrence of the null-terminated string
-.Fa little
+.Fa needle
 in the string
-.Fa big ,
+.Fa haystack ,
 where not more than
 .Fa len
 characters are searched.
@@ -96,18 +96,18 @@ function may be passed a locale directly. See
 for more information.
 .Sh RETURN VALUES
 If
-.Fa little
+.Fa needle
 is an empty string,
-.Fa big
+.Fa haystack
 is returned;
 if
-.Fa little
+.Fa needle
 occurs nowhere in
-.Fa big ,
+.Fa haystack ,
 .Dv NULL
 is returned;
 otherwise a pointer to the first character of the first occurrence of
-.Fa little
+.Fa needle
 is returned.
 .Sh EXAMPLES
 The following sets the pointer
diff --git a/string/alias.list b/string/alias.list
deleted file mode 100644 (file)
index 651244e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-__platform_bzero _bzero
-__platform_memccpy _memccpy
-__platform_memchr _memchr
-__platform_memcmp _memcmp
-__platform_memcmp _bcmp
-__platform_memmove _memmove
-__platform_memmove _memcpy
-__platform_memset _memset
-__platform_memset_pattern16 _memset_pattern16
-__platform_memset_pattern4 _memset_pattern4
-__platform_memset_pattern8 _memset_pattern8
-__platform_strchr _strchr
-__platform_strcmp _strcmp
-__platform_strncmp _strncmp
index 73da105b14c6021e1d2793faf06ba579fff83e26..9311b0d9b5947e7f023b678f9fc9a508cfa70970 100644 (file)
@@ -28,6 +28,7 @@
 
 extern void _arc4_fork_child();
 extern void _init_clock_port(void);
+extern void __environ_lock_fork_child();
 
 void _libc_fork_child(void); // todo: private_extern?
 void
@@ -37,4 +38,5 @@ _libc_fork_child(void)
 
        _arc4_fork_child();
        _init_clock_port();
+       __environ_lock_fork_child();
 }
index faf185a114ec31b6ca97abebed1bd83aeb111e6c..3f95640c5ef0ab4113dadb8e1bc466e4ab15e589 100644 (file)
  * _libc_initializer() is called from libSystem_initializer()
  */
 
+#include <crt_externs.h>
 #include <limits.h>
 #include <stdint.h>
 #include <string.h>
+#include <stdlib.h>
 #include <machine/cpu_capabilities.h>
 #include <TargetConditionals.h>
+#include <_simple.h>
 
 #include "libc_private.h"
 
 extern void _program_vars_init(const struct ProgramVars *vars);
 extern void _libc_fork_init(const struct _libc_functions *funcs);
+extern void _arc4_init(void);
 extern void __atexit_init(void);
 extern void __confstr_init(const struct _libc_functions *funcs);
 extern void _init_clock_port(void);
diff --git a/tests/Libc.plist b/tests/Libc.plist
deleted file mode 100644 (file)
index 8f724e5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>BATSConfigVersion</key>
-       <string>0.1.0</string>
-       <key>Project</key>
-       <string>Libc</string>
-       <key>Tests</key>
-       <array>
-               <dict>
-                       <key>Arch</key>
-                       <string>platform-native</string>
-                       <key>AsRoot</key>
-                       <false/>
-                       <key>Command</key>
-                       <array>
-                               <string>/usr/local/bin/bsdtesttool</string>
-                               <string>Libc</string>
-                       </array>
-                       <key>TestName</key>
-                       <string>Libc</string>
-                       <key>WorkingDirectory</key>
-                       <string>/tmp</string>
-               </dict>
-       </array>
-</dict>
-</plist>
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644 (file)
index 0000000..4165350
--- /dev/null
@@ -0,0 +1,18 @@
+PROJECT := Libc
+TEST_DIR := tests/
+
+ifeq ($(DEVELOPER_DIR),)
+    DEVELOPER_DIR := $(shell xcode-select -p)
+endif
+
+include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common
+
+OTHER_CFLAGS := -DDARWINTEST -Weverything -Wno-vla -Wno-missing-field-initializers -Wno-padded -Wno-gnu-flexible-array-initializer --std=gnu11 -Wno-gnu-empty-initializer
+OTHER_LDFLAGS := -ldarwintest_utils
+
+nxheap: OTHER_CFLAGS += -Wno-cast-align
+strlcat: OTHER_CFLAGS += -Wno-pointer-arith
+psort: OTHER_CFLAGS += -Wno-cast-qual -Wno-sign-conversion
+net: OTHER_CFLAGS += -Wno-sign-conversion -Wno-cast-align -Wno-incompatible-pointer-types-discards-qualifiers -Wno-sign-compare
+
+include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets
diff --git a/tests/arc4random.c b/tests/arc4random.c
new file mode 100644 (file)
index 0000000..fb544fa
--- /dev/null
@@ -0,0 +1,131 @@
+/*-
+ * Copyright (c) 2011 David Schultz
+ * 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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 <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <math.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+#include <darwintest.h>
+#include <darwintest_utils.h>
+
+#define LEN (1024 * 32)
+static void * stress(void *ptr __unused)
+{
+       uint32_t value;
+       uint8_t buf[LEN + 1];
+       buf[LEN] = 0;
+       for (int i = 0; i < LEN; i++){
+               value = arc4random();
+               if (value % 100 == 0)
+                       arc4random_stir();
+               if ((value & 0x70) == 0)
+                       arc4random_uniform(value);
+               if ((value & 0x7) == 0)
+                       arc4random_buf(buf, (size_t)i);
+       }
+       T_ASSERT_EQ(buf[LEN], 0, NULL);
+
+       return NULL;
+}
+
+T_DECL(arc4random_stress, "arc4random() stress")
+{
+       const int ncpu = dt_ncpu();
+
+       pthread_t thr[ncpu];
+       for (int i = 0; i < ncpu; i++){
+               T_ASSERT_POSIX_ZERO(pthread_create(&thr[i], NULL, stress, NULL), NULL);
+       }
+       for (int i = 0; i < ncpu; i++){
+               T_ASSERT_POSIX_ZERO(pthread_join(thr[i], NULL), NULL);
+       }
+}
+
+/*
+ * BUFSIZE is the number of bytes of rc4 output to compare.  The probability
+ * that this test fails spuriously is 2**(-BUFSIZE * 8).
+ */
+#define        BUFSIZE         8
+
+T_DECL(arc4random_fork, "arc4random() shouldn't return the same sequence in child post-fork()")
+{
+       struct shared_page {
+               char parentbuf[BUFSIZE];
+               char childbuf[BUFSIZE];
+       } *page;
+       pid_t pid;
+       char c;
+
+       page = mmap(NULL, sizeof(struct shared_page), PROT_READ | PROT_WRITE,
+                   MAP_ANON | MAP_SHARED, -1, 0);
+       T_ASSERT_NE(page, MAP_FAILED, "mmap()");
+
+       arc4random_buf(&c, 1);
+
+       pid = fork();
+       if (pid < 0) {
+               T_ASSERT_FAIL("fork() failed");
+       } else if (pid == 0) {
+               /* child */
+               arc4random_buf(page->childbuf, BUFSIZE);
+               exit(0);
+       } else {
+               /* parent */
+               int status;
+               arc4random_buf(page->parentbuf, BUFSIZE);
+               T_ASSERT_EQ(wait(&status), pid, "wait() returns child pid");
+       }
+       T_EXPECT_NE(memcmp(page->parentbuf, page->childbuf, BUFSIZE), 0, "sequences are distinct");
+}
+
+#define  ARC4_EXPECTATION ((2u << 31)  - 1)/2
+#define  ITER 10000000
+#define  PROB_THRESH sqrt(6*log2(ITER)/(ITER*1.0))
+/* Simple randomness test using a chernoff bound
+ * If this fails with probability (1 - 2/(ITER)^{4})
+ *  arc4random is NOT a uniform distribution between
+ *  0 and 2**32 - 1. Note that this test does not guarantee
+ *  that arc4random. Is correct, just that it isn't terribly
+ *  wrong.
+ * */
+T_DECL(arc4random_stats, "ensure arc4random() is random")
+{
+       int i;
+       int total = 0;
+       for (i = 0; i < ITER; i++) {
+               total += arc4random() > ARC4_EXPECTATION;
+       }
+       double prob = total/(ITER*1.0);
+       T_EXPECT_LT(fabs(prob - 0.5), PROB_THRESH, "probability is within threshold");
+}
diff --git a/tests/clock.c b/tests/clock.c
new file mode 100644 (file)
index 0000000..9daa47f
--- /dev/null
@@ -0,0 +1,247 @@
+#include <time.h>
+#include <sys/time.h>
+#include <mach/mach_time.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <darwintest.h>
+
+static void burn_cpu(void){
+       static char *dummy_text = "Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the";
+
+       for (int i = 0; i < 100; i++){
+               char key[64]; char txt[64];
+               strncpy(txt, dummy_text, 64);
+               for (int j = 0; i < 64; i++){
+                       key[j] = rand() % 1;
+               }
+               setkey(key);
+               encrypt(txt, 0);
+               encrypt(txt, 1);
+       }
+}
+
+T_DECL(clock_gettime_realtime, "clock_gettime(CLOCK_REALTIME, tp)")
+{
+       struct timespec ts;
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_REALTIME, &ts), NULL);
+
+       struct timeval tv;
+       T_ASSERT_POSIX_ZERO(gettimeofday(&tv, NULL), NULL);
+
+       T_EXPECT_LE((unsigned long)tv.tv_sec - (unsigned long)ts.tv_sec, (unsigned long)1, 
+                               "gettimeofday() should return same as clock_gettime(CLOCK_REALTIME)");
+}
+
+T_DECL(clock_gettime_monotonic, "clock_gettime(CLOCK_MONOTONIC, tp)")
+{
+       struct timespec ts1, ts2;
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC, &ts1), NULL);
+
+       sleep(1);
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC, &ts2), NULL);
+
+       uint64_t nsec1 = (uint64_t)ts1.tv_sec * NSEC_PER_SEC + (uint64_t)ts1.tv_nsec;
+       uint64_t nsec2 = (uint64_t)ts2.tv_sec * NSEC_PER_SEC + (uint64_t)ts2.tv_nsec;
+       uint64_t nsec_diff = (uint64_t)llabs((int64_t)nsec2 - (int64_t)nsec1);
+
+       T_EXPECT_GE(nsec_diff, 100 * NSEC_PER_MSEC, "clock_gettime(CLOCK_MONOTONIC) should advance at least 100ms");
+       T_EXPECT_LE(nsec_diff, 10 * NSEC_PER_SEC, "clock_gettime(CLOCK_MONOTONIC) should advance no more than 10s");
+}
+T_DECL(clock_gettime_monotonic_raw, "clock_gettime(CLOCK_MONOTONIC_RAW, tp)")
+{
+       struct timespec ts1, ts2;
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC_RAW, &ts1), NULL);
+
+       sleep(1);
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC_RAW, &ts2), NULL);
+
+       uint64_t nsec1 = (uint64_t)ts1.tv_sec * NSEC_PER_SEC + (uint64_t)ts1.tv_nsec;
+       uint64_t nsec2 = (uint64_t)ts2.tv_sec * NSEC_PER_SEC + (uint64_t)ts2.tv_nsec;
+       uint64_t nsec_diff = (uint64_t)llabs((int64_t)nsec2 - (int64_t)nsec1);
+
+       T_EXPECT_GE(nsec_diff, 100 * NSEC_PER_MSEC, "clock_gettime(CLOCK_MONOTONIC_RAW) should advance at least 100ms");
+       T_EXPECT_LE(nsec_diff, 10 * NSEC_PER_SEC, "clock_gettime(CLOCK_MONOTONIC_RAW) should advance no more than 10s");
+}
+
+T_DECL(clock_gettime_uptime_raw, "clock_gettime(CLOCK_UPTIME_RAW, tp)")
+{
+       struct timespec ts1, ts2;
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_UPTIME_RAW, &ts1), NULL);
+
+       sleep(1);
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_UPTIME_RAW, &ts2), NULL);
+
+       uint64_t nsec1 = (uint64_t)ts1.tv_sec * NSEC_PER_SEC + (uint64_t)ts1.tv_nsec;
+       uint64_t nsec2 = (uint64_t)ts2.tv_sec * NSEC_PER_SEC + (uint64_t)ts2.tv_nsec;
+       uint64_t nsec_diff = (uint64_t)llabs((int64_t)nsec2 - (int64_t)nsec1);
+
+       T_EXPECT_GE(nsec_diff, 100 * NSEC_PER_MSEC, "clock_gettime(CLOCK_UPTIME_RAW) should advance at least 100ms");
+       T_EXPECT_LE(nsec_diff, 10 * NSEC_PER_SEC, "clock_gettime(CLOCK_UPTIME_RAW) should advance no more than 10s");
+}
+
+T_DECL(clock_gettime_cputime, "clock_gettime(CLOCK_*_CPUTIME_ID, tp)")
+{
+       struct timespec thread_ts1, thread_ts2;
+       struct timespec process_ts1, process_ts2;
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &process_ts1), NULL);
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &thread_ts1), NULL);
+
+       burn_cpu();
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &process_ts2), NULL);
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &thread_ts1), NULL);
+
+       uint64_t nsec1, nsec2, nsec_diff;
+
+       // CLOCK_PROCESS_CPUTIME_ID
+       nsec1 = (uint64_t)process_ts1.tv_sec * NSEC_PER_SEC + (uint64_t)process_ts1.tv_nsec;
+       nsec2 = (uint64_t)process_ts2.tv_sec * NSEC_PER_SEC + (uint64_t)process_ts2.tv_nsec;
+       nsec_diff = (uint64_t)llabs((int64_t)nsec2 - (int64_t)nsec1);
+       T_EXPECT_GE(nsec_diff, NSEC_PER_USEC, "clock_gettime(CLOCK_PROCESS_CPUTIME_ID) should advance at least 1us");
+       T_EXPECT_LE(nsec_diff, 10 * NSEC_PER_SEC, "clock_gettime(CLOCK_PROCESS_CPUTIME_ID) should advance no more than 10s");
+
+       // CLOCK_THREAD_CPUTIME_ID
+       nsec1 = (uint64_t)thread_ts1.tv_sec * NSEC_PER_SEC + (uint64_t)thread_ts1.tv_nsec;
+       nsec2 = (uint64_t)thread_ts2.tv_sec * NSEC_PER_SEC + (uint64_t)thread_ts2.tv_nsec;
+       nsec_diff = (uint64_t)llabs((int64_t)nsec2 - (int64_t)nsec1);
+       T_EXPECT_GE(nsec_diff, NSEC_PER_USEC, "clock_gettime(CLOCK_THREAD_CPUTIME_ID) should advance at least 1us");
+       T_EXPECT_LE(nsec_diff, 10 * NSEC_PER_SEC, "clock_gettime(CLOCK_THREAD_CPUTIME_ID) should advance no more than 10s");
+}
+
+T_DECL(clock_gettime_monotonic_comparison, "compare CLOCK_MONOTONIC to CLOCK_MONOTONIC_RAW")
+{
+       struct timespec ts1, ts2;
+       bool should_retry = true;
+
+retry:
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC, &ts1), NULL);
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC_RAW, &ts2), NULL);
+
+       uint64_t nsec1 = (uint64_t)ts1.tv_sec * NSEC_PER_SEC + (uint64_t)ts1.tv_nsec;
+       uint64_t nsec2 = (uint64_t)ts2.tv_sec * NSEC_PER_SEC + (uint64_t)ts2.tv_nsec;
+       uint64_t nsec_diff = (uint64_t)llabs((int64_t)nsec2 - (int64_t)nsec1);
+
+       if (should_retry && nsec_diff > nsec2/20){
+               should_retry = false;
+               goto retry;
+       }
+
+       T_EXPECT_LE(nsec_diff, nsec2/20, "CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW should be within 5%%");
+}
+
+T_DECL(clock_gettime_nsec_np, "clock_gettime_nsec_np()")
+{
+       struct timespec ts;
+       uint64_t nsec, ts_nsec, diff;
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_REALTIME, &ts), NULL);
+       T_WITH_ERRNO; T_ASSERT_NE((nsec = clock_gettime_nsec_np(CLOCK_REALTIME)), (uint64_t)0, NULL);
+       ts_nsec = (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec;
+       diff = (uint64_t)llabs((int64_t)nsec - (int64_t)ts_nsec);
+       T_EXPECT_LE(diff, 100 * NSEC_PER_MSEC, "CLOCK_REALTIME: clock_gettime() and clock_gettime_nsec_np() should be within 100ms");
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC, &ts), NULL);
+       T_WITH_ERRNO; T_ASSERT_NE((nsec = clock_gettime_nsec_np(CLOCK_MONOTONIC)), (uint64_t)0, NULL);
+       ts_nsec = (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec;
+       diff = (uint64_t)llabs((int64_t)nsec - (int64_t)ts_nsec);
+       T_EXPECT_LE(diff, 100 * NSEC_PER_MSEC, "CLOCK_MONOTONIC: clock_gettime() and clock_gettime_nsec_np() should be within 100ms");
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC_RAW, &ts), NULL);
+       T_WITH_ERRNO; T_ASSERT_NE((nsec = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)), (uint64_t)0, NULL);
+       ts_nsec = (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec;
+       diff = (uint64_t)llabs((int64_t)nsec - (int64_t)ts_nsec);
+       T_EXPECT_LE(diff, 100 * NSEC_PER_MSEC, "CLOCK_MONOTONIC_RAW: clock_gettime() and clock_gettime_nsec_np() should be within 100ms");
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_UPTIME_RAW, &ts), NULL);
+       T_WITH_ERRNO; T_ASSERT_NE((nsec = clock_gettime_nsec_np(CLOCK_UPTIME_RAW)), (uint64_t)0, NULL);
+       ts_nsec = (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec;
+       diff = (uint64_t)llabs((int64_t)nsec - (int64_t)ts_nsec);
+       T_EXPECT_LE(diff, 100 * NSEC_PER_MSEC, "CLOCK_UPTIME_RAW: clock_gettime() and clock_gettime_nsec_np() should be within 100ms");
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts), NULL);
+       T_WITH_ERRNO; T_ASSERT_NE((nsec = clock_gettime_nsec_np(CLOCK_PROCESS_CPUTIME_ID)), (uint64_t)0, NULL);
+       ts_nsec = (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec;
+       diff = (uint64_t)llabs((int64_t)nsec - (int64_t)ts_nsec);
+       T_EXPECT_LE(diff, 100 * NSEC_PER_MSEC, "CLOCK_PROCESS_CPUTIME_ID: clock_gettime() and clock_gettime_nsec_np() should be within 100ms");
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts), NULL);
+       T_WITH_ERRNO; T_ASSERT_NE((nsec = clock_gettime_nsec_np(CLOCK_THREAD_CPUTIME_ID)), (uint64_t)0, NULL);
+       ts_nsec = (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec;
+       diff = (uint64_t)llabs((int64_t)nsec - (int64_t)ts_nsec);
+       T_EXPECT_LE(diff, 100 * NSEC_PER_MSEC, "CLOCK_THREAD_CPUTIME_ID: clock_gettime() and clock_gettime_nsec_np() should be within 100ms");
+}
+
+T_DECL(clock_getres, "clock_getres()")
+{
+       struct timespec ts;
+
+       T_ASSERT_POSIX_ZERO(clock_getres(CLOCK_REALTIME, &ts), NULL);
+       T_LOG("Resolution of CLOCK_REALTIME is %ld ns", ts.tv_nsec);
+       T_EXPECT_EQ(ts.tv_sec, (long)0, NULL);
+       T_EXPECT_GT(ts.tv_nsec, (long)0, NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_getres(CLOCK_MONOTONIC, &ts), NULL);
+       T_LOG("Resolution of CLOCK_MONOTONIC is %ld ns", ts.tv_nsec);
+       T_EXPECT_EQ(ts.tv_sec, (long)0, NULL);
+       T_EXPECT_GT(ts.tv_nsec, (long)0, NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_getres(CLOCK_MONOTONIC_RAW, &ts), NULL);
+       T_LOG("Resolution of CLOCK_MONOTONIC_RAW is %ld ns", ts.tv_nsec);
+       T_EXPECT_EQ(ts.tv_sec, (long)0, NULL);
+       T_EXPECT_GT(ts.tv_nsec, (long)0, NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_getres(CLOCK_UPTIME_RAW, &ts), NULL);
+       T_LOG("Resolution of CLOCK_UPTIME_RAW is %ld ns", ts.tv_nsec);
+       T_EXPECT_EQ(ts.tv_sec, (long)0, NULL);
+       T_EXPECT_GT(ts.tv_nsec, (long)0, NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_getres(CLOCK_PROCESS_CPUTIME_ID, &ts), NULL);
+       T_LOG("Resolution of CLOCK_MONOTONIC_RAW is %ld ns", ts.tv_nsec);
+       T_EXPECT_EQ(ts.tv_sec, (long)0, NULL);
+       T_EXPECT_GT(ts.tv_nsec, (long)0, NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_getres(CLOCK_THREAD_CPUTIME_ID, &ts), NULL);
+       T_LOG("Resolution of CLOCK_MONOTONIC_RAW is %ld ns", ts.tv_nsec);
+       T_EXPECT_EQ(ts.tv_sec, (long)0, NULL);
+       T_EXPECT_GT(ts.tv_nsec, (long)0, NULL);
+}
+
+T_DECL(clock_settime_realtime, "clock_settime(CLOCK_REALTIME, tp)",
+          T_META("as_root", "true"))
+{
+       struct timespec ts;
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_REALTIME, &ts), NULL);
+
+       time_t initial_time = ts.tv_sec;
+
+       ts.tv_nsec += 1 * NSEC_PER_SEC;
+       T_ASSERT_POSIX_ZERO(clock_settime(CLOCK_REALTIME, &ts), NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_REALTIME, &ts), NULL);
+       T_EXPECT_GT(ts.tv_sec - initial_time, (time_t)0, "time should move forward at least one second");
+       T_EXPECT_LE(ts.tv_sec - initial_time, (time_t)2, "time should move forward less than two seconds");
+}
+T_DECL(clock_settime_other, "clock_settime(CLOCK_*, tp)",
+          T_META("as_root", "true"))
+{
+       struct timespec ts;;
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_MONOTONIC_RAW, &ts), NULL);
+       T_EXPECT_EQ(clock_settime(CLOCK_MONOTONIC_RAW, &ts), -1, NULL);
+       T_EXPECT_EQ(errno, EINVAL, NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts), NULL);
+       T_EXPECT_EQ(clock_settime(CLOCK_PROCESS_CPUTIME_ID, &ts), -1, NULL);
+       T_EXPECT_EQ(errno, EINVAL, NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_UPTIME_RAW, &ts), NULL);
+       T_EXPECT_EQ(clock_settime(CLOCK_UPTIME_RAW, &ts), -1, NULL);
+       T_EXPECT_EQ(errno, EINVAL, NULL);
+
+       T_ASSERT_POSIX_ZERO(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts), NULL);
+       T_EXPECT_EQ(clock_settime(CLOCK_THREAD_CPUTIME_ID, &ts), -1, NULL);
+       T_EXPECT_EQ(errno, EINVAL, NULL);
+}
diff --git a/tests/fts_find.c b/tests/fts_find.c
new file mode 100644 (file)
index 0000000..1c0bc31
--- /dev/null
@@ -0,0 +1,126 @@
+#include <err.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <fts.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+// Can ASan fts by uncommenting below
+//#include "../gen/fts.c"
+
+#ifndef DARWINTEST
+#define fts_find_main main
+#else
+#include <darwintest.h>
+#endif
+
+int fts_find_main(int argc, char *argv[]);
+
+static char *
+stat_str(struct stat *st)
+{
+       static char charbuf[256];
+       snprintf(charbuf, sizeof(charbuf), "dev: %d, mode: %x, nlink: %d, ino: %lld, "
+                       "owner: %d/%d, rdev: %d, mtime: %ld, ctime: %ld, btime: %ld, "
+                       "size: %lld, blocks: %lld, blksize: %d, flags: %d, gen: %d",
+                       st->st_dev, st->st_mode, st->st_nlink, st->st_ino, st->st_uid,
+                       st->st_gid, st->st_rdev, st->st_mtimespec.tv_sec,
+                       st->st_ctimespec.tv_sec, st->st_birthtimespec.tv_sec, st->st_size,
+                       st->st_blocks, st->st_blksize, st->st_flags, st->st_gen);
+       return charbuf;
+}
+
+int
+fts_find_main(int argc, char *argv[])
+{
+       FTS *fts;
+       FTSENT *ftse;
+
+       bool print_children = false;
+       int fts_options = FTS_COMFOLLOW | FTS_XDEV;
+
+       int ch;
+       while ((ch = getopt(argc, argv, "lpcdsS")) != -1){
+               switch (ch){
+                       case 'l':
+                               fts_options |= FTS_LOGICAL;
+                               break;
+                       case 'p':
+                               fts_options |= FTS_PHYSICAL;
+                               break;
+                       case 'c':
+                               print_children = true;
+                               break;
+                       case 'd':
+                               fts_options |= FTS_NOCHDIR;
+                               break;
+                       case 's':
+                               fts_options |= FTS_NOSTAT;
+                               break;
+                       case 'S':
+                               fts_options |= FTS_NOSTAT_TYPE;
+                               break;
+                       case '?':
+                               fprintf(stderr, "Usage: %s (-l|-p) [-c] [-d] [-s|-S] <path> ...\n", argv[0]);
+                               exit(EX_USAGE);
+               }
+       }
+
+       if ((fts_options & (FTS_LOGICAL|FTS_PHYSICAL)) == 0){
+               fprintf(stderr, "Usage: %s (-l|-p) [-c] [-s|-S] <path> ...\n", argv[0]);
+               exit(EX_USAGE);
+       }
+
+       argc -= optind;
+       argv += optind;
+
+       char **args = alloca((size_t)(argc + 1)*sizeof(char*));
+       for (int i = 0; i < argc; i++){
+               args[i] = argv[i];
+       }
+       args[argc] = NULL;
+       fts = fts_open_b(args, fts_options, ^(const FTSENT **a, const FTSENT **b){
+               return strcmp((*a)->fts_name, (*b)->fts_name);
+       });
+       if (!fts) err(EX_DATAERR, "fts_open_b");
+
+       while ((ftse = fts_read(fts)) != NULL) {
+#ifndef DARWINTEST
+               if (!print_children || (ftse->fts_info & FTS_D)){
+                       printf("%s (%s): 0x%x\n", ftse->fts_path, ftse->fts_name, ftse->fts_info);
+                       if (!(fts_options & (FTS_NOSTAT|FTS_NOSTAT_TYPE))) printf("\t\t%s\n", stat_str(ftse->fts_statp));
+               }
+#endif
+               if (print_children){
+                       FTSENT *child = fts_children(fts, 0);
+                       while (child){
+#ifndef DARWINTEST
+                               if (child->fts_info & FTS_F){
+                                       printf("\t%s (%s): 0x%x\n", child->fts_path, child->fts_name, child->fts_info);
+                                       if (!(fts_options & (FTS_NOSTAT|FTS_NOSTAT_TYPE))) printf("\t\t%s\n", stat_str(child->fts_statp));
+                               }
+#endif
+                               child = child->fts_link;
+                       }
+               }
+       }
+
+       (void)fts_close(fts);
+       return 0;
+}
+
+#ifdef DARWINTEST
+T_DECL(fts_find, "A find(1) example in fts"){
+       int fts_argc = 3;
+       char *fts_argv[] = {"fts_find", "-lc", "/System", NULL};
+       if (fts_find_main(fts_argc, fts_argv) == 0){
+               T_PASS("fts_find() completed successfully");
+       } else {
+               T_FAIL("fts_find() exited with error");
+       }
+}
+#endif
diff --git a/tests/getdate.c b/tests/getdate.c
new file mode 100644 (file)
index 0000000..bdc5e89
--- /dev/null
@@ -0,0 +1,150 @@
+#include <limits.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+
+#include <darwintest.h>
+#include <darwintest_utils.h>
+
+//#include "../stdtime/getdate.c"
+
+extern int getdate_err;
+
+__unused static void
+log_tm(struct tm *tm) {
+       T_LOG("tm = {\n\t.tm_sec = %d, tm_min = %d, tm_hour = %d,\n\t.tm_mday = %d, .tm_mon = %d, .tm_year = %d,\n\t.tm_wday = %d, tm_yday = %d\n};",
+                       tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday, tm->tm_yday);
+}
+
+static char *
+create_template_file(const char *name, const char *contents)
+{
+       T_SETUPBEGIN;
+       char *template_path;
+       asprintf(&template_path, "%s/%s", dt_tmpdir(), name);
+       T_QUIET; T_WITH_ERRNO; T_ASSERT_NOTNULL(template_path, NULL);
+
+       FILE *template_file = fopen(template_path, "w");
+       T_QUIET; T_WITH_ERRNO; T_ASSERT_NOTNULL(template_file, NULL);
+       fprintf(template_file, "%s", contents);
+       fclose(template_file);
+       T_SETUPEND;
+
+       return template_path;
+}
+
+T_DECL(getdate3, "getdate() using \"%a\" with match")
+{
+       struct tm tm = {};
+       char *remainder = strptime("Fri", "%a", &tm);
+       T_EXPECT_NOTNULL(remainder, "strptime(\"Fri\", \"%%a\", &tm)");
+       T_EXPECT_EQ(tm.tm_wday, 5, "Returned time should be on Friday");
+
+       char *template_path = create_template_file("a3", "%a\n");
+       setenv("DATEMSK", template_path, 1);
+       free(template_path);
+
+       getdate_err = 0;
+       struct tm *ptr_tm = getdate("Fri");
+       T_LOG("getdate(\"Fri\") -> Should indicate Friday");
+       T_ASSERT_NOTNULL(ptr_tm, "getdate() returned NULL, error is %d", getdate_err);
+       T_PASS("getdate returned properly, with the time as: %s", asctime (ptr_tm));
+       T_EXPECT_EQ(ptr_tm->tm_wday, 5, "Returned time should be on Friday");
+}
+
+T_DECL(getdate4, "getdate() using \"%A\" with match")
+{
+       struct tm tm = {};
+       char *remainder = strptime("FriDay", "%A", &tm);
+       T_EXPECT_NOTNULL(remainder, "strptime(\"FriDay\", \"%%A\", &tm)");
+       T_EXPECT_EQ(tm.tm_wday, 5, "Returned time should be on Friday");
+
+       char *template_path = create_template_file("a4", "%A\n");
+       setenv("DATEMSK", template_path, 1);
+       free(template_path);
+
+       getdate_err = 0;
+       struct tm *ptr_tm = getdate("FriDay");
+       T_LOG("getdate(\"FriDay\") -> Should indicate Friday");
+       T_ASSERT_NOTNULL(ptr_tm, "getdate() returned NULL, error is %d", getdate_err);
+       T_PASS("getdate returned properly, with the time as: %s", asctime (ptr_tm));
+       T_EXPECT_EQ(ptr_tm->tm_wday, 5, "Returned time should be on Friday");
+}
+
+T_DECL(getdate15, "getdate() using \"%w\" with match")
+{
+       char *template_path = create_template_file("a4", "%w\n");
+       setenv("DATEMSK", template_path, 1);
+       free(template_path);
+
+       getdate_err = 0;
+       struct tm *ptr_tm = getdate("0");
+       T_LOG("getdate(\"0\") -> Should indicate weekday 0");
+       T_ASSERT_NOTNULL(ptr_tm, "getdate() returned NULL, error is %d", getdate_err);
+       T_PASS("getdate returned properly, with the time as: %s", asctime (ptr_tm));
+       T_EXPECT_EQ(ptr_tm->tm_wday, 0, "Returned time should be on weekday 0");
+
+       getdate_err = 0;
+       ptr_tm = getdate("6");
+       T_LOG("getdate(\"6\") -> Should indicate weekday 6");
+       T_ASSERT_NOTNULL(ptr_tm, "getdate() returned NULL, error is %d", getdate_err);
+       T_PASS("getdate returned properly, with the time as: %s", asctime (ptr_tm));
+       T_EXPECT_EQ(ptr_tm->tm_wday, 6, "Returned time should be on weekday 6");
+}
+
+T_DECL(getdate46, "getdate() using \"%%t\" without match")
+{
+       char *template_path = create_template_file("a46", "%t\n");
+       setenv("DATEMSK", template_path, 1);
+       free(template_path);
+
+       getdate_err = 0;
+       struct tm *ptr_tm = getdate("there'snotemplateforthis.");
+       if (ptr_tm) {
+               T_FAIL("getdate returned: %s", asctime (ptr_tm));
+       }
+       /* Now check for the getdate_err */
+       T_EXPECT_EQ(getdate_err, 7, NULL);
+}
+
+T_DECL(getdate21, "getdate() using \"%D\" with match")
+{
+       struct tm tm = {};
+       char *remainder = strptime("1/1/38", "%D", &tm);
+       T_EXPECT_NOTNULL(remainder, "strptime(\"1/1/38\", \"%%D\", &tm)");
+
+       char *template_path = create_template_file("a21", "%D\n");
+       setenv("DATEMSK", template_path, 1);
+       free(template_path);
+
+       getdate_err = 0;
+       struct tm *ptr_tm = getdate ("1/1/38");
+       T_LOG("getdate(\"1/1/38\") -> Should indicate 2038!");
+       T_ASSERT_NOTNULL(ptr_tm, "getdate() returned NULL, error is %d", getdate_err);
+       T_PASS("getdate returned properly, with the time as: %s", asctime (ptr_tm));
+
+       T_EXPECT_EQ(ptr_tm->tm_year, 2038 - 1900, NULL);
+       T_EXPECT_EQ(ptr_tm->tm_mon, 0, NULL);
+       T_EXPECT_EQ(ptr_tm->tm_mday, 1, NULL);
+}
+
+T_DECL(getdate53, "getdate() using \"%d+%m+%y %C\" with match")
+{
+       struct tm tm = {};
+       char *remainder = strptime("15+05+20 20", "%d+%m+%y %C", &tm);
+       T_EXPECT_NOTNULL(remainder, "strptime(\"15+05+20 20\", \"%%d+%%m+%%y %%C\", &tm)");
+
+       char *template_path = create_template_file("a53", "%d+%m+%y %C\n");
+       setenv("DATEMSK", template_path, 1);
+       free(template_path);
+
+       getdate_err = 0;
+       struct tm *ptr_tm = getdate ("15+05+20 20");
+       T_LOG("getdate(\"15+05+20 20\")");
+       T_ASSERT_NOTNULL(ptr_tm, "getdate() returned NULL, error is %d", getdate_err);
+       T_PASS("getdate returned properly, with the time as: %s", asctime (ptr_tm));
+
+       T_EXPECT_EQ(ptr_tm->tm_year, 2020 - 1900, NULL);
+       T_EXPECT_EQ(ptr_tm->tm_mon, 4, NULL);
+       T_EXPECT_EQ(ptr_tm->tm_mday, 15, NULL);
+}
diff --git a/tests/getenv.c b/tests/getenv.c
new file mode 100644 (file)
index 0000000..27685df
--- /dev/null
@@ -0,0 +1,67 @@
+#include <stdlib.h>
+
+#include <darwintest.h>
+
+T_DECL(setenv_getenv, "getenv returns value set by setenv")
+{
+       char *name = "foo";
+       char *value = "bar";
+       int setenv_rc = setenv(name, value, 0);
+       T_EXPECT_EQ(0, setenv_rc, "setenv must succeed with 0 return code");
+       char *getenv_result = getenv(name);
+       T_EXPECT_EQ_STR(value, getenv_result, "getenv must return setenv argument");
+}
+
+T_DECL(setenv_overwrite, "getenv returns the latest setenv argument")
+{
+       char *name = "foo";
+       char *first_value = "bar";
+       char *second_value = "baz";
+       int setenv_rc = 0;
+       setenv_rc = setenv(name, first_value, 0);
+       T_EXPECT_EQ(0, setenv_rc, "setenv must succeed with 0 return code");
+       setenv_rc = setenv(name, second_value, 1);
+       T_EXPECT_EQ(0, setenv_rc, "setenv must succeed with 0 return code");
+       char *getenv_result = getenv(name);
+       T_EXPECT_EQ_STR(second_value, getenv_result, "getenv must return the latest setenv argument");
+}
+
+T_DECL(setenv_dont_overwrite, "setenv respects overwrite")
+{
+       char *name = "foo";
+       char *first_value = "bar";
+       char *second_value = "baz";
+       int setenv_rc = 0;
+       setenv_rc = setenv(name, first_value, 0);
+       T_EXPECT_EQ(0, setenv_rc, "setenv must succeed with 0 return code");
+       setenv_rc = setenv(name, second_value, 0);
+       T_EXPECT_EQ(0, setenv_rc, "setenv must succeed with 0 return code");
+       char *getenv_result = getenv(name);
+       T_EXPECT_EQ_STR(first_value, getenv_result, "the second setenv must not overwrite the first one");
+}
+
+/* There are tests for leading '=' in values because BSDs used to strip them off: rdar://problem/19342460 */
+
+T_DECL(setenv_accepts_leading_eq_sign, "setenv accepts values starting with '='")
+{
+       char *name = "foo";
+       char *value = "=bar";
+       int setenv_rc = setenv(name, value, 0);
+       T_EXPECT_EQ(0, setenv_rc, "setenv must succeed with 0 return code");
+       char *getenv_result = getenv(name);
+       T_EXPECT_EQ_STR(value, getenv_result, "getenv must return setenv argument");
+}
+
+T_DECL(setenv_accepts_leading_eq_sign_overwrite, "setenv accepts values starting with '=' when overwriting an existing value")
+{
+       char *name = "foo";
+       char *first_value = "bar";
+       char *second_value = "=baz";
+       int setenv_rc = 0;
+       setenv_rc = setenv(name, first_value, 0);
+       T_EXPECT_EQ(0, setenv_rc, "setenv must succeed with 0 return code");
+       setenv_rc = setenv(name, second_value, 1);
+       T_EXPECT_EQ(0, setenv_rc, "setenv must succeed with 0 return code");
+       char *getenv_result = getenv(name);
+       T_EXPECT_EQ_STR(second_value, getenv_result, "getenv must return the latest setenv argument");
+}
diff --git a/tests/install.sh b/tests/install.sh
deleted file mode 100644 (file)
index fcdfec0..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/bash
-
-## Install results in /
-noinstall=0
-train=
-
-while [ $# -gt 0 ]; do
-       if [ "${1/=*/}" = "--build" ]; then
-               build="${1/*=/}"
-       elif [ "${1/=*/}" = "--train" ]; then
-               train="${1/*=/}"
-       elif [ "${1/=*/}" = "--sdk" ]; then
-               sdk="${1/*=/}"
-       elif [ "$1" = "--noinstall" ]; then
-               noinstall=1
-        elif [ "${1/=*/}" = "--arch" ]; then
-                arch="${1/*=/}"
-        elif [ "$1" = "--nightlies" ]; then
-                nightlies=1
-       else
-               echo "install: [--sdk=macosx10.6] [--build=10A432] [--train=SnowLeopard] [--noinstall] [--arch=armv7s] [--nightlies]" 2>&1
-               exit 1
-       fi
-       shift
-done
-
-if [ $EUID -ne 0 ]; then
-       echo "install: script must be run as root" 2>&1
-       exit 1
-fi
-
-if [ -n "$sdk" ]; then
-       export SDKROOT="$(xcodebuild -version -sdk "$sdk" Path)"
-fi
-
-if [ -n "$nightlies" ]; then
-        export BSDTESTS_NIGHTLIES=1
-        export TMPDIR="/tmp"
-fi
-
-if [ -z "$build" ]; then
-       if [ -n "$SDKROOT" ]; then
-               build="$(xcodebuild -version -sdk "$SDKROOT" ProductBuildVersion)"
-       else
-               build="$(sw_vers -buildVersion)"
-       fi
-fi
-
-# if [ -z "$train" -a -n "$SDKROOT" -a -d /Volumes/Build/Views ]; then
-#   train="$(find /Volumes/Build/Views/*/Updates -maxdepth 1 -type d -name "*$build" | \
-#     sed "s#.*/\\(.*\\)$build#\\1#")"
-# fi
-# if [ -z "$train" ]; then
-#   train="$(~rc/bin/getTrainForBuild --quiet "$build")"
-# fi
-
-if [ -n "$BSDTESTS_NIGHTLIES" ]; then
-        ROOTS="$(mktemp -d -t "LibcTestsRoots.$train$build")"
-else
-        ROOTS=/var/tmp/LibcTestsRoots."$train$build"
-fi
-: ${DSTROOT:="$ROOTS/LibcTests~dst"}
-
-if [ -z "$DSTROOT" -o "$DSTROOT" = "/" ]; then
-       echo "install: DSTROOT = \"$DSTROOT\"" 2>&1
-       exit 1
-fi
-TESTROOTS="$ROOTS/libctest.roots/bsdtests.libc"
-
-# Building for another version implies noinstall
-if [ -n "$SDKROOT" -o "$build" != "$(sw_vers -buildVersion)" ]; then
-       noinstall=1
-fi
-
-if [ -n "$arch" ]; then
-    ARCHS="$arch"
-else
-    ARCHS="$(xcrun lipo -detailed_info "$SDKROOT"/usr/lib/libSystem.dylib | \
-            awk '/^architecture /'"$([ -z "$SDKROOT" ] && \
-            echo ' && !/armv6$/')"' {sub("ppc7400", "ppc"); ORS=" "; print $2}')"
-fi
-
-set -ex
-mkdir -p "$ROOTS"
-if [ -z "$BSDTESTS_NIGHTLIES" ]; then
-    rm -rf "$(dirname $TESTROOTS)"
-fi
-
-xcodebuild install ARCHS="$ARCHS" \
-       SYMROOT="$TESTROOTS~sym" OBJROOT="$TESTROOTS~obj" DSTROOT="$TESTROOTS~dst" \
-       $([ -n "$SDKROOT" ] && echo "SDKROOT=$SDKROOT")
-
-if [ $noinstall -eq 0 ]; then
-       darwinup install "$TESTROOTS~dst"
-else
-       mkdir -p "$DSTROOT"
-       ditto "$TESTROOTS~dst" "$DSTROOT"
-        set -
-        echo "TEST_ROOT: $DSTROOT"
-  # if [ -n "$SDKROOT" ]; then
-  #   mkdir -p "$DSTROOT"/usr/share/dict
-  #   ln -f {,"$DSTROOT"}/usr/share/dict/words
-  # fi
-fi
diff --git a/tests/libctest.xcconfig b/tests/libctest.xcconfig
deleted file mode 100644 (file)
index 47a4b9a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "<DEVELOPER_DIR>/Makefiles/CoreOS/Xcode/BSD.xcconfig"
-ARCHS = $(ARCHS_STANDARD_32_64_BIT)
-SUPPORTED_PLATFORMS = macosx iphoneos
-DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT=YES
-GCC_DYNAMIC_NO_PIC = NO
-GCC_WARN_SHADOW = YES
-GCC_TREAT_WARNINGS_AS_ERRORS = YES
-WARNING_CFLAGS = -Wall -Wextra -Wno-shorten-64-to-32
-PREBINDING = NO
-PREFIX = /usr/local
-BINDIR = $PREFIX/bin
-DATDIR = $PREFIX/share
-TESTDIR = $DATDIR/bsdtests
-INSTALL_PATH = $(TESTDIR)/Libc
-SKIP_INSTALL = NO
-HEADER_SEARCH_PATHS = $(PREFIX)/include
-GCC_PREPROCESSOR_DEFINITIONS[sdk=macosx10.6] = $(value) __MAC_10_7=__MAC_10_6 __AVAILABILITY_INTERNAL__MAC_10_7=__AVAILABILITY_INTERNAL__MAC_10_6
-GCC_C_LANGUAGE_STANDARD = gnu99
diff --git a/tests/libctest.xcodeproj/project.pbxproj b/tests/libctest.xcodeproj/project.pbxproj
deleted file mode 100644 (file)
index c2886ed..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-// !$*UTF8*$!
-{
-       archiveVersion = 1;
-       classes = {
-       };
-       objectVersion = 46;
-       objects = {
-
-/* Begin PBXAggregateTarget section */
-               DFA94CCF109B8283001AC544 /* runtests */ = {
-                       isa = PBXAggregateTarget;
-                       buildConfigurationList = DFA94CD8109B82F2001AC544 /* Build configuration list for PBXAggregateTarget "runtests" */;
-                       buildPhases = (
-                               DF9FEC6610B30F1000D2A9DC /* Replacements */,
-                               E4F711E210C67E6400D6C029 /* CopyFiles */,
-                       );
-                       dependencies = (
-                       );
-                       name = runtests;
-                       productName = runtests;
-               };
-               E4D01DC5108E708E00FAA873 /* all */ = {
-                       isa = PBXAggregateTarget;
-                       buildConfigurationList = E4D01E08108E70D400FAA873 /* Build configuration list for PBXAggregateTarget "all" */;
-                       buildPhases = (
-                               4D791FFD1A2D45AB002616F3 /* CopyFiles */,
-                       );
-                       dependencies = (
-                               E423CC2D199C5B2F00A527F4 /* PBXTargetDependency */,
-                               DFA94CD5109B82B9001AC544 /* PBXTargetDependency */,
-                               FC2897D6127FCDB400B86C0C /* PBXTargetDependency */,
-                               C99475E2159258E0009FC2A7 /* PBXTargetDependency */,
-                       );
-                       name = all;
-                       productName = all;
-               };
-               E4D02077108EA00500FAA873 /* test */ = {
-                       isa = PBXAggregateTarget;
-                       buildConfigurationList = E4D0207E108EA04D00FAA873 /* Build configuration list for PBXAggregateTarget "test" */;
-                       buildPhases = (
-                               E4D02076108EA00500FAA873 /* Run Tests */,
-                       );
-                       dependencies = (
-                               E4D020C9108FA46C00FAA873 /* PBXTargetDependency */,
-                       );
-                       name = test;
-                       productName = test;
-               };
-/* End PBXAggregateTarget section */
-
-/* Begin PBXBuildFile section */
-               4D791FFF1A2D4611002616F3 /* Libc.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4D791FFC1A2D3D5F002616F3 /* Libc.plist */; };
-               925E7FE419E8901800AC7889 /* runtests in CopyFiles */ = {isa = PBXBuildFile; fileRef = E4F712A310C67FD800D6C029 /* runtests */; };
-               9268CAC019E4D2E30058F6A6 /* libbsdtests.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9268CABD19E4D2AD0058F6A6 /* libbsdtests.dylib */; };
-               9268CAC719E4D30D0058F6A6 /* libbsdtests.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9268CABD19E4D2AD0058F6A6 /* libbsdtests.dylib */; };
-               9268CAC919E4D31D0058F6A6 /* libbsdtests.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9268CABD19E4D2AD0058F6A6 /* libbsdtests.dylib */; };
-               C99475C715924B07009FC2A7 /* strlcat.c in Sources */ = {isa = PBXBuildFile; fileRef = C99475C615924B07009FC2A7 /* strlcat.c */; };
-               E423CC2B199C5B2100A527F4 /* psort.c in Sources */ = {isa = PBXBuildFile; fileRef = E423CC2A199C5B2100A527F4 /* psort.c */; };
-               E423CC43199C67C800A527F4 /* test_list.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = E423CC42199C67C800A527F4 /* test_list.txt */; };
-               FC2897D4127FCDA800B86C0C /* nxheap.c in Sources */ = {isa = PBXBuildFile; fileRef = FC2897D3127FCDA800B86C0C /* nxheap.c */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXContainerItemProxy section */
-               C99475E1159258E0009FC2A7 /* PBXContainerItemProxy */ = {
-                       isa = PBXContainerItemProxy;
-                       containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
-                       proxyType = 1;
-                       remoteGlobalIDString = C99475A415924ADA009FC2A7;
-                       remoteInfo = strlcat;
-               };
-               DFA94CD4109B82B9001AC544 /* PBXContainerItemProxy */ = {
-                       isa = PBXContainerItemProxy;
-                       containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
-                       proxyType = 1;
-                       remoteGlobalIDString = DFA94CCF109B8283001AC544;
-                       remoteInfo = runtests;
-               };
-               E423CC2C199C5B2F00A527F4 /* PBXContainerItemProxy */ = {
-                       isa = PBXContainerItemProxy;
-                       containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
-                       proxyType = 1;
-                       remoteGlobalIDString = E423CC17199C5AC200A527F4;
-                       remoteInfo = psort;
-               };
-               E4D020C8108FA46C00FAA873 /* PBXContainerItemProxy */ = {
-                       isa = PBXContainerItemProxy;
-                       containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
-                       proxyType = 1;
-                       remoteGlobalIDString = E4D01DC5108E708E00FAA873;
-                       remoteInfo = all;
-               };
-               FC2897D5127FCDB400B86C0C /* PBXContainerItemProxy */ = {
-                       isa = PBXContainerItemProxy;
-                       containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
-                       proxyType = 1;
-                       remoteGlobalIDString = FC2897C7127FCD4500B86C0C;
-                       remoteInfo = nxheap;
-               };
-/* End PBXContainerItemProxy section */
-
-/* Begin PBXCopyFilesBuildPhase section */
-               4D791FFD1A2D45AB002616F3 /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 8;
-                       dstPath = /AppleInternal/CoreOS/BATS/unit_tests;
-                       dstSubfolderSpec = 0;
-                       files = (
-                               4D791FFF1A2D4611002616F3 /* Libc.plist in CopyFiles */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 1;
-               };
-               E4F711E210C67E6400D6C029 /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 12;
-                       dstPath = "";
-                       dstSubfolderSpec = 1;
-                       files = (
-                               925E7FE419E8901800AC7889 /* runtests in CopyFiles */,
-                               E423CC43199C67C800A527F4 /* test_list.txt in CopyFiles */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-/* End PBXCopyFilesBuildPhase section */
-
-/* Begin PBXFileReference section */
-               4D791FFC1A2D3D5F002616F3 /* Libc.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Libc.plist; sourceTree = "<group>"; };
-               9268CABD19E4D2AD0058F6A6 /* libbsdtests.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbsdtests.dylib; path = usr/local/lib/libbsdtests.dylib; sourceTree = SDKROOT; };
-               C99475AF15924ADA009FC2A7 /* strlcat */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = strlcat; sourceTree = BUILT_PRODUCTS_DIR; };
-               C99475C615924B07009FC2A7 /* strlcat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = strlcat.c; sourceTree = "<group>"; };
-               DFA94CCD109B8209001AC544 /* runtests */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = runtests; sourceTree = "<group>"; };
-               E40F2D021098D9400010F089 /* libctest.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = libctest.xcconfig; sourceTree = "<group>"; };
-               E423CC22199C5AC200A527F4 /* psort */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = psort; sourceTree = BUILT_PRODUCTS_DIR; };
-               E423CC2A199C5B2100A527F4 /* psort.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psort.c; sourceTree = "<group>"; };
-               E423CC42199C67C800A527F4 /* test_list.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test_list.txt; sourceTree = "<group>"; };
-               E4F712A310C67FD800D6C029 /* runtests */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = runtests; sourceTree = PROJECT_TEMP_DIR; };
-               FC2897C8127FCD4500B86C0C /* nxheap */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = nxheap; sourceTree = BUILT_PRODUCTS_DIR; };
-               FC2897D3127FCDA800B86C0C /* nxheap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nxheap.c; sourceTree = "<group>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
-               C99475A915924ADA009FC2A7 /* Frameworks */ = {
-                       isa = PBXFrameworksBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               9268CAC919E4D31D0058F6A6 /* libbsdtests.dylib in Frameworks */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-               E423CC1C199C5AC200A527F4 /* Frameworks */ = {
-                       isa = PBXFrameworksBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               9268CAC019E4D2E30058F6A6 /* libbsdtests.dylib in Frameworks */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-               FC2897C6127FCD4500B86C0C /* Frameworks */ = {
-                       isa = PBXFrameworksBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               9268CAC719E4D30D0058F6A6 /* libbsdtests.dylib in Frameworks */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
-               08FB7794FE84155DC02AAC07 /* libdispatch */ = {
-                       isa = PBXGroup;
-                       children = (
-                               E40F2D021098D9400010F089 /* libctest.xcconfig */,
-                               DFA94CCD109B8209001AC544 /* runtests */,
-                               E423CC42199C67C800A527F4 /* test_list.txt */,
-                               E4EB36E31088F0DD00C33AD4 /* Test Sources */,
-                               E44A77051098E9F00024377F /* Other Sources */,
-                               4D791FFE1A2D45E0002616F3 /* BATS */,
-                               1AB674ADFE9D54B511CA2CBB /* Products */,
-                       );
-                       indentWidth = 4;
-                       name = libdispatch;
-                       sourceTree = "<group>";
-                       tabWidth = 4;
-                       usesTabs = 1;
-               };
-               1AB674ADFE9D54B511CA2CBB /* Products */ = {
-                       isa = PBXGroup;
-                       children = (
-                               E4F712A310C67FD800D6C029 /* runtests */,
-                               FC2897C8127FCD4500B86C0C /* nxheap */,
-                               C99475AF15924ADA009FC2A7 /* strlcat */,
-                               E423CC22199C5AC200A527F4 /* psort */,
-                       );
-                       name = Products;
-                       sourceTree = "<group>";
-               };
-               4D791FFE1A2D45E0002616F3 /* BATS */ = {
-                       isa = PBXGroup;
-                       children = (
-                               4D791FFC1A2D3D5F002616F3 /* Libc.plist */,
-                       );
-                       name = BATS;
-                       sourceTree = "<group>";
-               };
-               E44A77051098E9F00024377F /* Other Sources */ = {
-                       isa = PBXGroup;
-                       children = (
-                               9268CABD19E4D2AD0058F6A6 /* libbsdtests.dylib */,
-                       );
-                       name = "Other Sources";
-                       sourceTree = "<group>";
-               };
-               E4EB36E31088F0DD00C33AD4 /* Test Sources */ = {
-                       isa = PBXGroup;
-                       children = (
-                               FC2897D3127FCDA800B86C0C /* nxheap.c */,
-                               C99475C615924B07009FC2A7 /* strlcat.c */,
-                               E423CC2A199C5B2100A527F4 /* psort.c */,
-                       );
-                       name = "Test Sources";
-                       sourceTree = "<group>";
-               };
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
-               C99475A415924ADA009FC2A7 /* strlcat */ = {
-                       isa = PBXNativeTarget;
-                       buildConfigurationList = C99475AB15924ADA009FC2A7 /* Build configuration list for PBXNativeTarget "strlcat" */;
-                       buildPhases = (
-                               C99475A715924ADA009FC2A7 /* Sources */,
-                               C99475A915924ADA009FC2A7 /* Frameworks */,
-                       );
-                       buildRules = (
-                       );
-                       dependencies = (
-                       );
-                       name = strlcat;
-                       productName = strlcat;
-                       productReference = C99475AF15924ADA009FC2A7 /* strlcat */;
-                       productType = "com.apple.product-type.tool";
-               };
-               E423CC17199C5AC200A527F4 /* psort */ = {
-                       isa = PBXNativeTarget;
-                       buildConfigurationList = E423CC1E199C5AC200A527F4 /* Build configuration list for PBXNativeTarget "psort" */;
-                       buildPhases = (
-                               E423CC1A199C5AC200A527F4 /* Sources */,
-                               E423CC1C199C5AC200A527F4 /* Frameworks */,
-                       );
-                       buildRules = (
-                       );
-                       dependencies = (
-                       );
-                       name = psort;
-                       productName = psort;
-                       productReference = E423CC22199C5AC200A527F4 /* psort */;
-                       productType = "com.apple.product-type.tool";
-               };
-               FC2897C7127FCD4500B86C0C /* nxheap */ = {
-                       isa = PBXNativeTarget;
-                       buildConfigurationList = FC2897D2127FCD9B00B86C0C /* Build configuration list for PBXNativeTarget "nxheap" */;
-                       buildPhases = (
-                               FC2897C5127FCD4500B86C0C /* Sources */,
-                               FC2897C6127FCD4500B86C0C /* Frameworks */,
-                       );
-                       buildRules = (
-                       );
-                       dependencies = (
-                       );
-                       name = nxheap;
-                       productName = nxheap;
-                       productReference = FC2897C8127FCD4500B86C0C /* nxheap */;
-                       productType = "com.apple.product-type.tool";
-               };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
-               08FB7793FE84155DC02AAC07 /* Project object */ = {
-                       isa = PBXProject;
-                       attributes = {
-                               BuildIndependentTargetsInParallel = YES;
-                       };
-                       buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "libctest" */;
-                       compatibilityVersion = "Xcode 3.2";
-                       developmentRegion = English;
-                       hasScannedForEncodings = 1;
-                       knownRegions = (
-                               English,
-                               Japanese,
-                               French,
-                               German,
-                       );
-                       mainGroup = 08FB7794FE84155DC02AAC07 /* libdispatch */;
-                       projectDirPath = "";
-                       projectRoot = "";
-                       targets = (
-                               E4D01DC5108E708E00FAA873 /* all */,
-                               E4D02077108EA00500FAA873 /* test */,
-                               DFA94CCF109B8283001AC544 /* runtests */,
-                               FC2897C7127FCD4500B86C0C /* nxheap */,
-                               C99475A415924ADA009FC2A7 /* strlcat */,
-                               E423CC17199C5AC200A527F4 /* psort */,
-                       );
-               };
-/* End PBXProject section */
-
-/* Begin PBXShellScriptBuildPhase section */
-               DF9FEC6610B30F1000D2A9DC /* Replacements */ = {
-                       isa = PBXShellScriptBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                       );
-                       inputPaths = (
-                               "$(PROJECT_DIR)/runtests",
-                       );
-                       name = Replacements;
-                       outputPaths = (
-                               "$(PROJECT_TEMP_DIR)/runtests",
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-                       shellPath = "/bin/bash -e";
-                       shellScript = "/usr/bin/sed -e \"s,%%BINDIR%%,$BINDIR,\" \"$SCRIPT_INPUT_FILE_0\" > \"$SCRIPT_OUTPUT_FILE_0\"\n/bin/chmod 755 \"$SCRIPT_OUTPUT_FILE_0\"";
-                       showEnvVarsInLog = 0;
-               };
-               E4D02076108EA00500FAA873 /* Run Tests */ = {
-                       isa = PBXShellScriptBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                       );
-                       inputPaths = (
-                       );
-                       name = "Run Tests";
-                       outputPaths = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-                       shellPath = /bin/bash;
-                       shellScript = "\"${TARGET_BUILD_DIR}\"/runtests";
-                       showEnvVarsInLog = 0;
-               };
-/* End PBXShellScriptBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
-               C99475A715924ADA009FC2A7 /* Sources */ = {
-                       isa = PBXSourcesBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               C99475C715924B07009FC2A7 /* strlcat.c in Sources */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-               E423CC1A199C5AC200A527F4 /* Sources */ = {
-                       isa = PBXSourcesBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               E423CC2B199C5B2100A527F4 /* psort.c in Sources */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-               FC2897C5127FCD4500B86C0C /* Sources */ = {
-                       isa = PBXSourcesBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               FC2897D4127FCDA800B86C0C /* nxheap.c in Sources */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXTargetDependency section */
-               C99475E2159258E0009FC2A7 /* PBXTargetDependency */ = {
-                       isa = PBXTargetDependency;
-                       target = C99475A415924ADA009FC2A7 /* strlcat */;
-                       targetProxy = C99475E1159258E0009FC2A7 /* PBXContainerItemProxy */;
-               };
-               DFA94CD5109B82B9001AC544 /* PBXTargetDependency */ = {
-                       isa = PBXTargetDependency;
-                       target = DFA94CCF109B8283001AC544 /* runtests */;
-                       targetProxy = DFA94CD4109B82B9001AC544 /* PBXContainerItemProxy */;
-               };
-               E423CC2D199C5B2F00A527F4 /* PBXTargetDependency */ = {
-                       isa = PBXTargetDependency;
-                       target = E423CC17199C5AC200A527F4 /* psort */;
-                       targetProxy = E423CC2C199C5B2F00A527F4 /* PBXContainerItemProxy */;
-               };
-               E4D020C9108FA46C00FAA873 /* PBXTargetDependency */ = {
-                       isa = PBXTargetDependency;
-                       target = E4D01DC5108E708E00FAA873 /* all */;
-                       targetProxy = E4D020C8108FA46C00FAA873 /* PBXContainerItemProxy */;
-               };
-               FC2897D6127FCDB400B86C0C /* PBXTargetDependency */ = {
-                       isa = PBXTargetDependency;
-                       target = FC2897C7127FCD4500B86C0C /* nxheap */;
-                       targetProxy = FC2897D5127FCDB400B86C0C /* PBXContainerItemProxy */;
-               };
-/* End PBXTargetDependency section */
-
-/* Begin XCBuildConfiguration section */
-               1DEB91F108733DB70010E9CD /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
-                               GCC_OPTIMIZATION_LEVEL = s;
-                       };
-                       name = Release;
-               };
-               C99475AC15924ADA009FC2A7 /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = "$(TARGET_NAME)";
-                       };
-                       name = Release;
-               };
-               C99475AD15924ADA009FC2A7 /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = "$(TARGET_NAME)";
-                       };
-                       name = Debug;
-               };
-               DFA94CD0109B8283001AC544 /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = runtests;
-                       };
-                       name = Release;
-               };
-               DFA94CD1109B8283001AC544 /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = runtests;
-                       };
-                       name = Debug;
-               };
-               E423CC1F199C5AC200A527F4 /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = "$(TARGET_NAME)";
-                       };
-                       name = Release;
-               };
-               E423CC20199C5AC200A527F4 /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = "$(TARGET_NAME)";
-                       };
-                       name = Debug;
-               };
-               E4D01DC6108E708E00FAA873 /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = all;
-                       };
-                       name = Release;
-               };
-               E4D01DC7108E708E00FAA873 /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = all;
-                       };
-                       name = Debug;
-               };
-               E4D02078108EA00500FAA873 /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = test;
-                       };
-                       name = Release;
-               };
-               E4D02079108EA00500FAA873 /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = test;
-                       };
-                       name = Debug;
-               };
-               E4EB382D1089033000C33AD4 /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               DEBUG_INFORMATION_FORMAT = dwarf;
-                               GCC_OPTIMIZATION_LEVEL = 0;
-                               ONLY_ACTIVE_ARCH = YES;
-                               OTHER_LDFLAGS = "-lobjc";
-                               "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = "";
-                       };
-                       name = Debug;
-               };
-               FC2897CA127FCD4800B86C0C /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = "$(TARGET_NAME)";
-                       };
-                       name = Release;
-               };
-               FC2897CB127FCD4800B86C0C /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       baseConfigurationReference = E40F2D021098D9400010F089 /* libctest.xcconfig */;
-                       buildSettings = {
-                               PRODUCT_NAME = "$(TARGET_NAME)";
-                       };
-                       name = Debug;
-               };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
-               1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "libctest" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               1DEB91F108733DB70010E9CD /* Release */,
-                               E4EB382D1089033000C33AD4 /* Debug */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-               C99475AB15924ADA009FC2A7 /* Build configuration list for PBXNativeTarget "strlcat" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               C99475AC15924ADA009FC2A7 /* Release */,
-                               C99475AD15924ADA009FC2A7 /* Debug */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-               DFA94CD8109B82F2001AC544 /* Build configuration list for PBXAggregateTarget "runtests" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               DFA94CD0109B8283001AC544 /* Release */,
-                               DFA94CD1109B8283001AC544 /* Debug */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-               E423CC1E199C5AC200A527F4 /* Build configuration list for PBXNativeTarget "psort" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               E423CC1F199C5AC200A527F4 /* Release */,
-                               E423CC20199C5AC200A527F4 /* Debug */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-               E4D01E08108E70D400FAA873 /* Build configuration list for PBXAggregateTarget "all" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               E4D01DC6108E708E00FAA873 /* Release */,
-                               E4D01DC7108E708E00FAA873 /* Debug */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-               E4D0207E108EA04D00FAA873 /* Build configuration list for PBXAggregateTarget "test" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               E4D02078108EA00500FAA873 /* Release */,
-                               E4D02079108EA00500FAA873 /* Debug */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-               FC2897D2127FCD9B00B86C0C /* Build configuration list for PBXNativeTarget "nxheap" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               FC2897CA127FCD4800B86C0C /* Release */,
-                               FC2897CB127FCD4800B86C0C /* Debug */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-/* End XCConfigurationList section */
-       };
-       rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
-}
diff --git a/tests/locale.c b/tests/locale.c
new file mode 100644 (file)
index 0000000..3ec6e89
--- /dev/null
@@ -0,0 +1,28 @@
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <xlocale.h>
+
+#include <darwintest.h>
+
+T_DECL(PR_23679075, "converts a cyrillic a to uppercase")
+{
+       locale_t loc = newlocale(LC_COLLATE_MASK|LC_CTYPE_MASK, "ru_RU", 0);
+       T_ASSERT_NOTNULL(loc, "newlocale(LC_COLLATE_MASK|LC_CTYPE_MASK, \"ru_RU\", 0) should return a locale");
+
+       T_ASSERT_EQ(towupper_l(0x0430, loc), 0x0410, NULL);
+       freelocale(loc);
+}
+
+T_DECL(PR_24165555, "swprintf with Russian chars")
+{
+    setlocale(LC_ALL, "ru_RU.UTF-8");
+
+    wchar_t buffer[256];
+    T_EXPECT_POSIX_SUCCESS(swprintf(buffer, 256, L"%ls", L"English: Hello World"), "English");
+    T_EXPECT_POSIX_SUCCESS(swprintf(buffer, 256, L"%ls", L"Russian: ру́сский язы́к"), "Russian");
+
+    setlocale(LC_ALL, "");
+}
diff --git a/tests/mktemp.c b/tests/mktemp.c
new file mode 100644 (file)
index 0000000..ff26ddc
--- /dev/null
@@ -0,0 +1,233 @@
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <System/sys/content_protection.h>
+#include <TargetConditionals.h>
+#include <unistd.h>
+
+#include <darwintest.h>
+
+#define ALLOWED_MKOSTEMP_FLAGS (O_APPEND | O_SHLOCK | O_EXLOCK | O_CLOEXEC)
+#define FCNTL_GETFL_EXPOSED_OFLAGS (O_APPEND)
+
+#define TEMPLATE_BASE "/tmp/mktemp_test."
+#define TEMPLATE_XS "XXXXXXXX"
+static const char template[] = TEMPLATE_BASE TEMPLATE_XS;
+
+static void test_mkostemp(int oflags);
+
+T_DECL(test_mkstemp, "basic mkstemp test")
+{
+       char path[sizeof(template)];
+       struct stat path_stat;
+       struct stat fd_stat;
+
+       memcpy(path, template, sizeof(template));
+
+       int fd = mkstemp(path);
+       T_ASSERT_POSIX_SUCCESS(fd,
+                       "mkstemp must return a valid fd");
+       T_ASSERT_TRUE(memcmp(path, TEMPLATE_BASE, strlen(TEMPLATE_BASE)) == 0,
+                       "mkstemp must respect the template. template: %s, got: %s",
+                       template, path);
+
+       // stat fd and path, compare those
+       T_ASSERT_POSIX_ZERO(stat(path, &path_stat),
+                       "must be able to stat the path");
+       T_ASSERT_POSIX_ZERO(fstat(fd, &fd_stat),
+                       "must be able to fstat the fd");
+       T_ASSERT_TRUE(
+                       (path_stat.st_dev == fd_stat.st_dev) &&
+                       (path_stat.st_ino == fd_stat.st_ino),
+                       "fd does not match the file path");
+       // verify file attributes
+       T_ASSERT_TRUE(S_ISREG(path_stat.st_mode),
+                       "the path must point to a regular file");
+       T_ASSERT_EQ(0600, (path_stat.st_mode & 0777),
+                       "created file must have 0600 permissions");
+       T_ASSERT_EQ_LLONG(0LL, path_stat.st_size,
+                       "created file must be empty");
+       // unlink and stat again
+       T_ASSERT_POSIX_ZERO(unlink(path),
+                       "must be able to unlink the created file");
+       T_ASSERT_POSIX_ZERO(fstat(fd, &fd_stat),
+                       "must be able to stat the fd after unlink");
+       T_ASSERT_EQ(0, fd_stat.st_nlink,
+                       "must not have any hard links to the file after unlink");
+       // close
+       T_ASSERT_POSIX_ZERO(close(fd),
+                       "must be able to close the fd");
+}
+
+T_DECL(two_mkstemp_calls, "two mkstemp calls return different paths and fds")
+{
+       char path1[sizeof(template)];
+       char path2[sizeof(template)];
+       memcpy(path1, template, sizeof(path1));
+       memcpy(path2, template, sizeof(path2));
+
+       int fd1 = mkostemp(path1, 0);
+       T_ASSERT_POSIX_SUCCESS(fd1, "mkostemp must return a valid fd");
+
+       int fd2 = mkostemp(path2, 0);
+       T_ASSERT_POSIX_SUCCESS(fd2, "mkostemp must return a valid fd");
+
+       T_ASSERT_NE(fd1, fd2,
+                       "two mkostemp calls must return different fds");
+       T_ASSERT_NE_STR(path1, path2,
+                       "two mkostemp calls must return different paths");
+
+       T_EXPECT_POSIX_ZERO(unlink(path1),
+                       "unlink must succeed for the first file");
+       T_EXPECT_POSIX_ZERO(unlink(path2),
+                       "unlink must succeed for the second file");
+       T_EXPECT_POSIX_ZERO(close(fd1),
+                       "close must succeed for the first fd");
+       T_EXPECT_POSIX_ZERO(close(fd2),
+                       "close must succeed for the second fd");
+}
+
+T_DECL(test_mktemp, "basic mktemp test")
+{
+       char path[sizeof(template)];
+
+       memcpy(path, template, sizeof(template));
+
+       T_ASSERT_EQ_PTR((void *) mktemp(path), (void *) path,
+                       "mktemp must return its argument");
+
+       T_ASSERT_TRUE(memcmp(path, TEMPLATE_BASE, strlen(TEMPLATE_BASE)) == 0,
+                       "mktemp must respect the template. template: %s, got: %s",
+                       template, path);
+}
+
+T_DECL(test_mkdtemp, "basic mkdtemp test")
+{
+       char path[sizeof(template)];
+       struct stat dstat;
+
+       memcpy(path, template, sizeof(template));
+
+       T_ASSERT_EQ_PTR((void *) mkdtemp(path), (void *) path,
+                       "mkdtemp must return its argument");
+       T_ASSERT_TRUE(memcmp(path, TEMPLATE_BASE, strlen(TEMPLATE_BASE)) == 0,
+                       "mkdtemp must respect the template. template: %s, got: %s",
+                       template, path);
+
+       // stat fd and path, compare those
+       T_ASSERT_POSIX_ZERO(stat(path, &dstat),
+                       "must be able to stat the path");
+       // verify file attributes
+       T_ASSERT_TRUE(S_ISDIR(dstat.st_mode),
+                       "the path must point to a directory");
+       T_ASSERT_EQ(0700, (dstat.st_mode & 0777),
+                       "created directory must have 0700 permissions");
+       // cleanup
+       T_ASSERT_POSIX_ZERO(rmdir(path),
+                       "must be able to rmdir the created directory");
+}
+
+T_DECL(mkostemp_no_flags, "mkostemp works with 0 oflags")
+{
+       test_mkostemp(0);
+}
+
+T_DECL(mkostemp_cloexec, "mkostemp works with O_CLOEXEC")
+{
+       test_mkostemp(O_CLOEXEC);
+}
+
+T_DECL(mkostemp_append, "mkostemp works with O_APPEND")
+{
+       test_mkostemp(O_APPEND);
+}
+
+T_DECL(mkostemp_all_flags, "mkostemp works with all allowed flags")
+{
+       test_mkostemp(ALLOWED_MKOSTEMP_FLAGS);
+}
+
+T_DECL(mkostemp_bad_flags, "mkostemp checks for disallowed flags")
+{
+       char path[sizeof(template)];
+       memcpy(path, template, sizeof(path));
+
+       T_ASSERT_EQ(-1, mkostemp(path, O_CREAT), "mkostemp must not allow O_CREAT");
+       T_ASSERT_EQ(-1, mkostemp(path, O_NONBLOCK), "mkostemp must not allow O_NONBLOCK");
+}
+
+static void
+test_mkostemp(int oflags)
+{
+       char path[sizeof(template)];
+       int fd;
+
+       T_LOG("testing mkostemp with oflags %#x\n", oflags);
+
+       memcpy(path, template, sizeof(template));
+
+       fd = mkostemp(path, oflags);
+
+       T_ASSERT_POSIX_SUCCESS(fd,
+                       "mkostemp must return a valid fd");
+
+       if (oflags & O_CLOEXEC) {
+               T_ASSERT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD),
+                               "O_CLOEXEC must be visible through fcntl GETFD");
+       } else {
+               T_ASSERT_EQ(0, fcntl(fd, F_GETFD),
+                               "must not add fcntl GETFD flags at will");
+       }
+
+       T_ASSERT_EQ(
+                       (oflags & FCNTL_GETFL_EXPOSED_OFLAGS),
+                       (fcntl(fd, F_GETFL) & FCNTL_GETFL_EXPOSED_OFLAGS),
+                       "oflags must be visible through fcntl GETFL");
+
+       T_EXPECT_POSIX_ZERO(unlink(path),
+                       "must be able to unlink the created file");
+       T_EXPECT_POSIX_ZERO(close(fd),
+                       "must be able to close the fd");
+}
+
+#if TARGET_OS_IPHONE
+// mkstemp_dprotected_np is marked as __OSX_UNAVAILABLE, so its usage
+// has to be guarded by target conditionals. Having a testcase that
+// always does T_SKIP on OS X yields another issue. The compiler starts
+// demanding to mark the test function definition as noreturn. Just
+// don't compile the testcase for OS X.
+T_DECL(test_mkstemp_dprotected_np, "basic mkstemp_dprotected_np test")
+{
+       char path[sizeof(template)];
+       int fd;
+       int protection_class;
+       struct statfs sfs;
+
+       // the test requires /tmp to be HFS
+       T_ASSERT_POSIX_ZERO(statfs("/tmp", &sfs), "must be able to statfs /tmp");
+       if (strcmp(sfs.f_fstypename, "hfs") != 0) {
+               T_SKIP("Can only test dprotected on a HFS filesystem. Got %s,"
+                               "skipping the test.", sfs.f_fstypename);
+       }
+
+       memcpy(path, template, sizeof(template));
+       // create a file
+       fd = mkstemp_dprotected_np(path, PROTECTION_CLASS_B, 0);
+       T_ASSERT_POSIX_SUCCESS(fd,
+                       "mkstemp_dprotected_np must return a valid fd");
+       T_ASSERT_TRUE(memcmp(path, TEMPLATE_BASE, strlen(TEMPLATE_BASE)) == 0,
+                       "mkstemp_dprotected_np must respect the template. template: %s, got: %s",
+                       template, path);
+       // verify protection class
+       protection_class = fcntl(fd, F_GETPROTECTIONCLASS);
+       T_WITH_ERRNO; T_ASSERT_EQ(protection_class, PROTECTION_CLASS_B,
+                       "must get back the protection class from fcntl");
+       // cleanup
+       T_ASSERT_POSIX_ZERO(close(fd),
+                       "must be able to close the fd");
+       T_ASSERT_POSIX_ZERO(unlink(path),
+                       "must be able to unlink the created file");
+}
+#endif
diff --git a/tests/net.c b/tests/net.c
new file mode 100644 (file)
index 0000000..b173c25
--- /dev/null
@@ -0,0 +1,120 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if_dl.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <stdio.h>
+#include <darwintest.h>
+
+T_DECL(link_ntoa_basic, "link_ntoa converts to proper string")
+{
+//     u_char  sdl_len;        /* Total length of sockaddr */
+//     u_char  sdl_family;     /* AF_LINK */
+//     u_short sdl_index;      /* if != 0, system given index for interface */
+//     u_char  sdl_type;       /* interface type */
+//     u_char  sdl_nlen;       /* interface name length, no trailing 0 reqd. */
+//     u_char  sdl_alen;       /* link level address length */
+//     u_char  sdl_slen;       /* link layer selector length */
+//     char    sdl_data[12];   /* minimum work area, can be larger;
+//                                contains both if name and ll address */
+
+       struct sockaddr_dl sad;
+       bzero(&sad, sizeof(sad));
+       sad.sdl_nlen = 3;
+       sad.sdl_len = 0;
+       sad.sdl_data[0] = 'l';
+       sad.sdl_data[1] = 'e';
+       sad.sdl_data[2] = '0';
+       sad.sdl_data[3] = 0x01;
+       sad.sdl_data[4] = 0x80;
+       sad.sdl_data[5] = 0xc2;
+       sad.sdl_data[6] = 0x00;
+       sad.sdl_data[7] = 0x00;
+       sad.sdl_data[8] = 0x02;
+       sad.sdl_data[9] = 0xaa;
+       sad.sdl_data[10] = 0xbb;
+       sad.sdl_data[11] = 0xcc;
+       sad.sdl_alen = 6;
+
+       char *foo = link_ntoa(&sad);
+
+       T_EXPECT_EQ_STR("le0:1.80.c2.0.0.2", foo, NULL);
+}
+
+T_DECL(link_ntoa_overflow, "link_ntoa try to overflow")
+{
+       char sockraw[64];
+       struct sockaddr_dl *sad;
+       sad = (struct sockaddr_dl *)&sockraw;
+       bzero(sad, sizeof(*sad));
+       sad->sdl_nlen = 3;
+       sad->sdl_len = 0;
+       sad->sdl_data[0] = 'l';
+       sad->sdl_data[1] = 'e';
+       sad->sdl_data[2] = '0';
+       sad->sdl_data[3] = 0x11;
+       sad->sdl_data[4] = 0x80;
+       sad->sdl_data[5] = 0xc2;
+       sad->sdl_data[6] = 0x11;
+       sad->sdl_data[7] = 0x11;
+       sad->sdl_data[8] = 0xa2;
+       sad->sdl_data[9] = 0xaa;
+       sad->sdl_data[10] = 0xbb;
+       sad->sdl_data[11] = 0xcc;
+       sockraw[20] = 0xdd;
+       sockraw[21] = 0xee;
+       sockraw[22] = 0xff;
+       sockraw[23] = 0x1a;
+       sockraw[24] = 0x1b;
+       sockraw[25] = 0x1c;
+       sockraw[26] = 0x1d;
+       sockraw[27] = 0x1e;
+       sockraw[28] = 0x1f;
+       sockraw[29] = 0x2a;
+       sockraw[30] = 0x2b;
+       sockraw[31] = 0x2c;
+
+       /* set the length to something that will fit in the buffer */
+       sad->sdl_alen = 20;
+
+       char *foo = link_ntoa(sad);
+
+       char over = foo[64];
+       char over2 = foo[65];
+
+       /* this string should be 66 bytes long and exceed the buffer */
+       sad->sdl_alen = 21;
+
+       foo = link_ntoa(sad);
+
+       T_EXPECT_EQ_STR("", foo, NULL);
+
+       T_EXPECT_EQ(over, foo[64], "did not overflow");
+       T_EXPECT_EQ(over2, foo[65], "did not overflow either");
+}
+
+T_DECL(inet_ntop, "inet_ntop")
+{
+       char *addresses4[] = { "1.2.3.4", "10.0.0.1", "2.2.2.2" };
+       char *addresses6[] = {
+               "2001:db8:85a3::8a2e:370:7334",
+               "::1", "::"
+       };
+       for (int i = 0; i < sizeof(addresses4)/sizeof(addresses4[0]); i++){
+               struct in_addr addr4;
+               char buf[64];
+               T_EXPECT_EQ(inet_pton(AF_INET, addresses4[i], &addr4), 1, "inet_pton(AF_INET, %s)", addresses4[i]);
+               char *str = inet_ntop(AF_INET, &addr4, buf, sizeof(buf));
+               T_EXPECT_NOTNULL(str, "inet_ntop(AF_INET) of %s", addresses4[i]);
+               T_EXPECT_EQ_STR(str, addresses4[i], "round-trip of %s", addresses4[i]);
+       }
+       for (int i = 0; i < sizeof(addresses6)/sizeof(addresses6[0]); i++){
+               struct in6_addr addr6;
+               char buf[64];
+               T_EXPECT_EQ(inet_pton(AF_INET6, addresses6[i], &addr6), 1, "inet_pton(AF_INET6, %s)", addresses6[i]);
+               char *str = inet_ntop(AF_INET6, &addr6, buf, sizeof(buf));
+               T_EXPECT_NOTNULL(str, "inet_ntop(AF_INET) of %s", addresses6[i]);
+               T_EXPECT_EQ_STR(str, addresses6[i], "round-trip of %s", addresses6[i]);
+       }
+}
diff --git a/tests/netbsd_getcwd.c b/tests/netbsd_getcwd.c
new file mode 100644 (file)
index 0000000..4c9580a
--- /dev/null
@@ -0,0 +1,104 @@
+/*     $NetBSD: t_getcwd.c,v 1.3 2011/07/27 05:04:11 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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: t_getcwd.c,v 1.3 2011/07/27 05:04:11 jruoho Exp $");
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fts.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <darwintest.h>
+
+T_DECL(getcwd_err, "Test error conditions in getcwd(3)")
+{
+       char buf[MAXPATHLEN];
+
+       errno = 0;
+
+       T_ASSERT_NULL(getcwd(buf, 0), NULL);
+       T_ASSERT_EQ(errno, EINVAL, NULL);
+}
+
+T_DECL(getcwd_fts, "A basic test of getcwd(3)")
+{
+       char buf[MAXPATHLEN];
+       char *args[2] = {"/System", NULL};
+       FTSENT *ftse;
+       FTS *fts;
+       int ops;
+       short depth;
+
+       /*
+        * Do not traverse too deep
+        */
+       depth = 2;
+
+       /*
+        * Test that getcwd(3) works with basic
+        * system directories. Note that having
+        * no FTS_NOCHDIR specified should ensure
+        * that the current directory is visited.
+        */
+       ops = FTS_PHYSICAL | FTS_NOSTAT;
+       fts = fts_open(args, ops, NULL);
+
+       T_ASSERT_NOTNULL(fts, NULL);
+
+       while ((ftse = fts_read(fts)) != NULL) {
+
+               if (ftse->fts_level < 1)
+                       continue;
+
+               if (ftse->fts_level > depth) {
+                       (void)fts_set(fts, ftse, FTS_SKIP);
+                       continue;
+               }
+
+               switch(ftse->fts_info) {
+
+               case FTS_DP:
+                       (void)memset(buf, 0, sizeof(buf));
+                       T_ASSERT_NOTNULL(getcwd(buf, sizeof(buf)), NULL);
+                       T_ASSERT_NOTNULL(strstr(ftse->fts_path, buf), NULL);
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       (void)fts_close(fts);
+}
diff --git a/tests/netbsd_getenv_thread.c b/tests/netbsd_getenv_thread.c
new file mode 100644 (file)
index 0000000..bfab97b
--- /dev/null
@@ -0,0 +1,165 @@
+/*     $NetBSD: t_getenv_thread.c,v 1.2 2012/03/15 02:02:23 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matthias Scheler.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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: t_getenv_thread.c,v 1.2 2012/03/15 02:02:23 joerg Exp $");
+
+#include <darwintest.h>
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#define        THREADED_NUM_THREADS    8
+#define        THREADED_NUM_VARS       16
+#define        THREADED_VAR_NAME       "THREADED%zu"
+#define        THREADED_RUN_TIME       10
+
+static void     *thread_putenv(void *);
+static void     *thread_setenv(void *);
+static void     *thread_unsetenv(void *);
+
+static void *
+thread_putenv(void *arg)
+{
+       time_t endtime;
+       size_t i;
+       static char vars[THREADED_NUM_VARS][128];
+
+       for (i = 0; i < THREADED_NUM_VARS; i++) {
+               (void)snprintf(vars[i], sizeof(vars[i]),
+                   THREADED_VAR_NAME "=putenv %ld", i, lrand48());
+       }
+
+       endtime = *(time_t *)arg;
+       do {
+               char name[128];
+
+               i = lrand48() % THREADED_NUM_VARS;
+               (void)strlcpy(name, vars[i], sizeof(name));
+               *strchr(name, '=') = '\0';
+
+               T_QUIET; T_ASSERT_POSIX_ZERO(unsetenv(name), NULL);
+               T_QUIET; T_ASSERT_POSIX_ZERO(putenv(vars[i]), NULL);
+       } while (time(NULL) < endtime);
+
+       return NULL;
+}
+
+static void *
+thread_setenv(void *arg)
+{
+       time_t endtime;
+
+       endtime = *(time_t *)arg;
+       do {
+               size_t i;
+               char name[32], value[64];
+
+               i = lrand48() % THREADED_NUM_VARS;
+               (void)snprintf(name, sizeof(name), THREADED_VAR_NAME, i);
+               (void)snprintf(value, sizeof(value), "setenv %ld", lrand48());
+
+               T_QUIET; T_ASSERT_POSIX_ZERO(setenv(name, value, 1), NULL);
+       } while (time(NULL) < endtime);
+
+       return NULL;
+}
+
+static void *
+thread_unsetenv(void *arg)
+{
+       time_t endtime;
+
+       endtime = *(time_t *)arg;
+       do {
+               size_t i;
+               char name[32];
+
+               i = lrand48() % THREADED_NUM_VARS;
+               (void)snprintf(name, sizeof(name), THREADED_VAR_NAME, i);
+
+               T_QUIET; T_ASSERT_POSIX_ZERO(unsetenv(name), NULL);
+       } while (time(NULL) < endtime);
+
+       return NULL;
+}
+
+T_DECL(putenv_thread, "Test concurrent access by putenv(3)")
+{
+       pthread_t threads[THREADED_NUM_THREADS];
+       time_t endtime = time(NULL) + THREADED_RUN_TIME;
+
+       for (int i = 0; i < THREADED_NUM_THREADS; i++) {
+               T_QUIET; T_ASSERT_POSIX_ZERO(
+                               pthread_create(&threads[i], NULL, thread_putenv, &endtime),
+                               NULL);
+       }
+       for (int i = 0; i < THREADED_NUM_THREADS; i++) {
+               T_QUIET; T_ASSERT_POSIX_ZERO(pthread_join(threads[i], NULL), NULL);
+       }
+       T_PASS("putenv_thread() completed successfully");
+}
+
+T_DECL(setenv_thread, "Test concurrent access by setenv(3)")
+{
+       pthread_t threads[THREADED_NUM_THREADS];
+       time_t endtime = time(NULL) + THREADED_RUN_TIME;
+
+       for (int i = 0; i < THREADED_NUM_THREADS; i++) {
+               T_QUIET; T_ASSERT_POSIX_ZERO(
+                               pthread_create(&threads[i], NULL, thread_setenv, &endtime),
+                               NULL);
+       }
+       for (int i = 0; i < THREADED_NUM_THREADS; i++) {
+               T_QUIET; T_ASSERT_POSIX_ZERO(pthread_join(threads[i], NULL), NULL);
+       }
+       T_PASS("setenv_thread() completed successfully");
+}
+
+T_DECL(unsetenv_thread, "Test unsetenv(3) with threads")
+{
+       pthread_t threads[THREADED_NUM_THREADS];
+       time_t endtime = time(NULL) + THREADED_RUN_TIME;
+
+       for (int i = 0; i < THREADED_NUM_THREADS; i++) {
+               T_QUIET; T_ASSERT_POSIX_ZERO(
+                               pthread_create(&threads[i], NULL, thread_unsetenv, &endtime),
+                               NULL);
+       }
+       for (int i = 0; i < THREADED_NUM_THREADS; i++) {
+               T_QUIET; T_ASSERT_POSIX_ZERO(pthread_join(threads[i], NULL), NULL);
+       }
+       T_PASS("unsetenv_thread() completed successfully");
+}
+
diff --git a/tests/netbsd_stat.c b/tests/netbsd_stat.c
new file mode 100644 (file)
index 0000000..a2dc5f9
--- /dev/null
@@ -0,0 +1,380 @@
+/* $NetBSD: t_stat.c,v 1.4 2012/03/17 08:37:08 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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: t_stat.c,v 1.4 2012/03/17 08:37:08 jruoho Exp $");
+
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+
+#include <arpa/inet.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <fts.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <stdio.h>
+
+#include <netinet/in.h>
+
+#include <darwintest.h>
+
+static const char *path = "/tmp/stat";
+
+T_DECL(stat_chflags, "Test chflags(2) with stat(2)")
+{
+       struct stat sa, sb;
+       int fd;
+
+       (void)memset(&sa, 0, sizeof(struct stat));
+       (void)memset(&sb, 0, sizeof(struct stat));
+
+       unlink(path);
+       T_ASSERT_POSIX_SUCCESS((fd = open(path, O_RDONLY | O_CREAT)), NULL);
+
+       T_ASSERT_POSIX_ZERO(stat(path, &sa), NULL);
+       T_ASSERT_POSIX_ZERO(chflags(path, UF_NODUMP), NULL);
+       T_ASSERT_POSIX_ZERO(stat(path, &sb), NULL);
+
+       T_EXPECT_NE(sa.st_flags, sb.st_flags | UF_NODUMP, "stat(2) detects chflags(2)");
+
+       T_ASSERT_POSIX_ZERO(close(fd), NULL);
+       T_ASSERT_POSIX_ZERO(unlink(path), NULL);
+}
+
+T_DECL(stat_dir, "Test stat(2) with directories")
+{
+       const short depth = 2;
+       struct stat sa, sb;
+       char *args[] = {"/System", NULL};
+       FTSENT *ftse;
+       FTS *fts;
+       int ops;
+
+       ops = FTS_NOCHDIR;
+       ops |= FTS_PHYSICAL;
+
+       T_ASSERT_NOTNULL(fts = fts_open(args, ops, NULL), NULL);
+
+       while ((ftse = fts_read(fts)) != NULL) {
+
+               if (ftse->fts_level < 1)
+                       continue;
+
+               if (ftse->fts_level > depth) {
+                       (void)fts_set(fts, ftse, FTS_SKIP);
+                       continue;
+               }
+
+               switch(ftse->fts_info) {
+
+               case FTS_DP:
+
+                       (void)memset(&sa, 0, sizeof(struct stat));
+                       (void)memset(&sb, 0, sizeof(struct stat));
+
+                       T_ASSERT_POSIX_ZERO(stat(ftse->fts_parent->fts_path,&sa), NULL);
+                       T_ASSERT_POSIX_ZERO(chdir(ftse->fts_path), NULL);
+                       T_ASSERT_POSIX_ZERO(stat(".", &sb), NULL);
+
+                       /*
+                        * The previous two stat(2) calls
+                        * should be for the same directory.
+                        */
+                       T_EXPECT_EQ(sa.st_dev, sb.st_dev, "stat(2) should return consistent device");
+                       T_EXPECT_EQ(sa.st_ino, sb.st_ino, "stat(2) should return consistent inode");
+
+                       T_EXPECT_EQ(sb.st_ino, ftse->fts_statp->st_ino, "stat(2) and fts(3) should not differ");
+
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       (void)fts_close(fts);
+}
+
+#if 0 // TODO: port me
+ATF_TC(stat_err);
+ATF_TC_HEAD(stat_err, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test errors from the stat(2) family");
+}
+
+ATF_TC_BODY(stat_err, tc)
+{
+       char buf[NAME_MAX + 1];
+       struct stat st;
+
+       (void)memset(buf, 'x', sizeof(buf));
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(EBADF, fstat(-1, &st) == -1);
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(ENAMETOOLONG, stat(buf, &st) == -1);
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(ENAMETOOLONG, lstat(buf, &st) == -1);
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(EFAULT, stat((void *)-1, &st) == -1);
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(EFAULT, lstat((void *)-1, &st) == -1);
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(EFAULT, stat("/etc/passwd", (void *)-1) == -1);
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(EFAULT, lstat("/etc/passwd", (void *)-1) == -1);
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(ENOENT, stat("/a/b/c/d/e/f/g/h/i/j/k", &st) == -1);
+
+       errno = 0;
+       ATF_REQUIRE_ERRNO(ENOENT, lstat("/a/b/c/d/e/f/g/h/i/j/k", &st) == -1);
+}
+
+ATF_TC_WITH_CLEANUP(stat_mtime);
+ATF_TC_HEAD(stat_mtime, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test modification times with stat(2)");
+}
+
+ATF_TC_BODY(stat_mtime, tc)
+{
+       struct stat sa, sb;
+       int fd[3];
+       size_t i;
+
+       for (i = 0; i < __arraycount(fd); i++) {
+
+               (void)memset(&sa, 0, sizeof(struct stat));
+               (void)memset(&sb, 0, sizeof(struct stat));
+
+               fd[i] = open(path, O_WRONLY | O_CREAT);
+
+               ATF_REQUIRE(fd[i] != -1);
+               ATF_REQUIRE(write(fd[i], "X", 1) == 1);
+               ATF_REQUIRE(stat(path, &sa) == 0);
+
+               (void)sleep(1);
+
+               ATF_REQUIRE(write(fd[i], "X", 1) == 1);
+               ATF_REQUIRE(stat(path, &sb) == 0);
+
+               ATF_REQUIRE(close(fd[i]) == 0);
+               ATF_REQUIRE(unlink(path) == 0);
+
+               if (sa.st_mtime == sb.st_mtime)
+                       atf_tc_fail("mtimes did not change");
+       }
+}
+
+ATF_TC_CLEANUP(stat_mtime, tc)
+{
+       (void)unlink(path);
+}
+
+ATF_TC_WITH_CLEANUP(stat_perm);
+ATF_TC_HEAD(stat_perm, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test permissions with stat(2)");
+       atf_tc_set_md_var(tc, "require.user", "root");
+}
+
+ATF_TC_BODY(stat_perm, tc)
+{
+       struct stat sa, sb;
+       gid_t gid;
+       uid_t uid;
+       int fd;
+
+       (void)memset(&sa, 0, sizeof(struct stat));
+       (void)memset(&sb, 0, sizeof(struct stat));
+
+       uid = getuid();
+       gid = getgid();
+
+       fd = open(path, O_RDONLY | O_CREAT);
+
+       ATF_REQUIRE(fd != -1);
+       ATF_REQUIRE(fstat(fd, &sa) == 0);
+       ATF_REQUIRE(stat(path, &sb) == 0);
+
+       if (gid != sa.st_gid || sa.st_gid != sb.st_gid)
+               atf_tc_fail("invalid GID");
+
+       if (uid != sa.st_uid || sa.st_uid != sb.st_uid)
+               atf_tc_fail("invalid UID");
+
+       ATF_REQUIRE(close(fd) == 0);
+       ATF_REQUIRE(unlink(path) == 0);
+}
+
+ATF_TC_CLEANUP(stat_perm, tc)
+{
+       (void)unlink(path);
+}
+
+ATF_TC_WITH_CLEANUP(stat_size);
+ATF_TC_HEAD(stat_size, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test file sizes with stat(2)");
+}
+
+ATF_TC_BODY(stat_size, tc)
+{
+       struct stat sa, sb, sc;
+       const size_t n = 10;
+       size_t i;
+       int fd;
+
+       fd = open(path, O_WRONLY | O_CREAT);
+       ATF_REQUIRE(fd >= 0);
+
+       for (i = 0; i < n; i++) {
+
+               (void)memset(&sa, 0, sizeof(struct stat));
+               (void)memset(&sb, 0, sizeof(struct stat));
+               (void)memset(&sc, 0, sizeof(struct stat));
+
+               ATF_REQUIRE(fstat(fd, &sa) == 0);
+               ATF_REQUIRE(write(fd, "X", 1) == 1);
+               ATF_REQUIRE(fstat(fd, &sb) == 0);
+               ATF_REQUIRE(stat(path, &sc) == 0);
+
+               if (sa.st_size + 1 != sb.st_size)
+                       atf_tc_fail("invalid file size");
+
+               if (sb.st_size != sc.st_size)
+                       atf_tc_fail("stat(2) and fstat(2) mismatch");
+       }
+
+       ATF_REQUIRE(close(fd) == 0);
+       ATF_REQUIRE(unlink(path) == 0);
+}
+
+ATF_TC_CLEANUP(stat_size, tc)
+{
+       (void)unlink(path);
+}
+
+ATF_TC(stat_socket);
+ATF_TC_HEAD(stat_socket, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test fstat(2) with "
+           "a socket (PR kern/46077)");
+}
+
+ATF_TC_BODY(stat_socket, tc)
+{
+       struct sockaddr_in addr;
+       struct stat st;
+       uint32_t iaddr;
+       int fd, flags;
+
+       (void)memset(&st, 0, sizeof(struct stat));
+       (void)memset(&addr, 0, sizeof(struct sockaddr_in));
+
+       fd = socket(AF_INET, SOCK_STREAM, 0);
+       ATF_REQUIRE(fd >= 0);
+
+       flags = fcntl(fd, F_GETFL);
+
+       ATF_REQUIRE(flags != -1);
+       ATF_REQUIRE(fcntl(fd, F_SETFL, flags | O_NONBLOCK) != -1);
+       ATF_REQUIRE(inet_pton(AF_INET, "127.0.0.1", &iaddr) == 1);
+
+       addr.sin_port = htons(42);
+       addr.sin_family = AF_INET;
+       addr.sin_addr.s_addr = iaddr;
+
+       errno = 0;
+
+       ATF_REQUIRE_ERRNO(EINPROGRESS,
+           connect(fd, (struct sockaddr *)&addr,
+               sizeof(struct sockaddr_in)) == -1);
+
+       errno = 0;
+
+       if (fstat(fd, &st) != 0 || errno != 0)
+               atf_tc_fail("fstat(2) failed for a EINPROGRESS socket");
+
+       (void)close(fd);
+}
+
+ATF_TC_WITH_CLEANUP(stat_symlink);
+ATF_TC_HEAD(stat_symlink, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test symbolic links with stat(2)");
+}
+
+ATF_TC_BODY(stat_symlink, tc)
+{
+       const char *pathlink = "pathlink";
+       struct stat sa, sb;
+       int fd;
+
+       (void)memset(&sa, 0, sizeof(struct stat));
+       (void)memset(&sb, 0, sizeof(struct stat));
+
+       fd = open(path, O_WRONLY | O_CREAT);
+
+       ATF_REQUIRE(fd >= 0);
+       ATF_REQUIRE(symlink(path, pathlink) == 0);
+       ATF_REQUIRE(stat(pathlink, &sa) == 0);
+       ATF_REQUIRE(lstat(pathlink, &sb) == 0);
+
+       if (S_ISLNK(sa.st_mode) != 0)
+               atf_tc_fail("stat(2) detected symbolic link");
+
+       if (S_ISLNK(sb.st_mode) == 0)
+               atf_tc_fail("lstat(2) did not detect symbolic link");
+
+       if (sa.st_mode == sb.st_mode)
+               atf_tc_fail("inconsistencies between stat(2) and lstat(2)");
+
+       ATF_REQUIRE(unlink(path) == 0);
+       ATF_REQUIRE(unlink(pathlink) == 0);
+}
+
+ATF_TC_CLEANUP(stat_symlink, tc)
+{
+       (void)unlink(path);
+}
+#endif
diff --git a/tests/netbsd_strptime.c b/tests/netbsd_strptime.c
new file mode 100644 (file)
index 0000000..b1d1909
--- /dev/null
@@ -0,0 +1,214 @@
+/* $NetBSD: t_strptime.c,v 1.1 2011/01/13 00:14:10 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Laight.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_strptime.c,v 1.1 2011/01/13 00:14:10 pgoyette Exp $");
+
+#include <time.h>
+
+#include <darwintest.h>
+
+static void
+h_pass(const char *buf, const char *fmt, int len,
+    int tm_sec, int tm_min, int tm_hour, int tm_mday,
+    int tm_mon, int tm_year, int tm_wday, int tm_yday)
+{
+       struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
+       const char *ret, *exp;
+
+       exp = buf + len;
+       ret = strptime(buf, fmt, &tm);
+
+       T_EXPECT_EQ(ret, exp,
+           "strptime(\"%s\", \"%s\", tm): should return end of string", buf, fmt);
+
+#define H_REQUIRE_FIELD(field)                                         \
+               T_EXPECT_EQ(tm.field, field, "strptime(\"%s\", \"%s\", tm): " #field, buf, fmt)
+
+       H_REQUIRE_FIELD(tm_sec);
+       H_REQUIRE_FIELD(tm_min);
+       H_REQUIRE_FIELD(tm_hour);
+       H_REQUIRE_FIELD(tm_mday);
+       H_REQUIRE_FIELD(tm_mon);
+       H_REQUIRE_FIELD(tm_year);
+       H_REQUIRE_FIELD(tm_wday);
+       H_REQUIRE_FIELD(tm_yday);
+
+#undef H_REQUIRE_FIELD
+}
+
+static void
+h_fail(const char *buf, const char *fmt)
+{
+       struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
+
+       T_EXPECT_NULL(strptime(buf, fmt, &tm), "strptime(\"%s\", \"%s\", &tm) should fail", buf, fmt);
+}
+
+T_DECL(strptime_common, "Checks strptime(3): various checks")
+{
+
+       h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
+               24, 46, 27, 23, 20, 0, 98, 2, 19);
+       h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
+               24, 46, 27, 23, 20, 0, 98, 2, 19);
+       h_pass("Tue Jan 20 23:27:46 1998", "%c",
+               24, 46, 27, 23, 20, 0, 98, 2, 19);
+       h_pass("Fri Mar  4 20:05:34 2005", "%a %b %e %H:%M:%S %Y",
+               24, 34, 5, 20, 4, 2, 105, 5, 62);
+       h_pass("5\t3  4 8pm:05:34 2005", "%w%n%m%t%d%n%k%p:%M:%S %Y",
+               21, 34, 5, 20, 4, 2, 105, 5, 62);
+       h_pass("Fri Mar  4 20:05:34 2005", "%c",
+               24, 34, 5, 20, 4, 2, 105, 5, 62);
+
+       h_pass("x20y", "x%Cy", 4, -1, -1, -1, -1, -1, 100, -1, -1);
+       h_pass("x84y", "x%yy", 4, -1, -1, -1, -1, -1, 84, -1, -1);
+       h_pass("x2084y", "x%C%yy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
+       h_pass("x8420y", "x%y%Cy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
+       h_pass("%20845", "%%%C%y5", 6, -1, -1, -1, -1, -1, 184, -1, -1);
+       h_fail("%", "%E%");
+
+       h_pass("1980", "%Y", 4, -1, -1, -1, -1, -1, 80, -1, -1);
+       h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
+
+       h_pass("0", "%S", 1, 0, -1, -1, -1, -1, -1, -1, -1);
+       h_pass("59", "%S", 2, 59, -1, -1, -1, -1, -1, -1, -1);
+       h_pass("60", "%S", 2, 60, -1, -1, -1, -1, -1, -1, -1);
+       // This was a pass in the NetBSD test, but the C standard says seconds need to be [0,60]
+       h_fail("61", "%S" /*, 2, 61, -1, -1, -1, -1, -1, -1, -1 */);
+       h_fail("62", "%S");
+}
+
+T_DECL(strptime_day, "Checks strptime(3): day names")
+{
+
+       h_pass("Sun", "%a", 3, -1, -1, -1, -1, -1, -1, 0, -1);
+       h_pass("Sunday", "%a", 6, -1, -1, -1, -1, -1, -1, 0, -1);
+       h_pass("Mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
+       h_pass("Monday", "%a", 6, -1, -1, -1, -1, -1, -1, 1, -1);
+       h_pass("Tue", "%a", 3, -1, -1, -1, -1, -1, -1, 2, -1);
+       h_pass("Tuesday", "%a", 7, -1, -1, -1, -1, -1, -1, 2, -1);
+       h_pass("Wed", "%a", 3, -1, -1, -1, -1, -1, -1, 3, -1);
+       h_pass("Wednesday", "%a", 9, -1, -1, -1, -1, -1, -1, 3, -1);
+       h_pass("Thu", "%a", 3, -1, -1, -1, -1, -1, -1, 4, -1);
+       h_pass("Thursday", "%a", 8, -1, -1, -1, -1, -1, -1, 4, -1);
+       h_pass("Fri", "%a", 3, -1, -1, -1, -1, -1, -1, 5, -1);
+       h_pass("Friday", "%a", 6, -1, -1, -1, -1, -1, -1, 5, -1);
+       h_pass("Sat", "%a", 3, -1, -1, -1, -1, -1, -1, 6, -1);
+       h_pass("Saturday", "%a", 8, -1, -1, -1, -1, -1, -1, 6, -1);
+       h_pass("Saturn", "%a", 3, -1, -1, -1, -1, -1, -1, 6, -1);
+       h_fail("Moon", "%a");
+       h_pass("Sun", "%A", 3, -1, -1, -1, -1, -1, -1, 0, -1);
+       h_pass("Sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
+       h_pass("Mon", "%A", 3, -1, -1, -1, -1, -1, -1, 1, -1);
+       h_pass("Monday", "%A", 6, -1, -1, -1, -1, -1, -1, 1, -1);
+       h_pass("Tue", "%A", 3, -1, -1, -1, -1, -1, -1, 2, -1);
+       h_pass("Tuesday", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
+       h_pass("Wed", "%A", 3, -1, -1, -1, -1, -1, -1, 3, -1);
+       h_pass("Wednesday", "%A", 9, -1, -1, -1, -1, -1, -1, 3, -1);
+       h_pass("Thu", "%A", 3, -1, -1, -1, -1, -1, -1, 4, -1);
+       h_pass("Thursday", "%A", 8, -1, -1, -1, -1, -1, -1, 4, -1);
+       h_pass("Fri", "%A", 3, -1, -1, -1, -1, -1, -1, 5, -1);
+       h_pass("Friday", "%A", 6, -1, -1, -1, -1, -1, -1, 5, -1);
+       h_pass("Sat", "%A", 3, -1, -1, -1, -1, -1, -1, 6, -1);
+       h_pass("Saturday", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
+       h_pass("Saturn", "%A", 3, -1, -1, -1, -1, -1, -1, 6, -1);
+       h_fail("Moon", "%A");
+
+       h_pass("mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
+       h_pass("tueSDay", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
+       h_pass("sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
+       h_pass("Sunday", "%EA", 6, -1, -1, -1, -1, -1, -1, 0, -1);
+       h_pass("SaturDay", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
+       h_pass("SaturDay", "%OA", 8, -1, -1, -1, -1, -1, -1, 6, -1);
+}
+
+T_DECL(strptime_month, "Checks strptime(3): month names")
+{
+
+       h_pass("Jan", "%b", 3, -1, -1, -1, -1, 0, -1, -1, -1);
+       h_pass("January", "%b", 7, -1, -1, -1, -1, 0, -1, -1, -1);
+       h_pass("Feb", "%b", 3, -1, -1, -1, -1, 1, -1, -1, -1);
+       h_pass("February", "%b", 8, -1, -1, -1, -1, 1, -1, -1, -1);
+       h_pass("Mar", "%b", 3, -1, -1, -1, -1, 2, -1, -1, -1);
+       h_pass("March", "%b", 5, -1, -1, -1, -1, 2, -1, -1, -1);
+       h_pass("Apr", "%b", 3, -1, -1, -1, -1, 3, -1, -1, -1);
+       h_pass("April", "%b", 5, -1, -1, -1, -1, 3, -1, -1, -1);
+       h_pass("May", "%b", 3, -1, -1, -1, -1, 4, -1, -1, -1);
+       h_pass("Jun", "%b", 3, -1, -1, -1, -1, 5, -1, -1, -1);
+       h_pass("June", "%b", 4, -1, -1, -1, -1, 5, -1, -1, -1);
+       h_pass("Jul", "%b", 3, -1, -1, -1, -1, 6, -1, -1, -1);
+       h_pass("July", "%b", 4, -1, -1, -1, -1, 6, -1, -1, -1);
+       h_pass("Aug", "%b", 3, -1, -1, -1, -1, 7, -1, -1, -1);
+       h_pass("August", "%b", 6, -1, -1, -1, -1, 7, -1, -1, -1);
+       h_pass("Sep", "%b", 3, -1, -1, -1, -1, 8, -1, -1, -1);
+       h_pass("September", "%b", 9, -1, -1, -1, -1, 8, -1, -1, -1);
+       h_pass("Oct", "%b", 3, -1, -1, -1, -1, 9, -1, -1, -1);
+       h_pass("October", "%b", 7, -1, -1, -1, -1, 9, -1, -1, -1);
+       h_pass("Nov", "%b", 3, -1, -1, -1, -1, 10, -1, -1, -1);
+       h_pass("November", "%b", 8, -1, -1, -1, -1, 10, -1, -1, -1);
+       h_pass("Dec", "%b", 3, -1, -1, -1, -1, 11, -1, -1, -1);
+       h_pass("December", "%b", 8, -1, -1, -1, -1, 11, -1, -1, -1);
+       h_pass("Mayor", "%b", 3, -1, -1, -1, -1, 4, -1, -1, -1);
+       h_pass("Mars", "%b", 3, -1, -1, -1, -1, 2, -1, -1, -1);
+       h_fail("Rover", "%b");
+       h_pass("Jan", "%B", 3, -1, -1, -1, -1, 0, -1, -1, -1);
+       h_pass("January", "%B", 7, -1, -1, -1, -1, 0, -1, -1, -1);
+       h_pass("Feb", "%B", 3, -1, -1, -1, -1, 1, -1, -1, -1);
+       h_pass("February", "%B", 8, -1, -1, -1, -1, 1, -1, -1, -1);
+       h_pass("Mar", "%B", 3, -1, -1, -1, -1, 2, -1, -1, -1);
+       h_pass("March", "%B", 5, -1, -1, -1, -1, 2, -1, -1, -1);
+       h_pass("Apr", "%B", 3, -1, -1, -1, -1, 3, -1, -1, -1);
+       h_pass("April", "%B", 5, -1, -1, -1, -1, 3, -1, -1, -1);
+       h_pass("May", "%B", 3, -1, -1, -1, -1, 4, -1, -1, -1);
+       h_pass("Jun", "%B", 3, -1, -1, -1, -1, 5, -1, -1, -1);
+       h_pass("June", "%B", 4, -1, -1, -1, -1, 5, -1, -1, -1);
+       h_pass("Jul", "%B", 3, -1, -1, -1, -1, 6, -1, -1, -1);
+       h_pass("July", "%B", 4, -1, -1, -1, -1, 6, -1, -1, -1);
+       h_pass("Aug", "%B", 3, -1, -1, -1, -1, 7, -1, -1, -1);
+       h_pass("August", "%B", 6, -1, -1, -1, -1, 7, -1, -1, -1);
+       h_pass("Sep", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
+       h_pass("September", "%B", 9, -1, -1, -1, -1, 8, -1, -1, -1);
+       h_pass("Oct", "%B", 3, -1, -1, -1, -1, 9, -1, -1, -1);
+       h_pass("October", "%B", 7, -1, -1, -1, -1, 9, -1, -1, -1);
+       h_pass("Nov", "%B", 3, -1, -1, -1, -1, 10, -1, -1, -1);
+       h_pass("November", "%B", 8, -1, -1, -1, -1, 10, -1, -1, -1);
+       h_pass("Dec", "%B", 3, -1, -1, -1, -1, 11, -1, -1, -1);
+       h_pass("December", "%B", 8, -1, -1, -1, -1, 11, -1, -1, -1);
+       h_pass("Mayor", "%B", 3, -1, -1, -1, -1, 4, -1, -1, -1);
+       h_pass("Mars", "%B", 3, -1, -1, -1, -1, 2, -1, -1, -1);
+       h_fail("Rover", "%B");
+
+       h_pass("september", "%b", 9, -1, -1, -1, -1, 8, -1, -1, -1);
+       h_pass("septembe", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
+}
diff --git a/tests/netbsd_vis.c b/tests/netbsd_vis.c
new file mode 100644 (file)
index 0000000..0670964
--- /dev/null
@@ -0,0 +1,122 @@
+/*     $NetBSD: t_vis.c,v 1.7 2014/09/08 19:01:03 christos Exp $       */
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code was contributed to The NetBSD Foundation by Christos Zoulas.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 <string.h>
+#include <stdlib.h>
+#include <err.h>
+#include <vis.h>
+
+#include <darwintest.h>
+
+static int styles[] = {
+       VIS_OCTAL,
+       VIS_CSTYLE,
+       VIS_SP,
+       VIS_TAB,
+       VIS_NL,
+       VIS_WHITE,
+       VIS_SAFE,
+#if 0  /* Not reversible */
+       VIS_NOSLASH,
+#endif
+       VIS_HTTP1808,
+       VIS_MIMESTYLE,
+#if 0  /* Not supported by vis(3) */
+       VIS_HTTP1866,
+#endif
+};
+
+#define SIZE   256
+
+T_DECL(strvis_basic, "strvis(3)")
+{
+       char *srcbuf, *dstbuf, *visbuf;
+       unsigned int i, j;
+
+       T_ASSERT_NOTNULL((srcbuf = malloc(SIZE)), NULL);
+       T_ASSERT_NOTNULL((dstbuf = malloc(SIZE + 1)), NULL);
+       T_ASSERT_NOTNULL((visbuf = malloc(SIZE * 4 + 1)), NULL);
+
+       for (i = 0; i < SIZE; i++)
+               srcbuf[i] = (char)i;
+
+       for (i = 0; i < sizeof(styles)/sizeof(styles[0]); i++) {
+               T_ASSERT_GT(strsvisx(visbuf, srcbuf, SIZE, styles[i], ""), 0, NULL);
+               memset(dstbuf, 0, SIZE);
+               T_ASSERT_GT(strunvisx(dstbuf, visbuf, 
+                   styles[i] & (VIS_HTTP1808|VIS_MIMESTYLE)), 0, NULL);
+               for (j = 0; j < SIZE; j++)
+                       if (dstbuf[j] != (char)j)
+                               T_FAIL("Failed for style %x, char %d [%d]", styles[i], j, dstbuf[j]);
+               if (dstbuf[SIZE] != '\0')
+                       T_FAIL("Failed for style %x, the result must be null-terminated [%d]", dstbuf[SIZE]);
+       }
+       free(dstbuf);
+       free(srcbuf);
+       free(visbuf);
+}
+
+T_DECL(strvis_null, "strvis(3) NULL")
+{
+       char dst[] = "fail";
+       strvis(dst, NULL, VIS_SAFE);
+       T_ASSERT_EQ(dst[0], '\0', NULL);
+       T_ASSERT_EQ(dst[1], 'a', NULL);
+}
+
+T_DECL(strvis_empty, "strvis(3) empty")
+{
+       char dst[] = "fail";
+       strvis(dst, "", VIS_SAFE);
+       T_ASSERT_EQ(dst[0], '\0', NULL);
+       T_ASSERT_EQ(dst[1], 'a', NULL);
+}
+
+T_DECL(strunvis_hex, "strunvis(3) \\Xxx")
+{
+       static const struct {
+               const char *e;
+               const char *d;
+               int error;
+       } ed[] = {
+               { "\\xff", "\xff", 1 },
+               { "\\x1", "\x1", 1 },
+               { "\\x1\\x02", "\x1\x2", 2 },
+               { "\\x1x", "\x1x", 2 },
+               { "\\xx", "", -1 },
+       };
+       char uv[10];
+
+       for (size_t i = 0; i < sizeof(ed)/sizeof(ed[0]); i++) {
+               T_ASSERT_EQ(strunvis(uv, ed[i].e), ed[i].error, NULL);
+               if (ed[i].error > 0)
+                       T_ASSERT_EQ(memcmp(ed[i].d, uv, (unsigned long)ed[i].error), 0, NULL);
+       }
+}
index eb521e8ee7459e77724aec4a4ebc58dd29e59ac0..d75dc489ba61b5e2fa2deece1a5a2828a98b957a 100644 (file)
@@ -1,53 +1,41 @@
-#include <bsdtests.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <signal.h>
+#include <setjmp.h>
 
-char *heap;
-volatile int pass;
-sigjmp_buf jbuf;
+#include <darwintest.h>
 
-void
+static char *heap;
+static volatile int pass;
+static sigjmp_buf jbuf;
+
+static void __dead2
 action(int signo, struct __siginfo *info, void *uap __attribute__((unused)))
 {
        if (info) {
                pass = (signo == SIGBUS && info->si_addr == heap);
        }
-       return siglongjmp(jbuf, 0);
+       siglongjmp(jbuf, 0);
 }
 
-int
-main(void)
+T_DECL(nxheap, "Non-executable heap", T_META_CHECK_LEAKS(NO))
 {
-       int ret;
-
        struct sigaction sa = {
                .__sigaction_u.__sa_sigaction = action,
                .sa_flags = SA_SIGINFO,
        };
 
-       test_start("Non-executable heap");
-       
-       ret = sigaction(SIGBUS, &sa, NULL);
-       assert(ret == 0);
-       test_long("sigaction", ret, 0);
+       T_ASSERT_POSIX_ZERO(sigaction(SIGBUS, &sa, NULL), NULL);
        
        if (sigsetjmp(jbuf, 0)) {
-               // PASS
-               test_long("SIGBUS", 1, 1);
-               test_stop();
-               return EXIT_FAILURE;
+               T_PASS("SIGBUS");
+               T_END;
        }
 
-       heap = malloc(1);
-       test_ptr_notnull("malloc", heap);
+       T_QUIET; T_ASSERT_NOTNULL((heap = malloc(1)), NULL);
 
-       *heap = 0xc3; // retq
+       *heap = (char)0xc3; // retq
        ((void (*)(void))heap)(); // call *%eax
 
-       // FAIL
-       test_long("SIGBUS", 0, 1);
-
-       test_stop();
-       
-       return EXIT_SUCCESS;
+       T_FAIL("SIGBUS");
 }
index 3dc421c01fb6f8669b671a993594ed3112cc3b2c..41986e1d0c60d439cb9de47d40ea2ab9172abb9c 100644 (file)
@@ -1,8 +1,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/time.h>
+#include <mach/clock_types.h>
 
-#include <bsdtests.h>
+#include <darwintest.h>
 
 typedef unsigned long T;
 
@@ -12,8 +13,7 @@ comparT(const void* a, const void* b) {
        return x < y ? -1 : x > y ? 1 : 0;
 }
 
-static void
-test_psort(void)
+T_DECL(psort, "psort(3)")
 {
        struct timeval tv_start, tv_stop;
        struct rusage ru_start, ru_stop;
@@ -58,16 +58,7 @@ test_psort(void)
        free(sorted);
        free(buf);
 
-       test_double_less_than_or_equal("psort/qsort wall time", (double)pwt/qwt, 1.0);
-       test_double_less_than_or_equal("qsort/psort user time", (double)qut/put, 1.0);
-       test_long("psort matches qsort", match, true);
-}
-
-int main(void)
-{
-       test_start("psort");
-       test_psort();
-       test_stop();
-
-       return 0;
+       T_MAYFAIL; T_EXPECT_LE((double)pwt/qwt, 1.0, "psort/qsort wall time");
+       T_MAYFAIL; T_EXPECT_LE((double)qut/put, 1.0, "qsort/psort user time");
+       T_EXPECT_TRUE(match, "psort matches qsort");
 }
diff --git a/tests/readpassphrase.c b/tests/readpassphrase.c
new file mode 100644 (file)
index 0000000..251404f
--- /dev/null
@@ -0,0 +1,25 @@
+#include <darwintest.h>
+
+#include <unistd.h>
+#include <readpassphrase.h>
+
+T_DECL(readpassphrase_stdin, "readpassphrase_stdin")
+{
+       int stdin_pipe[2] = { 0 };
+       char pwd[] = "ishouldnotbedoingthis\n";
+       char buff[128];
+
+       T_ASSERT_POSIX_ZERO(pipe(stdin_pipe),
+                       "must be able to create a pipe");
+       T_ASSERT_EQ(STDIN_FILENO, dup2(stdin_pipe[0], STDIN_FILENO),
+                       "must be able to re-register the read end of the pipe with STDIN_FILENO");
+       T_ASSERT_EQ((ssize_t) sizeof(pwd), write(stdin_pipe[1], pwd, sizeof(pwd)),
+                       "must be able to write into the pipe");
+       T_ASSERT_EQ((void *) buff, (void *) readpassphrase("", buff, sizeof(buff), RPP_STDIN),
+                       "readpassphrase must return its buffer argument on success");
+       // readpassphrase eats newlines
+       pwd[sizeof(pwd) - 2] = 0;
+       T_ASSERT_EQ_STR(buff, pwd,
+                       "readpassphrase with RPP_STDIN must capture stdin");
+}
+
diff --git a/tests/runtests b/tests/runtests
deleted file mode 100644 (file)
index abf8ea7..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/bin/bash -e
-# Copyright 2009-2014 Apple Inc. All rights reserved.
-
-BINDIR="%%BINDIR%%"
-BINDIR="${BINDIR/%%*%%/.}"
-
-# If not already set by bsdtesttool
-if [ -z "$BSDTESTS_TMPDIR" ]; then
-       BSDTESTS_TMPDIR="$(mktemp -d -t bsdtests)/"
-       export BSDTESTS_TMPDIR
-       echo "Using temp dir $BSDTESTS_TMPDIR"
-fi
-
-function dotest {
-       T="\"$BINDIR\"/bsdtestharness ./$1"
-       LOG="${BSDTESTS_TMPDIR}$1${2:+.$2}"
-       SEP="\n**** %-40s ****\n"
-       
-       if [ -n "$BSDTESTS_STRESS" ]; then
-               x=0
-               while (( x < BSDTESTS_STRESS )); do
-                       printf "$SEP" "$1 $2 stress $x"
-                       eval $ENVIRON $T 2>&1 | tee -a "$LOG.$x.testlog"
-                       let x+=1
-               done
-       else
-       printf "$SEP" "$1 $2"
-       eval $ENVIRON $T 2>&1 | tee -a "$LOG.testlog"
-       if [ -z "$BSDTESTS_PREBUILD" ]; then
-               printf "$SEP" "$1 debug $2"
-               eval $ENVIRON DYLD_IMAGE_SUFFIX=_debug $T 2>&1 | tee -a "$LOG.debuglog"
-       fi
-       fi
-}
-
-function runtest {
-       echo; echo "   Libc test: $1 ..."
-       ENVIRON="LIBDISPATCH_LOG=NO"
-       dotest "$1"
-       if [ -n "$(lipo -info /usr/lib/libSystem.dylib 2>&- | grep i386)" \
-                       -a "$(sysctl -n hw.optional.x86_64 2>&-)" = "1" ]; then
-               ENVIRON="$ENVIRON BSDTEST_ARCH=i386"
-               dotest "$1" "i386"
-       fi
-}
-
-cd $(dirname $0)
-rm -f "${BSDTESTS_TMPDIR}"*.{test,debug,gctest,gcdebug,leaks}log
-
-if [ "$1" == "--nosummary" ]; then
-       NOSUMMARY=1; shift
-fi
-
-if [ "$#" -gt 0 ]; then
-       if [ "$1" == "--help" ]; then
-               echo "Usage: $0 [--nosummary] [<test>|<test>|...]";
-               echo "          --nosummary             run all tests but do not summarize results at the end"
-               exit 0;
-       fi
-       for T in "$@"; do runtest $T; done
-else
-       for T in $(cat test_list.txt); do runtest $T; done
-fi
-
-if [ -z "$NOSUMMARY" -a -x "$BINDIR"/bsdtestsummarize ]; then
-       shopt -s nullglob
-       cat "${BSDTESTS_TMPDIR}"*.{test,debug,gctest,gcdebug}log | "$BINDIR"/bsdtestsummarize
-fi
-       
diff --git a/tests/stdio.c b/tests/stdio.c
new file mode 100644 (file)
index 0000000..d0e96b2
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <err.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/resource.h>
+
+#include <darwintest.h>
+
+#define FILE_LIMIT 100
+
+T_DECL(PR_22813396, "STREAM_MAX is affected by changes to RLIMIT_NOFILE")
+{
+       struct rlimit theLimit;
+       getrlimit( RLIMIT_NOFILE, &theLimit );
+       theLimit.rlim_cur = FILE_LIMIT;
+       setrlimit( RLIMIT_NOFILE, &theLimit );
+
+       long stream_max = sysconf(_SC_STREAM_MAX);
+       T_EXPECT_EQ_LONG(stream_max, (long)FILE_LIMIT, "stream_max = FILE_LIMIT");
+
+       FILE *f;
+       for(int i = 3; i < stream_max; i++) {
+               if((f = fdopen(0, "r")) == NULL) {
+                       T_FAIL("Failed after %d streams", i);
+               }
+       }
+
+       f = fdopen(0, "r");
+       T_EXPECT_NULL(f, "fdopen fail after stream_max streams");
+
+       theLimit.rlim_cur = FILE_LIMIT + 1;
+       setrlimit( RLIMIT_NOFILE, &theLimit );
+
+       f = fdopen(0, "r");
+       T_EXPECT_NOTNULL(f, "fdopen succeed after RLIMIT_NOFILE increased");
+}
diff --git a/tests/stdtime.c b/tests/stdtime.c
new file mode 100644 (file)
index 0000000..47e987a
--- /dev/null
@@ -0,0 +1,178 @@
+#include <stdio.h>
+#include <time.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include <err.h>
+
+#include <darwintest.h>
+
+T_DECL(strptime_PR_24428248, "strptime parse day of year %j does not work correctly")
+{
+       struct tm percent_j = {0};
+       struct tm standard = {0};
+       strptime("2007 80 0 0 15", "%Y %j %H %M %S", &percent_j);
+       strptime("2007-03-21 0:0:15", "%Y-%m-%d %H:%M:%S", &standard);
+       time_t percent_j_out = mktime(&percent_j);
+       time_t standard_out = mktime(&standard);
+       T_EXPECT_EQ(percent_j_out, standard_out, NULL);
+}
+
+T_DECL(strptime_PR_5879606, "alloca(strlen(input)) in strptime(\"%Z\")")
+{
+    struct tm tm;
+    time_t t = time(NULL);
+    size_t s = 100000000;
+    char *buf;
+
+       localtime_r(&t, &tm);
+       T_LOG("%s", asctime(&tm));
+       T_ASSERT_NOTNULL(strptime("GMT", "%Z", &tm), "strptime GMT");
+       T_LOG("%s", asctime(&tm));
+
+       localtime_r(&t, &tm);
+       T_ASSERT_NOTNULL(strptime("PST", "%Z", &tm), "strptime PST");
+       T_LOG("%s", asctime(&tm));
+
+       localtime_r(&t, &tm);
+       T_ASSERT_NOTNULL(strptime("PDT", "%Z", &tm), "strptime PDT");
+       T_LOG("%s", asctime(&tm));
+
+       T_QUIET; T_ASSERT_NOTNULL((buf = malloc(s)), NULL);
+       memset(buf, 'Z', s);
+       buf[s - 1] = 0;
+       T_ASSERT_NULL(strptime(buf, "%Z", &tm), NULL);
+    free(buf);
+}
+
+T_DECL(strptime_PR_6882179, "date command fails with 'illegal time format'")
+{
+    struct tm tm;
+    char buf[] = "Tue May 12 18:19:41 PDT 2009";
+
+    T_ASSERT_NOTNULL(strptime(buf, "%a %b %d %T %Z %Y", &tm), NULL);
+
+    T_EXPECT_EQ(tm.tm_sec, 0x29, NULL);
+    T_EXPECT_EQ(tm.tm_min, 0x13, NULL);
+    T_EXPECT_EQ(tm.tm_hour, 0x12, NULL);
+    T_EXPECT_EQ(tm.tm_mday, 0xc, NULL);
+    T_EXPECT_EQ(tm.tm_mon, 0x4, NULL);
+    T_EXPECT_EQ(tm.tm_year, 0x6d, NULL);
+    T_EXPECT_EQ(tm.tm_wday, 0x2, NULL);
+    T_EXPECT_EQ(tm.tm_yday, 0x83, NULL);
+}
+
+T_DECL(strptime_lukemftp, "year parsing"){
+       struct tm tm;
+       setlocale(LC_ALL, "C");
+       T_ASSERT_NOTNULL(strptime("20090505223446", "%Y%m%d%H%M%S", &tm), NULL);
+}
+
+T_DECL(strptime_five_digit_year, "strptime(%Y) with a 5 digit year")
+{
+    char *timestr = "20080922T020000";
+    struct tm tm;
+    bzero(&tm, sizeof(tm));
+    T_ASSERT_NOTNULL(strptime("10001", "%Y", &tm), NULL);
+    T_EXPECT_EQ(tm.tm_year, 10001 - 1900, NULL);
+    T_ASSERT_NOTNULL(strptime(timestr, "%Y%m%dT%H%M%S", &tm), NULL);
+}
+
+T_DECL(strptime_PR_10842560, "strptime() with %W and %U")
+{
+    const struct test {
+        const char *fmt;
+        const char *str;
+        const char *result;
+    } test[] = {
+        {"%Y:%U:%w:%H", "2012:6:0:23", "Sun Feb 05 2012 23:00"},
+        {"%Y:%w:%U:%H", "2012:0:6:23", "Sun Feb 05 2012 23:00"},
+        {"%U:%w:%Y:%H", "6:0:2012:23", "Sun Feb 05 2012 23:00"},
+        {"%U:%Y:%w:%H", "6:2012:0:23", "Sun Feb 05 2012 23:00"},
+        {"%w:%Y:%U:%H", "0:2012:6:23", "Sun Feb 05 2012 23:00"},
+        {"%w:%U:%Y:%H", "0:6:2012:23", "Sun Feb 05 2012 23:00"},
+        {"%Y:%V:%w:%H", "2012:6:0:23", "Sun Feb 12 2012 23:00"},
+        {"%Y:%w:%V:%H", "2012:0:6:23", "Sun Feb 12 2012 23:00"},
+        {"%V:%w:%Y:%H", "6:0:2012:23", "Sun Feb 12 2012 23:00"},
+        {"%V:%Y:%w:%H", "6:2012:0:23", "Sun Feb 12 2012 23:00"},
+        {"%w:%Y:%V:%H", "0:2012:6:23", "Sun Feb 12 2012 23:00"},
+        {"%w:%V:%Y:%H", "0:6:2012:23", "Sun Feb 12 2012 23:00"},
+        {"%Y:%W:%w:%H", "2012:6:0:23", "Sun Feb 12 2012 23:00"},
+        {"%Y:%w:%W:%H", "2012:0:6:23", "Sun Feb 12 2012 23:00"},
+        {"%W:%w:%Y:%H", "6:0:2012:23", "Sun Feb 12 2012 23:00"},
+        {"%W:%Y:%w:%H", "6:2012:0:23", "Sun Feb 12 2012 23:00"},
+        {"%w:%Y:%W:%H", "0:2012:6:23", "Sun Feb 12 2012 23:00"},
+        {"%w:%W:%Y:%H", "0:6:2012:23", "Sun Feb 12 2012 23:00"},
+        {"%Y:%U:%w:%H", "2011:6:0:23", "Sun Feb 06 2011 23:00"},
+        {"%Y:%U:%w:%H", "2010:6:0:23", "Sun Feb 07 2010 23:00"},
+        {"%Y:%U:%w:%H", "2009:6:0:23", "Sun Feb 08 2009 23:00"},
+        {"%Y:%U:%w:%H", "2008:6:0:23", "Sun Feb 10 2008 23:00"},
+        {"%Y:%U:%w:%H", "2007:6:0:23", "Sun Feb 11 2007 23:00"},
+        {"%Y:%U:%w:%H", "2006:6:0:23", "Sun Feb 05 2006 23:00"},
+        {"%Y:%V:%w:%H", "2011:6:0:23", "Sun Feb 13 2011 23:00"},
+        {"%Y:%V:%w:%H", "2010:6:0:23", "Sun Feb 14 2010 23:00"},
+        {"%Y:%V:%w:%H", "2009:6:0:23", "Sun Feb 08 2009 23:00"},
+        {"%Y:%V:%w:%H", "2008:6:0:23", "Sun Feb 10 2008 23:00"},
+        {"%Y:%V:%w:%H", "2007:6:0:23", "Sun Feb 11 2007 23:00"},
+        {"%Y:%V:%w:%H", "2006:6:0:23", "Sun Feb 12 2006 23:00"},
+        {"%Y:%W:%w:%H", "2011:6:0:23", "Sun Feb 13 2011 23:00"},
+        {"%Y:%W:%w:%H", "2010:6:0:23", "Sun Feb 14 2010 23:00"},
+        {"%Y:%W:%w:%H", "2009:6:0:23", "Sun Feb 15 2009 23:00"},
+        {"%Y:%W:%w:%H", "2008:6:0:23", "Sun Feb 17 2008 23:00"},
+        {"%Y:%W:%w:%H", "2007:6:0:23", "Sun Feb 11 2007 23:00"},
+        {"%Y:%W:%w:%H", "2006:6:0:23", "Sun Feb 12 2006 23:00"},
+        {NULL, NULL, NULL}
+    };
+    const struct test *tp;
+
+    for(tp = test; tp->fmt; tp++){
+        struct tm      Tm;
+        char          *s;
+        char Buf[100];
+
+        memset(&Tm,0,sizeof(Tm));
+        s = strptime(tp->str, tp->fmt, &Tm);
+        T_QUIET; T_EXPECT_NOTNULL(s, "strptime() should return non-NULL");
+        if (s) {
+            strftime(Buf, sizeof(Buf), "%a %b %d %Y %R", &Tm);
+            T_EXPECT_EQ_STR(Buf, tp->result, "%s | %s", tp->fmt, tp->str);
+        }
+    }
+}
+
+T_DECL(strptime_asctime, "strptime->asctime")
+{
+    char *test[] = {
+        "Sun,  6 Apr 2003 03:30:00 -0500",
+        "Sun,  6 Apr 2003 04:30:00 -0500",
+        "Sun,  6 Apr 2003 05:30:00 -0500",
+        "Sun,  6 Apr 2003 06:30:00 -0500",
+        "Wed, 17 Sep 2003 13:30:00 -0500",
+        "Sun, 26 Oct 2003 03:30:00 -0500",
+        "Sun, 26 Oct 2003 04:30:00 -0500",
+        "Sun, 26 Oct 2003 05:30:00 -0500",
+        "Sun, 26 Oct 2003 06:30:00 -0500",
+        NULL
+    };
+
+    char *result[] = {
+        "Sun Apr  6 00:30:00 2003\n",
+        "Sun Apr  6 01:30:00 2003\n",
+        "Sun Apr  6 03:30:00 2003\n",
+        "Sun Apr  6 04:30:00 2003\n",
+        "Wed Sep 17 11:30:00 2003\n",
+        "Sun Oct 26 01:30:00 2003\n",
+        "Sun Oct 26 01:30:00 2003\n",
+        "Sun Oct 26 02:30:00 2003\n",
+        "Sun Oct 26 03:30:00 2003\n",
+        NULL
+    };
+
+    int i = 0;
+    while (test[i]){
+        struct tm tm = {0};
+        strptime(test[i], "%a, %d %b %Y %H:%M:%S %z", &tm);
+        T_EXPECT_EQ_STR(result[i], asctime(&tm), "%s", test[i]);
+        i++;
+    }
+}
index 6e649d1c8b7bac38dd1cc3d7ce28530e48387530..af1713ce48e6af8c1c9af131571db007e1cd2f79 100644 (file)
@@ -1,30 +1,29 @@
-#include <bsdtests.h>
 #include <mach/mach_types.h>
 #include <sys/mman.h>
 #include <string.h>
 
+#include <darwintest.h>
+
 static const char* qbf = "The quick brown fox jumps over the lazy dog";
 static const char* lynx = "Lynx c.q. vos prikt bh: dag zwemjuf!";
 
-int
-main(void)
+T_DECL(strlcat, "strlcat(3)")
 {
-       test_start("strlcat");
 
        void *ptr = mmap(NULL, PAGE_SIZE*2, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
-       test_ptr_not("mmap", ptr, MAP_FAILED);
+       T_ASSERT_NE(ptr, MAP_FAILED, NULL);
 
-       test_errno("mprotect", mprotect(ptr+PAGE_SIZE, PAGE_SIZE, PROT_READ), 0);
+       T_ASSERT_POSIX_ZERO(mprotect(ptr+PAGE_SIZE, PAGE_SIZE, PROT_READ), NULL);
 
-       off_t offset = strlen(qbf)+strlen(lynx)+1;
+       size_t offset = strlen(qbf)+strlen(lynx)+1;
        char *dst = (ptr+PAGE_SIZE)-offset;
        strcpy(dst, qbf);
 
        size_t res = strlcat(dst, lynx, offset);
-       test_long("strlcat", res, offset-1);
-       test_long("memcmp", memcmp(dst, qbf, strlen(qbf)), 0);
-       test_long("memcmp", memcmp(dst+strlen(qbf), lynx, strlen(lynx)), 0);
-       test_long("null-term", dst[offset], 0);
+       T_ASSERT_EQ(res, offset-1, "strlcat");
+       T_ASSERT_EQ(memcmp(dst, qbf, strlen(qbf)), 0, NULL);
+       T_ASSERT_EQ(memcmp(dst+strlen(qbf), lynx, strlen(lynx)), 0, NULL);
+       T_ASSERT_EQ(dst[offset], 0, "null-term");
 
        memset(ptr, '\0', PAGE_SIZE);
 
@@ -33,11 +32,11 @@ main(void)
        strcpy(dst, qbf);
 
        res = strlcat(dst, lynx, offset);
-       test_long("strlcat", res, strlen(qbf)+strlen(lynx));
-       test_long("memcmp", memcmp(dst, qbf, strlen(qbf)), 0);
-       test_long("memcmp", memcmp(dst+strlen(qbf), lynx, offset-strlen(qbf)-1), 0);
-       test_long("overrun", *(char*)(ptr+PAGE_SIZE), 0);
-       test_long("null-term", dst[offset], 0);
+       T_ASSERT_EQ(res, strlen(qbf)+strlen(lynx), "strlcat");
+       T_ASSERT_EQ(memcmp(dst, qbf, strlen(qbf)), 0, NULL);
+       T_ASSERT_EQ(memcmp(dst+strlen(qbf), lynx, offset-strlen(qbf)-1), 0, NULL);
+       T_ASSERT_EQ(*(char*)(ptr+PAGE_SIZE), 0, NULL);
+       T_ASSERT_EQ(dst[offset], 0, "null-term");
 
        memset(ptr, '\0', PAGE_SIZE);
 
@@ -46,11 +45,21 @@ main(void)
        strncpy(dst, qbf, offset);
 
        res = strlcat(dst, lynx, offset);
-       test_long("strlcat", res, offset+strlen(lynx));
-       test_long("memcmp", memcmp(dst, qbf, offset), 0);
-       test_long("overrun", *(char*)(ptr+PAGE_SIZE), 0);
-       test_long("null-term", dst[offset], 0);
-
-       test_stop();
-       return EXIT_SUCCESS;
-}
\ No newline at end of file
+       T_ASSERT_EQ(res, offset+strlen(lynx), "strlcat");
+       T_ASSERT_EQ(memcmp(dst, qbf, offset), 0, NULL);
+       T_ASSERT_EQ(*(char*)(ptr+PAGE_SIZE), 0, NULL);
+       T_ASSERT_EQ(dst[offset], 0, "null-term");
+}
+
+T_DECL(strlcat_overlap, "strlcat(3) with overlap: PR-20105548")
+{
+       char buffer[21];
+       memset(buffer,'x',sizeof(buffer));
+       buffer[0]='\0';
+       buffer[20]='\0';
+
+       char *a = &buffer[0];
+       char *b = &buffer[10];
+       strlcat(a,b,10);
+       T_PASS("did not abort");
+}
diff --git a/tests/strptime.c b/tests/strptime.c
new file mode 100644 (file)
index 0000000..804c5ec
--- /dev/null
@@ -0,0 +1,10 @@
+#include <time.h>
+
+#include <darwintest.h>
+#include <darwintest_utils.h>
+
+T_DECL(PR_27004626, "strptime() should fail when a %t doesn't match anything")
+{
+       struct tm tm;
+       T_ASSERT_NULL(strptime("there'snotemplateforthis", "%t", &tm), NULL);
+}
diff --git a/tests/test_list.txt b/tests/test_list.txt
deleted file mode 100644 (file)
index 0a17ea1..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-nxheap
-strlcat
-psort
diff --git a/tests/wchar.c b/tests/wchar.c
new file mode 100644 (file)
index 0000000..07d9aaa
--- /dev/null
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+#include <darwintest.h>
+
+/* 
+ * Test courtesy of Roel Standaert
+ * Source: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209907 
+ */
+T_DECL(PR_26556792, "wcsrtombs neglects to set src pointer on EILSEQ error")
+{
+    char out[64];
+    wchar_t *in = L"Hello! \x20AC Hello!";
+    const wchar_t *inptr = in;
+    mbstate_t state = {{0}};
+
+    T_ASSERT_EQ((size_t)-1, wcsrtombs(out, &inptr, sizeof(out), &state), NULL);
+    T_EXPECT_EQ((long)(inptr - in), (long)7, NULL);
+}
+
+
+T_DECL(PR_26828480, "double free in __vfwprintf")
+{
+    wchar_t *test;
+    int ret;
+
+    test = (wchar_t *) malloc(512 * sizeof(wchar_t));
+    ret = swprintf(test, 512, L"%a, %s\n", 3.14, (char *) NULL);
+
+    free(test);
+    T_ASSERT_GT(ret, 0, "swprintf");
+}
index fb02297278e1346d02d1250df992d007f0176e65..b830b3f63e396f5d93d2b876feb021c0feca6c58 100644 (file)
 #include <string.h>
 #include <errno.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 
-/* This extended version of mkpath_np is provided to help NSFileManager
- * maintain  binary compatibility.  If firstdir is not NULL, *firstdir will be
- * set to the path of the first created directory, and it is the caller's
- * responsibility to free the returned string.  This SPI is subject to removal
- * once NSFileManager no longer has a need for it, and use in new code is
- * highly discouraged.
- *
- * See: <rdar://problem/9888987>
- */
-
-int
-_mkpath_np(const char *path, mode_t omode, const char ** firstdir)
+static int
+_mkpath(int dfd, const char *path, mode_t omode, const char ** firstdir)
 {
        char *apath = NULL, *opath = NULL, *s, *sn, *sl;
        unsigned int depth = 0;
@@ -48,7 +39,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
        struct stat sbuf;
 
        /* Try the trivial case first. */
-       if (0 == mkdir(path, omode)) {
+       if (0 == mkdirat(dfd, path, omode)) {
                if (firstdir) {
                        *firstdir = strdup(path);
                }
@@ -63,7 +54,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
                case ENOENT:
                        break;
                case EEXIST:
-                       if (stat(path, &sbuf) == 0) {
+                       if (fstatat(dfd, path, &sbuf, 0) == 0) {
                            if (S_ISDIR(sbuf.st_mode)) {
                                        retval = EEXIST;
                                } else {
@@ -107,7 +98,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
        }
 
        /* Retry the trivial case after having stripped of trailing /. <rdar://problem/14351794> */
-       if (0 == mkdir(path, omode)) {
+       if (0 == mkdirat(dfd, path, omode)) {
                if (firstdir) {
                        *firstdir = strdup(path);
                }
@@ -127,7 +118,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
                *s = '\0';
                depth++;
 
-               if (0 == mkdir(apath, S_IRWXU | S_IRWXG | S_IRWXO)) {
+               if (0 == mkdirat(dfd, apath, S_IRWXU | S_IRWXG | S_IRWXO)) {
                        /* Found our starting point */
 
                        /* POSIX 1003.2:
@@ -140,7 +131,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
                         */
 
                        struct stat dirstat;
-                       if (-1 == stat(apath, &dirstat)) {
+                       if (-1 == fstatat(dfd, apath, &dirstat, 0)) {
                                /* Really unfortunate timing ... */
                                retval = ENOENT;
                                goto mkpath_exit;
@@ -148,7 +139,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
 
                        if ((dirstat.st_mode & (S_IWUSR | S_IXUSR)) != (S_IWUSR | S_IXUSR)) {
                                chmod_mode = dirstat.st_mode | S_IWUSR | S_IXUSR;
-                               if (-1 == chmod(apath, chmod_mode)) {
+                               if (-1 == fchmodat(dfd, apath, chmod_mode, 0)) {
                                        /* Really unfortunate timing ... */
                                        retval = ENOENT;
                                        goto mkpath_exit;
@@ -164,7 +155,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
                         * before we did.  We will use this as our starting point.
                         * See: <rdar://problem/10279893>
                         */
-                       if (stat(apath, &sbuf) == 0 &&
+                       if (fstatat(dfd, apath, &sbuf, 0) == 0 &&
                            S_ISDIR(sbuf.st_mode)) {
 
                                if (firstdir) {
@@ -187,7 +178,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
                *s = '/';
                depth--;
 
-               if (-1 == mkdir(apath, S_IRWXU | S_IRWXG | S_IRWXO)) {
+               if (-1 == mkdirat(dfd, apath, S_IRWXU | S_IRWXG | S_IRWXO)) {
                        /* This handles "." and ".." added to the new section of path */
                        if (errno == EEXIST)
                                continue;
@@ -196,7 +187,7 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
                }
 
                if (chmod_mode) {
-                       if (-1 == chmod(apath, chmod_mode)) {
+                       if (-1 == fchmodat(dfd, apath, chmod_mode, 0)) {
                                /* Really unfortunate timing ... */
                                retval = ENOENT;
                                goto mkpath_exit;
@@ -204,10 +195,10 @@ _mkpath_np(const char *path, mode_t omode, const char ** firstdir)
                }
        }
 
-       if (-1 == mkdir(path, omode)) {
+       if (-1 == mkdirat(dfd, path, omode)) {
                retval = errno;
                if (errno == EEXIST &&
-                   stat(path, &sbuf) == 0 &&
+                   fstatat(dfd, path, &sbuf, 0) == 0 &&
                    !S_ISDIR(sbuf.st_mode)) {
                        retval = ENOTDIR;
                }
@@ -221,6 +212,25 @@ mkpath_exit:
        return retval;
 }
 
+/* This extended version of mkpath_np is provided to help NSFileManager
+ * maintain  binary compatibility.  If firstdir is not NULL, *firstdir will be
+ * set to the path of the first created directory, and it is the caller's
+ * responsibility to free the returned string.  This SPI is subject to removal
+ * once NSFileManager no longer has a need for it, and use in new code is
+ * highly discouraged.
+ *
+ * See: <rdar://problem/9888987>
+ */
+
+int
+_mkpath_np(const char *path, mode_t omode, const char ** firstdir) {
+       return _mkpath(AT_FDCWD, path, omode, firstdir);
+}
+
 int mkpath_np(const char *path, mode_t omode) {
-       return _mkpath_np(path, omode, NULL);
+       return _mkpath(AT_FDCWD, path, omode, NULL);
+}
+
+int mkpathat_np(int dfd, const char *path, mode_t omode) {
+       return _mkpath(dfd, path, omode, NULL);
 }
diff --git a/xcodescripts/alias.list b/xcodescripts/alias.list
new file mode 100644 (file)
index 0000000..651244e
--- /dev/null
@@ -0,0 +1,14 @@
+__platform_bzero _bzero
+__platform_memccpy _memccpy
+__platform_memchr _memchr
+__platform_memcmp _memcmp
+__platform_memcmp _bcmp
+__platform_memmove _memmove
+__platform_memmove _memcpy
+__platform_memset _memset
+__platform_memset_pattern16 _memset_pattern16
+__platform_memset_pattern4 _memset_pattern4
+__platform_memset_pattern8 _memset_pattern8
+__platform_strchr _strchr
+__platform_strcmp _strcmp
+__platform_strncmp _strncmp
index c5c06aac9dd2e6a8aade7bc4a20cf5dffc5bf01b..59bf260ccde2064b7d455bdd761065e538e7b7f2 100755 (executable)
@@ -16,22 +16,27 @@ DEBUG_LIST="$BUILT_PRODUCTS_DIR/debug.linklist"
 INTERPOSABLE_LIST="$DERIVED_FILES_DIR/interposable.list"
 UNEXPORT_LIST="$DERIVED_FILES_DIR/unexport.list"
 
-rm -f $NORMAL_LIST
-rm -f $DEBUG_LIST
-rm -f $INTERPOSABLE_LIST
-rm -f $UNEXPORT_LIST
+rm -f "$NORMAL_LIST"
+rm -f "$DEBUG_LIST"
+rm -f "$INTERPOSABLE_LIST"
+rm -f "$UNEXPORT_LIST"
 
 for x in ${BUILD_ARCHIVES[@]}; do
        nm -AUamgf "$BUILT_PRODUCTS_DIR/lib${x}.a" 2>/dev/null | \
                grep '__TEXT,__text' | \
                grep -vE '\$VARIANT' | \
-               awk '{ print $NF }' >> $INTERPOSABLE_LIST
+               awk '{ print $NF }' >> "$INTERPOSABLE_LIST"
 
        nm -AUamgf "$BUILT_PRODUCTS_DIR/lib${x}.a" 2>/dev/null | \
-               awk '/\$VARIANT/ { print $NF }' >> $UNEXPORT_LIST
+               awk '/\$VARIANT/ { print $NF }' >> "$UNEXPORT_LIST"
 
-       echo "$BUILT_PRODUCTS_DIR/lib${x}.a" >> $NORMAL_LIST
-       echo "$BUILT_PRODUCTS_DIR/lib${x}_debug.a" >> $DEBUG_LIST
+       echo "$BUILT_PRODUCTS_DIR/lib${x}.a" >> "$NORMAL_LIST.libtool"
+       filename=$(printf %s "$BUILT_PRODUCTS_DIR/lib${x}.a" | sed "s/\ /\\\ /g")
+       echo "$filename" >> "$NORMAL_LIST"
+
+       echo "$BUILT_PRODUCTS_DIR/lib${x}_debug.a" >> "$DEBUG_LIST.libtool"
+       filename=$(printf %s "$BUILT_PRODUCTS_DIR/lib${x}_debug.a" | sed "s/\ /\\\ /g")
+       echo "$filename" >> "$DEBUG_LIST"
 done
 
 touch "$BUILT_PRODUCTS_DIR/deps.c"
index d0b87e7ccb2348df6482259f945e9999c748cac6..f2cbedd0ec3b7077d8e0374e12c940d7d9ce81e1 100644 (file)
@@ -4,7 +4,7 @@ BUILD_ARCHIVES = Base FreeBSD TRE vCancelable vDarwinExtsn
 BUILD_VARIANTS = normal
 EXECUTABLE_PREFIX = lib
 INSTALL_PATH = /usr/local/lib/eOS
-OTHER_LIBTOOLFLAGS = -filelist $(BUILT_PRODUCTS_DIR)/$(CURRENT_VARIANT).linklist
+OTHER_LIBTOOLFLAGS = -filelist $(BUILT_PRODUCTS_DIR)/$(CURRENT_VARIANT).linklist.libtool
 PRODUCT_NAME = c_eOS
 SKIP_INSTALL = YES
 SKIP_INSTALL[sdk=iphoneos*] = NO
@@ -21,7 +21,7 @@ INCLUDED_SOURCE_FILE_NAMES =
 INCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*] = $(VARIANT_EOS_INCLUDED_FILES)
 INCLUDED_SOURCE_FILE_NAMES[sdk=watchos*] = $(VARIANT_EOS_INCLUDED_FILES)
 INCLUDED_SOURCE_FILE_NAMES[sdk=appletvos*] = $(VARIANT_EOS_INCLUDED_FILES)
-VARIANT_PREPROCESSOR_MACROS = -UBUILDING_VARIANT -DVARIANT_DYLD -DVARIANT_EOS -DVARIANT_CANCELABLE -DVARIANT_DARWINEXTSN -U__DARWIN_NON_CANCELABLE -D__DARWIN_NON_CANCELABLE=0
+VARIANT_PREPROCESSOR_MACROS = -UBUILDING_VARIANT -DVARIANT_STATIC -DVARIANT_EOS -DVARIANT_CANCELABLE -DVARIANT_DARWINEXTSN -U__DARWIN_NON_CANCELABLE -D__DARWIN_NON_CANCELABLE=0
 
 SYSTEM_FRAMEWORK_HEADERS = $(DERIVED_FILES_DIR)/System.framework/Versions/B/PrivateHeaders
 HEADER_SEARCH_PATHS = $(FreeBSD_SEARCH_PATHS) $(inherited)
index d4ed3029c766cf6cacabaad072dae8a787ab260f..28b1c1edab9dc09db9bc58966b7dde11d3bba3cb 100644 (file)
@@ -10,4 +10,4 @@ if [ "x$ACTION" == "xinstallhdrs" ]; then exit 0; fi
 
 DEPS_C="$BUILT_PRODUCTS_DIR/deps.c"
 
-[ -e $DEPS_C ] && rm -f $DEPS_C
+[ -e "$DEPS_C" ] && rm -f "$DEPS_C"
index ac5479559ac3ea2c10a3f8033622be14a12dcfc6..e2d689f5e31697fd275fa562e40dd66d509034fd 100755 (executable)
@@ -19,8 +19,14 @@ for my $arch (split(/ /, $ENV{"ARCHS"}))
 {
        # set ENV{"CURRENT_ARCH"} so we can predicate on it
        $ENV{"CURRENT_ARCH"} = $arch;
-       
+
+       # BridgeOS shares the same platform name than the watch so
+       # we need to fix it and pick the right configuration.
        my $platformName = $ENV{"PLATFORM_NAME"};
+       if ($ENV{"RC_BRIDGE"} eq "YES") {
+               $platformName = "bridgeos";
+       }
+
        $platformName =~ s/simulator/os/;
 
        my $platformPath = $ENV{"SRCROOT"} . "/Platforms/" . $platformName . "/Makefile.inc";
@@ -122,6 +128,7 @@ for my $arch (split(/ /, $ENV{"ARCHS"}))
 
                my $shortarch = $arch;
                $shortarch =~ s/armv\d+[a-z]?/arm/g;
+               $shortarch =~ s/arm64_32/arm64/g;
 
                printf HEADER "#if !defined(__".$shortarch."__)\n";
                printf HEADER "#error Mismatched libc-features.h architecture\n";
index b8c99c9e5c0b6f8f02a1b762bd5211d89f78f85f..d447595b7db5c6750b2764dedafc8f32a237653d 100755 (executable)
@@ -178,7 +178,6 @@ TYPES_INSTHDRS=(
 
 LOCALHDRS=(
        ${SRCROOT}/darwin/libc_private.h
-       ${SRCROOT}/gen/assumes.h
        ${SRCROOT}/gen/utmpx_thread.h
        ${SRCROOT}/nls/FreeBSD/msgcat.h
 )
index 125f0c8b28b74acc83bd1f65caec90783d7dbf18..3559c3499829650174f2464b468d94fbba4a7f9c 100644 (file)
@@ -24,7 +24,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES;
 GCC_WARN_UNUSED_VARIABLE = YES;
 GCC_WARN_ABOUT_RETURN_TYPE = YES;
 //WARNING_CFLAGS = -Wall -Wextra
-WARNING_CFLAGS = -Wall
+WARNING_CFLAGS = -Wall -Werror=incompatible-pointer-types -Wno-error=incompatible-pointer-types-discards-qualifiers -Wno-nullability-completeness
 
 COPY_PHASE_STRIP = NO
 SKIP_INSTALL = YES
@@ -64,11 +64,11 @@ LIBPTHREAD_LDFLAGS = -lsystem$(SIM_SUFFIX)_pthread
 LIBSYSCALL_LDFLAGS = -lsystem$(SIM_SUFFIX)_kernel
 LIBM_LDFLAGS = -lsystem$(SIM_SUFFIX)_m
 LIBDYLD_LDFLAGS = -ldyld
-LIBSYSTEM_C_LDFLAGS = -all_load -nostdlib -L/usr/lib/system -umbrella System $(CR_LDFLAGS) $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBM_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(UPWARD_LDFLAGS) -Wl,-interposable_list,$(DERIVED_FILES_DIR)/interposable.list -Wl,-unexported_symbols_list,$(DERIVED_FILES_DIR)/unexport.list -Wl,-alias_list,$(SRCROOT)/string/alias.list -Wl,-order_file,$(SRCROOT)/xcodescripts/Libc.order -Wl,-sectalign,__DATA,__data,1000 @$(BUILT_PRODUCTS_DIR)/$(CURRENT_VARIANT).linklist
+LIBSYSTEM_C_LDFLAGS = -all_load -nostdlib -L/usr/lib/system -umbrella System $(CR_LDFLAGS) $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBM_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(UPWARD_LDFLAGS) -Wl,-interposable_list,$(DERIVED_FILES_DIR)/interposable.list -Wl,-unexported_symbols_list,$(DERIVED_FILES_DIR)/unexport.list -Wl,-alias_list,$(SRCROOT)/xcodescripts/alias.list -Wl,-order_file,$(SRCROOT)/xcodescripts/Libc.order -Wl,-sectalign,__DATA,__data,1000 @$(BUILT_PRODUCTS_DIR)/$(CURRENT_VARIANT).linklist
 
 // TODO: Remove upward links - mostly <rdar://problem/13183469>, macho is for assumes.c
-UPWARD_LDFLAGS = -Wl,-upward-ldispatch -Wl,-upward-llaunch -Wl,-upward-lmacho -Wl,-upward-lsystem_asl -Wl,-upward-lsystem_blocks -Wl,-upward-lsystem_info -Wl,-upward-lsystem_notify -Wl,-upward-lxpc
-UPWARD_LDFLAGS[sdk=*simulator*] = -Wl,-upward-ldispatch -Wl,-upward-lmacho_sim -Wl,-upward-lsystem_asl -Wl,-upward-lsystem_sim_blocks -Wl,-upward-lsystem_sim_info -Wl,-upward-lsystem_notify -Wl,-upward-lxpc
+UPWARD_LDFLAGS = -Wl,-upward-ldispatch -Wl,-upward-llaunch -Wl,-upward-lmacho -Wl,-upward-lsystem_asl -Wl,-upward-lsystem_blocks -Wl,-upward-lsystem_info -Wl,-upward-lsystem_notify -Wl,-upward-lxpc -Wl,-upward-lcorecrypto
+UPWARD_LDFLAGS[sdk=*simulator*] = -Wl,-upward-ldispatch -Wl,-upward-lmacho_sim -Wl,-upward-lsystem_asl -Wl,-upward-lsystem_sim_blocks -Wl,-upward-lsystem_sim_info -Wl,-upward-lsystem_notify -Wl,-upward-lxpc -Wl,-upward-lcorecrypto
 
 // libPlatform.a architectures
 ARCH_FAMILY = $(ARCH_FAMILY_$(CURRENT_ARCH))
diff --git a/xcodescripts/libc_static.xcconfig b/xcodescripts/libc_static.xcconfig
new file mode 100644 (file)
index 0000000..d6f7765
--- /dev/null
@@ -0,0 +1,21 @@
+#include "libc.xcconfig"
+
+BUILD_ARCHIVES = Base FreeBSD TRE vCancelable vDarwinExtsn
+BUILD_VARIANTS = normal debug
+EXECUTABLE_PREFIX = lib
+INSTALL_PATH = /usr/local/lib/system
+OTHER_LIBTOOLFLAGS = -filelist $(BUILT_PRODUCTS_DIR)/$(CURRENT_VARIANT).linklist.libtool
+PRODUCT_NAME = c
+SKIP_INSTALL = NO
+STRIP_INSTALLED_PRODUCT = NO
+VARIANT = STATIC_VERSION
+VERSIONING_SYSTEM = apple-generic
+
+// Only include what's needed
+EXCLUDED_SOURCE_FILE_NAMES = *
+INCLUDED_SOURCE_FILE_NAMES = secure/*.c $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.c $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.S $(ARCH_FAMILY_$(CURRENT_ARCH))/*/*.s
+
+VARIANT_PREPROCESSOR_MACROS = -UBUILDING_VARIANT -DVARIANT_STATIC -DVARIANT_CANCELABLE -DVARIANT_DARWINEXTSN -U__DARWIN_NON_CANCELABLE -D__DARWIN_NON_CANCELABLE=0
+
+SYSTEM_FRAMEWORK_HEADERS = $(DERIVED_FILES_DIR)/System.framework/Versions/B/PrivateHeaders
+HEADER_SEARCH_PATHS = $(FreeBSD_SEARCH_PATHS) $(inherited)
diff --git a/xcodescripts/skip_installhdrs.sh b/xcodescripts/skip_installhdrs.sh
new file mode 100644 (file)
index 0000000..9256418
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+if [[ "x${ACTION}" == "xinstallhdrs" ]]; then
+       exit 0
+fi
+
+$@
index ac21aa6d21145526a36727f1da900498eec8e507..6134dccf710d6a25dbfa4f039f8435ac63aba28a 100644 (file)
@@ -72,7 +72,7 @@ VARIANT_INODE32_INCLUDE_sys = statx_np.c
 
 // DYLD (libc.a)
 
-VARIANT_DYLD_MACROS = -UBUILDING_VARIANT -DVARIANT_DYLD -DVARIANT_CANCELABLE -DVARIANT_DARWINEXTSN -U__DARWIN_NON_CANCELABLE -D__DARWIN_NON_CANCELABLE=0
+VARIANT_DYLD_MACROS = -UBUILDING_VARIANT -DVARIANT_STATIC -DVARIANT_CANCELABLE -DVARIANT_DARWINEXTSN -U__DARWIN_NON_CANCELABLE -D__DARWIN_NON_CANCELABLE=0
 
 VARIANT_DYLD_INCLUDE = $(VARIANT_DYLD_INCLUDE_generic) $(VARIANT_DYLD_INCLUDE_$(CURRENT_ARCH))