summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2013-09-05 20:18:59 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2013-09-05 20:18:59 +0000
commitd1d015864103b253b3fcb2f72a0da5b0cfeb31b6 (patch)
tree22b131dceb13c3df96da594fbaadb693504797c7 /lib
parent12d4083451fc39b3e831d4ea0bfa67d3b32cfb54 (diff)
parentb6f49c23a36f329cbf1e7f28078e17fd87f0e245 (diff)
downloadsrc-test2-d1d015864103b253b3fcb2f72a0da5b0cfeb31b6.tar.gz
src-test2-d1d015864103b253b3fcb2f72a0da5b0cfeb31b6.zip
Notes
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile19
-rw-r--r--lib/bind/config.h15
-rw-r--r--lib/bind/dns/Makefile6
-rw-r--r--lib/bind/dns/code.h209
-rw-r--r--lib/bind/dns/dns/enumtype.h14
-rw-r--r--lib/bind/dns/dns/rdatastruct.h251
-rw-r--r--lib/bind/isc/Makefile7
-rw-r--r--lib/clang/Makefile2
-rw-r--r--lib/clang/clang.build.mk130
-rw-r--r--lib/clang/include/ARMGenEDInfo.inc2
-rw-r--r--lib/clang/include/Makefile4
-rw-r--r--lib/clang/include/MipsGenEDInfo.inc2
-rw-r--r--lib/clang/include/X86GenEDInfo.inc2
-rw-r--r--lib/clang/include/clang/AST/AttrDump.inc2
-rw-r--r--lib/clang/include/clang/AST/CommentCommandList.inc2
-rw-r--r--lib/clang/include/clang/AST/CommentHTMLNamedCharacterReferences.inc2
-rw-r--r--lib/clang/include/clang/Basic/Version.inc8
-rw-r--r--lib/clang/include/clang/Parse/AttrExprArgs.inc2
-rw-r--r--lib/clang/include/clang/Sema/AttrSpellingListIndex.inc2
-rw-r--r--lib/clang/include/llvm/Config/config.h52
-rw-r--r--lib/clang/include/llvm/Config/llvm-config.h12
-rw-r--r--lib/clang/include/llvm/IR/Intrinsics.gen (renamed from lib/clang/include/llvm/Intrinsics.gen)0
-rw-r--r--lib/clang/libclanganalysis/Makefile1
-rw-r--r--lib/clang/libclangarcmigrate/Makefile8
-rw-r--r--lib/clang/libclangast/Makefile11
-rw-r--r--lib/clang/libclangbasic/Makefile9
-rw-r--r--lib/clang/libclangcodegen/Makefile2
-rw-r--r--lib/clang/libclangedit/Makefile1
-rw-r--r--lib/clang/libclangfrontend/Makefile1
-rw-r--r--lib/clang/libclanglex/Makefile1
-rw-r--r--lib/clang/libclangparse/Makefile3
-rw-r--r--lib/clang/libclangrewritefrontend/Makefile1
-rw-r--r--lib/clang/libclangsema/Makefile3
-rw-r--r--lib/clang/libclangserialization/Makefile2
-rw-r--r--lib/clang/libclangstaticanalyzercheckers/Makefile6
-rw-r--r--lib/clang/libclangstaticanalyzercore/Makefile1
-rw-r--r--lib/clang/libclangstaticanalyzerfrontend/Makefile1
-rw-r--r--lib/clang/libllvmanalysis/Makefile15
-rw-r--r--lib/clang/libllvmarmasmparser/Makefile3
-rw-r--r--lib/clang/libllvmarmcodegen/Makefile4
-rw-r--r--lib/clang/libllvmarmdesc/Makefile4
-rw-r--r--lib/clang/libllvmarmdisassembler/Makefile1
-rw-r--r--lib/clang/libllvmasmprinter/Makefile3
-rw-r--r--lib/clang/libllvmbitreader/Makefile4
-rw-r--r--lib/clang/libllvmbitwriter/Makefile3
-rw-r--r--lib/clang/libllvmcodegen/Makefile8
-rw-r--r--lib/clang/libllvmcore/Makefile4
-rw-r--r--lib/clang/libllvmdebuginfo/Makefile1
-rw-r--r--lib/clang/libllvminstrumentation/Makefile1
-rw-r--r--lib/clang/libllvmipa/Makefile4
-rw-r--r--lib/clang/libllvmirreader/Makefile10
-rw-r--r--lib/clang/libllvmlinker/Makefile5
-rw-r--r--lib/clang/libllvmmc/Makefile1
-rw-r--r--lib/clang/libllvmmcdisassembler/Makefile6
-rw-r--r--lib/clang/libllvmmcjit/Makefile3
-rw-r--r--lib/clang/libllvmmipscodegen/Makefile7
-rw-r--r--lib/clang/libllvmmipsdesc/Makefile4
-rw-r--r--lib/clang/libllvmmipsdisassembler/Makefile1
-rw-r--r--lib/clang/libllvmobjcarcopts/Makefile20
-rw-r--r--lib/clang/libllvmobject/Makefile1
-rw-r--r--lib/clang/libllvmpowerpccodegen/Makefile3
-rw-r--r--lib/clang/libllvmscalaropts/Makefile1
-rw-r--r--lib/clang/libllvmsupport/Makefile21
-rw-r--r--lib/clang/libllvmtablegen/Makefile1
-rw-r--r--lib/clang/libllvmtarget/Makefile5
-rw-r--r--lib/clang/libllvmtransformutils/Makefile3
-rw-r--r--lib/clang/libllvmvectorize/Makefile2
-rw-r--r--lib/clang/libllvmx86asmparser/Makefile3
-rw-r--r--lib/clang/libllvmx86codegen/Makefile5
-rw-r--r--lib/clang/libllvmx86disassembler/Makefile1
-rw-r--r--lib/csu/Makefile10
-rw-r--r--lib/csu/Makefile.inc2
-rw-r--r--lib/libc++/Makefile2
-rw-r--r--lib/libc++/libc++.ldscript2
-rw-r--r--lib/libc/Makefile2
-rw-r--r--lib/libc/amd64/gen/getcontextx.c16
-rw-r--r--lib/libc/amd64/sys/setlogin.S5
-rw-r--r--lib/libc/arm/gen/Makefile.inc3
-rw-r--r--lib/libc/arm/gen/_setjmp.S84
-rw-r--r--lib/libc/arm/gen/arm_initfini.c78
-rw-r--r--lib/libc/arm/gen/getcontextx.c7
-rw-r--r--lib/libc/arm/gen/setjmp.S117
-rw-r--r--lib/libc/arm/gen/sigsetjmp.S12
-rw-r--r--lib/libc/capability/Makefile.inc19
-rw-r--r--lib/libc/capability/Symbol.map14
-rw-r--r--lib/libc/db/btree/bt_open.c7
-rw-r--r--lib/libc/db/hash/hash.c3
-rw-r--r--lib/libc/db/hash/hash_page.c4
-rw-r--r--lib/libc/gen/Makefile.inc2
-rw-r--r--lib/libc/gen/Symbol.map5
-rw-r--r--lib/libc/gen/closedir.c11
-rw-r--r--lib/libc/gen/directory.315
-rw-r--r--lib/libc/gen/dl_iterate_phdr.32
-rw-r--r--lib/libc/gen/dup3.3116
-rw-r--r--lib/libc/gen/dup3.c (renamed from lib/libcompiler_rt/__sync_val_compare_and_swap_n.h)36
-rw-r--r--lib/libc/gen/errlst.c8
-rw-r--r--lib/libc/gen/fnmatch.c2
-rw-r--r--lib/libc/gen/fts-compat.h6
-rw-r--r--lib/libc/gen/fts.34
-rw-r--r--lib/libc/gen/getlogin.c2
-rw-r--r--lib/libc/gen/popen.37
-rw-r--r--lib/libc/gen/popen.c30
-rw-r--r--lib/libc/gen/posix_spawn_file_actions_addopen.329
-rw-r--r--lib/libc/gen/pututxline.c12
-rw-r--r--lib/libc/gen/sem_wait.39
-rw-r--r--lib/libc/gen/siginterrupt.c2
-rw-r--r--lib/libc/gen/signal.31
-rw-r--r--lib/libc/gen/signal.c2
-rw-r--r--lib/libc/gen/stringlist.32
-rw-r--r--lib/libc/gen/stringlist.c14
-rw-r--r--lib/libc/gen/strtofflags.c20
-rw-r--r--lib/libc/gen/sysconf.34
-rw-r--r--lib/libc/gen/sysctl.322
-rw-r--r--lib/libc/gen/wordexp.c27
-rw-r--r--lib/libc/gmon/gmon.c4
-rw-r--r--lib/libc/i386/gen/getcontextx.c16
-rw-r--r--lib/libc/i386/string/memchr.S2
-rw-r--r--lib/libc/i386/string/strchr.S4
-rw-r--r--lib/libc/i386/string/strrchr.S4
-rw-r--r--lib/libc/i386/sys/setlogin.S9
-rw-r--r--lib/libc/ia64/gen/getcontextx.c7
-rw-r--r--lib/libc/iconv/Symbol.map12
-rw-r--r--lib/libc/iconv/citrus_csmapper.c6
-rw-r--r--lib/libc/iconv/citrus_iconv.c31
-rw-r--r--lib/libc/iconv/citrus_iconv.h2
-rw-r--r--lib/libc/iconv/citrus_iconv_local.h5
-rw-r--r--lib/libc/iconv/citrus_lock.h10
-rw-r--r--lib/libc/iconv/citrus_mapper.c24
-rw-r--r--lib/libc/iconv/citrus_mapper_local.h1
-rw-r--r--lib/libc/iconv/citrus_none.c4
-rw-r--r--lib/libc/iconv/citrus_stdenc.h2
-rw-r--r--lib/libc/iconv/citrus_stdenc_local.h9
-rw-r--r--lib/libc/iconv/citrus_stdenc_template.h4
-rw-r--r--lib/libc/iconv/iconv.c73
-rw-r--r--lib/libc/include/compat.h2
-rw-r--r--lib/libc/include/errlst.h (renamed from lib/libcompiler_rt/__sync_fetch_and_op_n.h)30
-rw-r--r--lib/libc/include/libc_private.h4
-rw-r--r--lib/libc/libc.ldscript2
-rw-r--r--lib/libc/locale/Makefile.inc8
-rw-r--r--lib/libc/locale/Symbol.map8
-rw-r--r--lib/libc/locale/c16rtomb.c81
-rw-r--r--lib/libc/locale/c16rtomb_iconv.c8
-rw-r--r--lib/libc/locale/c32rtomb.c59
-rw-r--r--lib/libc/locale/c32rtomb_iconv.c8
-rw-r--r--lib/libc/locale/cXXrtomb_iconv.h116
-rw-r--r--lib/libc/locale/duplocale.36
-rw-r--r--lib/libc/locale/freelocale.313
-rw-r--r--lib/libc/locale/mbrtoc16.c89
-rw-r--r--lib/libc/locale/mbrtoc16_iconv.c8
-rw-r--r--lib/libc/locale/mbrtoc32.c53
-rw-r--r--lib/libc/locale/mbrtoc32_iconv.c8
-rw-r--r--lib/libc/locale/mbrtocXX_iconv.h159
-rw-r--r--lib/libc/locale/mbrtowc.396
-rw-r--r--lib/libc/locale/newlocale.36
-rw-r--r--lib/libc/locale/querylocale.35
-rw-r--r--lib/libc/locale/uselocale.34
-rw-r--r--lib/libc/locale/wcrtomb.360
-rw-r--r--lib/libc/locale/xlocale.32
-rw-r--r--lib/libc/locale/xlocale_private.h8
-rw-r--r--lib/libc/mips/gen/getcontextx.c7
-rw-r--r--lib/libc/mips/gen/longjmp.c7
-rw-r--r--lib/libc/mips/net/htonl.S7
-rw-r--r--lib/libc/mips/net/htons.S7
-rw-r--r--lib/libc/mips/net/ntohl.S7
-rw-r--r--lib/libc/mips/net/ntohs.S7
-rw-r--r--lib/libc/net/ether_addr.c4
-rw-r--r--lib/libc/net/eui64.c4
-rw-r--r--lib/libc/net/getaddrinfo.313
-rw-r--r--lib/libc/net/getaddrinfo.c4
-rw-r--r--lib/libc/net/gethostbyht.c4
-rw-r--r--lib/libc/net/gethostbyname.34
-rw-r--r--lib/libc/net/getifaddrs.34
-rw-r--r--lib/libc/net/getifmaddrs.34
-rw-r--r--lib/libc/net/getifmaddrs.c28
-rw-r--r--lib/libc/net/getnameinfo.322
-rw-r--r--lib/libc/net/getnetbyht.c4
-rw-r--r--lib/libc/net/getprotoent.c4
-rw-r--r--lib/libc/net/getservent.c4
-rw-r--r--lib/libc/net/hesiod.c2
-rw-r--r--lib/libc/net/name6.c6
-rw-r--r--lib/libc/net/nsdispatch.c9
-rw-r--r--lib/libc/net/nslexer.l12
-rw-r--r--lib/libc/net/nsparser.y7
-rw-r--r--lib/libc/net/rcmd.c4
-rw-r--r--lib/libc/net/recv.c8
-rw-r--r--lib/libc/net/sctp_bindx.36
-rw-r--r--lib/libc/net/sctp_connectx.36
-rw-r--r--lib/libc/net/sctp_freepaddrs.36
-rw-r--r--lib/libc/net/sctp_getaddrlen.36
-rw-r--r--lib/libc/net/sctp_getassocid.36
-rw-r--r--lib/libc/net/sctp_getpaddrs.36
-rw-r--r--lib/libc/net/sctp_opt_info.36
-rw-r--r--lib/libc/net/sctp_recvmsg.36
-rw-r--r--lib/libc/net/sctp_send.36
-rw-r--r--lib/libc/net/sctp_sendmsg.36
-rw-r--r--lib/libc/net/sctp_sys_calls.c8
-rw-r--r--lib/libc/net/send.c8
-rw-r--r--lib/libc/nls/C.msg6
-rw-r--r--lib/libc/nls/fr_FR.ISO8859-1.msg2
-rw-r--r--lib/libc/posix1e/acl_is_trivial_np.32
-rw-r--r--lib/libc/posix1e/mac.c2
-rw-r--r--lib/libc/powerpc/gen/getcontextx.c7
-rw-r--r--lib/libc/powerpc64/gen/fpgetmask.c7
-rw-r--r--lib/libc/powerpc64/gen/fpgetround.c7
-rw-r--r--lib/libc/powerpc64/gen/fpgetsticky.c7
-rw-r--r--lib/libc/powerpc64/gen/fpsetmask.c7
-rw-r--r--lib/libc/powerpc64/gen/fpsetround.c7
-rw-r--r--lib/libc/powerpc64/gen/getcontextx.c7
-rw-r--r--lib/libc/resolv/res_init.c2
-rw-r--r--lib/libc/resolv/res_query.c2
-rw-r--r--lib/libc/sparc64/gen/getcontextx.c7
-rw-r--r--lib/libc/sparc64/gen/makecontext.c10
-rw-r--r--lib/libc/sparc64/gen/signalcontext.c6
-rw-r--r--lib/libc/stdio/Makefile.inc3
-rw-r--r--lib/libc/stdio/Symbol.map2
-rw-r--r--lib/libc/stdio/asprintf.c2
-rw-r--r--lib/libc/stdio/clrerr.c5
-rw-r--r--lib/libc/stdio/fclose.c2
-rw-r--r--lib/libc/stdio/fdopen.c6
-rw-r--r--lib/libc/stdio/feof.c2
-rw-r--r--lib/libc/stdio/ferror.c2
-rw-r--r--lib/libc/stdio/fflush.c2
-rw-r--r--lib/libc/stdio/fgetc.c5
-rw-r--r--lib/libc/stdio/fgetln.c2
-rw-r--r--lib/libc/stdio/fgetpos.c2
-rw-r--r--lib/libc/stdio/fgets.c7
-rw-r--r--lib/libc/stdio/fileno.c2
-rw-r--r--lib/libc/stdio/findfp.c5
-rw-r--r--lib/libc/stdio/flags.c6
-rw-r--r--lib/libc/stdio/fopen.c6
-rw-r--r--lib/libc/stdio/fprintf.c2
-rw-r--r--lib/libc/stdio/fpurge.c5
-rw-r--r--lib/libc/stdio/fputc.c6
-rw-r--r--lib/libc/stdio/fputs.c6
-rw-r--r--lib/libc/stdio/fread.c2
-rw-r--r--lib/libc/stdio/freopen.c8
-rw-r--r--lib/libc/stdio/fscanf.c2
-rw-r--r--lib/libc/stdio/fseek.c18
-rw-r--r--lib/libc/stdio/fsetpos.c6
-rw-r--r--lib/libc/stdio/ftell.c12
-rw-r--r--lib/libc/stdio/funopen.c2
-rw-r--r--lib/libc/stdio/fvwrite.c6
-rw-r--r--lib/libc/stdio/fwalk.c5
-rw-r--r--lib/libc/stdio/fwrite.c9
-rw-r--r--lib/libc/stdio/getc.c2
-rw-r--r--lib/libc/stdio/getchar.c2
-rw-r--r--lib/libc/stdio/gets.c5
-rw-r--r--lib/libc/stdio/getw.c5
-rw-r--r--lib/libc/stdio/makebuf.c10
-rw-r--r--lib/libc/stdio/mktemp.3114
-rw-r--r--lib/libc/stdio/mktemp.c57
-rw-r--r--lib/libc/stdio/perror.c5
-rw-r--r--lib/libc/stdio/printf-pos.c2
-rw-r--r--lib/libc/stdio/printf.c2
-rw-r--r--lib/libc/stdio/putc.c6
-rw-r--r--lib/libc/stdio/putchar.c5
-rw-r--r--lib/libc/stdio/puts.c5
-rw-r--r--lib/libc/stdio/putw.c6
-rw-r--r--lib/libc/stdio/refill.c2
-rw-r--r--lib/libc/stdio/remove.c5
-rw-r--r--lib/libc/stdio/rewind.c2
-rw-r--r--lib/libc/stdio/rget.c2
-rw-r--r--lib/libc/stdio/scanf.c2
-rw-r--r--lib/libc/stdio/setbuf.c2
-rw-r--r--lib/libc/stdio/setbuffer.c10
-rw-r--r--lib/libc/stdio/setvbuf.c2
-rw-r--r--lib/libc/stdio/snprintf.c2
-rw-r--r--lib/libc/stdio/sprintf.c2
-rw-r--r--lib/libc/stdio/sscanf.c2
-rw-r--r--lib/libc/stdio/stdio.c35
-rw-r--r--lib/libc/stdio/tempnam.c5
-rw-r--r--lib/libc/stdio/tmpfile.c2
-rw-r--r--lib/libc/stdio/tmpnam.c5
-rw-r--r--lib/libc/stdio/ungetc.c2
-rw-r--r--lib/libc/stdio/vfprintf.c2
-rw-r--r--lib/libc/stdio/vfscanf.c2
-rw-r--r--lib/libc/stdio/vfwprintf.c2
-rw-r--r--lib/libc/stdio/vfwscanf.c2
-rw-r--r--lib/libc/stdio/vprintf.c2
-rw-r--r--lib/libc/stdio/vscanf.c11
-rw-r--r--lib/libc/stdio/vsnprintf.c2
-rw-r--r--lib/libc/stdio/vsprintf.c2
-rw-r--r--lib/libc/stdio/vsscanf.c2
-rw-r--r--lib/libc/stdio/vswscanf.c2
-rw-r--r--lib/libc/stdio/wbuf.c6
-rw-r--r--lib/libc/stdio/wsetup.c5
-rw-r--r--lib/libc/stdio/xprintf_errno.c3
-rw-r--r--lib/libc/stdlib/abort.32
-rw-r--r--lib/libc/stdlib/abort.c2
-rw-r--r--lib/libc/stdlib/abs.32
-rw-r--r--lib/libc/stdlib/abs.c2
-rw-r--r--lib/libc/stdlib/alloca.32
-rw-r--r--lib/libc/stdlib/atexit.32
-rw-r--r--lib/libc/stdlib/atexit.c2
-rw-r--r--lib/libc/stdlib/atexit.h2
-rw-r--r--lib/libc/stdlib/atof.32
-rw-r--r--lib/libc/stdlib/atof.c2
-rw-r--r--lib/libc/stdlib/atoi.32
-rw-r--r--lib/libc/stdlib/atoi.c2
-rw-r--r--lib/libc/stdlib/atol.38
-rw-r--r--lib/libc/stdlib/atol.c2
-rw-r--r--lib/libc/stdlib/atoll.c2
-rw-r--r--lib/libc/stdlib/bsearch.32
-rw-r--r--lib/libc/stdlib/bsearch.c2
-rw-r--r--lib/libc/stdlib/div.32
-rw-r--r--lib/libc/stdlib/div.c2
-rw-r--r--lib/libc/stdlib/exit.32
-rw-r--r--lib/libc/stdlib/exit.c2
-rw-r--r--lib/libc/stdlib/getenv.32
-rw-r--r--lib/libc/stdlib/getenv.c5
-rw-r--r--lib/libc/stdlib/getopt.32
-rw-r--r--lib/libc/stdlib/getopt.c2
-rw-r--r--lib/libc/stdlib/getsubopt.32
-rw-r--r--lib/libc/stdlib/getsubopt.c2
-rw-r--r--lib/libc/stdlib/heapsort.c2
-rw-r--r--lib/libc/stdlib/jemalloc/Symbol.map11
-rw-r--r--lib/libc/stdlib/labs.32
-rw-r--r--lib/libc/stdlib/labs.c2
-rw-r--r--lib/libc/stdlib/ldiv.32
-rw-r--r--lib/libc/stdlib/ldiv.c2
-rw-r--r--lib/libc/stdlib/lsearch.343
-rw-r--r--lib/libc/stdlib/memory.32
-rw-r--r--lib/libc/stdlib/merge.c2
-rw-r--r--lib/libc/stdlib/qsort.32
-rw-r--r--lib/libc/stdlib/qsort.c2
-rw-r--r--lib/libc/stdlib/radixsort.32
-rw-r--r--lib/libc/stdlib/radixsort.c2
-rw-r--r--lib/libc/stdlib/rand.32
-rw-r--r--lib/libc/stdlib/rand.c43
-rw-r--r--lib/libc/stdlib/random.32
-rw-r--r--lib/libc/stdlib/random.c2
-rw-r--r--lib/libc/stdlib/realpath.32
-rw-r--r--lib/libc/stdlib/realpath.c2
-rw-r--r--lib/libc/stdlib/strtod.32
-rw-r--r--lib/libc/stdlib/strtoimax.c2
-rw-r--r--lib/libc/stdlib/strtol.32
-rw-r--r--lib/libc/stdlib/strtol.c2
-rw-r--r--lib/libc/stdlib/strtoll.c2
-rw-r--r--lib/libc/stdlib/strtonum.32
-rw-r--r--lib/libc/stdlib/strtoq.c2
-rw-r--r--lib/libc/stdlib/strtoul.32
-rw-r--r--lib/libc/stdlib/strtoul.c2
-rw-r--r--lib/libc/stdlib/strtoull.c2
-rw-r--r--lib/libc/stdlib/strtoumax.c2
-rw-r--r--lib/libc/stdlib/strtouq.c2
-rw-r--r--lib/libc/stdlib/system.32
-rw-r--r--lib/libc/stdlib/system.c42
-rw-r--r--lib/libc/string/bcmp.32
-rw-r--r--lib/libc/string/bcmp.c2
-rw-r--r--lib/libc/string/bcopy.32
-rw-r--r--lib/libc/string/bcopy.c2
-rw-r--r--lib/libc/string/bstring.32
-rw-r--r--lib/libc/string/bzero.32
-rw-r--r--lib/libc/string/ffs.32
-rw-r--r--lib/libc/string/ffs.c2
-rw-r--r--lib/libc/string/ffsl.c2
-rw-r--r--lib/libc/string/ffsll.c2
-rw-r--r--lib/libc/string/fls.c2
-rw-r--r--lib/libc/string/flsl.c2
-rw-r--r--lib/libc/string/flsll.c2
-rw-r--r--lib/libc/string/index.32
-rw-r--r--lib/libc/string/memccpy.32
-rw-r--r--lib/libc/string/memccpy.c2
-rw-r--r--lib/libc/string/memchr.32
-rw-r--r--lib/libc/string/memchr.c2
-rw-r--r--lib/libc/string/memcmp.32
-rw-r--r--lib/libc/string/memcmp.c2
-rw-r--r--lib/libc/string/memcpy.32
-rw-r--r--lib/libc/string/memmove.32
-rw-r--r--lib/libc/string/memset.32
-rw-r--r--lib/libc/string/memset.c2
-rw-r--r--lib/libc/string/strcasecmp.32
-rw-r--r--lib/libc/string/strcasecmp.c2
-rw-r--r--lib/libc/string/strcasestr.c2
-rw-r--r--lib/libc/string/strcat.32
-rw-r--r--lib/libc/string/strcat.c2
-rw-r--r--lib/libc/string/strchr.32
-rw-r--r--lib/libc/string/strchr.c2
-rw-r--r--lib/libc/string/strcmp.32
-rw-r--r--lib/libc/string/strcmp.c2
-rw-r--r--lib/libc/string/strcoll.32
-rw-r--r--lib/libc/string/strcpy.32
-rw-r--r--lib/libc/string/strcpy.c2
-rw-r--r--lib/libc/string/strcspn.32
-rw-r--r--lib/libc/string/strdup.32
-rw-r--r--lib/libc/string/strdup.c2
-rw-r--r--lib/libc/string/strerror.32
-rw-r--r--lib/libc/string/strerror.c10
-rw-r--r--lib/libc/string/string.32
-rw-r--r--lib/libc/string/strlen.32
-rw-r--r--lib/libc/string/strmode.32
-rw-r--r--lib/libc/string/strmode.c2
-rw-r--r--lib/libc/string/strncat.c2
-rw-r--r--lib/libc/string/strncmp.c2
-rw-r--r--lib/libc/string/strncpy.c2
-rw-r--r--lib/libc/string/strndup.c2
-rw-r--r--lib/libc/string/strnstr.c2
-rw-r--r--lib/libc/string/strpbrk.32
-rw-r--r--lib/libc/string/strpbrk.c2
-rw-r--r--lib/libc/string/strrchr.c2
-rw-r--r--lib/libc/string/strsep.32
-rw-r--r--lib/libc/string/strsep.c2
-rw-r--r--lib/libc/string/strsignal.c2
-rw-r--r--lib/libc/string/strspn.32
-rw-r--r--lib/libc/string/strstr.32
-rw-r--r--lib/libc/string/strstr.c2
-rw-r--r--lib/libc/string/strtok.32
-rw-r--r--lib/libc/string/strtok.c2
-rw-r--r--lib/libc/string/strxfrm.32
-rw-r--r--lib/libc/string/swab.32
-rw-r--r--lib/libc/string/swab.c2
-rw-r--r--lib/libc/string/wcscmp.c2
-rw-r--r--lib/libc/string/wcscoll.32
-rw-r--r--lib/libc/string/wcsncmp.c2
-rw-r--r--lib/libc/string/wcsncpy.c2
-rw-r--r--lib/libc/string/wcsstr.c2
-rw-r--r--lib/libc/string/wcstok.c2
-rw-r--r--lib/libc/string/wcswidth.c2
-rw-r--r--lib/libc/string/wcsxfrm.32
-rw-r--r--lib/libc/string/wmemchr.32
-rw-r--r--lib/libc/sys/Makefile.inc3
-rw-r--r--lib/libc/sys/Symbol.map8
-rw-r--r--lib/libc/sys/accept.251
-rw-r--r--lib/libc/sys/aio_mlock.2133
-rw-r--r--lib/libc/sys/cap_ioctls_limit.24
-rw-r--r--lib/libc/sys/cap_rights_limit.24
-rw-r--r--lib/libc/sys/chflags.266
-rw-r--r--lib/libc/sys/cpuset.21
-rw-r--r--lib/libc/sys/cpuset_getaffinity.25
-rw-r--r--lib/libc/sys/dup.215
-rw-r--r--lib/libc/sys/fork.215
-rw-r--r--lib/libc/sys/getdtablesize.220
-rw-r--r--lib/libc/sys/intro.215
-rw-r--r--lib/libc/sys/kqueue.217
-rw-r--r--lib/libc/sys/mmap.253
-rw-r--r--lib/libc/sys/pdfork.222
-rw-r--r--lib/libc/sys/pipe.246
-rw-r--r--lib/libc/sys/pselect.25
-rw-r--r--lib/libc/sys/ptrace.210
-rw-r--r--lib/libc/sys/sctp_generic_recvmsg.26
-rw-r--r--lib/libc/sys/sctp_generic_sendmsg.26
-rw-r--r--lib/libc/sys/sctp_peeloff.26
-rw-r--r--lib/libc/sys/setfib.29
-rw-r--r--lib/libc/sys/sigaction.2150
-rw-r--r--lib/libc/sys/sigreturn.24
-rw-r--r--lib/libc/sys/sigsuspend.26
-rw-r--r--lib/libcam/camlib.c2
-rw-r--r--lib/libcompiler_rt/Makefile43
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_add_4.c6
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_add_8.c6
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_and_4.c7
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_and_8.c7
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_or_4.c7
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_or_8.c7
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_sub_4.c6
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_sub_8.c6
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_xor_4.c7
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_xor_8.c7
-rw-r--r--lib/libcompiler_rt/__sync_lock_test_and_set_4.c7
-rw-r--r--lib/libcompiler_rt/__sync_lock_test_and_set_8.c7
-rw-r--r--lib/libcompiler_rt/__sync_val_compare_and_swap_4.c6
-rw-r--r--lib/libcompiler_rt/__sync_val_compare_and_swap_8.c6
-rw-r--r--lib/libdwarf/dwarf_init.c2
-rw-r--r--lib/libdwarf/dwarf_loc.c2
-rw-r--r--lib/libelf/libelf_data.c10
-rw-r--r--lib/libexecinfo/Makefile23
-rw-r--r--lib/libfetch/common.c535
-rw-r--r--lib/libfetch/common.h5
-rw-r--r--lib/libfetch/fetch.3117
-rw-r--r--lib/libfetch/fetch.c2
-rw-r--r--lib/libfetch/http.c35
-rw-r--r--lib/libgeom/geom_xml2tree.c2
-rw-r--r--lib/libgeom/libgeom.h4
-rw-r--r--lib/libiconv_compat/Makefile9
-rw-r--r--lib/libiconv_compat/stub.c8
-rw-r--r--lib/libiconv_modules/BIG5/citrus_big5.c4
-rw-r--r--lib/libiconv_modules/DECHanyu/citrus_dechanyu.c4
-rw-r--r--lib/libiconv_modules/EUC/citrus_euc.c4
-rw-r--r--lib/libiconv_modules/EUCTW/citrus_euctw.c4
-rw-r--r--lib/libiconv_modules/GBK2K/citrus_gbk2k.c4
-rw-r--r--lib/libiconv_modules/HZ/citrus_hz.c4
-rw-r--r--lib/libiconv_modules/ISO2022/citrus_iso2022.c6
-rw-r--r--lib/libiconv_modules/JOHAB/citrus_johab.c4
-rw-r--r--lib/libiconv_modules/MSKanji/citrus_mskanji.c4
-rw-r--r--lib/libiconv_modules/UES/citrus_ues.c4
-rw-r--r--lib/libiconv_modules/UTF1632/citrus_utf1632.c4
-rw-r--r--lib/libiconv_modules/UTF7/citrus_utf7.c8
-rw-r--r--lib/libiconv_modules/UTF8/citrus_utf8.c4
-rw-r--r--lib/libiconv_modules/VIQR/citrus_viqr.c4
-rw-r--r--lib/libiconv_modules/ZW/citrus_zw.c4
-rw-r--r--lib/libiconv_modules/iconv_none/citrus_iconv_none.c2
-rw-r--r--lib/libiconv_modules/iconv_std/citrus_iconv_std.c6
-rw-r--r--lib/libipsec/policy_token.l4
-rw-r--r--lib/libkiconv/xlat16_iconv.c3
-rw-r--r--lib/libkvm/Makefile1
-rw-r--r--lib/libkvm/kvm.c21
-rw-r--r--lib/libkvm/kvm.h2
-rw-r--r--lib/libkvm/kvm_mips.c26
-rw-r--r--lib/libldns/Makefile50
-rw-r--r--lib/libmemstat/memstat_uma.c2
-rw-r--r--lib/libpam/Makefile.inc4
-rw-r--r--lib/libpam/libpam/pam_std_option.c178
-rw-r--r--lib/libpam/modules/pam_passwdqc/Makefile2
-rw-r--r--lib/libpcap/config.h20
-rw-r--r--lib/libpmc/Makefile20
-rw-r--r--lib/libproc/proc_sym.c1
-rw-r--r--lib/libprocstat/Makefile6
-rw-r--r--lib/libprocstat/Symbol.map18
-rw-r--r--lib/libprocstat/common_kvm.h1
-rw-r--r--lib/libprocstat/core.c433
-rw-r--r--lib/libprocstat/core.h53
-rw-r--r--lib/libprocstat/libprocstat.3286
-rw-r--r--lib/libprocstat/libprocstat.c1194
-rw-r--r--lib/libprocstat/libprocstat.h51
-rw-r--r--lib/libprocstat/libprocstat_internal.h3
-rw-r--r--lib/libradius/radius.conf.54
-rw-r--r--lib/librt/sigev_thread.c7
-rw-r--r--lib/libstand/Makefile7
-rw-r--r--lib/libstand/arm/_setjmp.S106
-rw-r--r--lib/libstand/ext2fs.c2
-rw-r--r--lib/libstand/mips/_setjmp.S81
-rw-r--r--lib/libstand/nfs.c5
-rw-r--r--lib/libtacplus/libtacplus.34
-rw-r--r--lib/libtacplus/tacplus.conf.54
-rw-r--r--lib/libthr/pthread.map5
-rw-r--r--lib/libthr/thread/thr_cancel.c3
-rw-r--r--lib/libthr/thread/thr_private.h1
-rw-r--r--lib/libthr/thread/thr_rtld.c11
-rw-r--r--lib/libthr/thread/thr_sig.c66
-rw-r--r--lib/libthr/thread/thr_spec.c11
-rw-r--r--lib/libthr/thread/thr_syscalls.c22
-rw-r--r--lib/libthr/thread/thr_umtx.h2
-rw-r--r--lib/libthread_db/arch/arm/libpthread_md.c2
-rw-r--r--lib/libthread_db/arch/sparc64/libpthread_md.c12
-rw-r--r--lib/libusb/Makefile24
-rw-r--r--lib/libusb/libusb-0.1.pc11
-rw-r--r--lib/libusb/libusb-1.0.pc11
-rw-r--r--lib/libusb/libusb-2.0.pc11
-rw-r--r--lib/libusb/libusb.315
-rw-r--r--lib/libusb/libusb.h4
-rw-r--r--lib/libusb/libusb10.c13
-rw-r--r--lib/libusb/libusb10_io.c4
-rw-r--r--lib/libusb/libusb20.324
-rw-r--r--lib/libusb/libusb20.c27
-rw-r--r--lib/libusb/libusb20.h1
-rw-r--r--lib/libusb/libusb20_int.h2
-rw-r--r--lib/libusb/libusb20_ugen20.c97
-rw-r--r--lib/libusb/libusb_global_linux.h9
-rw-r--r--lib/libutil/expand_number.c30
-rw-r--r--lib/libutil/login_auth.c2
-rw-r--r--lib/libutil/login_cap.c2
-rw-r--r--lib/libutil/login_times.c2
-rw-r--r--lib/libutil/pidfile.c2
-rw-r--r--lib/libutil/quotafile.c8
-rw-r--r--lib/libutil/uucplock.c7
-rw-r--r--lib/libvmmapi/vmmapi.c24
-rw-r--r--lib/libvmmapi/vmmapi.h2
-rw-r--r--lib/libz/ChangeLog63
-rw-r--r--lib/libz/README6
-rw-r--r--lib/libz/Symbol.map5
-rw-r--r--lib/libz/Versions.def3
-rw-r--r--lib/libz/compress.c2
-rw-r--r--lib/libz/contrib/README.contrib1
-rw-r--r--lib/libz/deflate.c12
-rw-r--r--lib/libz/deflate.h2
-rw-r--r--lib/libz/gzguts.h22
-rw-r--r--lib/libz/gzlib.c40
-rw-r--r--lib/libz/gzread.c21
-rw-r--r--lib/libz/gzwrite.c64
-rw-r--r--lib/libz/infback.c2
-rw-r--r--lib/libz/inffast.c6
-rw-r--r--lib/libz/inflate.c64
-rw-r--r--lib/libz/inftrees.c14
-rw-r--r--lib/libz/test/example.c8
-rw-r--r--lib/libz/test/minigzip.c20
-rw-r--r--lib/libz/trees.c14
-rw-r--r--lib/libz/uncompr.c2
-rw-r--r--lib/libz/zconf.h33
-rw-r--r--lib/libz/zlib.36
-rw-r--r--lib/libz/zlib.h48
-rw-r--r--lib/libz/zutil.c2
-rw-r--r--lib/libz/zutil.h9
-rw-r--r--lib/msun/Makefile43
-rw-r--r--lib/msun/Symbol.map20
-rw-r--r--lib/msun/amd64/fenv.h222
-rw-r--r--lib/msun/ld128/s_exp2l.c9
-rw-r--r--lib/msun/ld128/s_expl.c315
-rw-r--r--lib/msun/ld128/s_logl.c737
-rw-r--r--lib/msun/ld80/s_exp2l.c72
-rw-r--r--lib/msun/ld80/s_expl.c237
-rw-r--r--lib/msun/ld80/s_logl.c717
-rw-r--r--lib/msun/man/acosh.333
-rw-r--r--lib/msun/man/asinh.333
-rw-r--r--lib/msun/man/atanh.333
-rw-r--r--lib/msun/man/cacos.3128
-rw-r--r--lib/msun/man/ccos.31
-rw-r--r--lib/msun/man/ccosh.31
-rw-r--r--lib/msun/man/complex.320
-rw-r--r--lib/msun/man/exp.310
-rw-r--r--lib/msun/man/log.341
-rw-r--r--lib/msun/src/catrig.c639
-rw-r--r--lib/msun/src/catrigf.c393
-rw-r--r--lib/msun/src/e_acosh.c6
-rw-r--r--lib/msun/src/e_acoshl.c89
-rw-r--r--lib/msun/src/e_atanh.c6
-rw-r--r--lib/msun/src/e_atanhl.c74
-rw-r--r--lib/msun/src/e_exp.c2
-rw-r--r--lib/msun/src/e_expf.c5
-rw-r--r--lib/msun/src/e_log.c9
-rw-r--r--lib/msun/src/e_log10.c9
-rw-r--r--lib/msun/src/e_log10f.c3
-rw-r--r--lib/msun/src/e_log2.c9
-rw-r--r--lib/msun/src/e_log2f.c3
-rw-r--r--lib/msun/src/e_logf.c3
-rw-r--r--lib/msun/src/math.h118
-rw-r--r--lib/msun/src/math_private.h292
-rw-r--r--lib/msun/src/s_asinh.c6
-rw-r--r--lib/msun/src/s_asinhl.c91
-rw-r--r--lib/msun/src/s_erf.c2
-rw-r--r--lib/msun/src/s_erff.c168
-rw-r--r--lib/msun/src/s_exp2.c5
-rw-r--r--lib/msun/src/s_exp2f.c5
-rw-r--r--lib/msun/src/s_expm1.c7
-rw-r--r--lib/msun/src/s_expm1f.c3
-rw-r--r--lib/msun/src/s_fma.c10
-rw-r--r--lib/msun/src/s_fmal.c10
-rw-r--r--lib/msun/src/s_log1p.c7
-rw-r--r--lib/msun/src/s_log1pf.c3
-rw-r--r--lib/msun/src/s_nearbyint.c6
-rw-r--r--lib/msun/x86/fenv.h (renamed from lib/msun/i387/fenv.h)224
-rw-r--r--lib/ncurses/form/Makefile2
-rw-r--r--lib/ncurses/menu/Makefile2
-rw-r--r--lib/ncurses/panel/Makefile2
633 files changed, 11145 insertions, 2995 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 8846164a8a9a..feca8d3b305d 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -72,12 +72,14 @@ SUBDIR= ${SUBDIR_ORDERED} \
libdwarf \
libedit \
${_libefi} \
+ libexecinfo \
libexpat \
libfetch \
libgeom \
${_libgpib} \
${_libgssapi} \
${_librpcsec_gss} \
+ ${_libiconv_compat} \
libipsec \
${_libipx} \
libjail \
@@ -102,6 +104,7 @@ SUBDIR= ${SUBDIR_ORDERED} \
${_librtld_db} \
${_libsdp} \
${_libsm} \
+ ${_libsmb} \
${_libsmdb} \
${_libsmutil} \
libstand \
@@ -188,6 +191,10 @@ _libcxxrt= libcxxrt
_libcplusplus= libc++
.endif
+.if ${MK_LIBICONV_COMPAT} != "no"
+_libiconv_compat= libiconv_compat
+.endif
+
.if ${MK_LIBTHR} != "no"
_libthr= libthr
.endif
@@ -205,6 +212,7 @@ _libypclnt= libypclnt
.endif
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+_libsmb= libsmb
_libvgl= libvgl
_libproc= libproc
_librtld_db= librtld_db
@@ -216,6 +224,7 @@ _libvmmapi= libvmmapi
.if ${MACHINE_CPUARCH} == "ia64"
_libefi= libefi
+_libsmb= libsmb
.endif
.if ${MACHINE_CPUARCH} == "mips"
@@ -226,6 +235,11 @@ _librtld_db= librtld_db
.if ${MACHINE_CPUARCH} == "powerpc"
_libproc= libproc
_librtld_db= librtld_db
+_libsmb= libsmb
+.endif
+
+.if ${MACHINE_CPUARCH} == "sparc64"
+_libsmb= libsmb
.endif
.if ${MK_OPENSSL} != "no"
@@ -252,4 +266,9 @@ _libusbhid= libusbhid
_libusb= libusb
.endif
+.if !defined(LIBRARIES_ONLY)
+afterinstall:
+ ${INSTALL_SYMLINK} ../include ${DESTDIR}/usr/lib/include
+.endif
+
.include <bsd.subdir.mk>
diff --git a/lib/bind/config.h b/lib/bind/config.h
index bf6f8ce3fbb0..d720a775c030 100644
--- a/lib/bind/config.h
+++ b/lib/bind/config.h
@@ -283,9 +283,18 @@ int sigwait(const unsigned int *set, int *sig);
/* Define to 1 if you have the <net/if6.h> header file. */
/* #undef HAVE_NET_IF6_H */
+/* Define if your OpenSSL version supports ECDSA. */
+#define HAVE_OPENSSL_ECDSA 1
+
/* Define if your OpenSSL version supports GOST. */
/* #undef HAVE_OPENSSL_GOST */
+/* Define to 1 if you have the `readline' function. */
+#define HAVE_READLINE 1
+
+/* Define to 1 if you have the <regex.h> header file. */
+#define HAVE_REGEX_H 1
+
/* Define to 1 if you have the `setegid' function. */
#define HAVE_SETEGID 1
@@ -355,6 +364,9 @@ int sigwait(const unsigned int *set, int *sig);
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
+/* Define to 1 if you have the `usleep' function. */
+#define HAVE_USLEEP 1
+
/* return type of gai_strerror */
#define IRS_GAISTRERROR_RETURN_T const char *
@@ -378,6 +390,9 @@ int sigwait(const unsigned int *set, int *sig);
*/
/* #undef NEED_SECURE_DIRECTORY */
+/* Use the new XML schema for statistics */
+/* #undef NEWSTATS */
+
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
diff --git a/lib/bind/dns/Makefile b/lib/bind/dns/Makefile
index 89dfd408286b..01925b722b99 100644
--- a/lib/bind/dns/Makefile
+++ b/lib/bind/dns/Makefile
@@ -13,7 +13,7 @@ LIB= dns
.PATH: ${SRCDIR}
SRCS+= acache.c acl.c adb.c byaddr.c \
- cache.c callbacks.c compress.c \
+ cache.c callbacks.c clientinfo.c compress.c \
db.c dbiterator.c dbtable.c diff.c dispatch.c \
dlz.c dns64.c dnssec.c ds.c \
dst_api.c dst_lib.c dst_parse.c dst_result.c \
@@ -33,7 +33,7 @@ SRCS+= acache.c acl.c adb.c byaddr.c \
resolver.c result.c rootns.c rpz.c rriterator.c \
sdb.c sdlz.c soa.c ssu.c ssu_external.c \
stats.c tcpmsg.c time.c timer.c tkey.c \
- tsec.c tsig.c ttl.c validator.c \
+ tsec.c tsig.c ttl.c update.c validator.c \
version.c view.c xfrin.c zone.c zonekey.c zt.c
CFLAGS+= -I${SRCDIR}/include/dst -I${SRCDIR}/include -I${SRCDIR}
@@ -52,6 +52,7 @@ DNSINCS= ${SRCDIR}/include/dns/acache.h \
${SRCDIR}/include/dns/cache.h \
${SRCDIR}/include/dns/callbacks.h \
${SRCDIR}/include/dns/cert.h \
+ ${SRCDIR}/include/dns/clientinfo.h \
${SRCDIR}/include/dns/compress.h \
${SRCDIR}/include/dns/db.h \
${SRCDIR}/include/dns/dbiterator.h \
@@ -111,6 +112,7 @@ DNSINCS= ${SRCDIR}/include/dns/acache.h \
${SRCDIR}/include/dns/tsig.h \
${SRCDIR}/include/dns/ttl.h \
${SRCDIR}/include/dns/types.h \
+ ${SRCDIR}/include/dns/update.h \
${SRCDIR}/include/dns/validator.h \
${SRCDIR}/include/dns/version.h \
${SRCDIR}/include/dns/view.h \
diff --git a/lib/bind/dns/code.h b/lib/bind/dns/code.h
index 99944ad52d6f..462601729ab7 100644
--- a/lib/bind/dns/code.h
+++ b/lib/bind/dns/code.h
@@ -67,7 +67,7 @@
#include "rdata/generic/loc_29.c"
#include "rdata/generic/nxt_30.c"
#include "rdata/in_1/srv_33.c"
-#include "rdata/in_1/naptr_35.c"
+#include "rdata/generic/naptr_35.c"
#include "rdata/in_1/kx_36.c"
#include "rdata/generic/cert_37.c"
#include "rdata/in_1/a6_38.c"
@@ -87,8 +87,15 @@
#include "rdata/generic/hip_55.c"
#include "rdata/generic/spf_99.c"
#include "rdata/generic/unspec_103.c"
+#include "rdata/generic/nid_104.c"
+#include "rdata/generic/l32_105.c"
+#include "rdata/generic/l64_106.c"
+#include "rdata/generic/lp_107.c"
+#include "rdata/generic/eui48_108.c"
+#include "rdata/generic/eui64_109.c"
#include "rdata/generic/tkey_249.c"
#include "rdata/any_255/tsig_250.c"
+#include "rdata/generic/uri_256.c"
#include "rdata/generic/dlv_32769.c"
#include "rdata/generic/keydata_65533.c"
@@ -157,11 +164,7 @@
default: result = DNS_R_UNKNOWN; break; \
} \
break; \
- case 35: switch (rdclass) { \
- case 1: result = fromtext_in_naptr(rdclass, type, lexer, origin, options, target, callbacks); break; \
- default: result = DNS_R_UNKNOWN; break; \
- } \
- break; \
+ case 35: result = fromtext_naptr(rdclass, type, lexer, origin, options, target, callbacks); break; \
case 36: switch (rdclass) { \
case 1: result = fromtext_in_kx(rdclass, type, lexer, origin, options, target, callbacks); break; \
default: result = DNS_R_UNKNOWN; break; \
@@ -197,12 +200,19 @@
case 55: result = fromtext_hip(rdclass, type, lexer, origin, options, target, callbacks); break; \
case 99: result = fromtext_spf(rdclass, type, lexer, origin, options, target, callbacks); break; \
case 103: result = fromtext_unspec(rdclass, type, lexer, origin, options, target, callbacks); break; \
+ case 104: result = fromtext_nid(rdclass, type, lexer, origin, options, target, callbacks); break; \
+ case 105: result = fromtext_l32(rdclass, type, lexer, origin, options, target, callbacks); break; \
+ case 106: result = fromtext_l64(rdclass, type, lexer, origin, options, target, callbacks); break; \
+ case 107: result = fromtext_lp(rdclass, type, lexer, origin, options, target, callbacks); break; \
+ case 108: result = fromtext_eui48(rdclass, type, lexer, origin, options, target, callbacks); break; \
+ case 109: result = fromtext_eui64(rdclass, type, lexer, origin, options, target, callbacks); break; \
case 249: result = fromtext_tkey(rdclass, type, lexer, origin, options, target, callbacks); break; \
case 250: switch (rdclass) { \
case 255: result = fromtext_any_tsig(rdclass, type, lexer, origin, options, target, callbacks); break; \
default: result = DNS_R_UNKNOWN; break; \
} \
break; \
+ case 256: result = fromtext_uri(rdclass, type, lexer, origin, options, target, callbacks); break; \
case 32769: result = fromtext_dlv(rdclass, type, lexer, origin, options, target, callbacks); break; \
case 65533: result = fromtext_keydata(rdclass, type, lexer, origin, options, target, callbacks); break; \
default: result = DNS_R_UNKNOWN; break; \
@@ -271,11 +281,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdata->rdclass) { \
- case 1: result = totext_in_naptr(rdata, tctx, target); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = totext_naptr(rdata, tctx, target); break; \
case 36: switch (rdata->rdclass) { \
case 1: result = totext_in_kx(rdata, tctx, target); break; \
default: use_default = ISC_TRUE; break; \
@@ -311,12 +317,19 @@
case 55: result = totext_hip(rdata, tctx, target); break; \
case 99: result = totext_spf(rdata, tctx, target); break; \
case 103: result = totext_unspec(rdata, tctx, target); break; \
+ case 104: result = totext_nid(rdata, tctx, target); break; \
+ case 105: result = totext_l32(rdata, tctx, target); break; \
+ case 106: result = totext_l64(rdata, tctx, target); break; \
+ case 107: result = totext_lp(rdata, tctx, target); break; \
+ case 108: result = totext_eui48(rdata, tctx, target); break; \
+ case 109: result = totext_eui64(rdata, tctx, target); break; \
case 249: result = totext_tkey(rdata, tctx, target); break; \
case 250: switch (rdata->rdclass) { \
case 255: result = totext_any_tsig(rdata, tctx, target); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = totext_uri(rdata, tctx, target); break; \
case 32769: result = totext_dlv(rdata, tctx, target); break; \
case 65533: result = totext_keydata(rdata, tctx, target); break; \
default: use_default = ISC_TRUE; break; \
@@ -385,11 +398,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdclass) { \
- case 1: result = fromwire_in_naptr(rdclass, type, source, dctx, options, target); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = fromwire_naptr(rdclass, type, source, dctx, options, target); break; \
case 36: switch (rdclass) { \
case 1: result = fromwire_in_kx(rdclass, type, source, dctx, options, target); break; \
default: use_default = ISC_TRUE; break; \
@@ -425,12 +434,19 @@
case 55: result = fromwire_hip(rdclass, type, source, dctx, options, target); break; \
case 99: result = fromwire_spf(rdclass, type, source, dctx, options, target); break; \
case 103: result = fromwire_unspec(rdclass, type, source, dctx, options, target); break; \
+ case 104: result = fromwire_nid(rdclass, type, source, dctx, options, target); break; \
+ case 105: result = fromwire_l32(rdclass, type, source, dctx, options, target); break; \
+ case 106: result = fromwire_l64(rdclass, type, source, dctx, options, target); break; \
+ case 107: result = fromwire_lp(rdclass, type, source, dctx, options, target); break; \
+ case 108: result = fromwire_eui48(rdclass, type, source, dctx, options, target); break; \
+ case 109: result = fromwire_eui64(rdclass, type, source, dctx, options, target); break; \
case 249: result = fromwire_tkey(rdclass, type, source, dctx, options, target); break; \
case 250: switch (rdclass) { \
case 255: result = fromwire_any_tsig(rdclass, type, source, dctx, options, target); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = fromwire_uri(rdclass, type, source, dctx, options, target); break; \
case 32769: result = fromwire_dlv(rdclass, type, source, dctx, options, target); break; \
case 65533: result = fromwire_keydata(rdclass, type, source, dctx, options, target); break; \
default: use_default = ISC_TRUE; break; \
@@ -499,11 +515,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdata->rdclass) { \
- case 1: result = towire_in_naptr(rdata, cctx, target); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = towire_naptr(rdata, cctx, target); break; \
case 36: switch (rdata->rdclass) { \
case 1: result = towire_in_kx(rdata, cctx, target); break; \
default: use_default = ISC_TRUE; break; \
@@ -539,12 +551,19 @@
case 55: result = towire_hip(rdata, cctx, target); break; \
case 99: result = towire_spf(rdata, cctx, target); break; \
case 103: result = towire_unspec(rdata, cctx, target); break; \
+ case 104: result = towire_nid(rdata, cctx, target); break; \
+ case 105: result = towire_l32(rdata, cctx, target); break; \
+ case 106: result = towire_l64(rdata, cctx, target); break; \
+ case 107: result = towire_lp(rdata, cctx, target); break; \
+ case 108: result = towire_eui48(rdata, cctx, target); break; \
+ case 109: result = towire_eui64(rdata, cctx, target); break; \
case 249: result = towire_tkey(rdata, cctx, target); break; \
case 250: switch (rdata->rdclass) { \
case 255: result = towire_any_tsig(rdata, cctx, target); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = towire_uri(rdata, cctx, target); break; \
case 32769: result = towire_dlv(rdata, cctx, target); break; \
case 65533: result = towire_keydata(rdata, cctx, target); break; \
default: use_default = ISC_TRUE; break; \
@@ -613,11 +632,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdata1->rdclass) { \
- case 1: result = compare_in_naptr(rdata1, rdata2); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = compare_naptr(rdata1, rdata2); break; \
case 36: switch (rdata1->rdclass) { \
case 1: result = compare_in_kx(rdata1, rdata2); break; \
default: use_default = ISC_TRUE; break; \
@@ -653,12 +668,19 @@
case 55: result = compare_hip(rdata1, rdata2); break; \
case 99: result = compare_spf(rdata1, rdata2); break; \
case 103: result = compare_unspec(rdata1, rdata2); break; \
+ case 104: result = compare_nid(rdata1, rdata2); break; \
+ case 105: result = compare_l32(rdata1, rdata2); break; \
+ case 106: result = compare_l64(rdata1, rdata2); break; \
+ case 107: result = compare_lp(rdata1, rdata2); break; \
+ case 108: result = compare_eui48(rdata1, rdata2); break; \
+ case 109: result = compare_eui64(rdata1, rdata2); break; \
case 249: result = compare_tkey(rdata1, rdata2); break; \
case 250: switch (rdata1->rdclass) { \
case 255: result = compare_any_tsig(rdata1, rdata2); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = compare_uri(rdata1, rdata2); break; \
case 32769: result = compare_dlv(rdata1, rdata2); break; \
case 65533: result = compare_keydata(rdata1, rdata2); break; \
default: use_default = ISC_TRUE; break; \
@@ -727,11 +749,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdata1->rdclass) { \
- case 1: result = casecompare_in_naptr(rdata1, rdata2); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = casecompare_naptr(rdata1, rdata2); break; \
case 36: switch (rdata1->rdclass) { \
case 1: result = casecompare_in_kx(rdata1, rdata2); break; \
default: use_default = ISC_TRUE; break; \
@@ -767,12 +785,19 @@
case 55: result = casecompare_hip(rdata1, rdata2); break; \
case 99: result = casecompare_spf(rdata1, rdata2); break; \
case 103: result = casecompare_unspec(rdata1, rdata2); break; \
+ case 104: result = casecompare_nid(rdata1, rdata2); break; \
+ case 105: result = casecompare_l32(rdata1, rdata2); break; \
+ case 106: result = casecompare_l64(rdata1, rdata2); break; \
+ case 107: result = casecompare_lp(rdata1, rdata2); break; \
+ case 108: result = casecompare_eui48(rdata1, rdata2); break; \
+ case 109: result = casecompare_eui64(rdata1, rdata2); break; \
case 249: result = casecompare_tkey(rdata1, rdata2); break; \
case 250: switch (rdata1->rdclass) { \
case 255: result = casecompare_any_tsig(rdata1, rdata2); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = casecompare_uri(rdata1, rdata2); break; \
case 32769: result = casecompare_dlv(rdata1, rdata2); break; \
case 65533: result = casecompare_keydata(rdata1, rdata2); break; \
default: use_default = ISC_TRUE; break; \
@@ -841,11 +866,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdclass) { \
- case 1: result = fromstruct_in_naptr(rdclass, type, source, target); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = fromstruct_naptr(rdclass, type, source, target); break; \
case 36: switch (rdclass) { \
case 1: result = fromstruct_in_kx(rdclass, type, source, target); break; \
default: use_default = ISC_TRUE; break; \
@@ -881,12 +902,19 @@
case 55: result = fromstruct_hip(rdclass, type, source, target); break; \
case 99: result = fromstruct_spf(rdclass, type, source, target); break; \
case 103: result = fromstruct_unspec(rdclass, type, source, target); break; \
+ case 104: result = fromstruct_nid(rdclass, type, source, target); break; \
+ case 105: result = fromstruct_l32(rdclass, type, source, target); break; \
+ case 106: result = fromstruct_l64(rdclass, type, source, target); break; \
+ case 107: result = fromstruct_lp(rdclass, type, source, target); break; \
+ case 108: result = fromstruct_eui48(rdclass, type, source, target); break; \
+ case 109: result = fromstruct_eui64(rdclass, type, source, target); break; \
case 249: result = fromstruct_tkey(rdclass, type, source, target); break; \
case 250: switch (rdclass) { \
case 255: result = fromstruct_any_tsig(rdclass, type, source, target); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = fromstruct_uri(rdclass, type, source, target); break; \
case 32769: result = fromstruct_dlv(rdclass, type, source, target); break; \
case 65533: result = fromstruct_keydata(rdclass, type, source, target); break; \
default: use_default = ISC_TRUE; break; \
@@ -955,11 +983,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdata->rdclass) { \
- case 1: result = tostruct_in_naptr(rdata, target, mctx); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = tostruct_naptr(rdata, target, mctx); break; \
case 36: switch (rdata->rdclass) { \
case 1: result = tostruct_in_kx(rdata, target, mctx); break; \
default: use_default = ISC_TRUE; break; \
@@ -995,12 +1019,19 @@
case 55: result = tostruct_hip(rdata, target, mctx); break; \
case 99: result = tostruct_spf(rdata, target, mctx); break; \
case 103: result = tostruct_unspec(rdata, target, mctx); break; \
+ case 104: result = tostruct_nid(rdata, target, mctx); break; \
+ case 105: result = tostruct_l32(rdata, target, mctx); break; \
+ case 106: result = tostruct_l64(rdata, target, mctx); break; \
+ case 107: result = tostruct_lp(rdata, target, mctx); break; \
+ case 108: result = tostruct_eui48(rdata, target, mctx); break; \
+ case 109: result = tostruct_eui64(rdata, target, mctx); break; \
case 249: result = tostruct_tkey(rdata, target, mctx); break; \
case 250: switch (rdata->rdclass) { \
case 255: result = tostruct_any_tsig(rdata, target, mctx); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = tostruct_uri(rdata, target, mctx); break; \
case 32769: result = tostruct_dlv(rdata, target, mctx); break; \
case 65533: result = tostruct_keydata(rdata, target, mctx); break; \
default: use_default = ISC_TRUE; break; \
@@ -1069,11 +1100,7 @@
default: break; \
} \
break; \
- case 35: switch (common->rdclass) { \
- case 1: freestruct_in_naptr(source); break; \
- default: break; \
- } \
- break; \
+ case 35: freestruct_naptr(source); break; \
case 36: switch (common->rdclass) { \
case 1: freestruct_in_kx(source); break; \
default: break; \
@@ -1109,12 +1136,19 @@
case 55: freestruct_hip(source); break; \
case 99: freestruct_spf(source); break; \
case 103: freestruct_unspec(source); break; \
+ case 104: freestruct_nid(source); break; \
+ case 105: freestruct_l32(source); break; \
+ case 106: freestruct_l64(source); break; \
+ case 107: freestruct_lp(source); break; \
+ case 108: freestruct_eui48(source); break; \
+ case 109: freestruct_eui64(source); break; \
case 249: freestruct_tkey(source); break; \
case 250: switch (common->rdclass) { \
case 255: freestruct_any_tsig(source); break; \
default: break; \
} \
break; \
+ case 256: freestruct_uri(source); break; \
case 32769: freestruct_dlv(source); break; \
case 65533: freestruct_keydata(source); break; \
default: break; \
@@ -1183,11 +1217,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdata->rdclass) { \
- case 1: result = additionaldata_in_naptr(rdata, add, arg); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = additionaldata_naptr(rdata, add, arg); break; \
case 36: switch (rdata->rdclass) { \
case 1: result = additionaldata_in_kx(rdata, add, arg); break; \
default: use_default = ISC_TRUE; break; \
@@ -1223,12 +1253,19 @@
case 55: result = additionaldata_hip(rdata, add, arg); break; \
case 99: result = additionaldata_spf(rdata, add, arg); break; \
case 103: result = additionaldata_unspec(rdata, add, arg); break; \
+ case 104: result = additionaldata_nid(rdata, add, arg); break; \
+ case 105: result = additionaldata_l32(rdata, add, arg); break; \
+ case 106: result = additionaldata_l64(rdata, add, arg); break; \
+ case 107: result = additionaldata_lp(rdata, add, arg); break; \
+ case 108: result = additionaldata_eui48(rdata, add, arg); break; \
+ case 109: result = additionaldata_eui64(rdata, add, arg); break; \
case 249: result = additionaldata_tkey(rdata, add, arg); break; \
case 250: switch (rdata->rdclass) { \
case 255: result = additionaldata_any_tsig(rdata, add, arg); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = additionaldata_uri(rdata, add, arg); break; \
case 32769: result = additionaldata_dlv(rdata, add, arg); break; \
case 65533: result = additionaldata_keydata(rdata, add, arg); break; \
default: use_default = ISC_TRUE; break; \
@@ -1297,11 +1334,7 @@
default: use_default = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdata->rdclass) { \
- case 1: result = digest_in_naptr(rdata, digest, arg); break; \
- default: use_default = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = digest_naptr(rdata, digest, arg); break; \
case 36: switch (rdata->rdclass) { \
case 1: result = digest_in_kx(rdata, digest, arg); break; \
default: use_default = ISC_TRUE; break; \
@@ -1337,12 +1370,19 @@
case 55: result = digest_hip(rdata, digest, arg); break; \
case 99: result = digest_spf(rdata, digest, arg); break; \
case 103: result = digest_unspec(rdata, digest, arg); break; \
+ case 104: result = digest_nid(rdata, digest, arg); break; \
+ case 105: result = digest_l32(rdata, digest, arg); break; \
+ case 106: result = digest_l64(rdata, digest, arg); break; \
+ case 107: result = digest_lp(rdata, digest, arg); break; \
+ case 108: result = digest_eui48(rdata, digest, arg); break; \
+ case 109: result = digest_eui64(rdata, digest, arg); break; \
case 249: result = digest_tkey(rdata, digest, arg); break; \
case 250: switch (rdata->rdclass) { \
case 255: result = digest_any_tsig(rdata, digest, arg); break; \
default: use_default = ISC_TRUE; break; \
} \
break; \
+ case 256: result = digest_uri(rdata, digest, arg); break; \
case 32769: result = digest_dlv(rdata, digest, arg); break; \
case 65533: result = digest_keydata(rdata, digest, arg); break; \
default: use_default = ISC_TRUE; break; \
@@ -1411,11 +1451,7 @@
default: result = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdclass) { \
- case 1: result = checkowner_in_naptr(name, rdclass, type, wildcard); break; \
- default: result = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = checkowner_naptr(name, rdclass, type, wildcard); break; \
case 36: switch (rdclass) { \
case 1: result = checkowner_in_kx(name, rdclass, type, wildcard); break; \
default: result = ISC_TRUE; break; \
@@ -1451,12 +1487,19 @@
case 55: result = checkowner_hip(name, rdclass, type, wildcard); break; \
case 99: result = checkowner_spf(name, rdclass, type, wildcard); break; \
case 103: result = checkowner_unspec(name, rdclass, type, wildcard); break; \
+ case 104: result = checkowner_nid(name, rdclass, type, wildcard); break; \
+ case 105: result = checkowner_l32(name, rdclass, type, wildcard); break; \
+ case 106: result = checkowner_l64(name, rdclass, type, wildcard); break; \
+ case 107: result = checkowner_lp(name, rdclass, type, wildcard); break; \
+ case 108: result = checkowner_eui48(name, rdclass, type, wildcard); break; \
+ case 109: result = checkowner_eui64(name, rdclass, type, wildcard); break; \
case 249: result = checkowner_tkey(name, rdclass, type, wildcard); break; \
case 250: switch (rdclass) { \
case 255: result = checkowner_any_tsig(name, rdclass, type, wildcard); break; \
default: result = ISC_TRUE; break; \
} \
break; \
+ case 256: result = checkowner_uri(name, rdclass, type, wildcard); break; \
case 32769: result = checkowner_dlv(name, rdclass, type, wildcard); break; \
case 65533: result = checkowner_keydata(name, rdclass, type, wildcard); break; \
default: result = ISC_TRUE; break; \
@@ -1525,11 +1568,7 @@
default: result = ISC_TRUE; break; \
} \
break; \
- case 35: switch (rdata->rdclass) { \
- case 1: result = checknames_in_naptr(rdata, owner, bad); break; \
- default: result = ISC_TRUE; break; \
- } \
- break; \
+ case 35: result = checknames_naptr(rdata, owner, bad); break; \
case 36: switch (rdata->rdclass) { \
case 1: result = checknames_in_kx(rdata, owner, bad); break; \
default: result = ISC_TRUE; break; \
@@ -1565,12 +1604,19 @@
case 55: result = checknames_hip(rdata, owner, bad); break; \
case 99: result = checknames_spf(rdata, owner, bad); break; \
case 103: result = checknames_unspec(rdata, owner, bad); break; \
+ case 104: result = checknames_nid(rdata, owner, bad); break; \
+ case 105: result = checknames_l32(rdata, owner, bad); break; \
+ case 106: result = checknames_l64(rdata, owner, bad); break; \
+ case 107: result = checknames_lp(rdata, owner, bad); break; \
+ case 108: result = checknames_eui48(rdata, owner, bad); break; \
+ case 109: result = checknames_eui64(rdata, owner, bad); break; \
case 249: result = checknames_tkey(rdata, owner, bad); break; \
case 250: switch (rdata->rdclass) { \
case 255: result = checknames_any_tsig(rdata, owner, bad); break; \
default: result = ISC_TRUE; break; \
} \
break; \
+ case 256: result = checknames_uri(rdata, owner, bad); break; \
case 32769: result = checknames_dlv(rdata, owner, bad); break; \
case 65533: result = checknames_keydata(rdata, owner, bad); break; \
default: result = ISC_TRUE; break; \
@@ -1659,6 +1705,7 @@
break; \
case 140: \
RDATATYPE_COMPARE("nsap-ptr", 23, _typename, _length, _typep); \
+ RDATATYPE_COMPARE("l64", 106, _typename, _length, _typep); \
break; \
case 122: \
RDATATYPE_COMPARE("sig", 24, _typename, _length, _typep); \
@@ -1706,6 +1753,7 @@
break; \
case 48: \
RDATATYPE_COMPARE("apl", 42, _typename, _length, _typep); \
+ RDATATYPE_COMPARE("eui48", 108, _typename, _length, _typep); \
break; \
case 210: \
RDATATYPE_COMPARE("ds", 43, _typename, _length, _typep); \
@@ -1747,6 +1795,18 @@
case 145: \
RDATATYPE_COMPARE("unspec", 103, _typename, _length, _typep); \
break; \
+ case 36: \
+ RDATATYPE_COMPARE("nid", 104, _typename, _length, _typep); \
+ break; \
+ case 174: \
+ RDATATYPE_COMPARE("l32", 105, _typename, _length, _typep); \
+ break; \
+ case 32: \
+ RDATATYPE_COMPARE("lp", 107, _typename, _length, _typep); \
+ break; \
+ case 136: \
+ RDATATYPE_COMPARE("eui64", 109, _typename, _length, _typep); \
+ break; \
case 184: \
RDATATYPE_COMPARE("tkey", 249, _typename, _length, _typep); \
break; \
@@ -1769,6 +1829,9 @@
case 68: \
RDATATYPE_COMPARE("any", 255, _typename, _length, _typep); \
break; \
+ case 56: \
+ RDATATYPE_COMPARE("uri", 256, _typename, _length, _typep); \
+ break; \
}
#define RDATATYPE_ATTRIBUTE_SW \
switch (type) { \
@@ -1830,6 +1893,12 @@
case 101: return (DNS_RDATATYPEATTR_RESERVED); \
case 102: return (DNS_RDATATYPEATTR_RESERVED); \
case 103: return (RRTYPE_UNSPEC_ATTRIBUTES); \
+ case 104: return (RRTYPE_NID_ATTRIBUTES); \
+ case 105: return (RRTYPE_L32_ATTRIBUTES); \
+ case 106: return (RRTYPE_L64_ATTRIBUTES); \
+ case 107: return (RRTYPE_LP_ATTRIBUTES); \
+ case 108: return (RRTYPE_EUI48_ATTRIBUTES); \
+ case 109: return (RRTYPE_EUI64_ATTRIBUTES); \
case 249: return (RRTYPE_TKEY_ATTRIBUTES); \
case 250: return (RRTYPE_TSIG_ATTRIBUTES); \
case 251: return (DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_QUESTIONONLY); \
@@ -1837,6 +1906,7 @@
case 253: return (DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_QUESTIONONLY); \
case 254: return (DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_QUESTIONONLY); \
case 255: return (DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_QUESTIONONLY); \
+ case 256: return (RRTYPE_URI_ATTRIBUTES); \
case 32769: return (RRTYPE_DLV_ATTRIBUTES); \
case 65533: return (RRTYPE_KEYDATA_ATTRIBUTES); \
}
@@ -1900,6 +1970,12 @@
case 101: return (str_totext("UID", target)); \
case 102: return (str_totext("GID", target)); \
case 103: return (str_totext("UNSPEC", target)); \
+ case 104: return (str_totext("NID", target)); \
+ case 105: return (str_totext("L32", target)); \
+ case 106: return (str_totext("L64", target)); \
+ case 107: return (str_totext("LP", target)); \
+ case 108: return (str_totext("EUI48", target)); \
+ case 109: return (str_totext("EUI64", target)); \
case 249: return (str_totext("TKEY", target)); \
case 250: return (str_totext("TSIG", target)); \
case 251: return (str_totext("IXFR", target)); \
@@ -1907,6 +1983,7 @@
case 253: return (str_totext("MAILB", target)); \
case 254: return (str_totext("MAILA", target)); \
case 255: return (str_totext("ANY", target)); \
+ case 256: return (str_totext("URI", target)); \
case 32769: return (str_totext("DLV", target)); \
case 65533: return (str_totext("KEYDATA", target)); \
}
diff --git a/lib/bind/dns/dns/enumtype.h b/lib/bind/dns/dns/enumtype.h
index 5ab36d18f859..aa53689d2da2 100644
--- a/lib/bind/dns/dns/enumtype.h
+++ b/lib/bind/dns/dns/enumtype.h
@@ -82,8 +82,15 @@ enum {
dns_rdatatype_hip = 55,
dns_rdatatype_spf = 99,
dns_rdatatype_unspec = 103,
+ dns_rdatatype_nid = 104,
+ dns_rdatatype_l32 = 105,
+ dns_rdatatype_l64 = 106,
+ dns_rdatatype_lp = 107,
+ dns_rdatatype_eui48 = 108,
+ dns_rdatatype_eui64 = 109,
dns_rdatatype_tkey = 249,
dns_rdatatype_tsig = 250,
+ dns_rdatatype_uri = 256,
dns_rdatatype_dlv = 32769,
dns_rdatatype_keydata = 65533,
dns_rdatatype_ixfr = 251,
@@ -145,8 +152,15 @@ enum {
#define dns_rdatatype_hip ((dns_rdatatype_t)dns_rdatatype_hip)
#define dns_rdatatype_spf ((dns_rdatatype_t)dns_rdatatype_spf)
#define dns_rdatatype_unspec ((dns_rdatatype_t)dns_rdatatype_unspec)
+#define dns_rdatatype_nid ((dns_rdatatype_t)dns_rdatatype_nid)
+#define dns_rdatatype_l32 ((dns_rdatatype_t)dns_rdatatype_l32)
+#define dns_rdatatype_l64 ((dns_rdatatype_t)dns_rdatatype_l64)
+#define dns_rdatatype_lp ((dns_rdatatype_t)dns_rdatatype_lp)
+#define dns_rdatatype_eui48 ((dns_rdatatype_t)dns_rdatatype_eui48)
+#define dns_rdatatype_eui64 ((dns_rdatatype_t)dns_rdatatype_eui64)
#define dns_rdatatype_tkey ((dns_rdatatype_t)dns_rdatatype_tkey)
#define dns_rdatatype_tsig ((dns_rdatatype_t)dns_rdatatype_tsig)
+#define dns_rdatatype_uri ((dns_rdatatype_t)dns_rdatatype_uri)
#define dns_rdatatype_dlv ((dns_rdatatype_t)dns_rdatatype_dlv)
#define dns_rdatatype_keydata ((dns_rdatatype_t)dns_rdatatype_keydata)
#define dns_rdatatype_ixfr ((dns_rdatatype_t)dns_rdatatype_ixfr)
diff --git a/lib/bind/dns/dns/rdatastruct.h b/lib/bind/dns/dns/rdatastruct.h
index 10cba31aff72..3828c8ed9dc2 100644
--- a/lib/bind/dns/dns/rdatastruct.h
+++ b/lib/bind/dns/dns/rdatastruct.h
@@ -1178,7 +1178,7 @@ typedef struct dns_rdata_in_srv {
#endif /* IN_1_SRV_33_H */
/*
- * Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -1194,15 +1194,15 @@ typedef struct dns_rdata_in_srv {
* PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef IN_1_NAPTR_35_H
-#define IN_1_NAPTR_35_H 1
+#ifndef GENERIC_NAPTR_35_H
+#define GENERIC_NAPTR_35_H 1
/* $Id$ */
/*!
* \brief Per RFC2915 */
-typedef struct dns_rdata_in_naptr {
+typedef struct dns_rdata_naptr {
dns_rdatacommon_t common;
isc_mem_t *mctx;
isc_uint16_t order;
@@ -1214,9 +1214,9 @@ typedef struct dns_rdata_in_naptr {
char *regexp;
isc_uint8_t regexp_len;
dns_name_t replacement;
-} dns_rdata_in_naptr_t;
+} dns_rdata_naptr_t;
-#endif /* IN_1_NAPTR_35_H */
+#endif /* GENERIC_NAPTR_35_H */
/*
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2001 Internet Software Consortium.
@@ -1709,7 +1709,7 @@ typedef struct dns_rdata_in_dhcid {
#endif /* IN_1_DHCID_49_H */
/*
- * Copyright (C) 2008, 2012 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2008, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1756,7 +1756,16 @@ typedef struct dns_rdata_nsec3 {
#define DNS_NSEC3FLAG_OPTOUT 0x01U
/*%
- * Non-standard, NSEC3PARAM only.
+ * The following flags are used in the private-type record (implemented in
+ * lib/dns/private.c) which is used to store NSEC3PARAM data during the
+ * time when it is not legal to have an actual NSEC3PARAM record in the
+ * zone. They are defined here because the private-type record uses the
+ * same flags field for the OPTOUT flag above and for the private flags
+ * below. XXX: This should be considered for refactoring.
+ */
+
+/*%
+ * Non-standard, private type only.
*
* Create a corresponding NSEC3 chain.
* Once the NSEC3 chain is complete this flag will be removed to signal
@@ -1765,13 +1774,14 @@ typedef struct dns_rdata_nsec3 {
* This flag is automatically set when a NSEC3PARAM record is added to
* the zone via UPDATE.
*
- * NSEC3PARAM records with this flag set are supposed to be ignored by
- * RFC 5155 compliant nameservers.
+ * NSEC3PARAM records containing this flag should never be published,
+ * but if they are, they should be ignored by RFC 5155 compliant
+ * nameservers.
*/
#define DNS_NSEC3FLAG_CREATE 0x80U
/*%
- * Non-standard, NSEC3PARAM only.
+ * Non-standard, private type only.
*
* The corresponding NSEC3 set is to be removed once the NSEC chain
* has been generated.
@@ -1779,24 +1789,39 @@ typedef struct dns_rdata_nsec3 {
* This flag is automatically set when the last active NSEC3PARAM record
* is removed from the zone via UPDATE.
*
- * NSEC3PARAM records with this flag set are supposed to be ignored by
- * RFC 5155 compliant nameservers.
+ * NSEC3PARAM records containing this flag should never be published,
+ * but if they are, they should be ignored by RFC 5155 compliant
+ * nameservers.
*/
#define DNS_NSEC3FLAG_REMOVE 0x40U
/*%
- * Non-standard, NSEC3PARAM only.
+ * Non-standard, private type only.
*
- * Used to identify NSEC3PARAM records added in this UPDATE request.
+ * When set with the CREATE flag, a corresponding NSEC3 chain will be
+ * created when the zone becomes capable of supporting one (i.e., when it
+ * has a DNSKEY RRset containing at least one NSEC3-capable algorithm).
+ * Without this flag, NSEC3 chain creation would be attempted immediately,
+ * fail, and the private type record would be removed. With it, the NSEC3
+ * parameters are stored until they can be used. When the zone has the
+ * necessary prerequisites for NSEC3, then the INITIAL flag can be cleared,
+ * and the record will be cleaned up normally.
+ *
+ * NSEC3PARAM records containing this flag should never be published, but
+ * if they are, they should be ignored by RFC 5155 compliant nameservers.
*/
-#define DNS_NSEC3FLAG_UPDATE 0x20U
+#define DNS_NSEC3FLAG_INITIAL 0x20U
/*%
- * Non-standard, NSEC3PARAM only.
+ * Non-standard, private type only.
*
* Prevent the creation of a NSEC chain before the last NSEC3 chain
* is removed. This will normally only be set when the zone is
* transitioning from secure with NSEC3 chains to insecure.
+ *
+ * NSEC3PARAM records containing this flag should never be published,
+ * but if they are, they should be ignored by RFC 5155 compliant
+ * nameservers.
*/
#define DNS_NSEC3FLAG_NONSEC 0x10U
@@ -2004,6 +2029,167 @@ typedef struct dns_rdata_unspec_t {
#endif /* GENERIC_UNSPEC_103_H */
/*
+ * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC 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.
+ */
+
+/* */
+#ifndef GENERIC_NID_104_H
+#define GENERIC_NID_104_H 1
+
+typedef struct dns_rdata_nid {
+ dns_rdatacommon_t common;
+ isc_uint16_t pref;
+ unsigned char nid[8];
+} dns_rdata_nid_t;
+
+#endif /* GENERIC_NID_104_H */
+/*
+ * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC 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.
+ */
+
+/* */
+#ifndef GENERIC_L32_105_H
+#define GENERIC_L32_105_H 1
+
+typedef struct dns_rdata_l32 {
+ dns_rdatacommon_t common;
+ isc_uint16_t pref;
+ struct in_addr l32;
+} dns_rdata_l32_t;
+
+#endif /* GENERIC_L32_105_H */
+/*
+ * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC 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.
+ */
+
+/* */
+#ifndef GENERIC_L64_106_H
+#define GENERIC_L64_106_H 1
+
+typedef struct dns_rdata_l64 {
+ dns_rdatacommon_t common;
+ isc_uint16_t pref;
+ unsigned char l64[8];
+} dns_rdata_l64_t;
+
+#endif /* GENERIC_L64_106_H */
+/*
+ * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC 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.
+ */
+
+/* */
+#ifndef GENERIC_LP_107_H
+#define GENERIC_LP_107_H 1
+
+typedef struct dns_rdata_lp {
+ dns_rdatacommon_t common;
+ isc_mem_t *mctx;
+ isc_uint16_t pref;
+ dns_name_t lp;
+} dns_rdata_lp_t;
+
+#endif /* GENERIC_LP_107_H */
+/*
+ * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC 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.
+ */
+
+/* */
+#ifndef GENERIC_EUI48_108_H
+#define GENERIC_EUI48_108_H 1
+
+typedef struct dns_rdata_eui48 {
+ dns_rdatacommon_t common;
+ unsigned char eui48[6];
+} dns_rdata_eui48_t;
+
+#endif /* GENERIC_EUI48_10k_H */
+/*
+ * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC 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.
+ */
+
+/* */
+#ifndef GENERIC_EUI64_109_H
+#define GENERIC_EUI64_109_H 1
+
+typedef struct dns_rdata_eui64 {
+ dns_rdatacommon_t common;
+ unsigned char eui64[8];
+} dns_rdata_eui64_t;
+
+#endif /* GENERIC_EUI64_10k_H */
+/*
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2001, 2003 Internet Software Consortium.
*
@@ -2083,6 +2269,37 @@ typedef struct dns_rdata_any_tsig {
#endif /* ANY_255_TSIG_250_H */
/*
+ * Copyright (C) 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC 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.
+ */
+
+#ifndef GENERIC_URI_256_H
+#define GENERIC_URI_256_H 1
+
+/* $Id$ */
+
+typedef struct dns_rdata_uri {
+ dns_rdatacommon_t common;
+ isc_mem_t * mctx;
+ isc_uint16_t priority;
+ isc_uint16_t weight;
+ unsigned char * target;
+ isc_uint16_t tgt_len;
+} dns_rdata_uri_t;
+
+#endif /* GENERIC_URI_256_H */
+/*
* Copyright (C) 2004, 2006, 2007 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
diff --git a/lib/bind/isc/Makefile b/lib/bind/isc/Makefile
index f41f604bf0e9..773666e05f9d 100644
--- a/lib/bind/isc/Makefile
+++ b/lib/bind/isc/Makefile
@@ -37,10 +37,10 @@ SRCS+= inet_pton.c \
lex.c lfsr.c lib.c log.c \
md5.c mem.c mutexblock.c \
netaddr.c netscope.c ondestroy.c \
- parseint.c portset.c \
+ parseint.c pool.c portset.c \
print.c \
quota.c radix.c random.c \
- ratelimiter.c refcount.c region.c result.c rwlock.c \
+ ratelimiter.c refcount.c region.c regex.c result.c rwlock.c \
serial.c sha1.c sha2.c sockaddr.c stats.c string.c strtoul.c \
symtab.c task.c taskpool.c timer.c version.c
@@ -99,14 +99,17 @@ INCS= ${SRCDIR}/include/isc/app.h \
${SRCDIR}/include/isc/ondestroy.h \
${SRCDIR}/include/isc/os.h \
${SRCDIR}/include/isc/parseint.h \
+ ${SRCDIR}/include/isc/pool.h \
${SRCDIR}/include/isc/portset.h \
${SRCDIR}/include/isc/print.h \
+ ${SRCDIR}/include/isc/queue.h \
${SRCDIR}/include/isc/quota.h \
${SRCDIR}/include/isc/radix.h \
${SRCDIR}/include/isc/random.h \
${SRCDIR}/include/isc/ratelimiter.h \
${SRCDIR}/include/isc/refcount.h \
${SRCDIR}/include/isc/region.h \
+ ${SRCDIR}/include/isc/regex.h \
${SRCDIR}/include/isc/resource.h \
${SRCDIR}/include/isc/result.h \
${SRCDIR}/include/isc/resultclass.h \
diff --git a/lib/clang/Makefile b/lib/clang/Makefile
index a77d241986f3..6bc955210bd3 100644
--- a/lib/clang/Makefile
+++ b/lib/clang/Makefile
@@ -43,9 +43,11 @@ SUBDIR= libclanganalysis \
libllvminstrumentation \
libllvmipa \
libllvmipo \
+ libllvmirreader \
libllvmlinker \
libllvmmc \
libllvmmcparser \
+ libllvmobjcarcopts \
libllvmobject \
libllvmscalaropts \
libllvmselectiondag \
diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk
index 6de044a3b6be..2cf1e5b8b864 100644
--- a/lib/clang/clang.build.mk
+++ b/lib/clang/clang.build.mk
@@ -30,7 +30,7 @@ TARGET_ABI= unknown
TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd10.0
BUILD_TRIPLE?= ${BUILD_ARCH:C/amd64/x86_64/}-unknown-freebsd10.0
CFLAGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_TRIPLE}\" \
- -DLLVM_HOSTTRIPLE=\"${BUILD_TRIPLE}\" \
+ -DLLVM_HOST_TRIPLE=\"${BUILD_TRIPLE}\" \
-DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"
CXXFLAGS+= -fno-exceptions -fno-rtti
@@ -38,11 +38,19 @@ CXXFLAGS+= -fno-exceptions -fno-rtti
TBLGEN?= tblgen
CLANG_TBLGEN?= clang-tblgen
-TBLINC+= -I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target
-Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/Intrinsics.td
- ${TBLGEN} -I ${LLVM_SRCS}/lib/VMCore ${TBLINC} -gen-intrinsic \
- -o ${.TARGET} ${LLVM_SRCS}/include/llvm/Intrinsics.td
+Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/IR/Intrinsics.td \
+ ${LLVM_SRCS}/include/llvm/IR/IntrinsicsARM.td \
+ ${LLVM_SRCS}/include/llvm/IR/IntrinsicsHexagon.td \
+ ${LLVM_SRCS}/include/llvm/IR/IntrinsicsMips.td \
+ ${LLVM_SRCS}/include/llvm/IR/IntrinsicsNVVM.td \
+ ${LLVM_SRCS}/include/llvm/IR/IntrinsicsPowerPC.td \
+ ${LLVM_SRCS}/include/llvm/IR/IntrinsicsR600.td \
+ ${LLVM_SRCS}/include/llvm/IR/IntrinsicsX86.td \
+ ${LLVM_SRCS}/include/llvm/IR/IntrinsicsXCore.td
+ ${TBLGEN} -I ${LLVM_SRCS}/include \
+ -gen-intrinsic -o ${.TARGET} \
+ ${LLVM_SRCS}/include/llvm/IR/Intrinsics.td
.for arch in \
ARM/ARM Mips/Mips PowerPC/PPC X86/X86
. for hdr in \
@@ -53,7 +61,6 @@ Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/Intrinsics.td
CodeEmitter/-gen-emitter \
DAGISel/-gen-dag-isel \
DisassemblerTables/-gen-disassembler \
- EDInfo/-gen-enhanced-disassembly-info \
FastISel/-gen-fast-isel \
InstrInfo/-gen-instr-info \
MCCodeEmitter/-gen-emitter,-mc-emitter \
@@ -61,118 +68,129 @@ Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/Intrinsics.td
RegisterInfo/-gen-register-info \
SubtargetInfo/-gen-subtarget
${arch:T}Gen${hdr:H:C/$/.inc.h/}: ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
- ${TBLGEN} -I ${LLVM_SRCS}/lib/Target/${arch:H} ${TBLINC} \
+ ${TBLGEN} -I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target/${arch:H} \
${hdr:T:C/,/ /g} -o ${.TARGET} \
${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
. endfor
.endfor
Attrs.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
- -gen-clang-attr-classes -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-classes -o ${.TARGET} ${.ALLSRC}
-AttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
- -gen-clang-attr-impl -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+AttrDump.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-dump -o ${.TARGET} ${.ALLSRC}
+
+AttrExprArgs.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-expr-args-list -o ${.TARGET} ${.ALLSRC}
+AttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-impl -o ${.TARGET} ${.ALLSRC}
AttrLateParsed.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
- -gen-clang-attr-late-parsed-list -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-late-parsed-list -o ${.TARGET} ${.ALLSRC}
AttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
- -gen-clang-attr-list -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-list -o ${.TARGET} ${.ALLSRC}
AttrParsedAttrKinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
- -gen-clang-attr-parsed-attr-kinds -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-parsed-attr-kinds -o ${.TARGET} ${.ALLSRC}
AttrParsedAttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
- -gen-clang-attr-parsed-attr-list -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-parsed-attr-list -o ${.TARGET} ${.ALLSRC}
AttrPCHRead.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
- ${TBLINC} -gen-clang-attr-pch-read -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-pch-read -o ${.TARGET} ${.ALLSRC}
AttrPCHWrite.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
- ${TBLINC} -gen-clang-attr-pch-write -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-pch-write -o ${.TARGET} ${.ALLSRC}
AttrSpellings.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Lex ${TBLINC} \
- -gen-clang-attr-spelling-list -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-spelling-list -o ${.TARGET} ${.ALLSRC}
+
+AttrSpellingListIndex.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-spelling-index -o ${.TARGET} ${.ALLSRC}
AttrTemplateInstantiate.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
- -gen-clang-attr-template-instantiate -o ${.TARGET} \
- -I ${CLANG_SRCS}/include ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-attr-template-instantiate -o ${.TARGET} ${.ALLSRC}
CommentCommandInfo.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} \
-gen-clang-comment-command-info -o ${.TARGET} ${.ALLSRC}
+CommentCommandList.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
+ ${CLANG_TBLGEN} \
+ -gen-clang-comment-command-list -o ${.TARGET} ${.ALLSRC}
+
+CommentHTMLNamedCharacterReferences.inc.h: \
+ ${CLANG_SRCS}/include/clang/AST/CommentHTMLNamedCharacterReferences.td
+ ${CLANG_TBLGEN} \
+ -gen-clang-comment-html-named-character-references -o ${.TARGET} \
+ ${.ALLSRC}
+
CommentHTMLTags.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} \
-gen-clang-comment-html-tags -o ${.TARGET} ${.ALLSRC}
-CommentHTMLTagsProperties.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+CommentHTMLTagsProperties.inc.h: \
+ ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
+ ${CLANG_TBLGEN} \
-gen-clang-comment-html-tags-properties -o ${.TARGET} ${.ALLSRC}
CommentNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/CommentNodes.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} \
-gen-clang-comment-nodes -o ${.TARGET} ${.ALLSRC}
DeclNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} \
-gen-clang-decl-nodes -o ${.TARGET} ${.ALLSRC}
StmtNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} \
-gen-clang-stmt-nodes -o ${.TARGET} ${.ALLSRC}
arm_neon.inc.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ ${CLANG_TBLGEN} \
-gen-arm-neon-sema -o ${.TARGET} ${.ALLSRC}
DiagnosticGroups.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic \
-gen-clang-diag-groups -o ${.TARGET} ${.ALLSRC}
DiagnosticIndexName.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic \
-gen-clang-diags-index-name -o ${.TARGET} ${.ALLSRC}
.for hdr in AST Analysis Comment Common Driver Frontend Lex Parse Sema Serialization
Diagnostic${hdr}Kinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
- -gen-clang-diags-defs -clang-component=${hdr} \
- -o ${.TARGET} ${.ALLSRC}
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic \
+ -gen-clang-diags-defs -clang-component=${hdr} -o ${.TARGET} \
+ ${.ALLSRC}
.endfor
Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/Options.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver \
-gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC}
CC1AsOptions.inc.h: ${CLANG_SRCS}/include/clang/Driver/CC1AsOptions.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver \
-gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC}
Checkers.inc.h: ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td \
${CLANG_SRCS}/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
- ${CLANG_TBLGEN} -I ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers \
- ${TBLINC} -gen-clang-sa-checkers -o ${.TARGET} \
- -I ${CLANG_SRCS}/include \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include \
+ -gen-clang-sa-checkers -o ${.TARGET} \
${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
SRCS+= ${TGHDRS:C/$/.inc.h/}
diff --git a/lib/clang/include/ARMGenEDInfo.inc b/lib/clang/include/ARMGenEDInfo.inc
deleted file mode 100644
index c2b7a097f1cf..000000000000
--- a/lib/clang/include/ARMGenEDInfo.inc
+++ /dev/null
@@ -1,2 +0,0 @@
-/* $FreeBSD$ */
-#include "ARMGenEDInfo.inc.h"
diff --git a/lib/clang/include/Makefile b/lib/clang/include/Makefile
index 918c6dff8ad9..1c6bd5c0ed0f 100644
--- a/lib/clang/include/Makefile
+++ b/lib/clang/include/Makefile
@@ -2,7 +2,7 @@
.PATH: ${.CURDIR}/../../../contrib/llvm/tools/clang/lib/Headers
-INCSDIR=${INCLUDEDIR}/clang/3.2
+INCSDIR=${INCLUDEDIR}/clang/3.3
INCS= __wmmintrin_aes.h \
__wmmintrin_pclmul.h \
@@ -26,6 +26,8 @@ INCS= __wmmintrin_aes.h \
nmmintrin.h \
pmmintrin.h \
popcntintrin.h \
+ prfchwintrin.h \
+ rdseedintrin.h \
rtmintrin.h \
smmintrin.h \
tmmintrin.h \
diff --git a/lib/clang/include/MipsGenEDInfo.inc b/lib/clang/include/MipsGenEDInfo.inc
deleted file mode 100644
index 5b8099f33d9a..000000000000
--- a/lib/clang/include/MipsGenEDInfo.inc
+++ /dev/null
@@ -1,2 +0,0 @@
-/* $FreeBSD$ */
-#include "MipsGenEDInfo.inc.h"
diff --git a/lib/clang/include/X86GenEDInfo.inc b/lib/clang/include/X86GenEDInfo.inc
deleted file mode 100644
index 7b4cd8f187d5..000000000000
--- a/lib/clang/include/X86GenEDInfo.inc
+++ /dev/null
@@ -1,2 +0,0 @@
-/* $FreeBSD$ */
-#include "X86GenEDInfo.inc.h"
diff --git a/lib/clang/include/clang/AST/AttrDump.inc b/lib/clang/include/clang/AST/AttrDump.inc
new file mode 100644
index 000000000000..ca3c42ff6ba5
--- /dev/null
+++ b/lib/clang/include/clang/AST/AttrDump.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "AttrDump.inc.h"
diff --git a/lib/clang/include/clang/AST/CommentCommandList.inc b/lib/clang/include/clang/AST/CommentCommandList.inc
new file mode 100644
index 000000000000..bc369059a832
--- /dev/null
+++ b/lib/clang/include/clang/AST/CommentCommandList.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "CommentCommandList.inc.h"
diff --git a/lib/clang/include/clang/AST/CommentHTMLNamedCharacterReferences.inc b/lib/clang/include/clang/AST/CommentHTMLNamedCharacterReferences.inc
new file mode 100644
index 000000000000..b4f11ca6d86b
--- /dev/null
+++ b/lib/clang/include/clang/AST/CommentHTMLNamedCharacterReferences.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "CommentHTMLNamedCharacterReferences.inc.h"
diff --git a/lib/clang/include/clang/Basic/Version.inc b/lib/clang/include/clang/Basic/Version.inc
index 84a96a630c49..1b62e7f0b7ce 100644
--- a/lib/clang/include/clang/Basic/Version.inc
+++ b/lib/clang/include/clang/Basic/Version.inc
@@ -1,10 +1,10 @@
/* $FreeBSD$ */
-#define CLANG_VERSION 3.2
+#define CLANG_VERSION 3.3
#define CLANG_VERSION_MAJOR 3
-#define CLANG_VERSION_MINOR 2
+#define CLANG_VERSION_MINOR 3
#define CLANG_VENDOR "FreeBSD "
-#define CLANG_VENDOR_SUFFIX " 20121221"
+#define CLANG_VENDOR_SUFFIX " 20130610"
-#define SVN_REVISION "170710"
+#define SVN_REVISION "183502"
diff --git a/lib/clang/include/clang/Parse/AttrExprArgs.inc b/lib/clang/include/clang/Parse/AttrExprArgs.inc
new file mode 100644
index 000000000000..043e034c2647
--- /dev/null
+++ b/lib/clang/include/clang/Parse/AttrExprArgs.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "AttrExprArgs.inc.h"
diff --git a/lib/clang/include/clang/Sema/AttrSpellingListIndex.inc b/lib/clang/include/clang/Sema/AttrSpellingListIndex.inc
new file mode 100644
index 000000000000..229273cb5440
--- /dev/null
+++ b/lib/clang/include/clang/Sema/AttrSpellingListIndex.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "AttrSpellingListIndex.inc.h"
diff --git a/lib/clang/include/llvm/Config/config.h b/lib/clang/include/llvm/Config/config.h
index 1894727df545..d72aba857b8d 100644
--- a/lib/clang/include/llvm/Config/config.h
+++ b/lib/clang/include/llvm/Config/config.h
@@ -5,6 +5,9 @@
#ifndef CONFIG_H
#define CONFIG_H
+/* Get __FreeBSD_version. */
+#include <osreldate.h>
+
/* Bug report URL. */
#define BUG_REPORT_URL "http://llvm.org/bugs/"
@@ -74,12 +77,23 @@
/* Define to 1 if you have the <CrashReporterClient.h> header file. */
/* #undef HAVE_CRASHREPORTERCLIENT_H */
-/* Define if __crashreporter_info__ exists. */
+/* can use __crashreporter_info__ */
#define HAVE_CRASHREPORTER_INFO 0
/* Define to 1 if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
+/* Define to 1 if you have the <cxxabi.h> header file. */
+#define HAVE_CXXABI_H 1
+
+/* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you
+ don't. */
+#define HAVE_DECL_FE_ALL_EXCEPT 1
+
+/* Define to 1 if you have the declaration of `FE_INEXACT', and to 0 if you
+ don't. */
+#define HAVE_DECL_FE_INEXACT 1
+
/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you
don't. */
#define HAVE_DECL_STRERROR_S 0
@@ -124,6 +138,12 @@
/* Define to 1 if you have the <execinfo.h> header file. */
/* #undef HAVE_EXECINFO_H */
+/* Define to 1 if you have the `exp' function. */
+#define HAVE_EXP 1
+
+/* Define to 1 if you have the `exp2' function. */
+#define HAVE_EXP2 1
+
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
@@ -214,6 +234,9 @@
/* Define to 1 if you have the `udis86' library (-ludis86). */
/* #undef HAVE_LIBUDIS86 */
+/* Define to 1 if you have the `z' library (-lz). */
+#define HAVE_LIBZ 1
+
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
@@ -227,6 +250,17 @@
the current directory to the dynamic linker search path. */
#define HAVE_LINK_R 1
+/* Define to 1 if you have the `log' function. */
+#define HAVE_LOG 1
+
+/* Define to 1 if you have the `log10' function. */
+#define HAVE_LOG10 1
+
+/* Define to 1 if you have the `log2' function. */
+#if __FreeBSD_version >= 900027 || (__FreeBSD_version < 900000 && __FreeBSD_version >= 802502)
+#define HAVE_LOG2 1
+#endif
+
/* Define to 1 if you have the `longjmp' function. */
#define HAVE_LONGJMP 1
@@ -482,6 +516,9 @@
/* Define if the xdot.py program is available */
/* #undef HAVE_XDOT_PY */
+/* Define to 1 if you have the <zlib.h> header file. */
+#define HAVE_ZLIB_H 1
+
/* Have host's _alloca */
/* #undef HAVE__ALLOCA */
@@ -554,6 +591,9 @@
/* Define if threads enabled */
#define LLVM_ENABLE_THREADS 0
+/* Define if zlib is enabled */
+#define LLVM_ENABLE_ZLIB 1
+
/* Installation directory for config files */
/* #undef LLVM_ETCDIR */
@@ -561,7 +601,7 @@
#define LLVM_HAS_ATOMICS 0
/* Host triple LLVM will be executed on */
-/* #undef LLVM_HOSTTRIPLE */
+/* #undef LLVM_HOST_TRIPLE */
/* Installation directory for include files */
/* #undef LLVM_INCLUDEDIR */
@@ -630,7 +670,7 @@
/* #undef LLVM_PATH_XDOT_PY */
/* Installation prefix directory */
-/* #undef LLVM_PREFIX */
+#define LLVM_PREFIX ""
/* Define if we have the Intel JIT API runtime support library */
#define LLVM_USE_INTEL_JITEVENTS 0
@@ -642,7 +682,7 @@
#define LLVM_VERSION_MAJOR 3
/* Minor version of the LLVM API */
-#define LLVM_VERSION_MINOR 2
+#define LLVM_VERSION_MINOR 3
/* Define if the OS needs help to load dependent libraries for dlopen(). */
#define LTDL_DLOPEN_DEPLIBS 1
@@ -675,13 +715,13 @@
#define PACKAGE_NAME "LLVM"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "LLVM 3.2svn"
+#define PACKAGE_STRING "LLVM 3.3"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "llvm"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "3.2svn"
+#define PACKAGE_VERSION "3.3"
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
diff --git a/lib/clang/include/llvm/Config/llvm-config.h b/lib/clang/include/llvm/Config/llvm-config.h
index ff4355c3f177..86e0e491c1f1 100644
--- a/lib/clang/include/llvm/Config/llvm-config.h
+++ b/lib/clang/include/llvm/Config/llvm-config.h
@@ -43,7 +43,7 @@
#define LLVM_HAS_ATOMICS 0
/* Host triple LLVM will be executed on */
-/* #undef LLVM_HOSTTRIPLE */
+/* #undef LLVM_HOST_TRIPLE */
/* Installation directory for include files */
/* #undef LLVM_INCLUDEDIR */
@@ -112,12 +112,18 @@
/* #undef LLVM_PATH_XDOT_PY */
/* Installation prefix directory */
-/* #undef LLVM_PREFIX */
+#define LLVM_PREFIX ""
+
+/* Define if we have the Intel JIT API runtime support library */
+#define LLVM_USE_INTEL_JITEVENTS 0
+
+/* Define if we have the oprofile JIT-support library */
+#define LLVM_USE_OPROFILE 0
/* Major version of the LLVM API */
#define LLVM_VERSION_MAJOR 3
/* Minor version of the LLVM API */
-#define LLVM_VERSION_MINOR 2
+#define LLVM_VERSION_MINOR 3
#endif
diff --git a/lib/clang/include/llvm/Intrinsics.gen b/lib/clang/include/llvm/IR/Intrinsics.gen
index a3dbd63f1068..a3dbd63f1068 100644
--- a/lib/clang/include/llvm/Intrinsics.gen
+++ b/lib/clang/include/llvm/IR/Intrinsics.gen
diff --git a/lib/clang/libclanganalysis/Makefile b/lib/clang/libclanganalysis/Makefile
index 76bf1e5c8db6..40deb80ddff7 100644
--- a/lib/clang/libclanganalysis/Makefile
+++ b/lib/clang/libclanganalysis/Makefile
@@ -27,6 +27,7 @@ SRCS= AnalysisDeclContext.cpp \
TGHDRS= AttrList \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticAnalysisKinds \
diff --git a/lib/clang/libclangarcmigrate/Makefile b/lib/clang/libclangarcmigrate/Makefile
index 7597e9c67f15..1604a50b5003 100644
--- a/lib/clang/libclangarcmigrate/Makefile
+++ b/lib/clang/libclangarcmigrate/Makefile
@@ -15,19 +15,21 @@ SRCS= ARCMT.cpp \
TransAutoreleasePool.cpp \
TransBlockObjCVariable.cpp \
TransEmptyStatementsAndDealloc.cpp \
- TransformActions.cpp \
- Transforms.cpp \
TransGCAttrs.cpp \
TransGCCalls.cpp \
TransProperties.cpp \
+ TransProtectedScope.cpp \
TransRetainReleaseDealloc.cpp \
TransUnbridgedCasts.cpp \
TransUnusedInitDelegate.cpp \
- TransZeroOutPropsInDealloc.cpp
+ TransZeroOutPropsInDealloc.cpp \
+ TransformActions.cpp \
+ Transforms.cpp
TGHDRS= AttrList \
AttrParsedAttrList \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangast/Makefile b/lib/clang/libclangast/Makefile
index 0ddeb53080de..a867725598ce 100644
--- a/lib/clang/libclangast/Makefile
+++ b/lib/clang/libclangast/Makefile
@@ -9,13 +9,13 @@ SRCS= APValue.cpp \
ASTConsumer.cpp \
ASTContext.cpp \
ASTDiagnostic.cpp \
+ ASTDumper.cpp \
ASTImporter.cpp \
AttrImpl.cpp \
CXXInheritance.cpp \
Comment.cpp \
CommentBriefParser.cpp \
CommentCommandTraits.cpp \
- CommentDumper.cpp \
CommentLexer.cpp \
CommentParser.cpp \
CommentSema.cpp \
@@ -25,6 +25,7 @@ SRCS= APValue.cpp \
DeclFriend.cpp \
DeclGroup.cpp \
DeclObjC.cpp \
+ DeclOpenMP.cpp \
DeclPrinter.cpp \
DeclTemplate.cpp \
DeclarationName.cpp \
@@ -41,15 +42,14 @@ SRCS= APValue.cpp \
Mangle.cpp \
MicrosoftCXXABI.cpp \
MicrosoftMangle.cpp \
- NestedNameSpecifier.cpp \
NSAPI.cpp \
+ NestedNameSpecifier.cpp \
ParentMap.cpp \
RawCommentList.cpp \
RecordLayout.cpp \
RecordLayoutBuilder.cpp \
SelectorLocationsKind.cpp \
Stmt.cpp \
- StmtDumper.cpp \
StmtIterator.cpp \
StmtPrinter.cpp \
StmtProfile.cpp \
@@ -62,10 +62,13 @@ SRCS= APValue.cpp \
VTTBuilder.cpp \
VTableBuilder.cpp
-TGHDRS= AttrImpl \
+TGHDRS= AttrDump \
+ AttrImpl \
AttrList \
Attrs \
CommentCommandInfo \
+ CommentCommandList \
+ CommentHTMLNamedCharacterReferences \
CommentHTMLTags \
CommentHTMLTagsProperties \
CommentNodes \
diff --git a/lib/clang/libclangbasic/Makefile b/lib/clang/libclangbasic/Makefile
index eec941a2fe16..16bae4c39387 100644
--- a/lib/clang/libclangbasic/Makefile
+++ b/lib/clang/libclangbasic/Makefile
@@ -6,8 +6,7 @@ LIB= clangbasic
SRCDIR= tools/clang/lib/Basic
SRCS= Builtins.cpp \
- ConvertUTF.c \
- ConvertUTFWrapper.cpp \
+ CharInfo.cpp \
Diagnostic.cpp \
DiagnosticIDs.cpp \
FileManager.cpp \
@@ -16,13 +15,15 @@ SRCS= Builtins.cpp \
LangOptions.cpp \
Module.cpp \
ObjCRuntime.cpp \
+ OpenMPKinds.cpp \
+ OperatorPrecedence.cpp \
SourceLocation.cpp \
SourceManager.cpp \
TargetInfo.cpp \
Targets.cpp \
TokenKinds.cpp \
- VersionTuple.cpp \
- Version.cpp
+ Version.cpp \
+ VersionTuple.cpp
TGHDRS= DiagnosticAnalysisKinds \
DiagnosticASTKinds \
diff --git a/lib/clang/libclangcodegen/Makefile b/lib/clang/libclangcodegen/Makefile
index 7aefa7c64489..cf58049472cb 100644
--- a/lib/clang/libclangcodegen/Makefile
+++ b/lib/clang/libclangcodegen/Makefile
@@ -6,6 +6,7 @@ LIB= clangcodegen
SRCDIR= tools/clang/lib/CodeGen
SRCS= BackendUtil.cpp \
+ CGAtomic.cpp \
CGBlocks.cpp \
CGBuiltin.cpp \
CGCUDANV.cpp \
@@ -47,6 +48,7 @@ SRCS= BackendUtil.cpp \
TGHDRS= AttrList \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangedit/Makefile b/lib/clang/libclangedit/Makefile
index 59b0b54e4e0d..f403b00822ed 100644
--- a/lib/clang/libclangedit/Makefile
+++ b/lib/clang/libclangedit/Makefile
@@ -11,6 +11,7 @@ SRCS= Commit.cpp \
TGHDRS= AttrList \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
StmtNodes \
diff --git a/lib/clang/libclangfrontend/Makefile b/lib/clang/libclangfrontend/Makefile
index 44ba2fb74325..4ea35565554d 100644
--- a/lib/clang/libclangfrontend/Makefile
+++ b/lib/clang/libclangfrontend/Makefile
@@ -38,6 +38,7 @@ SRCS= ASTConsumers.cpp \
TGHDRS= AttrList \
AttrParsedAttrList \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticASTKinds \
diff --git a/lib/clang/libclanglex/Makefile b/lib/clang/libclanglex/Makefile
index 768d43c1e79c..3a2873faaed0 100644
--- a/lib/clang/libclanglex/Makefile
+++ b/lib/clang/libclanglex/Makefile
@@ -14,6 +14,7 @@ SRCS= HeaderMap.cpp \
ModuleMap.cpp \
PPCaching.cpp \
PPCallbacks.cpp \
+ PPConditionalDirectiveRecord.cpp \
PPDirectives.cpp \
PPExpressions.cpp \
PPLexerChange.cpp \
diff --git a/lib/clang/libclangparse/Makefile b/lib/clang/libclangparse/Makefile
index dbe9adb03fb9..279d003eed5d 100644
--- a/lib/clang/libclangparse/Makefile
+++ b/lib/clang/libclangparse/Makefile
@@ -13,6 +13,7 @@ SRCS= ParseAST.cpp \
ParseExprCXX.cpp \
ParseInit.cpp \
ParseObjc.cpp \
+ ParseOpenMP.cpp \
ParsePragma.cpp \
ParseStmt.cpp \
ParseTemplate.cpp \
@@ -22,7 +23,9 @@ SRCS= ParseAST.cpp \
TGHDRS= AttrLateParsed \
AttrList \
AttrParsedAttrList \
+ AttrExprArgs \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangrewritefrontend/Makefile b/lib/clang/libclangrewritefrontend/Makefile
index ffa11b4fe328..8c41669f89c2 100644
--- a/lib/clang/libclangrewritefrontend/Makefile
+++ b/lib/clang/libclangrewritefrontend/Makefile
@@ -17,6 +17,7 @@ SRCS= FixItRewriter.cpp \
TGHDRS= AttrList \
AttrParsedAttrList \
Attrs \
+ CommentCommandList \
DeclNodes \
DiagnosticCommonKinds \
DiagnosticFrontendKinds \
diff --git a/lib/clang/libclangsema/Makefile b/lib/clang/libclangsema/Makefile
index 9ced8b4c6895..c9f56d4d5a75 100644
--- a/lib/clang/libclangsema/Makefile
+++ b/lib/clang/libclangsema/Makefile
@@ -37,6 +37,7 @@ SRCS= AnalysisBasedWarnings.cpp \
SemaLambda.cpp \
SemaLookup.cpp \
SemaObjCProperty.cpp \
+ SemaOpenMP.cpp \
SemaOverload.cpp \
SemaPseudoObject.cpp \
SemaStmt.cpp \
@@ -53,8 +54,10 @@ SRCS= AnalysisBasedWarnings.cpp \
TGHDRS= AttrList \
AttrParsedAttrKinds \
AttrParsedAttrList \
+ AttrSpellingListIndex \
AttrTemplateInstantiate \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticASTKinds \
diff --git a/lib/clang/libclangserialization/Makefile b/lib/clang/libclangserialization/Makefile
index 962bbf09b5c8..3a6a65eeea31 100644
--- a/lib/clang/libclangserialization/Makefile
+++ b/lib/clang/libclangserialization/Makefile
@@ -13,6 +13,7 @@ SRCS= ASTCommon.cpp \
ASTWriterDecl.cpp \
ASTWriterStmt.cpp \
GeneratePCH.cpp \
+ GlobalModuleIndex.cpp \
Module.cpp \
ModuleManager.cpp
@@ -21,6 +22,7 @@ TGHDRS= AttrList \
AttrPCHWrite \
AttrParsedAttrList \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangstaticanalyzercheckers/Makefile b/lib/clang/libclangstaticanalyzercheckers/Makefile
index 95361519d8d8..10968d27dd5d 100644
--- a/lib/clang/libclangstaticanalyzercheckers/Makefile
+++ b/lib/clang/libclangstaticanalyzercheckers/Makefile
@@ -5,10 +5,10 @@
LIB= clangstaticanalyzercheckers
SRCDIR= tools/clang/lib/StaticAnalyzer/Checkers
-SRCS= AnalyzerStatsChecker.cpp \
+SRCS= AllocationDiagnostics.cpp \
+ AnalyzerStatsChecker.cpp \
ArrayBoundChecker.cpp \
ArrayBoundCheckerV2.cpp \
- AttrNonNullChecker.cpp \
BasicObjCFoundationChecks.cpp \
BoolAssignmentChecker.cpp \
BuiltinFunctionChecker.cpp \
@@ -44,6 +44,7 @@ SRCS= AnalyzerStatsChecker.cpp \
MallocSizeofChecker.cpp \
NSAutoreleasePoolChecker.cpp \
NSErrorChecker.cpp \
+ NonNullParamChecker.cpp \
NoReturnFunctionChecker.cpp \
ObjCAtSyncChecker.cpp \
ObjCContainersASTChecker.cpp \
@@ -75,6 +76,7 @@ SRCS= AnalyzerStatsChecker.cpp \
TGHDRS= AttrList \
Attrs \
Checkers \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangstaticanalyzercore/Makefile b/lib/clang/libclangstaticanalyzercore/Makefile
index 9c263f03d5b5..eda991e314c2 100644
--- a/lib/clang/libclangstaticanalyzercore/Makefile
+++ b/lib/clang/libclangstaticanalyzercore/Makefile
@@ -46,6 +46,7 @@ SRCS= APSIntType.cpp \
TGHDRS= AttrList \
Attrs \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangstaticanalyzerfrontend/Makefile b/lib/clang/libclangstaticanalyzerfrontend/Makefile
index 9e19f923d7a0..de7b326a073c 100644
--- a/lib/clang/libclangstaticanalyzerfrontend/Makefile
+++ b/lib/clang/libclangstaticanalyzerfrontend/Makefile
@@ -12,6 +12,7 @@ SRCS= AnalysisConsumer.cpp \
TGHDRS= AttrList \
Attrs \
Checkers \
+ CommentCommandList \
CommentNodes \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libllvmanalysis/Makefile b/lib/clang/libllvmanalysis/Makefile
index 3c01352115d2..1bd8e9eb6ddd 100644
--- a/lib/clang/libllvmanalysis/Makefile
+++ b/lib/clang/libllvmanalysis/Makefile
@@ -12,19 +12,16 @@ SRCS= AliasAnalysis.cpp \
AliasSetTracker.cpp \
Analysis.cpp \
BasicAliasAnalysis.cpp \
- BlockFrequencyInfo.cpp \
BranchProbabilityInfo.cpp \
CFGPrinter.cpp \
CaptureTracking.cpp \
CodeMetrics.cpp \
ConstantFolding.cpp \
CostModel.cpp \
- DbgInfoPrinter.cpp \
DependenceAnalysis.cpp \
DomPrinter.cpp \
DominanceFrontier.cpp \
IVUsers.cpp \
- InlineCost.cpp \
InstCount.cpp \
InstructionSimplify.cpp \
Interval.cpp \
@@ -46,13 +43,14 @@ SRCS= AliasAnalysis.cpp \
PathProfileInfo.cpp \
PathProfileVerifier.cpp \
PostDominators.cpp \
+ ProfileDataLoader.cpp \
+ ProfileDataLoaderPass.cpp \
ProfileEstimatorPass.cpp \
ProfileInfo.cpp \
ProfileInfoLoader.cpp \
ProfileInfoLoaderPass.cpp \
ProfileVerifierPass.cpp \
- ProfileDataLoader.cpp \
- ProfileDataLoaderPass.cpp \
+ PtrUseVisitor.cpp \
RegionInfo.cpp \
RegionPass.cpp \
RegionPrinter.cpp \
@@ -61,16 +59,13 @@ SRCS= AliasAnalysis.cpp \
ScalarEvolutionExpander.cpp \
ScalarEvolutionNormalization.cpp \
SparsePropagation.cpp \
+ TargetTransformInfo.cpp \
Trace.cpp \
TypeBasedAliasAnalysis.cpp \
ValueTracking.cpp
.if ${MK_CLANG_EXTRAS} != "no"
-SRCS+= BlockFrequencyInfo.cpp \
- LibCallSemantics.cpp \
- PathNumbering.cpp \
- PathProfileInfo.cpp \
- PathProfileVerifier.cpp
+SRCS+= BlockFrequencyInfo.cpp
.endif
TGHDRS= Intrinsics
diff --git a/lib/clang/libllvmarmasmparser/Makefile b/lib/clang/libllvmarmasmparser/Makefile
index 05e6263aa894..134d8a2ed0dc 100644
--- a/lib/clang/libllvmarmasmparser/Makefile
+++ b/lib/clang/libllvmarmasmparser/Makefile
@@ -6,8 +6,7 @@ LIB= llvmarmasmparser
SRCDIR= lib/Target/ARM/AsmParser
INCDIR= lib/Target/ARM
-SRCS= ARMAsmLexer.cpp \
- ARMAsmParser.cpp
+SRCS= ARMAsmParser.cpp
TGHDRS= ARMGenAsmMatcher \
ARMGenInstrInfo \
diff --git a/lib/clang/libllvmarmcodegen/Makefile b/lib/clang/libllvmarmcodegen/Makefile
index 6a10eaf0825f..db574187a04f 100644
--- a/lib/clang/libllvmarmcodegen/Makefile
+++ b/lib/clang/libllvmarmcodegen/Makefile
@@ -5,7 +5,8 @@
LIB= llvmarmcodegen
SRCDIR= lib/Target/ARM
-SRCS= ARMAsmPrinter.cpp \
+SRCS= A15SDOptimizer.cpp \
+ ARMAsmPrinter.cpp \
ARMBaseInstrInfo.cpp \
ARMBaseRegisterInfo.cpp \
ARMCodeEmitter.cpp \
@@ -27,6 +28,7 @@ SRCS= ARMAsmPrinter.cpp \
ARMSubtarget.cpp \
ARMTargetMachine.cpp \
ARMTargetObjectFile.cpp \
+ ARMTargetTransformInfo.cpp \
MLxExpansionPass.cpp \
Thumb1FrameLowering.cpp \
Thumb1InstrInfo.cpp \
diff --git a/lib/clang/libllvmarmdesc/Makefile b/lib/clang/libllvmarmdesc/Makefile
index 61679a666683..777e669a4ede 100644
--- a/lib/clang/libllvmarmdesc/Makefile
+++ b/lib/clang/libllvmarmdesc/Makefile
@@ -7,11 +7,13 @@ LIB= llvmarmdesc
SRCDIR= lib/Target/ARM/MCTargetDesc
SRCS= ARMAsmBackend.cpp \
ARMELFObjectWriter.cpp \
+ ARMELFStreamer.cpp \
ARMMachObjectWriter.cpp \
ARMMCAsmInfo.cpp \
ARMMCCodeEmitter.cpp \
ARMMCExpr.cpp \
- ARMMCTargetDesc.cpp
+ ARMMCTargetDesc.cpp \
+ ARMUnwindOpAsm.cpp
CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= ARMGenInstrInfo \
diff --git a/lib/clang/libllvmarmdisassembler/Makefile b/lib/clang/libllvmarmdisassembler/Makefile
index eb4673672b1d..6af72652c64b 100644
--- a/lib/clang/libllvmarmdisassembler/Makefile
+++ b/lib/clang/libllvmarmdisassembler/Makefile
@@ -9,7 +9,6 @@ INCDIR= lib/Target/ARM
SRCS= ARMDisassembler.cpp
TGHDRS= ARMGenDisassemblerTables \
- ARMGenEDInfo \
ARMGenInstrInfo \
ARMGenRegisterInfo \
ARMGenSubtargetInfo
diff --git a/lib/clang/libllvmasmprinter/Makefile b/lib/clang/libllvmasmprinter/Makefile
index 97bc73d3f41d..5df08988827d 100644
--- a/lib/clang/libllvmasmprinter/Makefile
+++ b/lib/clang/libllvmasmprinter/Makefile
@@ -15,7 +15,10 @@ SRCS= ARMException.cpp \
DwarfCompileUnit.cpp \
DwarfDebug.cpp \
DwarfException.cpp \
+ ErlangGCPrinter.cpp \
OcamlGCPrinter.cpp \
Win64Exception.cpp
+TGHDRS= Intrinsics
+
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmbitreader/Makefile b/lib/clang/libllvmbitreader/Makefile
index 094e0e773304..6add8a39ab08 100644
--- a/lib/clang/libllvmbitreader/Makefile
+++ b/lib/clang/libllvmbitreader/Makefile
@@ -5,7 +5,9 @@
LIB= llvmbitreader
SRCDIR= lib/Bitcode/Reader
-SRCS= BitcodeReader.cpp
+SRCS= BitReader.cpp \
+ BitcodeReader.cpp \
+ BitstreamReader.cpp
TGHDRS= Intrinsics
diff --git a/lib/clang/libllvmbitwriter/Makefile b/lib/clang/libllvmbitwriter/Makefile
index 1cb9d411281e..a99d1aca836d 100644
--- a/lib/clang/libllvmbitwriter/Makefile
+++ b/lib/clang/libllvmbitwriter/Makefile
@@ -5,7 +5,8 @@
LIB= llvmbitwriter
SRCDIR= lib/Bitcode/Writer
-SRCS= BitcodeWriter.cpp \
+SRCS= BitWriter.cpp \
+ BitcodeWriter.cpp \
BitcodeWriterPass.cpp \
ValueEnumerator.cpp
diff --git a/lib/clang/libllvmcodegen/Makefile b/lib/clang/libllvmcodegen/Makefile
index e65d19ce275d..1d41a6affbb3 100644
--- a/lib/clang/libllvmcodegen/Makefile
+++ b/lib/clang/libllvmcodegen/Makefile
@@ -8,17 +8,18 @@ SRCDIR= lib/CodeGen
SRCS= AggressiveAntiDepBreaker.cpp \
AllocationOrder.cpp \
Analysis.cpp \
+ BasicTargetTransformInfo.cpp \
BranchFolding.cpp \
CalcSpillWeights.cpp \
CallingConvLower.cpp \
CodeGen.cpp \
- CodePlacementOpt.cpp \
CriticalAntiDepBreaker.cpp \
DFAPacketizer.cpp \
DeadMachineInstructionElim.cpp \
DwarfEHPrepare.cpp \
EarlyIfConversion.cpp \
EdgeBundles.cpp \
+ ErlangGC.cpp \
ExecutionDepsFix.cpp \
ExpandISelPseudos.cpp \
ExpandPostRAPseudos.cpp \
@@ -59,7 +60,6 @@ SRCS= AggressiveAntiDepBreaker.cpp \
MachineInstrBundle.cpp \
MachineLICM.cpp \
MachineLoopInfo.cpp \
- MachineLoopRanges.cpp \
MachineModuleInfo.cpp \
MachineModuleInfoImpls.cpp \
MachinePassRegistry.cpp \
@@ -106,9 +106,11 @@ SRCS= AggressiveAntiDepBreaker.cpp \
StrongPHIElimination.cpp \
TailDuplication.cpp \
TargetFrameLoweringImpl.cpp \
- TargetInstrInfoImpl.cpp \
+ TargetInstrInfo.cpp \
+ TargetLoweringBase.cpp \
TargetLoweringObjectFileImpl.cpp \
TargetOptionsImpl.cpp \
+ TargetRegisterInfo.cpp \
TargetSchedule.cpp \
TwoAddressInstructionPass.cpp \
UnreachableBlockElim.cpp \
diff --git a/lib/clang/libllvmcore/Makefile b/lib/clang/libllvmcore/Makefile
index d2010c0d97dd..4cbf3d63aaa9 100644
--- a/lib/clang/libllvmcore/Makefile
+++ b/lib/clang/libllvmcore/Makefile
@@ -4,7 +4,7 @@
LIB= llvmcore
-SRCDIR= lib/VMCore
+SRCDIR= lib/IR
SRCS= AsmWriter.cpp \
Attributes.cpp \
AutoUpgrade.cpp \
@@ -37,14 +37,12 @@ SRCS= AsmWriter.cpp \
PrintModulePass.cpp \
Type.cpp \
TypeFinder.cpp \
- TargetTransformInfo.cpp \
Use.cpp \
User.cpp \
Value.cpp \
ValueSymbolTable.cpp \
ValueTypes.cpp \
Verifier.cpp
-LLVM_REQUIRES_RTTI=
TGHDRS= Intrinsics
diff --git a/lib/clang/libllvmdebuginfo/Makefile b/lib/clang/libllvmdebuginfo/Makefile
index 757b9097a38d..72218ad82fd1 100644
--- a/lib/clang/libllvmdebuginfo/Makefile
+++ b/lib/clang/libllvmdebuginfo/Makefile
@@ -12,6 +12,7 @@ SRCS= DIContext.cpp \
DWARFDebugAbbrev.cpp \
DWARFDebugArangeSet.cpp \
DWARFDebugAranges.cpp \
+ DWARFDebugFrame.cpp \
DWARFDebugInfoEntry.cpp \
DWARFDebugLine.cpp \
DWARFDebugRangeList.cpp \
diff --git a/lib/clang/libllvminstrumentation/Makefile b/lib/clang/libllvminstrumentation/Makefile
index 6d666e518dca..e5e8b591e9a6 100644
--- a/lib/clang/libllvminstrumentation/Makefile
+++ b/lib/clang/libllvminstrumentation/Makefile
@@ -10,6 +10,7 @@ SRCS= AddressSanitizer.cpp \
BoundsChecking.cpp \
EdgeProfiling.cpp \
GCOVProfiling.cpp \
+ MemorySanitizer.cpp \
Instrumentation.cpp \
OptimalEdgeProfiling.cpp \
PathProfiling.cpp \
diff --git a/lib/clang/libllvmipa/Makefile b/lib/clang/libllvmipa/Makefile
index 4caa0e5dec84..85b75afa1c37 100644
--- a/lib/clang/libllvmipa/Makefile
+++ b/lib/clang/libllvmipa/Makefile
@@ -7,8 +7,10 @@ LIB= llvmipa
SRCDIR= lib/Analysis/IPA
SRCS= CallGraph.cpp \
CallGraphSCCPass.cpp \
+ CallPrinter.cpp \
FindUsedTypes.cpp \
- GlobalsModRef.cpp
+ GlobalsModRef.cpp \
+ InlineCost.cpp
.if ${MK_CLANG_EXTRAS} != "no"
SRCS+= IPA.cpp
diff --git a/lib/clang/libllvmirreader/Makefile b/lib/clang/libllvmirreader/Makefile
new file mode 100644
index 000000000000..d9f7e693fd43
--- /dev/null
+++ b/lib/clang/libllvmirreader/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+LIB= llvmirreader
+
+SRCDIR= lib/IRReader
+SRCS= IRReader.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmlinker/Makefile b/lib/clang/libllvmlinker/Makefile
index 7275131fc6ab..711b36986c16 100644
--- a/lib/clang/libllvmlinker/Makefile
+++ b/lib/clang/libllvmlinker/Makefile
@@ -5,9 +5,6 @@
LIB= llvmlinker
SRCDIR= lib/Linker
-SRCS= LinkArchives.cpp \
- LinkItems.cpp \
- LinkModules.cpp \
- Linker.cpp
+SRCS= LinkModules.cpp
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmc/Makefile b/lib/clang/libllvmmc/Makefile
index 61b8c370bbb2..3986ba6419e4 100644
--- a/lib/clang/libllvmmc/Makefile
+++ b/lib/clang/libllvmmc/Makefile
@@ -41,7 +41,6 @@ SRCS= ELFObjectWriter.cpp \
MCStreamer.cpp \
MCSubtargetInfo.cpp \
MCSymbol.cpp \
- MCTargetAsmLexer.cpp \
MCValue.cpp \
MCWin64EH.cpp \
MachObjectWriter.cpp \
diff --git a/lib/clang/libllvmmcdisassembler/Makefile b/lib/clang/libllvmmcdisassembler/Makefile
index 94aff3e90576..cfcf9193776a 100644
--- a/lib/clang/libllvmmcdisassembler/Makefile
+++ b/lib/clang/libllvmmcdisassembler/Makefile
@@ -5,10 +5,6 @@
LIB= llvmmcdisassembler
SRCDIR= lib/MC/MCDisassembler
-SRCS= Disassembler.cpp \
- EDDisassembler.cpp \
- EDInst.cpp \
- EDOperand.cpp \
- EDToken.cpp
+SRCS= Disassembler.cpp
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmcjit/Makefile b/lib/clang/libllvmmcjit/Makefile
index 207fd81725d4..ea3cf078c896 100644
--- a/lib/clang/libllvmmcjit/Makefile
+++ b/lib/clang/libllvmmcjit/Makefile
@@ -5,6 +5,7 @@
LIB= llvmmcjit
SRCDIR= lib/ExecutionEngine/MCJIT
-SRCS= MCJIT.cpp
+SRCS= MCJIT.cpp \
+ SectionMemoryManager.cpp
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmipscodegen/Makefile b/lib/clang/libllvmmipscodegen/Makefile
index 7675a01666c5..e5a99c942163 100644
--- a/lib/clang/libllvmmipscodegen/Makefile
+++ b/lib/clang/libllvmmipscodegen/Makefile
@@ -6,11 +6,14 @@ LIB= llvmmipscodegen
SRCDIR= lib/Target/Mips
SRCS= Mips16FrameLowering.cpp \
+ Mips16ISelDAGToDAG.cpp \
+ Mips16ISelLowering.cpp \
Mips16InstrInfo.cpp \
Mips16RegisterInfo.cpp \
MipsAnalyzeImmediate.cpp \
MipsAsmPrinter.cpp \
MipsCodeEmitter.cpp \
+ MipsConstantIslandPass.cpp \
MipsDelaySlotFiller.cpp \
MipsFrameLowering.cpp \
MipsISelDAGToDAG.cpp \
@@ -20,8 +23,12 @@ SRCS= Mips16FrameLowering.cpp \
MipsLongBranch.cpp \
MipsMCInstLower.cpp \
MipsMachineFunction.cpp \
+ MipsModuleISelDAGToDAG.cpp \
+ MipsOs16.cpp \
MipsRegisterInfo.cpp \
MipsSEFrameLowering.cpp \
+ MipsSEISelDAGToDAG.cpp \
+ MipsSEISelLowering.cpp \
MipsSEInstrInfo.cpp \
MipsSERegisterInfo.cpp \
MipsSelectionDAGInfo.cpp \
diff --git a/lib/clang/libllvmmipsdesc/Makefile b/lib/clang/libllvmmipsdesc/Makefile
index 4ddb64635367..c5e60c648a78 100644
--- a/lib/clang/libllvmmipsdesc/Makefile
+++ b/lib/clang/libllvmmipsdesc/Makefile
@@ -8,9 +8,11 @@ SRCDIR= lib/Target/Mips/MCTargetDesc
SRCS= MipsAsmBackend.cpp \
MipsDirectObjLower.cpp \
MipsELFObjectWriter.cpp \
+ MipsELFStreamer.cpp \
MipsMCAsmInfo.cpp \
MipsMCCodeEmitter.cpp \
- MipsMCTargetDesc.cpp
+ MipsMCTargetDesc.cpp \
+ MipsReginfo.cpp
CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= MipsGenInstrInfo \
diff --git a/lib/clang/libllvmmipsdisassembler/Makefile b/lib/clang/libllvmmipsdisassembler/Makefile
index 1c0a4b66fb4c..41d20628416b 100644
--- a/lib/clang/libllvmmipsdisassembler/Makefile
+++ b/lib/clang/libllvmmipsdisassembler/Makefile
@@ -9,7 +9,6 @@ INCDIR= lib/Target/Mips
SRCS= MipsDisassembler.cpp
TGHDRS= MipsGenDisassemblerTables \
- MipsGenEDInfo \
MipsGenInstrInfo \
MipsGenRegisterInfo \
MipsGenSubtargetInfo
diff --git a/lib/clang/libllvmobjcarcopts/Makefile b/lib/clang/libllvmobjcarcopts/Makefile
new file mode 100644
index 000000000000..5c47aa8f98e7
--- /dev/null
+++ b/lib/clang/libllvmobjcarcopts/Makefile
@@ -0,0 +1,20 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+LIB= llvmobjcarcopts
+
+SRCDIR= lib/Transforms/ObjCARC
+SRCS= ObjCARC.cpp \
+ ObjCARCOpts.cpp \
+ ObjCARCExpand.cpp \
+ ObjCARCAPElim.cpp \
+ ObjCARCAliasAnalysis.cpp \
+ ObjCARCUtil.cpp \
+ ObjCARCContract.cpp \
+ DependencyAnalysis.cpp \
+ ProvenanceAnalysis.cpp
+
+TGHDRS= Intrinsics
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmobject/Makefile b/lib/clang/libllvmobject/Makefile
index c8c8068ed3c1..7358c137c8ed 100644
--- a/lib/clang/libllvmobject/Makefile
+++ b/lib/clang/libllvmobject/Makefile
@@ -10,7 +10,6 @@ SRCS= Archive.cpp \
COFFObjectFile.cpp \
ELFObjectFile.cpp \
Error.cpp \
- MachOObject.cpp \
MachOObjectFile.cpp \
Object.cpp \
ObjectFile.cpp
diff --git a/lib/clang/libllvmpowerpccodegen/Makefile b/lib/clang/libllvmpowerpccodegen/Makefile
index a09da599a9bb..0c77b5c48a2c 100644
--- a/lib/clang/libllvmpowerpccodegen/Makefile
+++ b/lib/clang/libllvmpowerpccodegen/Makefile
@@ -20,7 +20,8 @@ SRCS= PPCAsmPrinter.cpp \
PPCRegisterInfo.cpp \
PPCSelectionDAGInfo.cpp \
PPCSubtarget.cpp \
- PPCTargetMachine.cpp
+ PPCTargetMachine.cpp \
+ PPCTargetTransformInfo.cpp
TGHDRS= Intrinsics \
PPCGenCallingConv \
diff --git a/lib/clang/libllvmscalaropts/Makefile b/lib/clang/libllvmscalaropts/Makefile
index 87eaf23dcf70..38d945c11a80 100644
--- a/lib/clang/libllvmscalaropts/Makefile
+++ b/lib/clang/libllvmscalaropts/Makefile
@@ -27,7 +27,6 @@ SRCS= ADCE.cpp \
LoopUnswitch.cpp \
LowerAtomic.cpp \
MemCpyOptimizer.cpp \
- ObjCARC.cpp \
Reassociate.cpp \
Reg2Mem.cpp \
SCCP.cpp \
diff --git a/lib/clang/libllvmsupport/Makefile b/lib/clang/libllvmsupport/Makefile
index 5fcff88dd82d..6d043b49cf48 100644
--- a/lib/clang/libllvmsupport/Makefile
+++ b/lib/clang/libllvmsupport/Makefile
@@ -14,6 +14,8 @@ SRCS= APFloat.cpp \
BranchProbability.cpp \
CommandLine.cpp \
ConstantRange.cpp \
+ ConvertUTF.c \
+ ConvertUTFWrapper.cpp \
CrashRecoveryContext.cpp \
DAGDeltaAlgorithm.cpp \
Debug.cpp \
@@ -22,14 +24,18 @@ SRCS= APFloat.cpp \
DynamicLibrary.cpp \
Errno.cpp \
ErrorHandling.cpp \
+ FileOutputBuffer.cpp \
FoldingSet.cpp \
FormattedStream.cpp \
GraphWriter.cpp \
Hashing.cpp \
Host.cpp \
- IntervalMap.cpp \
+ IncludeFile.cpp \
IntEqClasses.cpp \
+ IntervalMap.cpp \
IntrusiveRefCntPtr.cpp \
+ IsInf.cpp \
+ IsNAN.cpp \
Locale.cpp \
LockFileManager.cpp \
ManagedStatic.cpp \
@@ -65,6 +71,9 @@ SRCS= APFloat.cpp \
Triple.cpp \
Twine.cpp \
Valgrind.cpp \
+ Watchdog.cpp \
+ YAMLParser.cpp \
+ YAMLTraits.cpp \
circular_raw_ostream.cpp \
raw_os_ostream.cpp \
raw_ostream.cpp \
@@ -74,17 +83,19 @@ SRCS= APFloat.cpp \
regfree.c \
regstrlcpy.c \
system_error.cpp
-LLVM_REQUIRES_RTTI=
.if ${MK_CLANG_EXTRAS} != "no"
-SRCS+= BlockFrequency.cpp \
- BranchProbability.cpp \
+SRCS+= Compression.cpp \
DataExtractor.cpp \
DataStream.cpp \
Disassembler.cpp \
FileUtilities.cpp \
- MemoryObject.cpp \
SystemUtils.cpp
.endif
.include "../clang.lib.mk"
+
+# Ugly hack to work around CLOCK_PROCESS_CPUTIME_ID not being properly defined
+# between r239347 and r245428.
+CXXFLAGS.Process.cpp= -DCLOCK_PROCESS_CPUTIME_ID=15
+CXXFLAGS+= ${CXXFLAGS.${.IMPSRC:T}}
diff --git a/lib/clang/libllvmtablegen/Makefile b/lib/clang/libllvmtablegen/Makefile
index 069cec0b0e3e..9a764b30766f 100644
--- a/lib/clang/libllvmtablegen/Makefile
+++ b/lib/clang/libllvmtablegen/Makefile
@@ -12,6 +12,5 @@ SRCS= Error.cpp \
TableGenBackend.cpp \
TGLexer.cpp \
TGParser.cpp
-LLVM_REQUIRES_EH=
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmtarget/Makefile b/lib/clang/libllvmtarget/Makefile
index 595d2ccbc504..b85fbec0b2b9 100644
--- a/lib/clang/libllvmtarget/Makefile
+++ b/lib/clang/libllvmtarget/Makefile
@@ -7,15 +7,12 @@ LIB= llvmtarget
SRCDIR= lib/Target
SRCS= Mangler.cpp \
Target.cpp \
- TargetInstrInfo.cpp \
TargetIntrinsicInfo.cpp \
TargetJITInfo.cpp \
TargetLibraryInfo.cpp \
TargetLoweringObjectFile.cpp \
TargetMachine.cpp \
TargetMachineC.cpp \
- TargetRegisterInfo.cpp \
- TargetSubtargetInfo.cpp \
- TargetTransformImpl.cpp
+ TargetSubtargetInfo.cpp
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmtransformutils/Makefile b/lib/clang/libllvmtransformutils/Makefile
index 0ed2624f1aab..cfdc85f2454f 100644
--- a/lib/clang/libllvmtransformutils/Makefile
+++ b/lib/clang/libllvmtransformutils/Makefile
@@ -5,8 +5,7 @@
LIB= llvmtransformutils
SRCDIR= lib/Transforms/Utils
-SRCS= AddrModeMatcher.cpp \
- BasicBlockUtils.cpp \
+SRCS= BasicBlockUtils.cpp \
BreakCriticalEdges.cpp \
BuildLibCalls.cpp \
BypassSlowDivision.cpp \
diff --git a/lib/clang/libllvmvectorize/Makefile b/lib/clang/libllvmvectorize/Makefile
index d0f5b73fd5e0..9a760faf664e 100644
--- a/lib/clang/libllvmvectorize/Makefile
+++ b/lib/clang/libllvmvectorize/Makefile
@@ -7,6 +7,8 @@ LIB= llvmvectorize
SRCDIR= lib/Transforms/Vectorize
SRCS= BBVectorize.cpp \
LoopVectorize.cpp \
+ SLPVectorizer.cpp \
+ VecUtils.cpp \
Vectorize.cpp
TGHDRS= Intrinsics
diff --git a/lib/clang/libllvmx86asmparser/Makefile b/lib/clang/libllvmx86asmparser/Makefile
index 252b2d09a7e8..0d32f9c158d2 100644
--- a/lib/clang/libllvmx86asmparser/Makefile
+++ b/lib/clang/libllvmx86asmparser/Makefile
@@ -6,8 +6,7 @@ LIB= llvmx86asmparser
SRCDIR= lib/Target/X86/AsmParser
INCDIR= lib/Target/X86
-SRCS= X86AsmLexer.cpp \
- X86AsmParser.cpp
+SRCS= X86AsmParser.cpp
TGHDRS= X86GenAsmMatcher \
X86GenInstrInfo \
diff --git a/lib/clang/libllvmx86codegen/Makefile b/lib/clang/libllvmx86codegen/Makefile
index 939b257ffb90..ed7ab8eccf33 100644
--- a/lib/clang/libllvmx86codegen/Makefile
+++ b/lib/clang/libllvmx86codegen/Makefile
@@ -9,6 +9,7 @@ SRCS= X86AsmPrinter.cpp \
X86COFFMachineModuleInfo.cpp \
X86CodeEmitter.cpp \
X86FastISel.cpp \
+ X86FixupLEAs.cpp \
X86FloatingPoint.cpp \
X86FrameLowering.cpp \
X86ISelDAGToDAG.cpp \
@@ -17,12 +18,14 @@ SRCS= X86AsmPrinter.cpp \
X86JITInfo.cpp \
X86MCInstLower.cpp \
X86MachineFunctionInfo.cpp \
+ X86PadShortFunction.cpp \
X86RegisterInfo.cpp \
X86SelectionDAGInfo.cpp \
X86Subtarget.cpp \
X86TargetMachine.cpp \
X86TargetObjectFile.cpp \
- X86VZeroUpper.cpp \
+ X86TargetTransformInfo.cpp \
+ X86VZeroUpper.cpp
TGHDRS= Intrinsics \
X86GenCallingConv \
diff --git a/lib/clang/libllvmx86disassembler/Makefile b/lib/clang/libllvmx86disassembler/Makefile
index 9b738007c72a..fbaa5c60bb1d 100644
--- a/lib/clang/libllvmx86disassembler/Makefile
+++ b/lib/clang/libllvmx86disassembler/Makefile
@@ -13,7 +13,6 @@ SRCS+= X86DisassemblerDecoder.c
.endif
TGHDRS= X86GenDisassemblerTables \
- X86GenEDInfo \
X86GenInstrInfo \
X86GenRegisterInfo
diff --git a/lib/csu/Makefile b/lib/csu/Makefile
new file mode 100644
index 000000000000..320a5a4d4732
--- /dev/null
+++ b/lib/csu/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+ARCH= ${MACHINE_ARCH:S/i386/i386-elf/}
+.if exists(${.CURDIR}/${ARCH})
+SUBDIR+= ${ARCH}
+.else
+SUBDIR+= ${MACHINE_CPUARCH}
+.endif
+
+.include <bsd.subdir.mk>
diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc
index 11ddc664c55b..95d5c5e5f355 100644
--- a/lib/csu/Makefile.inc
+++ b/lib/csu/Makefile.inc
@@ -4,4 +4,6 @@ SSP_CFLAGS=
SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/'
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
.include "../Makefile.inc"
diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile
index d1d70178c09c..567144aaed10 100644
--- a/lib/libc++/Makefile
+++ b/lib/libc++/Makefile
@@ -9,6 +9,7 @@ CXXINCLUDEDIR= ${INCLUDEDIR}/c++/v${SHLIB_MAJOR}
LIB= c++
SHLIB_MAJOR= 1
+SHLIB_LDSCRIPT= libc++.ldscript
SRCS+= algorithm.cpp\
bind.cpp\
@@ -164,6 +165,7 @@ RT_HEADERS= cxxabi.h\
.for hdr in ${STD_HEADERS}
STD+= ${HDRDIR}/${hdr}
+INCSLINKS+= ${CXXINCLUDEDIR}/${hdr} ${CXXINCLUDEDIR}/tr1/${hdr}
.endfor
.for hdr in ${RT_HEADERS}
STD+= ${LIBCXXRTDIR}/${hdr}
diff --git a/lib/libc++/libc++.ldscript b/lib/libc++/libc++.ldscript
new file mode 100644
index 000000000000..bec57f161698
--- /dev/null
+++ b/lib/libc++/libc++.ldscript
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+GROUP ( @@SHLIB@@ @@LIBDIR@@/libcxxrt.so )
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index ad98d41f802e..ba4dd0ae16c3 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -23,6 +23,7 @@ LIBC_ARCH=${MACHINE_CPUARCH}
# to CFLAGS below. -DSYSLIBC_SCCS affects just the system call stubs.
LIB=c
SHLIB_MAJOR= 7
+SHLIB_LDSCRIPT=libc.ldscript
WARNS?= 2
CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include
CFLAGS+=-I${.CURDIR}/${LIBC_ARCH}
@@ -99,6 +100,7 @@ NOASM=
CFLAGS+= -DYP
.include "${.CURDIR}/yp/Makefile.inc"
.endif
+.include "${.CURDIR}/capability/Makefile.inc"
.if ${MK_HESIOD} != "no"
CFLAGS+= -DHESIOD
.endif
diff --git a/lib/libc/amd64/gen/getcontextx.c b/lib/libc/amd64/gen/getcontextx.c
index 7412560b80dd..749bfbda0c51 100644
--- a/lib/libc/amd64/gen/getcontextx.c
+++ b/lib/libc/amd64/gen/getcontextx.c
@@ -57,14 +57,12 @@ __getcontextx_size(void)
}
int
-__fillcontextx(char *ctx)
+__fillcontextx2(char *ctx)
{
struct amd64_get_xfpustate xfpu;
ucontext_t *ucp;
ucp = (ucontext_t *)ctx;
- if (getcontext(ucp) == -1)
- return (-1);
if (xstate_sz != 0) {
xfpu.addr = (char *)(ucp + 1);
xfpu.len = xstate_sz;
@@ -80,6 +78,18 @@ __fillcontextx(char *ctx)
return (0);
}
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ if (getcontext(ucp) == -1)
+ return (-1);
+ __fillcontextx2(ctx);
+ return (0);
+}
+
__weak_reference(__getcontextx, getcontextx);
ucontext_t *
diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S
index a451491658d7..73b53641ad73 100644
--- a/lib/libc/amd64/sys/setlogin.S
+++ b/lib/libc/amd64/sys/setlogin.S
@@ -48,12 +48,7 @@ ENTRY(__sys_setlogin)
mov $SYS_setlogin,%rax
KERNCALL
jb HIDENAME(cerror)
-#ifdef PIC
- movq PIC_GOT(CNAME(_logname_valid)),%rdx
- movl $0,(%rdx)
-#else
movl $0,CNAME(_logname_valid)(%rip)
-#endif
ret /* setlogin(name) */
END(__sys_setlogin)
diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc
index ec36d4508216..cfc8a46575f3 100644
--- a/lib/libc/arm/gen/Makefile.inc
+++ b/lib/libc/arm/gen/Makefile.inc
@@ -3,7 +3,8 @@
SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \
getcontextx.c infinity.c ldexp.c makecontext.c \
- __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c
+ __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c \
+ arm_initfini.c
.if ${MK_ARM_EABI} == "no"
SRCS+= divsi3.S
diff --git a/lib/libc/arm/gen/_setjmp.S b/lib/libc/arm/gen/_setjmp.S
index 6594afba0744..b475f1eb4dfd 100644
--- a/lib/libc/arm/gen/_setjmp.S
+++ b/lib/libc/arm/gen/_setjmp.S
@@ -1,4 +1,4 @@
-/* $NetBSD: _setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */
+/* $NetBSD: _setjmp.S,v 1.12 2013/04/19 13:45:45 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
@@ -32,7 +32,17 @@
* SUCH DAMAGE.
*/
+#if !defined(__SOFTFP__) && !defined(__VFP_FP__) && !defined(__ARM_PCS)
+#error FPA is not supported anymore
+#endif
+
+#if defined(__ARM_EABI__) && !defined(_STANDALONE)
+ .fpu vfp
+#endif
+
#include <machine/asm.h>
+#include <machine/setjmp.h>
+
__FBSDID("$FreeBSD$");
/*
@@ -45,21 +55,35 @@ __FBSDID("$FreeBSD$");
* The previous signal state is NOT restored.
*
* Note: r0 is the return value
- * r1-r3 are scratch registers in functions
+ * r1-r3,ip are scratch registers in functions
*/
ENTRY(_setjmp)
ldr r1, .L_setjmp_magic
- str r1, [r0], #4
-#ifdef __SOFTFP__
- add r0, r0, #52
+
+#if defined(__ARM_EABI__) && !defined(_STANDALONE)
+ ldr r2, .Lfpu_present
+#ifdef PIC
+ GOT_INIT(r3, .L_setjmp_got, .L_setjmp_gotinit)
+ ldr r2, [r2, r3]
#else
- /* Store fp registers */
- sfm f4, 4, [r0], #48
- /* Store fpsr */
- rfs r1
- str r1, [r0], #0x0004
-#endif /* __SOFTFP__ */
+ ldr r2, [r2]
+#endif
+ teq r2, #0 /* do we have a FPU? */
+ beq 1f /* no, don't save VFP registers */
+
+ orr r1, r1, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
+ /* change magic to VFP magic */
+ add r2, r0, #(_JB_REG_D8 * 4)
+ vstmia r2, {d8-d15}
+ vmrs r2, fpscr
+ str r2, [r0, #(_JB_REG_FPSCR * 4)]
+1:
+#endif /* __ARM_EABI__ */
+
+ str r1, [r0]
+
+ add r0, r0, #(_JB_REG_R4 * 4)
/* Store integer registers */
stmia r0, {r4-r14}
@@ -68,23 +92,32 @@ ENTRY(_setjmp)
.L_setjmp_magic:
.word _JB_MAGIC__SETJMP
+#if defined(__ARM_EABI__) && !defined(_STANDALONE)
+ GOT_INITSYM(.L_setjmp_got, .L_setjmp_gotinit)
+.Lfpu_present:
+ .word PIC_SYM(_libc_arm_fpu_present, GOTOFF)
+#endif /* __ARM_EABI__ */
WEAK_ALIAS(___longjmp, _longjmp)
ENTRY(_longjmp)
- ldr r2, .L_setjmp_magic
- ldr r3, [r0], #4
- teq r2, r3
- bne botch
+ ldr r2, [r0] /* get magic from jmp_buf */
+ bic r3, r2, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
+ /* ignore VFP-ness of magic */
+ ldr ip, .L_setjmp_magic /* load magic */
+ teq ip, r3 /* magic correct? */
+ bne botch /* no, botch */
-#ifdef __SOFTFP__
- add r0, r0, #52
-#else
- /* Restore fp registers */
- lfm f4, 4, [r0], #48
- /* Restore fpsr */
- ldr r4, [r0], #0x0004
- wfs r4
-#endif /* __SOFTFP__ */
+#if defined(__ARM_EABI__) && !defined(_STANDALONE)
+ teq r3, r2 /* did magic change? */
+ beq 1f /* no, don't restore VFP */
+ add ip, r0, #(_JB_REG_D8 * 4)
+ vldmia ip, {d8-d15}
+ ldr ip, [r0, #(_JB_REG_FPSCR * 4)]
+ vmsr fpscr, ip
+1:
+#endif /* __ARM_EABI__ */
+
+ add r0, r0, #(_JB_REG_R4 * 4)
/* Restore integer registers */
ldmia r0, {r4-r14}
@@ -94,8 +127,7 @@ ENTRY(_longjmp)
beq botch
/* Set return value */
- mov r0, r1
- teq r0, #0x00000000
+ movs r0, r1
moveq r0, #0x00000001
RET
diff --git a/lib/libc/arm/gen/arm_initfini.c b/lib/libc/arm/gen/arm_initfini.c
new file mode 100644
index 000000000000..9def8c8dfbcb
--- /dev/null
+++ b/lib/libc/arm/gen/arm_initfini.c
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * Copyright (c) 2013 Andrew Turner
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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.
+ *
+ * Bases on NetBSD lib/libc/arch/arm/misc/arm_initfini.c
+ * $NetBSD: arm_initfini.c,v 1.2 2013/01/31 06:47:55 matt Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * To properly implement setjmp/longjmp for the ARM AAPCS ABI, it has to be
+ * aware of whether there is a FPU is present or not. Regardless of whether
+ * the hard-float ABI is being used, setjmp needs to save D8-D15. But it can
+ * only do this if those instructions won't cause an exception.
+ */
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+
+#include <stdbool.h>
+#include <stddef.h>
+
+extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
+ void *newp, size_t newlen);
+
+int _libc_arm_fpu_present;
+static bool _libc_aapcs_initialized;
+
+void _libc_aapcs_init(void) __attribute__((__constructor__, __used__));
+
+void
+_libc_aapcs_init(void)
+{
+ int mib[2];
+ size_t len;
+
+ if (_libc_aapcs_initialized)
+ return;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_FLOATINGPT;
+
+ len = sizeof(_libc_arm_fpu_present);
+ if (__sysctl(mib, 2, &_libc_arm_fpu_present, &len, NULL, 0) == -1 ||
+ len != sizeof(_libc_arm_fpu_present)) {
+ /* sysctl failed, assume no vfp */
+ _libc_arm_fpu_present = 0;
+ }
+
+ _libc_aapcs_initialized = true;
+}
diff --git a/lib/libc/arm/gen/getcontextx.c b/lib/libc/arm/gen/getcontextx.c
index 307978a466dd..54f851384811 100644
--- a/lib/libc/arm/gen/getcontextx.c
+++ b/lib/libc/arm/gen/getcontextx.c
@@ -40,6 +40,13 @@ __getcontextx_size(void)
}
int
+__fillcontextx2(char *ctx)
+{
+
+ return (0);
+}
+
+int
__fillcontextx(char *ctx)
{
ucontext_t *ucp;
diff --git a/lib/libc/arm/gen/setjmp.S b/lib/libc/arm/gen/setjmp.S
index e5f581f0e3f2..b7af33b8856a 100644
--- a/lib/libc/arm/gen/setjmp.S
+++ b/lib/libc/arm/gen/setjmp.S
@@ -1,4 +1,4 @@
-/* $NetBSD: setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */
+/* $NetBSD: setjmp.S,v 1.14 2013/04/19 13:45:45 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
@@ -32,8 +32,19 @@
* SUCH DAMAGE.
*/
+#if !defined(__SOFTFP__) && !defined(__VFP_FP__) && !defined(__ARM_PCS)
+#error FPA is not supported anymore
+#endif
+
+#ifdef __ARM_EABI__
+ .fpu vfp
+#endif
+
#include <machine/asm.h>
+#include <machine/setjmp.h>
+
__FBSDID("$FreeBSD$");
+
/*
* C library -- setjmp, longjmp
*
@@ -47,83 +58,95 @@ __FBSDID("$FreeBSD$");
ENTRY(setjmp)
/* Block all signals and retrieve the old signal mask */
stmfd sp!, {r0, r14}
- add r2, r0, #(25 * 4) /* oset */
- mov r0, #0x00000001 /* SIG_BLOCK */
- mov r1, #0 /* set */
-
+ add r2, r0, #(_JB_SIGMASK * 4) /* oset */
+ mov r1, #0x00000000 /* set */
+ mov r0, #0x00000001 /* SIG_BLOCK */
bl PIC_SYM(_C_LABEL(sigprocmask), PLT)
-
ldmfd sp!, {r0, r14}
ldr r1, .Lsetjmp_magic
- str r1, [r0], #4
-#ifdef __SOFTFP__
- add r0, r0, #52
+#ifdef __ARM_EABI__
+ ldr r2, .Lfpu_present
+#ifdef PIC
+ GOT_INIT(r3, .Lsetjmp_got, .Lsetjmp_gotinit)
+ ldr r2, [r2, r3]
#else
- /* Store fp registers */
- sfm f4, 4, [r0], #48
- /* Store fpsr */
- rfs r1
- str r1, [r0], #0x0004
-#endif /* __SOFTFP__ */
+ ldr r2, [r2]
+#endif
+ teq r2, #0 /* do we have a FPU? */
+ beq 1f /* no, don't save VFP registers */
+
+ orr r1, r1, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
+ /* change magic to VFP magic */
+ add r2, r0, #(_JB_REG_D8 * 4)
+ vstmia r2, {d8-d15}
+ vmrs r2, fpscr
+ str r2, [r0, #(_JB_REG_FPSCR * 4)]
+1:
+#endif /* __ARM_EABI__ */
+
+ str r1, [r0] /* store magic */
+
/* Store integer registers */
+ add r0, r0, #(_JB_REG_R4 * 4)
stmia r0, {r4-r14}
mov r0, #0x00000000
RET
.Lsetjmp_magic:
.word _JB_MAGIC_SETJMP
+#ifdef __ARM_EABI__
+ GOT_INITSYM(.Lsetjmp_got, .Lsetjmp_gotinit)
+.Lfpu_present:
+ .word PIC_SYM(_libc_arm_fpu_present, GOTOFF)
+#endif /* __ARM_EABI__ */
.weak _C_LABEL(longjmp)
.set _C_LABEL(longjmp), _C_LABEL(__longjmp)
ENTRY(__longjmp)
- ldr r2, .Lsetjmp_magic
- ldr r3, [r0]
- teq r2, r3
- bne botch
-
-
- /* Set signal mask */
- stmfd sp!, {r0, r1, r14}
- sub sp, sp, #4 /* align the stack */
-
- add r1, r0, #(25 * 4) /* Signal mask */
- mov r0, #3 /* SIG_SETMASK */
- mov r2, #0
+ ldr r2, [r0]
+ ldr ip, .Lsetjmp_magic
+ bic r3, r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
+ teq r3, ip
+ bne .Lbotch
+
+ /* Restore the signal mask. */
+ stmfd sp!, {r0-r2, r14}
+ mov r2, #0x00000000
+ add r1, r0, #(_JB_SIGMASK * 4) /* Signal mask */
+ mov r0, #3 /* SIG_SETMASK */
bl PIC_SYM(_C_LABEL(sigprocmask), PLT)
-
- add sp, sp, #4 /* unalign the stack */
- ldmfd sp!, {r0, r1, r14}
-
- add r0, r0, #4
-#ifdef __SOFTFP__
- add r0, r0, #52
-#else
- /* Restore fp registers */
- lfm f4, 4, [r0], #48
- /* Restore FPSR */
- ldr r4, [r0], #0x0004
- wfs r4
-#endif /* __SOFTFP__ */
+ ldmfd sp!, {r0-r2, r14}
+
+#ifdef __ARM_EABI__
+ tst r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP)
+ /* is this a VFP magic? */
+ beq 1f /* no, don't restore VFP */
+ add ip, r0, #(_JB_REG_D8 * 4)
+ vldmia ip, {d8-d15}
+ ldr ip, [r0, #(_JB_REG_FPSCR * 4)]
+ vmsr fpscr, ip
+1:
+#endif /* __ARM_EABI__ */
+
+ add r0, r0, #(_JB_REG_R4 * 4)
/* Restore integer registers */
ldmia r0, {r4-r14}
/* Validate sp and r14 */
teq sp, #0
teqne r14, #0
- beq botch
+ beq .Lbotch
/* Set return value */
-
- mov r0, r1
- teq r0, #0x00000000
+ movs r0, r1
moveq r0, #0x00000001
RET
/* validation failed, die die die. */
-botch:
+.Lbotch:
bl PIC_SYM(_C_LABEL(longjmperror), PLT)
bl PIC_SYM(_C_LABEL(abort), PLT)
b . - 8 /* Cannot get here */
diff --git a/lib/libc/arm/gen/sigsetjmp.S b/lib/libc/arm/gen/sigsetjmp.S
index 09ec2561029b..79f1f9d4cebe 100644
--- a/lib/libc/arm/gen/sigsetjmp.S
+++ b/lib/libc/arm/gen/sigsetjmp.S
@@ -1,4 +1,4 @@
-/* $NetBSD: sigsetjmp.S,v 1.3 2002/08/17 19:54:30 thorpej Exp $ */
+/* $NetBSD: sigsetjmp.S,v 1.6 2013/04/19 16:50:22 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
@@ -35,6 +35,8 @@
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
+#include <machine/setjmp.h>
+
/*
* C library -- sigsetjmp, siglongjmp
*
@@ -55,8 +57,10 @@ ENTRY(sigsetjmp)
WEAK_ALIAS(__siglongjmp, siglongjmp)
ENTRY(siglongjmp)
- ldr r2, .L_setjmp_magic
- ldr r3, [r0]
- teq r2, r3
+ ldr r2, .L_setjmp_magic /* load magic */
+ ldr r3, [r0] /* get magic from jmp_buf */
+ bic r3, r3, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
+ /* ignore VFP-ness of magic */
+ teq r2, r3 /* magic correct? */
beq PIC_SYM(_C_LABEL(_longjmp), PLT)
b PIC_SYM(_C_LABEL(longjmp), PLT)
diff --git a/lib/libc/capability/Makefile.inc b/lib/libc/capability/Makefile.inc
new file mode 100644
index 000000000000..934fc8b91767
--- /dev/null
+++ b/lib/libc/capability/Makefile.inc
@@ -0,0 +1,19 @@
+# $FreeBSD$
+
+# capability sources
+.PATH: ${.CURDIR}/../../sys/kern
+
+SRCS+= subr_capability.c
+
+SYM_MAPS+= ${.CURDIR}/capability/Symbol.map
+
+#MAN+= cap_rights_init.3
+
+#MLINKS+=cap_rights_init.3 cap_rights_set.3
+#MLINKS+=cap_rights_init.3 cap_rights_clear.3
+#MLINKS+=cap_rights_init.3 cap_rights_is_set.3
+#MLINKS+=cap_rights_init.3 cap_rights_is_valid.3
+#MLINKS+=cap_rights_init.3 cap_rights_merge.3
+#MLINKS+=cap_rights_init.3 cap_rights_remove.3
+#MLINKS+=cap_rights_init.3 cap_rights_contains.3
+
diff --git a/lib/libc/capability/Symbol.map b/lib/libc/capability/Symbol.map
new file mode 100644
index 000000000000..c5c18c2f5315
--- /dev/null
+++ b/lib/libc/capability/Symbol.map
@@ -0,0 +1,14 @@
+/*
+ * $FreeBSD$
+ */
+
+FBSD_1.3 {
+ __cap_rights_clear;
+ cap_rights_contains;
+ __cap_rights_init;
+ __cap_rights_is_set;
+ cap_rights_is_valid;
+ cap_rights_merge;
+ cap_rights_remove;
+ __cap_rights_set;
+};
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c
index 47f3646ac46a..94ba014ed3af 100644
--- a/lib/libc/db/btree/bt_open.c
+++ b/lib/libc/db/btree/bt_open.c
@@ -196,7 +196,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int
goto einval;
}
- if ((t->bt_fd = _open(fname, flags, mode)) < 0)
+ if ((t->bt_fd = _open(fname, flags | O_CLOEXEC, mode)) < 0)
goto err;
} else {
@@ -207,9 +207,6 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int
F_SET(t, B_INMEM);
}
- if (_fcntl(t->bt_fd, F_SETFD, 1) == -1)
- goto err;
-
if (_fstat(t->bt_fd, &sb))
goto err;
if (sb.st_size) {
@@ -405,7 +402,7 @@ tmp(void)
(void)sigfillset(&set);
(void)_sigprocmask(SIG_BLOCK, &set, &oset);
- if ((fd = mkstemp(path)) != -1)
+ if ((fd = mkostemp(path, O_CLOEXEC)) != -1)
(void)unlink(path);
(void)_sigprocmask(SIG_SETMASK, &oset, NULL);
return(fd);
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c
index 638814ceb5d2..af80929112b0 100644
--- a/lib/libc/db/hash/hash.c
+++ b/lib/libc/db/hash/hash.c
@@ -121,9 +121,8 @@ __hash_open(const char *file, int flags, int mode,
hashp->flags = flags;
if (file) {
- if ((hashp->fp = _open(file, flags, mode)) == -1)
+ if ((hashp->fp = _open(file, flags | O_CLOEXEC, mode)) == -1)
RETURN_ERROR(errno, error0);
- (void)_fcntl(hashp->fp, F_SETFD, 1);
new_table = _fstat(hashp->fp, &statbuf) == 0 &&
statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY;
} else
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
index fa01775fe8b3..d319d988c165 100644
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -862,10 +862,8 @@ open_temp(HTAB *hashp)
/* Block signals; make sure file goes away at process exit. */
(void)sigfillset(&set);
(void)_sigprocmask(SIG_BLOCK, &set, &oset);
- if ((hashp->fp = mkstemp(path)) != -1) {
+ if ((hashp->fp = mkostemp(path, O_CLOEXEC)) != -1)
(void)unlink(path);
- (void)_fcntl(hashp->fp, F_SETFD, 1);
- }
(void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
return (hashp->fp != -1 ? 0 : -1);
}
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index fac1e43f2fd0..a88150c2035c 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -31,6 +31,7 @@ SRCS+= __getosreldate.c \
disklabel.c \
dlfcn.c \
drand48.c \
+ dup3.c \
elf_utils.c \
erand48.c \
err.c \
@@ -184,6 +185,7 @@ MAN+= alarm.3 \
dlinfo.3 \
dllockinit.3 \
dlopen.3 \
+ dup3.3 \
err.3 \
exec.3 \
feature_present.3 \
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index 243895137210..5885420bb24a 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -383,7 +383,9 @@ FBSD_1.2 {
FBSD_1.3 {
clock_getcpuclockid;
dirfd;
- fdlopen;
+ dup3;
+ fdclosedir;
+ fdlopen;
__FreeBSD_libc_enter_restricted_mode;
getcontextx;
gid_from_group;
@@ -529,5 +531,6 @@ FBSDprivate_1.0 {
__elf_aux_vector;
__pthread_map_stacks_exec;
__fillcontextx;
+ __fillcontextx2;
__getcontextx_size;
};
diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c
index 4b520cc458ae..88ded37be51f 100644
--- a/lib/libc/gen/closedir.c
+++ b/lib/libc/gen/closedir.c
@@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
* close a directory.
*/
int
-closedir(DIR *dirp)
+fdclosedir(DIR *dirp)
{
int fd;
@@ -65,5 +65,12 @@ closedir(DIR *dirp)
_pthread_mutex_destroy(&dirp->dd_lock);
}
free((void *)dirp);
- return(_close(fd));
+ return (fd);
+}
+
+int
+closedir(DIR *dirp)
+{
+
+ return (_close(fdclosedir(dirp)));
}
diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3
index 0fd5bba32b7a..4573d4513fe2 100644
--- a/lib/libc/gen/directory.3
+++ b/lib/libc/gen/directory.3
@@ -28,7 +28,7 @@
.\" @(#)directory.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd July 5, 2012
+.Dd August 18, 2013
.Dt DIRECTORY 3
.Os
.Sh NAME
@@ -40,6 +40,7 @@
.Nm seekdir ,
.Nm rewinddir ,
.Nm closedir ,
+.Nm fdclosedir ,
.Nm dirfd
.Nd directory operations
.Sh LIBRARY
@@ -64,6 +65,8 @@
.Ft int
.Fn closedir "DIR *dirp"
.Ft int
+.Fn fdclosedir "DIR *dirp"
+.Ft int
.Fn dirfd "DIR *dirp"
.Sh DESCRIPTION
The
@@ -208,6 +211,13 @@ On failure, \-1 is returned and the global variable
is set to indicate the error.
.Pp
The
+.Fn fdclosedir
+function is equivalent to the
+.Fn closedir
+function except that this function returns directory file descriptor instead of
+closing it.
+.Pp
+The
.Fn dirfd
function
returns the integer file descriptor associated with the named
@@ -252,6 +262,9 @@ The
.Fn fdopendir
function appeared in
.Fx 8.0 .
+.Fn fdclosedir
+function appeared in
+.Fx 10.0 .
.Sh BUGS
The invalidation of
.Fn telldir
diff --git a/lib/libc/gen/dl_iterate_phdr.3 b/lib/libc/gen/dl_iterate_phdr.3
index f148ab104c4e..5b8afc6a09f4 100644
--- a/lib/libc/gen/dl_iterate_phdr.3
+++ b/lib/libc/gen/dl_iterate_phdr.3
@@ -29,7 +29,7 @@ Statically linked programs use an implementation of
.Fn dl_iterate_phdr
from libc.
.Sh SYNOPSIS
-.Fd #include <link.h>
+.In link.h
.Ft int
.Fn dl_iterate_phdr "int (*callback)(struct dl_phdr_info *, size_t, void *)" "void *data"
.Sh DESCRIPTION
diff --git a/lib/libc/gen/dup3.3 b/lib/libc/gen/dup3.3
new file mode 100644
index 000000000000..d3bb116189b7
--- /dev/null
+++ b/lib/libc/gen/dup3.3
@@ -0,0 +1,116 @@
+.\" Copyright (c) 2013 Jilles Tjoelker
+.\" 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd August 16, 2013
+.Dt DUP3 3
+.Os
+.Sh NAME
+.Nm dup3
+.Nd duplicate an existing file descriptor
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.In unistd.h
+.Ft int
+.Fn dup3 "int oldd" "int newd" "int flags"
+.Sh DESCRIPTION
+The
+.Fn dup3
+function
+duplicates an existing object descriptor
+while allowing the value of the new descriptor to be specified.
+.Pp
+The close-on-exec flag on the new file descriptor is determined by the
+.Dv O_CLOEXEC
+bit in
+.Fa flags .
+.Pp
+If
+.Fa oldd
+\*(Ne
+.Fa newd
+and
+.Fa flags
+== 0,
+the behavior is identical to
+.Li dup2(oldd, newd) .
+.Pp
+If
+.Fa oldd
+==
+.Fa newd ,
+then
+.Fn dup3
+fails, unlike
+.Xr dup2 2 .
+.Sh RETURN VALUES
+The value -1 is returned if an error occurs.
+The external variable
+.Va errno
+indicates the cause of the error.
+.Sh ERRORS
+The
+.Fn dup3
+function fails if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa oldd
+argument is not a valid active descriptor or the
+.Fa newd
+argument is negative or exceeds the maximum allowable descriptor number
+.It Bq Er EINVAL
+The
+.Fa oldd
+argument is equal to the
+.Fa newd
+argument.
+.It Bq Er EINVAL
+The
+.Fa flags
+argument has bits set other than
+.Dv O_CLOEXEC .
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr close 2 ,
+.Xr dup2 2 ,
+.Xr fcntl 2 ,
+.Xr getdtablesize 2 ,
+.Xr open 2 ,
+.Xr pipe 2 ,
+.Xr socket 2 ,
+.Xr socketpair 2
+.Sh STANDARDS
+The
+.Fn dup3
+function does not conform to any standard.
+.Sh HISTORY
+The
+.Fn dup3
+function appeared in
+.Fx 10.0 .
diff --git a/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h b/lib/libc/gen/dup3.c
index cd4c9a3d1663..ac8877cdc8a6 100644
--- a/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h
+++ b/lib/libc/gen/dup3.c
@@ -1,7 +1,9 @@
/*-
- * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
+ * Copyright (c) 2012 Jukka A. Ukkonen
* All rights reserved.
*
+ * This software was developed by Jukka Ukkonen for FreeBSD.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -27,19 +29,31 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
-#include <machine/atomic.h>
+#include "namespace.h"
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "un-namespace.h"
-TYPE
-NAME(volatile TYPE *ptr, TYPE oldval, TYPE newval)
+int
+__dup3(int oldfd, int newfd, int flags)
{
- TYPE t;
+ int how;
+
+ if (oldfd == newfd) {
+ errno = EINVAL;
+ return (-1);
+ }
- while (!CMPSET(ptr, oldval, newval)) {
- t = *ptr;
- if (t != oldval)
- return (t);
+ if (flags & ~O_CLOEXEC) {
+ errno = EINVAL;
+ return (-1);
}
- return (oldval);
+ how = (flags & O_CLOEXEC) ? F_DUP2FD_CLOEXEC : F_DUP2FD;
+
+ return (_fcntl(oldfd, how, newfd));
}
+
+__weak_reference(__dup3, dup3);
+__weak_reference(__dup3, _dup3);
diff --git a/lib/libc/gen/errlst.c b/lib/libc/gen/errlst.c
index d8178236deed..f8fe9684a26a 100644
--- a/lib/libc/gen/errlst.c
+++ b/lib/libc/gen/errlst.c
@@ -34,6 +34,7 @@ static char sccsid[] = "@(#)errlst.c 8.2 (Berkeley) 11/16/93";
__FBSDID("$FreeBSD$");
#include <stdio.h>
+#include "errlst.h"
const char *const sys_errlist[] = {
"No error: 0", /* 0 - ENOERROR */
@@ -152,5 +153,12 @@ const char *const sys_errlist[] = {
"Protocol error", /* 92 - EPROTO */
"Capabilities insufficient", /* 93 - ENOTCAPABLE */
"Not permitted in capability mode", /* 94 - ECAPMODE */
+ "State not recoverable", /* 95 - ENOTRECOVERABLE */
+ "Previous owner died", /* 96 - EOWNERDEAD */
};
const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]);
+
+#ifdef PIC
+__strong_reference(sys_errlist, __hidden_sys_errlist);
+__strong_reference(sys_nerr, __hidden_sys_nerr);
+#endif
diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c
index c38aafc8b0b5..47d0a4131f5c 100644
--- a/lib/libc/gen/fnmatch.c
+++ b/lib/libc/gen/fnmatch.c
@@ -194,8 +194,6 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs)
&patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (FNM_NOMATCH);
- if (pclen == 0)
- pc = '\\';
pattern += pclen;
}
/* FALLTHROUGH */
diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h
index dfdd53bfb65c..d8fe6895f11c 100644
--- a/lib/libc/gen/fts-compat.h
+++ b/lib/libc/gen/fts-compat.h
@@ -10,11 +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.
- * 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.
*
diff --git a/lib/libc/gen/fts.3 b/lib/libc/gen/fts.3
index 35e4d459238f..9133e378f66b 100644
--- a/lib/libc/gen/fts.3
+++ b/lib/libc/gen/fts.3
@@ -28,7 +28,7 @@
.\" @(#)fts.3 8.5 (Berkeley) 4/16/94
.\" $FreeBSD$
.\"
-.Dd March 18, 2012
+.Dd May 21, 2013
.Dt FTS 3
.Os
.Sh NAME
@@ -37,8 +37,6 @@
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/stat.h
.In fts.h
.Ft FTS *
.Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT * const *, const FTSENT * const *)"
diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c
index 569cf4276ad9..4dab3cb07f28 100644
--- a/lib/libc/gen/getlogin.c
+++ b/lib/libc/gen/getlogin.c
@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
extern int _getlogin(char *, int);
-int _logname_valid; /* known to setlogin() */
+int _logname_valid __hidden; /* known to setlogin() */
static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER;
static char *
diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3
index 90297e46f728..386a0bdf9857 100644
--- a/lib/libc/gen/popen.3
+++ b/lib/libc/gen/popen.3
@@ -28,7 +28,7 @@
.\" @(#)popen.3 8.2 (Berkeley) 5/3/95
.\" $FreeBSD$
.\"
-.Dd May 3, 1995
+.Dd May 20, 2013
.Dt POPEN 3
.Os
.Sh NAME
@@ -79,6 +79,11 @@ for writing, or
.Ql r+
for reading and writing.
.Pp
+A letter
+.Ql e
+may be appended to that to request that the underlying file descriptor
+be set close-on-exec.
+.Pp
The
.Fa command
argument is a pointer to a null-terminated string
diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c
index b123234837ee..b0597c80783f 100644
--- a/lib/libc/gen/popen.c
+++ b/lib/libc/gen/popen.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <signal.h>
#include <errno.h>
+#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -71,10 +72,11 @@ popen(command, type)
{
struct pid *cur;
FILE *iop;
- int pdes[2], pid, twoway;
+ int pdes[2], pid, twoway, cloexec;
char *argv[4];
struct pid *p;
+ cloexec = strchr(type, 'e') != NULL;
/*
* Lite2 introduced two-way popen() pipes using _socketpair().
* FreeBSD's pipe() is bidirectional, so we use that.
@@ -84,10 +86,11 @@ popen(command, type)
type = "r+";
} else {
twoway = 0;
- if ((*type != 'r' && *type != 'w') || type[1])
+ if ((*type != 'r' && *type != 'w') ||
+ (type[1] && (type[1] != 'e' || type[2])))
return (NULL);
}
- if (pipe(pdes) < 0)
+ if ((cloexec ? pipe2(pdes, O_CLOEXEC) : pipe(pdes)) < 0)
return (NULL);
if ((cur = malloc(sizeof(struct pid))) == NULL) {
@@ -120,20 +123,29 @@ popen(command, type)
* the compiler is free to corrupt all the local
* variables.
*/
- (void)_close(pdes[0]);
+ if (!cloexec)
+ (void)_close(pdes[0]);
if (pdes[1] != STDOUT_FILENO) {
(void)_dup2(pdes[1], STDOUT_FILENO);
- (void)_close(pdes[1]);
+ if (!cloexec)
+ (void)_close(pdes[1]);
if (twoway)
(void)_dup2(STDOUT_FILENO, STDIN_FILENO);
- } else if (twoway && (pdes[1] != STDIN_FILENO))
+ } else if (twoway && (pdes[1] != STDIN_FILENO)) {
(void)_dup2(pdes[1], STDIN_FILENO);
+ if (cloexec)
+ (void)_fcntl(pdes[1], F_SETFD, 0);
+ } else if (cloexec)
+ (void)_fcntl(pdes[1], F_SETFD, 0);
} else {
if (pdes[0] != STDIN_FILENO) {
(void)_dup2(pdes[0], STDIN_FILENO);
- (void)_close(pdes[0]);
- }
- (void)_close(pdes[1]);
+ if (!cloexec)
+ (void)_close(pdes[0]);
+ } else if (cloexec)
+ (void)_fcntl(pdes[0], F_SETFD, 0);
+ if (!cloexec)
+ (void)_close(pdes[1]);
}
SLIST_FOREACH(p, &pidlist, next)
(void)_close(fileno(p->fp));
diff --git a/lib/libc/gen/posix_spawn_file_actions_addopen.3 b/lib/libc/gen/posix_spawn_file_actions_addopen.3
index c6fd017f22d1..9cd47efb02da 100644
--- a/lib/libc/gen/posix_spawn_file_actions_addopen.3
+++ b/lib/libc/gen/posix_spawn_file_actions_addopen.3
@@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 24, 2008
+.Dd May 9, 2013
.Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3
.Os
.Sh NAME
@@ -123,7 +123,19 @@ to be duplicated as
dup2(fildes, newfildes)
.Ed
.Pp
-had been called) when a new process is spawned using this file actions object.
+had been called) when a new process is spawned using this file actions object,
+except that the
+.Dv FD_CLOEXEC
+flag for
+.Fa newfildes
+is cleared even if
+.Fa fildes
+is equal to
+.Fa newfildes .
+The difference from
+.Fn dup2
+is useful for passing a particular file descriptor
+to a particular child process.
.Pp
The
.Fn posix_spawn_file_actions_addclose
@@ -145,7 +157,7 @@ otherwise, an error number is returned to indicate the error.
These
functions fail if:
.Bl -tag -width Er
-.It Bq Er EINVAL
+.It Bq Er EBADF
The value specified by
.Fa fildes
or
@@ -169,7 +181,16 @@ The
and
.Fn posix_spawn_file_actions_addclose
functions conform to
-.St -p1003.1-2001 .
+.St -p1003.1-2001 ,
+with the exception of the behavior of
+.Fn posix_spawn_file_actions_adddup2
+if
+.Fa fildes
+is equal to
+.Fa newfildes
+(clearing
+.Dv FD_CLOEXEC ) .
+A future update of the Standard is expected to require this behavior.
.Sh HISTORY
The
.Fn posix_spawn_file_actions_addopen ,
diff --git a/lib/libc/gen/pututxline.c b/lib/libc/gen/pututxline.c
index 555386c549c0..4982c0276fbf 100644
--- a/lib/libc/gen/pututxline.c
+++ b/lib/libc/gen/pututxline.c
@@ -131,7 +131,8 @@ exact:
else
error = 0;
fclose(fp);
- errno = error;
+ if (error != 0)
+ errno = error;
return (error == 0 ? 0 : 1);
}
@@ -169,7 +170,8 @@ utx_active_remove(struct futx *fu)
}
fclose(fp);
- errno = error;
+ if (ret != 0)
+ errno = error;
return (ret);
}
@@ -225,7 +227,8 @@ utx_lastlogin_add(const struct futx *fu)
ret = -1;
}
fclose(fp);
- errno = error;
+ if (ret == -1)
+ errno = error;
return (ret);
}
@@ -277,7 +280,8 @@ utx_log_add(const struct futx *fu)
else
error = 0;
_close(fd);
- errno = error;
+ if (error != 0)
+ errno = error;
return (error == 0 ? 0 : 1);
}
diff --git a/lib/libc/gen/sem_wait.3 b/lib/libc/gen/sem_wait.3
index 18e95868f202..993ac4a15a29 100644
--- a/lib/libc/gen/sem_wait.3
+++ b/lib/libc/gen/sem_wait.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 15, 2000
+.Dd April 16, 2013
.Dt SEM_WAIT 3
.Os
.Sh NAME
@@ -75,6 +75,13 @@ points to an invalid semaphore.
.El
.Pp
Additionally,
+.Fn sem_wait
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINTR
+A signal interrupted this function.
+.El
+Additionally,
.Fn sem_trywait
will fail if:
.Bl -tag -width Er
diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c
index dde474c43e0c..fde33ca567ce 100644
--- a/lib/libc/gen/siginterrupt.c
+++ b/lib/libc/gen/siginterrupt.c
@@ -46,7 +46,7 @@ int
siginterrupt(sig, flag)
int sig, flag;
{
- extern sigset_t _sigintr;
+ extern sigset_t _sigintr __hidden;
struct sigaction sa;
int ret;
diff --git a/lib/libc/gen/signal.3 b/lib/libc/gen/signal.3
index a41d2589778a..ea6df4410b2c 100644
--- a/lib/libc/gen/signal.3
+++ b/lib/libc/gen/signal.3
@@ -132,6 +132,7 @@ is possible on a descriptor (see
.It 30 Ta Dv SIGUSR1 Ta "terminate process" Ta "User defined signal 1"
.It 31 Ta Dv SIGUSR2 Ta "terminate process" Ta "User defined signal 2"
.It 32 Ta Dv SIGTHR Ta "terminate process" Ta "thread interrupt"
+.It 33 Ta Dv SIGLIBRT Ta "terminate process" Ta "real-time library interrupt"
.El
.Pp
The
diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c
index c93633e23bbb..ee96dcc3c5b6 100644
--- a/lib/libc/gen/signal.c
+++ b/lib/libc/gen/signal.c
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "libc_private.h"
-sigset_t _sigintr; /* shared with siginterrupt */
+sigset_t _sigintr __hidden; /* shared with siginterrupt */
sig_t
signal(s, a)
diff --git a/lib/libc/gen/stringlist.3 b/lib/libc/gen/stringlist.3
index 82465b6055e0..d4480beb0e2d 100644
--- a/lib/libc/gen/stringlist.3
+++ b/lib/libc/gen/stringlist.3
@@ -49,7 +49,7 @@
.Ft void
.Fn sl_free "StringList *sl" "int freeall"
.Ft char *
-.Fn sl_find "StringList *sl" "char *item"
+.Fn sl_find "StringList *sl" "const char *item"
.Sh DESCRIPTION
The
.Nm
diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c
index e0db3b675942..a09a8e705e36 100644
--- a/lib/libc/gen/stringlist.c
+++ b/lib/libc/gen/stringlist.c
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
* sl_init(): Initialize a string list
*/
StringList *
-sl_init()
+sl_init(void)
{
StringList *sl;
@@ -67,9 +67,7 @@ sl_init()
* sl_add(): Add an item to the string list
*/
int
-sl_add(sl, name)
- StringList *sl;
- char *name;
+sl_add(StringList *sl, char *name)
{
if (sl->sl_cur == sl->sl_max - 1) {
sl->sl_max += _SL_CHUNKSIZE;
@@ -86,9 +84,7 @@ sl_add(sl, name)
* sl_free(): Free a stringlist
*/
void
-sl_free(sl, all)
- StringList *sl;
- int all;
+sl_free(StringList *sl, int all)
{
size_t i;
@@ -108,9 +104,7 @@ sl_free(sl, all)
* sl_find(): Find a name in the string list
*/
char *
-sl_find(sl, name)
- StringList *sl;
- char *name;
+sl_find(StringList *sl, const char *name)
{
size_t i;
diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c
index 1edaa5a91154..55e99451b13d 100644
--- a/lib/libc/gen/strtofflags.c
+++ b/lib/libc/gen/strtofflags.c
@@ -62,13 +62,29 @@ static struct {
#endif
{ "nouappnd", 0, UF_APPEND },
{ "nouappend", 0, UF_APPEND },
+ { "nouarch", 0, UF_ARCHIVE },
+ { "nouarchive", 0, UF_ARCHIVE },
+ { "nohidden", 0, UF_HIDDEN },
+ { "nouhidden", 0, UF_HIDDEN },
{ "nouchg", 0, UF_IMMUTABLE },
{ "nouchange", 0, UF_IMMUTABLE },
{ "nouimmutable", 0, UF_IMMUTABLE },
{ "nodump", 1, UF_NODUMP },
- { "noopaque", 0, UF_OPAQUE },
{ "nouunlnk", 0, UF_NOUNLINK },
- { "nouunlink", 0, UF_NOUNLINK }
+ { "nouunlink", 0, UF_NOUNLINK },
+ { "nooffline", 0, UF_OFFLINE },
+ { "nouoffline", 0, UF_OFFLINE },
+ { "noopaque", 0, UF_OPAQUE },
+ { "nordonly", 0, UF_READONLY },
+ { "nourdonly", 0, UF_READONLY },
+ { "noreadonly", 0, UF_READONLY },
+ { "noureadonly", 0, UF_READONLY },
+ { "noreparse", 0, UF_REPARSE },
+ { "noureparse", 0, UF_REPARSE },
+ { "nosparse", 0, UF_SPARSE },
+ { "nousparse", 0, UF_SPARSE },
+ { "nosystem", 0, UF_SYSTEM },
+ { "nousystem", 0, UF_SYSTEM }
};
#define nmappings (sizeof(mapping) / sizeof(mapping[0]))
diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3
index 4af6f821f138..4631aeb6bf1b 100644
--- a/lib/libc/gen/sysconf.3
+++ b/lib/libc/gen/sysconf.3
@@ -28,7 +28,7 @@
.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd February 13, 2011
+.Dd April 26, 2013
.Dt SYSCONF 3
.Os
.Sh NAME
@@ -82,7 +82,7 @@ The number of processors configured.
.It Li _SC_NPROCESSORS_ONLN
The number of processors currently online.
.It Li _SC_OPEN_MAX
-The maximum number of open files per user id.
+One more than the maximum value the system may assign to a new file descriptor.
.It Li _SC_PAGESIZE
The size of a system page in bytes.
.It Li _SC_PAGE_SIZE
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3
index b3737e2d1aaa..7d7b90a7442e 100644
--- a/lib/libc/gen/sysctl.3
+++ b/lib/libc/gen/sysctl.3
@@ -28,7 +28,7 @@
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\" $FreeBSD$
.\"
-.Dd February 11, 2012
+.Dd May 17, 2013
.Dt SYSCTL 3
.Os
.Sh NAME
@@ -547,14 +547,14 @@ The length of each message is contained in the message header.
The third level name is a protocol number, which is currently always 0.
The fourth level name is an address family, which may be set to 0 to
select all address families.
-The fifth and sixth level names are as follows:
-.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
-.It Sy "Fifth level name Sixth level is:"
-.It "NET_RT_FLAGS rtflags"
-.It "NET_RT_DUMP None"
-.It "NET_RT_IFLIST 0 or if_index"
-.It "NET_RT_IFMALIST 0 or if_index"
-.It "NET_RT_IFLISTL 0 or if_index"
+The fifth, sixth, and seventh level names are as follows:
+.Bl -column -offset indent "Fifth level Sixth level" "Seventh level"
+.It Sy "Fifth level Sixth level" Ta Sy "Seventh level"
+.It "NET_RT_FLAGS rtflags" Ta "None"
+.It "NET_RT_DUMP None" Ta "None or fib number"
+.It "NET_RT_IFLIST 0 or if_index" Ta None
+.It "NET_RT_IFMALIST 0 or if_index" Ta None
+.It "NET_RT_IFLISTL 0 or if_index" Ta None
.El
.Pp
The
@@ -735,7 +735,6 @@ privilege may change the value.
.It Sy "Second level name Type Changeable"
.It "VM_LOADAVG struct loadavg no"
.It "VM_TOTAL struct vmtotal no"
-.It "VM_PAGEOUT_ALGORITHM integer yes"
.It "VM_SWAPPING_ENABLED integer maybe"
.It "VM_V_CACHE_MAX integer yes"
.It "VM_V_CACHE_MIN integer yes"
@@ -754,9 +753,6 @@ The returned data consists of a
Return the system wide virtual memory statistics.
The returned data consists of a
.Va struct vmtotal .
-.It Li VM_PAGEOUT_ALGORITHM
-0 if the statistics-based page management algorithm is in use
-or 1 if the near-LRU algorithm is in use.
.It Li VM_SWAPPING_ENABLED
1 if process swapping is enabled or 0 if disabled.
This variable is
diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c
index b518b57ae5ea..377caff51cc5 100644
--- a/lib/libc/gen/wordexp.c
+++ b/lib/libc/gen/wordexp.c
@@ -121,7 +121,7 @@ we_askshell(const char *words, wordexp_t *we, int flags)
serrno = errno;
- if (pipe(pdes) < 0)
+ if (pipe2(pdes, O_CLOEXEC) < 0)
return (WRDE_NOSPACE); /* XXX */
(void)sigemptyset(&newsigblock);
(void)sigaddset(&newsigblock, SIGCHLD);
@@ -139,25 +139,15 @@ we_askshell(const char *words, wordexp_t *we, int flags)
* We are the child; just get /bin/sh to run the wordexp
* builtin on `words'.
*/
- int devnull;
- char *cmd;
-
(void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
- _close(pdes[0]);
- if (_dup2(pdes[1], STDOUT_FILENO) < 0)
+ if ((pdes[1] != STDOUT_FILENO ?
+ _dup2(pdes[1], STDOUT_FILENO) :
+ _fcntl(pdes[1], F_SETFD, 0)) < 0)
_exit(1);
- _close(pdes[1]);
- if (asprintf(&cmd, "wordexp %s\n", words) < 0)
- _exit(1);
- if ((flags & WRDE_SHOWERR) == 0) {
- if ((devnull = _open(_PATH_DEVNULL, O_RDWR, 0666)) < 0)
- _exit(1);
- if (_dup2(devnull, STDERR_FILENO) < 0)
- _exit(1);
- _close(devnull);
- }
execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u",
- "-c", cmd, (char *)NULL);
+ "-c", "eval \"$1\";eval \"wordexp $2\"", "",
+ flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", words,
+ (char *)NULL);
_exit(1);
}
@@ -261,7 +251,8 @@ we_check(const char *words, int flags)
while ((c = *words++) != '\0') {
switch (c) {
case '\\':
- quote ^= 1;
+ if (squote == 0)
+ quote ^= 1;
continue;
case '\'':
if (quote + dquote == 0)
diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c
index 8f508b065a0d..1f56bc2c3617 100644
--- a/lib/libc/gmon/gmon.c
+++ b/lib/libc/gmon/gmon.c
@@ -163,13 +163,13 @@ _mcleanup(void)
else
snprintf(outname, sizeof(outname), "%s.gmon", _getprogname());
- fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY|O_CLOEXEC, 0666);
if (fd < 0) {
_warn("_mcleanup: %s", outname);
return;
}
#ifdef DEBUG
- log = _open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664);
+ log = _open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY|O_CLOEXEC, 0664);
if (log < 0) {
_warn("_mcleanup: gmon.log");
return;
diff --git a/lib/libc/i386/gen/getcontextx.c b/lib/libc/i386/gen/getcontextx.c
index 2d3b5625bbad..3c6dd33ef10f 100644
--- a/lib/libc/i386/gen/getcontextx.c
+++ b/lib/libc/i386/gen/getcontextx.c
@@ -89,14 +89,12 @@ __getcontextx_size(void)
}
int
-__fillcontextx(char *ctx)
+__fillcontextx2(char *ctx)
{
struct i386_get_xfpustate xfpu;
ucontext_t *ucp;
ucp = (ucontext_t *)ctx;
- if (getcontext(ucp) == -1)
- return (-1);
if (xstate_sz != 0) {
xfpu.addr = (char *)(ucp + 1);
xfpu.len = xstate_sz;
@@ -112,6 +110,18 @@ __fillcontextx(char *ctx)
return (0);
}
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ if (getcontext(ucp) == -1)
+ return (-1);
+ __fillcontextx2(ctx);
+ return (0);
+}
+
__weak_reference(__getcontextx, getcontextx);
ucontext_t *
diff --git a/lib/libc/i386/string/memchr.S b/lib/libc/i386/string/memchr.S
index 03828db95c72..3bd4d9c3a4d6 100644
--- a/lib/libc/i386/string/memchr.S
+++ b/lib/libc/i386/string/memchr.S
@@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$");
/*
* memchr (b, c, len)
- * locates the first occurance of c in string b.
+ * locates the first occurrence of c in string b.
*
* Written by:
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
diff --git a/lib/libc/i386/string/strchr.S b/lib/libc/i386/string/strchr.S
index 57fc6dd6fbea..f57c2cd8abe4 100644
--- a/lib/libc/i386/string/strchr.S
+++ b/lib/libc/i386/string/strchr.S
@@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$");
/*
* strchr(s, c)
- * return a pointer to the first occurance of the character c in
+ * return a pointer to the first occurrence of the character c in
* string s, or NULL if c does not occur in the string.
*
* %edx - pointer iterating through string
- * %eax - pointer to first occurance of 'c'
+ * %eax - pointer to first occurrence of 'c'
* %cl - character we're comparing against
* %bl - character at %edx
*
diff --git a/lib/libc/i386/string/strrchr.S b/lib/libc/i386/string/strrchr.S
index 29942c498004..5ec5287a4c68 100644
--- a/lib/libc/i386/string/strrchr.S
+++ b/lib/libc/i386/string/strrchr.S
@@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$");
/*
* strrchr(s, c)
- * return a pointer to the last occurance of the character c in
+ * return a pointer to the last occurrence of the character c in
* string s, or NULL if c does not occur in the string.
*
* %edx - pointer iterating through string
- * %eax - pointer to last occurance of 'c'
+ * %eax - pointer to last occurrence of 'c'
* %cl - character we're comparing against
* %bl - character at %edx
*
diff --git a/lib/libc/i386/sys/setlogin.S b/lib/libc/i386/sys/setlogin.S
index c6436b51cfac..9247955c5664 100644
--- a/lib/libc/i386/sys/setlogin.S
+++ b/lib/libc/i386/sys/setlogin.S
@@ -41,16 +41,9 @@ __FBSDID("$FreeBSD$");
.globl CNAME(_logname_valid) /* in _getlogin() */
SYSCALL(setlogin)
-#ifdef PIC
PIC_PROLOGUE
- pushl %eax
- movl PIC_GOT(CNAME(_logname_valid)),%eax
- movl $0,(%eax)
- popl %eax
+ movl $0,PIC_GOTOFF(CNAME(_logname_valid))
PIC_EPILOGUE
-#else
- movl $0,CNAME(_logname_valid)
-#endif
ret /* setlogin(name) */
END(__sys_setlogin)
diff --git a/lib/libc/ia64/gen/getcontextx.c b/lib/libc/ia64/gen/getcontextx.c
index 307978a466dd..54f851384811 100644
--- a/lib/libc/ia64/gen/getcontextx.c
+++ b/lib/libc/ia64/gen/getcontextx.c
@@ -40,6 +40,13 @@ __getcontextx_size(void)
}
int
+__fillcontextx2(char *ctx)
+{
+
+ return (0);
+}
+
+int
__fillcontextx(char *ctx)
{
ucontext_t *ucp;
diff --git a/lib/libc/iconv/Symbol.map b/lib/libc/iconv/Symbol.map
index 73e0e225ffe2..05df2eac2f7c 100644
--- a/lib/libc/iconv/Symbol.map
+++ b/lib/libc/iconv/Symbol.map
@@ -17,6 +17,17 @@ FBSD_1.2 {
libiconvlist;
};
+FBSD_1.3 {
+ _iconv_version;
+ iconv;
+ iconv_open;
+ iconv_close;
+ iconv_open_into;
+ iconv_set_relocation_prefix;
+ iconvctl;
+ iconvlist;
+};
+
FBSDprivate_1.0 {
_citrus_bcs_convert_to_lower;
_citrus_bcs_convert_to_upper;
@@ -39,6 +50,7 @@ FBSDprivate_1.0 {
_citrus_bcs_strtoul;
_citrus_bcs_tolower;
_citrus_bcs_toupper;
+ _citrus_bcs_trunc_rws_len;
_citrus_bcs_trunc_ws_len;
_citrus_csmapper_open;
_citrus_csmapper_close;
diff --git a/lib/libc/iconv/citrus_csmapper.c b/lib/libc/iconv/citrus_csmapper.c
index 5e0a01ad8a90..e2d10d5a4ba7 100644
--- a/lib/libc/iconv/citrus_csmapper.c
+++ b/lib/libc/iconv/citrus_csmapper.c
@@ -58,6 +58,8 @@
static struct _citrus_mapper_area *maparea = NULL;
+static pthread_rwlock_t ma_lock = PTHREAD_RWLOCK_INITIALIZER;
+
#define CS_ALIAS _PATH_CSMAPPER "/charset.alias"
#define CS_PIVOT _PATH_CSMAPPER "/charset.pivot"
@@ -314,7 +316,7 @@ get_none(struct _citrus_mapper_area *__restrict ma,
{
int ret;
- WLOCK;
+ WLOCK(&ma_lock);
if (csm_none) {
*rcsm = csm_none;
ret = 0;
@@ -329,7 +331,7 @@ get_none(struct _citrus_mapper_area *__restrict ma,
*rcsm = csm_none;
ret = 0;
quit:
- UNLOCK;
+ UNLOCK(&ma_lock);
return (ret);
}
diff --git a/lib/libc/iconv/citrus_iconv.c b/lib/libc/iconv/citrus_iconv.c
index 941ee0255ecb..e4bd24f4a39a 100644
--- a/lib/libc/iconv/citrus_iconv.c
+++ b/lib/libc/iconv/citrus_iconv.c
@@ -68,11 +68,13 @@ static int shared_max_reuse, shared_num_unused;
static _CITRUS_HASH_HEAD(, _citrus_iconv_shared, CI_HASH_SIZE) shared_pool;
static TAILQ_HEAD(, _citrus_iconv_shared) shared_unused;
+static pthread_rwlock_t ci_lock = PTHREAD_RWLOCK_INITIALIZER;
+
static __inline void
init_cache(void)
{
- WLOCK;
+ WLOCK(&ci_lock);
if (!isinit) {
_CITRUS_HASH_INIT(&shared_pool, CI_HASH_SIZE);
TAILQ_INIT(&shared_unused);
@@ -83,7 +85,7 @@ init_cache(void)
shared_max_reuse = CI_INITIAL_MAX_REUSE;
isinit = true;
}
- UNLOCK;
+ UNLOCK(&ci_lock);
}
static __inline void
@@ -114,7 +116,20 @@ open_shared(struct _citrus_iconv_shared * __restrict * __restrict rci,
size_t len_convname;
int ret;
+#ifdef INCOMPATIBLE_WITH_GNU_ICONV
+ /*
+ * Sadly, the gnu tools expect iconv to actually parse the
+ * byte stream and don't allow for a pass-through when
+ * the (src,dest) encodings are the same.
+ * See gettext-0.18.3+ NEWS:
+ * msgfmt now checks PO file headers more strictly with less
+ * false-positives.
+ * NetBSD don't do this either.
+ */
module = (strcmp(src, dst) != 0) ? "iconv_std" : "iconv_none";
+#else
+ module = "iconv_std";
+#endif
/* initialize iconv handle */
len_convname = strlen(convname);
@@ -195,7 +210,7 @@ get_shared(struct _citrus_iconv_shared * __restrict * __restrict rci,
snprintf(convname, sizeof(convname), "%s/%s", src, dst);
- WLOCK;
+ WLOCK(&ci_lock);
/* lookup alread existing entry */
hashval = hash_func(convname);
@@ -222,7 +237,7 @@ get_shared(struct _citrus_iconv_shared * __restrict * __restrict rci,
*rci = ci;
quit:
- UNLOCK;
+ UNLOCK(&ci_lock);
return (ret);
}
@@ -231,7 +246,7 @@ static void
release_shared(struct _citrus_iconv_shared * __restrict ci)
{
- WLOCK;
+ WLOCK(&ci_lock);
ci->ci_used_count--;
if (ci->ci_used_count == 0) {
/* put it into unused list */
@@ -247,7 +262,7 @@ release_shared(struct _citrus_iconv_shared * __restrict ci)
}
}
- UNLOCK;
+ UNLOCK(&ci_lock);
}
/*
@@ -258,7 +273,7 @@ int
_citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
const char * __restrict src, const char * __restrict dst)
{
- struct _citrus_iconv *cv;
+ struct _citrus_iconv *cv = NULL;
struct _citrus_iconv_shared *ci = NULL;
char realdst[PATH_MAX], realsrc[PATH_MAX];
char buf[PATH_MAX], path[PATH_MAX];
@@ -301,7 +316,7 @@ _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
ret = (*ci->ci_ops->io_init_context)(*rcv);
if (ret) {
release_shared(ci);
- free(*rcv);
+ free(cv);
return (ret);
}
return (0);
diff --git a/lib/libc/iconv/citrus_iconv.h b/lib/libc/iconv/citrus_iconv.h
index 99604e92063d..ac14ac318ac5 100644
--- a/lib/libc/iconv/citrus_iconv.h
+++ b/lib/libc/iconv/citrus_iconv.h
@@ -52,7 +52,7 @@ __END_DECLS
*/
static __inline int
_citrus_iconv_convert(struct _citrus_iconv * __restrict cv,
- char * __restrict * __restrict in, size_t * __restrict inbytes,
+ const char * __restrict * __restrict in, size_t * __restrict inbytes,
char * __restrict * __restrict out, size_t * __restrict outbytes,
uint32_t flags, size_t * __restrict nresults)
{
diff --git a/lib/libc/iconv/citrus_iconv_local.h b/lib/libc/iconv/citrus_iconv_local.h
index db2036384e5b..52ac8251cd24 100644
--- a/lib/libc/iconv/citrus_iconv_local.h
+++ b/lib/libc/iconv/citrus_iconv_local.h
@@ -45,7 +45,7 @@ static void _citrus_##_m_##_iconv_uninit_shared \
(struct _citrus_iconv_shared *); \
static int _citrus_##_m_##_iconv_convert \
(struct _citrus_iconv * __restrict, \
- char * __restrict * __restrict, \
+ const char * __restrict * __restrict, \
size_t * __restrict, \
char * __restrict * __restrict, \
size_t * __restrict outbytes, \
@@ -57,6 +57,7 @@ static void _citrus_##_m_##_iconv_uninit_context \
#define _CITRUS_ICONV_DEF_OPS(_m_) \
+extern struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops; \
struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = { \
/* io_init_shared */ &_citrus_##_m_##_iconv_init_shared, \
/* io_uninit_shared */ &_citrus_##_m_##_iconv_uninit_shared, \
@@ -73,7 +74,7 @@ typedef void (*_citrus_iconv_uninit_shared_t)
(struct _citrus_iconv_shared *);
typedef int (*_citrus_iconv_convert_t)
(struct _citrus_iconv * __restrict,
- char *__restrict* __restrict, size_t * __restrict,
+ const char *__restrict* __restrict, size_t * __restrict,
char * __restrict * __restrict, size_t * __restrict, uint32_t,
size_t * __restrict);
typedef int (*_citrus_iconv_init_context_t)(struct _citrus_iconv *);
diff --git a/lib/libc/iconv/citrus_lock.h b/lib/libc/iconv/citrus_lock.h
index ad9443ab01ef..395064453b67 100644
--- a/lib/libc/iconv/citrus_lock.h
+++ b/lib/libc/iconv/citrus_lock.h
@@ -27,9 +27,7 @@
#include <pthread.h>
-static pthread_rwlock_t lock;
-
-#define WLOCK if (__isthreaded) \
- pthread_rwlock_wrlock(&lock);
-#define UNLOCK if (__isthreaded) \
- pthread_rwlock_unlock(&lock);
+#define WLOCK(lock) if (__isthreaded) \
+ pthread_rwlock_wrlock(lock);
+#define UNLOCK(lock) if (__isthreaded) \
+ pthread_rwlock_unlock(lock);
diff --git a/lib/libc/iconv/citrus_mapper.c b/lib/libc/iconv/citrus_mapper.c
index b5ae96d920f7..b1ee8fbe7ecf 100644
--- a/lib/libc/iconv/citrus_mapper.c
+++ b/lib/libc/iconv/citrus_mapper.c
@@ -55,6 +55,8 @@
#define CM_HASH_SIZE 101
#define REFCOUNT_PERSISTENT -1
+static pthread_rwlock_t cm_lock = PTHREAD_RWLOCK_INITIALIZER;
+
struct _citrus_mapper_area {
_CITRUS_HASH_HEAD(, _citrus_mapper, CM_HASH_SIZE) ma_cache;
char *ma_dir;
@@ -75,7 +77,7 @@ _citrus_mapper_create_area(
char path[PATH_MAX];
int ret;
- WLOCK;
+ WLOCK(&cm_lock);
if (*rma != NULL) {
ret = 0;
@@ -96,7 +98,7 @@ _citrus_mapper_create_area(
ma->ma_dir = strdup(area);
if (ma->ma_dir == NULL) {
ret = errno;
- free(ma->ma_dir);
+ free(ma);
goto quit;
}
_CITRUS_HASH_INIT(&ma->ma_cache, CM_HASH_SIZE);
@@ -104,7 +106,7 @@ _citrus_mapper_create_area(
*rma = ma;
ret = 0;
quit:
- UNLOCK;
+ UNLOCK(&cm_lock);
return (ret);
}
@@ -316,7 +318,7 @@ _citrus_mapper_open(struct _citrus_mapper_area *__restrict ma,
variable = NULL;
- WLOCK;
+ WLOCK(&cm_lock);
/* search in the cache */
hashval = hash_func(mapname);
@@ -337,9 +339,9 @@ _citrus_mapper_open(struct _citrus_mapper_area *__restrict ma,
goto quit;
/* open mapper */
- UNLOCK;
+ UNLOCK(&cm_lock);
ret = mapper_open(ma, &cm, module, variable);
- WLOCK;
+ WLOCK(&cm_lock);
if (ret)
goto quit;
cm->cm_key = strdup(mapname);
@@ -356,7 +358,7 @@ _citrus_mapper_open(struct _citrus_mapper_area *__restrict ma,
*rcm = cm;
ret = 0;
quit:
- UNLOCK;
+ UNLOCK(&cm_lock);
return (ret);
}
@@ -370,7 +372,7 @@ _citrus_mapper_close(struct _citrus_mapper *cm)
{
if (cm) {
- WLOCK;
+ WLOCK(&cm_lock);
if (cm->cm_refcount == REFCOUNT_PERSISTENT)
goto quit;
if (cm->cm_refcount > 0) {
@@ -381,7 +383,7 @@ _citrus_mapper_close(struct _citrus_mapper *cm)
}
mapper_close(cm);
quit:
- UNLOCK;
+ UNLOCK(&cm_lock);
}
}
@@ -393,7 +395,7 @@ void
_citrus_mapper_set_persistent(struct _citrus_mapper * __restrict cm)
{
- WLOCK;
+ WLOCK(&cm_lock);
cm->cm_refcount = REFCOUNT_PERSISTENT;
- UNLOCK;
+ UNLOCK(&cm_lock);
}
diff --git a/lib/libc/iconv/citrus_mapper_local.h b/lib/libc/iconv/citrus_mapper_local.h
index 887a35d376a4..8d29e63a4a96 100644
--- a/lib/libc/iconv/citrus_mapper_local.h
+++ b/lib/libc/iconv/citrus_mapper_local.h
@@ -52,6 +52,7 @@ static void _citrus_##_m_##_mapper_init_state \
(void);
#define _CITRUS_MAPPER_DEF_OPS(_m_) \
+extern struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops; \
struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops = { \
/* mo_init */ &_citrus_##_m_##_mapper_init, \
/* mo_uninit */ &_citrus_##_m_##_mapper_uninit, \
diff --git a/lib/libc/iconv/citrus_none.c b/lib/libc/iconv/citrus_none.c
index 9ec4bd360cb8..4f9b254fc133 100644
--- a/lib/libc/iconv/citrus_none.c
+++ b/lib/libc/iconv/citrus_none.c
@@ -83,7 +83,7 @@ _citrus_NONE_stdenc_init_state(struct _citrus_stdenc * __restrict ce __unused,
static int
_citrus_NONE_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce __unused,
- _csid_t *csid, _index_t *idx, char **s, size_t n,
+ _csid_t *csid, _index_t *idx, const char **s, size_t n,
void *ps __unused, size_t *nresult, struct iconv_hooks *hooks)
{
@@ -159,7 +159,7 @@ _citrus_NONE_stdenc_cstomb(struct _citrus_stdenc * __restrict ce __unused,
static int
_citrus_NONE_stdenc_mbtowc(struct _citrus_stdenc * __restrict ce __unused,
- _wc_t * __restrict pwc, char ** __restrict s, size_t n,
+ _wc_t * __restrict pwc, const char ** __restrict s, size_t n,
void * __restrict pspriv __unused, size_t * __restrict nresult,
struct iconv_hooks *hooks)
{
diff --git a/lib/libc/iconv/citrus_stdenc.h b/lib/libc/iconv/citrus_stdenc.h
index 50f4dffa4e16..28fa29d8cc94 100644
--- a/lib/libc/iconv/citrus_stdenc.h
+++ b/lib/libc/iconv/citrus_stdenc.h
@@ -69,7 +69,7 @@ _citrus_stdenc_init_state(struct _citrus_stdenc * __restrict ce,
static __inline int
_citrus_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce,
_citrus_csid_t * __restrict csid, _citrus_index_t * __restrict idx,
- char ** __restrict s, size_t n, void * __restrict ps,
+ const char ** __restrict s, size_t n, void * __restrict ps,
size_t * __restrict nresult, struct iconv_hooks *hooks)
{
diff --git a/lib/libc/iconv/citrus_stdenc_local.h b/lib/libc/iconv/citrus_stdenc_local.h
index c55387a10bf2..7b627a05fd19 100644
--- a/lib/libc/iconv/citrus_stdenc_local.h
+++ b/lib/libc/iconv/citrus_stdenc_local.h
@@ -55,7 +55,7 @@ static int _citrus_##_e_##_stdenc_mbtocs \
(struct _citrus_stdenc * __restrict, \
_citrus_csid_t * __restrict, \
_citrus_index_t * __restrict, \
- char ** __restrict, size_t, \
+ const char ** __restrict, size_t, \
void * __restrict, size_t * __restrict, \
struct iconv_hooks *); \
static int _citrus_##_e_##_stdenc_cstomb \
@@ -66,7 +66,7 @@ static int _citrus_##_e_##_stdenc_cstomb \
static int _citrus_##_e_##_stdenc_mbtowc \
(struct _citrus_stdenc * __restrict, \
_citrus_wc_t * __restrict, \
- char ** __restrict, size_t, \
+ const char ** __restrict, size_t, \
void * __restrict, size_t * __restrict, \
struct iconv_hooks *); \
static int _citrus_##_e_##_stdenc_wctomb \
@@ -84,6 +84,7 @@ static int _citrus_##_e_##_stdenc_get_state_desc \
struct _citrus_stdenc_state_desc * __restrict)
#define _CITRUS_STDENC_DEF_OPS(_e_) \
+extern struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops; \
struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops = { \
/* eo_init */ &_citrus_##_e_##_stdenc_init, \
/* eo_uninit */ &_citrus_##_e_##_stdenc_uninit, \
@@ -105,7 +106,7 @@ typedef int (*_citrus_stdenc_init_state_t)
typedef int (*_citrus_stdenc_mbtocs_t)
(struct _citrus_stdenc * __restrict,
_citrus_csid_t * __restrict, _citrus_index_t * __restrict,
- char ** __restrict, size_t,
+ const char ** __restrict, size_t,
void * __restrict, size_t * __restrict,
struct iconv_hooks *);
typedef int (*_citrus_stdenc_cstomb_t)
@@ -115,7 +116,7 @@ typedef int (*_citrus_stdenc_cstomb_t)
typedef int (*_citrus_stdenc_mbtowc_t)
(struct _citrus_stdenc * __restrict,
_citrus_wc_t * __restrict,
- char ** __restrict, size_t,
+ const char ** __restrict, size_t,
void * __restrict, size_t * __restrict,
struct iconv_hooks *);
typedef int (*_citrus_stdenc_wctomb_t)
diff --git a/lib/libc/iconv/citrus_stdenc_template.h b/lib/libc/iconv/citrus_stdenc_template.h
index 9a05fa789fa6..21bc5cc95cd9 100644
--- a/lib/libc/iconv/citrus_stdenc_template.h
+++ b/lib/libc/iconv/citrus_stdenc_template.h
@@ -112,7 +112,7 @@ _FUNCNAME(stdenc_init_state)(struct _citrus_stdenc * __restrict ce,
static int
_FUNCNAME(stdenc_mbtocs)(struct _citrus_stdenc * __restrict ce,
_citrus_csid_t * __restrict csid, _citrus_index_t * __restrict idx,
- char ** __restrict s, size_t n, void * __restrict ps,
+ const char ** __restrict s, size_t n, void * __restrict ps,
size_t * __restrict nresult, struct iconv_hooks *hooks)
{
wchar_t wc;
@@ -151,7 +151,7 @@ _FUNCNAME(stdenc_cstomb)(struct _citrus_stdenc * __restrict ce,
static int
_FUNCNAME(stdenc_mbtowc)(struct _citrus_stdenc * __restrict ce,
- _citrus_wc_t * __restrict wc, char ** __restrict s, size_t n,
+ _citrus_wc_t * __restrict wc, const char ** __restrict s, size_t n,
void * __restrict ps, size_t * __restrict nresult,
struct iconv_hooks *hooks)
{
diff --git a/lib/libc/iconv/iconv.c b/lib/libc/iconv/iconv.c
index d1e01e88d10c..f388e8b59d0f 100644
--- a/lib/libc/iconv/iconv.c
+++ b/lib/libc/iconv/iconv.c
@@ -47,56 +47,51 @@
#include "citrus_hash.h"
#include "citrus_iconv.h"
-#ifdef __weak_alias
-__weak_alias(libiconv, _iconv)
-__weak_alias(libiconv_open, _iconv_open)
-__weak_alias(libiconv_open_into, _iconv_open_into)
-__weak_alias(libiconv_close, _iconv_close)
-__weak_alias(libiconvlist, _iconvlist)
-__weak_alias(libiconvctl, _iconvctl)
-__weak_alias(libiconv_set_relocation_prefix, _iconv_set_relocation_prefix)
-__weak_alias(iconv_canonicalize, _iconv_canonicalize)
+#include <_libiconv_compat.h>
+#ifdef __LIBICONV_COMPAT
+__weak_reference(iconv, libiconv);
+__weak_reference(iconv_open, libiconv_open);
+__weak_reference(iconv_open_into, libiconv_open_into);
+__weak_reference(iconv_close, libiconv_close);
+__weak_reference(iconvlist, libiconvlist);
+__weak_reference(iconvctl, libiconvctl);
+__weak_reference(iconv_set_relocation_prefix, libiconv_set_relocation_prefix);
+__weak_reference(_iconv_version, _libiconv_version);
#endif
#define ISBADF(_h_) (!(_h_) || (_h_) == (iconv_t)-1)
-int _libiconv_version = _LIBICONV_VERSION;
+int _iconv_version = _ICONV_VERSION;
iconv_t _iconv_open(const char *out, const char *in,
struct _citrus_iconv *prealloc);
iconv_t
-_iconv_open(const char *out, const char *in, struct _citrus_iconv *prealloc)
+_iconv_open(const char *out, const char *in, struct _citrus_iconv *handle)
{
- struct _citrus_iconv *handle;
- char *out_truncated, *p;
+ const char *out_slashes;
+ char *out_noslashes;
int ret;
- handle = prealloc;
-
/*
* Remove anything following a //, as these are options (like
* //ignore, //translate, etc) and we just don't handle them.
- * This is for compatibilty with software that uses thees
+ * This is for compatibility with software that uses these
* blindly.
*/
- out_truncated = strdup(out);
- if (out_truncated == NULL) {
- errno = ENOMEM;
- return ((iconv_t)-1);
+ out_slashes = strstr(out, "//");
+ if (out_slashes != NULL) {
+ out_noslashes = strndup(out, out_slashes - out);
+ if (out_noslashes == NULL) {
+ errno = ENOMEM;
+ return ((iconv_t)-1);
+ }
+ ret = _citrus_iconv_open(&handle, in, out_noslashes);
+ free(out_noslashes);
+ } else {
+ ret = _citrus_iconv_open(&handle, in, out);
}
- p = out_truncated;
- while (*p != 0) {
- if (p[0] == '/' && p[1] == '/') {
- *p = '\0';
- break;
- }
- p++;
- }
-
- ret = _citrus_iconv_open(&handle, in, out_truncated);
- free(out_truncated);
if (ret) {
errno = ret == ENOENT ? EINVAL : ret;
return ((iconv_t)-1);
@@ -109,14 +104,14 @@ _iconv_open(const char *out, const char *in, struct _citrus_iconv *prealloc)
}
iconv_t
-libiconv_open(const char *out, const char *in)
+iconv_open(const char *out, const char *in)
{
return (_iconv_open(out, in, NULL));
}
int
-libiconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr)
+iconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr)
{
struct _citrus_iconv *handle;
@@ -125,7 +120,7 @@ libiconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr)
}
int
-libiconv_close(iconv_t handle)
+iconv_close(iconv_t handle)
{
if (ISBADF(handle)) {
@@ -139,7 +134,7 @@ libiconv_close(iconv_t handle)
}
size_t
-libiconv(iconv_t handle, char **in, size_t *szin, char **out, size_t *szout)
+iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout)
{
size_t ret;
int err;
@@ -160,7 +155,7 @@ libiconv(iconv_t handle, char **in, size_t *szin, char **out, size_t *szout)
}
size_t
-__iconv(iconv_t handle, char **in, size_t *szin, char **out,
+__iconv(iconv_t handle, const char **in, size_t *szin, char **out,
size_t *szout, uint32_t flags, size_t *invalids)
{
size_t ret;
@@ -219,7 +214,7 @@ qsort_helper(const void *first, const void *second)
}
void
-libiconvlist(int (*do_one) (unsigned int, const char * const *,
+iconvlist(int (*do_one) (unsigned int, const char * const *,
void *), void *data)
{
char **list, **names;
@@ -273,7 +268,7 @@ __inline const char
}
int
-libiconvctl(iconv_t cd, int request, void *argument)
+iconvctl(iconv_t cd, int request, void *argument)
{
struct _citrus_iconv *cv;
struct iconv_hooks *hooks;
@@ -325,7 +320,7 @@ libiconvctl(iconv_t cd, int request, void *argument)
}
void
-libiconv_set_relocation_prefix(const char *orig_prefix __unused,
+iconv_set_relocation_prefix(const char *orig_prefix __unused,
const char *curr_prefix __unused)
{
diff --git a/lib/libc/include/compat.h b/lib/libc/include/compat.h
index 3739fe105c8f..769454002788 100644
--- a/lib/libc/include/compat.h
+++ b/lib/libc/include/compat.h
@@ -42,8 +42,6 @@ __sym_compat(__semctl, freebsd7___semctl, FBSD_1.0);
__sym_compat(msgctl, freebsd7_msgctl, FBSD_1.0);
__sym_compat(shmctl, freebsd7_shmctl, FBSD_1.0);
-__sym_compat(cap_getrights, cap_rights_get, FBSD_1.2);
-
#undef __sym_compat
#endif /* __LIBC_COMPAT_H__ */
diff --git a/lib/libcompiler_rt/__sync_fetch_and_op_n.h b/lib/libc/include/errlst.h
index f7f0e06e83a0..4e9e29fc3345 100644
--- a/lib/libcompiler_rt/__sync_fetch_and_op_n.h
+++ b/lib/libc/include/errlst.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
+ * Copyright (c) 2013 Jilles Tjoelker
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,26 +22,22 @@
* 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$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <machine/atomic.h>
+#ifndef __ERRLST_H__
+#define __ERRLST_H__
-TYPE
-NAME(volatile TYPE *ptr, TYPE value)
-{
- TYPE t;
+#include <sys/cdefs.h>
-#ifdef FETCHADD
- t = FETCHADD(ptr, value);
+#ifdef PIC
+/* If the main executable imports these, do not use its copy from libc.so. */
+extern const char *const __hidden_sys_errlist[] __hidden;
+extern const int __hidden_sys_nerr __hidden;
#else
- do {
- t = *ptr;
- } while (!CMPSET(ptr, t, EXPRESSION));
+#define __hidden_sys_errlist sys_errlist
+#define __hidden_sys_nerr sys_nerr
#endif
- return (t);
-}
+#endif /* __ERRLST_H__ */
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index faae02811d17..40a5f7266709 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -83,7 +83,7 @@ void _rtld_error(const char *fmt, ...);
#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp)
struct _spinlock;
-extern struct _spinlock __stdio_thread_lock;
+extern struct _spinlock __stdio_thread_lock __hidden;
#define STDIO_THREAD_LOCK() \
do { \
if (__isthreaded) \
@@ -218,7 +218,7 @@ void _malloc_postfork(void);
/*
* Function to clean up streams, called from abort() and exit().
*/
-extern void (*__cleanup)(void);
+extern void (*__cleanup)(void) __hidden;
/*
* Get kern.osreldate to detect ABI revisions. Explicitly
diff --git a/lib/libc/libc.ldscript b/lib/libc/libc.ldscript
new file mode 100644
index 000000000000..a5c8a274db74
--- /dev/null
+++ b/lib/libc/libc.ldscript
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+GROUP ( @@SHLIB@@ @@LIBDIR@@/libssp_nonshared.a )
diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc
index f2161be470ae..c2f2f4e61727 100644
--- a/lib/libc/locale/Makefile.inc
+++ b/lib/libc/locale/Makefile.inc
@@ -23,6 +23,12 @@ SRCS+= ascii.c big5.c btowc.c collate.c collcmp.c euc.c fix_grouping.c \
wcwidth.c\
xlocale.c
+.if ${MK_ICONV} != "no"
+SRCS+= c16rtomb_iconv.c c32rtomb_iconv.c mbrtoc16_iconv.c mbrtoc32_iconv.c
+.else
+SRCS+= c16rtomb.c c32rtomb.c mbrtoc16.c mbrtoc32.c
+.endif
+
SYM_MAPS+=${.CURDIR}/locale/Symbol.map
MAN+= btowc.3 \
@@ -72,7 +78,9 @@ MLINKS+=iswalnum_l.3 iswalpha_l.3 iswalnum_l.3 iswcntrl_l.3 \
iswalnum_l.3 iswspecial_l.3 iswalnum_l.3 nextwctype_l.3 \
iswalnum_l.3 towctrans_l.3 iswalnum_l.3 wctrans_l.3
MLINKS+=isxdigit.3 ishexnumber.3
+MLINKS+=mbrtowc.3 mbrtoc16.3 mbrtowc.3 mbrtoc32.3
MLINKS+=mbsrtowcs.3 mbsnrtowcs.3
+MLINKS+=wcrtomb.3 c16rtomb.3 wcrtomb.3 c32rtomb.3
MLINKS+=wcsrtombs.3 wcsnrtombs.3
MLINKS+=wcstod.3 wcstof.3 wcstod.3 wcstold.3
MLINKS+=wcstol.3 wcstoul.3 wcstol.3 wcstoll.3 wcstol.3 wcstoull.3 \
diff --git a/lib/libc/locale/Symbol.map b/lib/libc/locale/Symbol.map
index f6367dacf3fd..b2f2a35f2fe4 100644
--- a/lib/libc/locale/Symbol.map
+++ b/lib/libc/locale/Symbol.map
@@ -199,6 +199,14 @@ FBSD_1.3 {
__istype_l;
__runes_for_locale;
_ThreadRuneLocale;
+ c16rtomb;
+ c16rtomb_l;
+ c32rtomb;
+ c32rtomb_l;
+ mbrtoc16;
+ mbrtoc16_l;
+ mbrtoc32;
+ mbrtoc32_l;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/locale/c16rtomb.c b/lib/libc/locale/c16rtomb.c
new file mode 100644
index 000000000000..8bad98267b69
--- /dev/null
+++ b/lib/libc/locale/c16rtomb.c
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <errno.h>
+#include <uchar.h>
+#include "xlocale_private.h"
+
+typedef struct {
+ char16_t lead_surrogate;
+ mbstate_t c32_mbstate;
+} _Char16State;
+
+size_t
+c16rtomb_l(char * __restrict s, char16_t c16, mbstate_t * __restrict ps,
+ locale_t locale)
+{
+ _Char16State *cs;
+ char32_t c32;
+
+ FIX_LOCALE(locale);
+ if (ps == NULL)
+ ps = &locale->c16rtomb;
+ cs = (_Char16State *)ps;
+
+ /* If s is a null pointer, the value of parameter c16 is ignored. */
+ if (s == NULL) {
+ c32 = 0;
+ } else if (cs->lead_surrogate >= 0xd800 &&
+ cs->lead_surrogate <= 0xdbff) {
+ /* We should see a trail surrogate now. */
+ if (c16 < 0xdc00 || c16 > 0xdfff) {
+ errno = EILSEQ;
+ return ((size_t)-1);
+ }
+ c32 = 0x10000 + ((cs->lead_surrogate & 0x3ff) << 10 |
+ (c16 & 0x3ff));
+ } else if (c16 >= 0xd800 && c16 <= 0xdbff) {
+ /* Store lead surrogate for next invocation. */
+ cs->lead_surrogate = c16;
+ return (0);
+ } else {
+ /* Regular character. */
+ c32 = c16;
+ }
+ cs->lead_surrogate = 0;
+
+ return (c32rtomb_l(s, c32, &cs->c32_mbstate, locale));
+}
+
+size_t
+c16rtomb(char * __restrict s, char16_t c16, mbstate_t * __restrict ps)
+{
+
+ return (c16rtomb_l(s, c16, ps, __get_locale()));
+}
diff --git a/lib/libc/locale/c16rtomb_iconv.c b/lib/libc/locale/c16rtomb_iconv.c
new file mode 100644
index 000000000000..86bd9dab2a52
--- /dev/null
+++ b/lib/libc/locale/c16rtomb_iconv.c
@@ -0,0 +1,8 @@
+/* $FreeBSD$ */
+#define charXX_t char16_t
+#define cXXrtomb c16rtomb
+#define cXXrtomb_l c16rtomb_l
+#define SRCBUF_LEN 2
+#define UTF_XX_INTERNAL "UTF-16-INTERNAL"
+
+#include "cXXrtomb_iconv.h"
diff --git a/lib/libc/locale/c32rtomb.c b/lib/libc/locale/c32rtomb.c
new file mode 100644
index 000000000000..c5f008fdea69
--- /dev/null
+++ b/lib/libc/locale/c32rtomb.c
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <errno.h>
+#include <uchar.h>
+#include <wchar.h>
+#include "xlocale_private.h"
+
+size_t
+c32rtomb_l(char * __restrict s, char32_t c32, mbstate_t * __restrict ps,
+ locale_t locale)
+{
+
+ /* Unicode Standard 5.0, D90: ill-formed characters. */
+ if ((c32 >= 0xd800 && c32 <= 0xdfff) || c32 > 0x10ffff) {
+ errno = EILSEQ;
+ return ((size_t)-1);
+ }
+
+ FIX_LOCALE(locale);
+ if (ps == NULL)
+ ps = &locale->c32rtomb;
+
+ /* Assume wchar_t uses UTF-32. */
+ return (wcrtomb_l(s, c32, ps, locale));
+}
+
+size_t
+c32rtomb(char * __restrict s, char32_t c32, mbstate_t * __restrict ps)
+{
+
+ return (c32rtomb_l(s, c32, ps, __get_locale()));
+}
diff --git a/lib/libc/locale/c32rtomb_iconv.c b/lib/libc/locale/c32rtomb_iconv.c
new file mode 100644
index 000000000000..dabbfd7f7ab4
--- /dev/null
+++ b/lib/libc/locale/c32rtomb_iconv.c
@@ -0,0 +1,8 @@
+/* $FreeBSD$ */
+#define charXX_t char32_t
+#define cXXrtomb c32rtomb
+#define cXXrtomb_l c32rtomb_l
+#define SRCBUF_LEN 1
+#define UTF_XX_INTERNAL "UTF-32-INTERNAL"
+
+#include "cXXrtomb_iconv.h"
diff --git a/lib/libc/locale/cXXrtomb_iconv.h b/lib/libc/locale/cXXrtomb_iconv.h
new file mode 100644
index 000000000000..0ea553bc0809
--- /dev/null
+++ b/lib/libc/locale/cXXrtomb_iconv.h
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/queue.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <langinfo.h>
+#include <uchar.h>
+
+#include "../iconv/citrus_hash.h"
+#include "../iconv/citrus_module.h"
+#include "../iconv/citrus_iconv.h"
+#include "xlocale_private.h"
+
+typedef struct {
+ bool initialized;
+ struct _citrus_iconv iconv;
+ union {
+ charXX_t widechar[SRCBUF_LEN];
+ char bytes[sizeof(charXX_t) * SRCBUF_LEN];
+ } srcbuf;
+ size_t srcbuf_len;
+} _ConversionState;
+_Static_assert(sizeof(_ConversionState) <= sizeof(mbstate_t),
+ "Size of _ConversionState must not exceed mbstate_t's size.");
+
+size_t
+cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps,
+ locale_t locale)
+{
+ _ConversionState *cs;
+ struct _citrus_iconv *handle;
+ const char *src;
+ char *dst;
+ size_t srcleft, dstleft, invlen;
+ int err;
+
+ FIX_LOCALE(locale);
+ if (ps == NULL)
+ ps = &locale->cXXrtomb;
+ cs = (_ConversionState *)ps;
+ handle = &cs->iconv;
+
+ /* Reinitialize mbstate_t. */
+ if (s == NULL || !cs->initialized) {
+ if (_citrus_iconv_open(&handle, UTF_XX_INTERNAL,
+ nl_langinfo_l(CODESET, locale)) != 0) {
+ cs->initialized = false;
+ errno = EINVAL;
+ return (-1);
+ }
+ handle->cv_shared->ci_discard_ilseq = true;
+ handle->cv_shared->ci_hooks = NULL;
+ cs->srcbuf_len = 0;
+ cs->initialized = true;
+ if (s == NULL)
+ return (1);
+ }
+
+ assert(cs->srcbuf_len < sizeof(cs->srcbuf.widechar) / sizeof(charXX_t));
+ cs->srcbuf.widechar[cs->srcbuf_len++] = c;
+
+ /* Perform conversion. */
+ src = cs->srcbuf.bytes;
+ srcleft = cs->srcbuf_len * sizeof(charXX_t);
+ dst = s;
+ dstleft = MB_CUR_MAX_L(locale);
+ err = _citrus_iconv_convert(handle, &src, &srcleft, &dst, &dstleft,
+ 0, &invlen);
+
+ /* Character is part of a surrogate pair. We need more input. */
+ if (err == EINVAL)
+ return (0);
+ cs->srcbuf_len = 0;
+
+ /* Illegal sequence. */
+ if (dst == s) {
+ errno = EILSEQ;
+ return ((size_t)-1);
+ }
+ return (dst - s);
+}
+
+size_t
+cXXrtomb(char * __restrict s, charXX_t c, mbstate_t * __restrict ps)
+{
+
+ return (cXXrtomb_l(s, c, ps, __get_locale()));
+}
diff --git a/lib/libc/locale/duplocale.3 b/lib/libc/locale/duplocale.3
index 1e149c05d7cb..f2e82158ae0e 100644
--- a/lib/libc/locale/duplocale.3
+++ b/lib/libc/locale/duplocale.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 17 2011
+.Dd September 17, 2011
.Dt DUPLOCALE 3
.Os
.Sh NAME
@@ -66,8 +66,8 @@ The locale returned by this call must be freed with
.Xr uselocale 3 ,
.Xr xlocale 3
.Sh STANDARDS
-This function, conforms to
-.St -p1003.1-2008
+This function conforms to
+.St -p1003.1-2008 .
.Sh BUGS
Ideally,
.Xr uselocale 3
diff --git a/lib/libc/locale/freelocale.3 b/lib/libc/locale/freelocale.3
index 26060e87731f..86f4809d6cac 100644
--- a/lib/libc/locale/freelocale.3
+++ b/lib/libc/locale/freelocale.3
@@ -26,7 +26,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
-.Dd September 17 2011
+.Dd September 17, 2011
.Dt FREELOCALE 3
.Os
.Sh NAME
@@ -57,5 +57,12 @@ Returns 0 on success or -1 on error.
.Xr uselocale 3 ,
.Xr xlocale 3
.Sh STANDARDS
-This function, conforms to
-.St -p1003.1-2008 .
+The
+.Fn freelocale
+function
+differs from
+.St -p1003.1-2008
+in that its return type is
+.Vt int
+rather than
+.Vt void .
diff --git a/lib/libc/locale/mbrtoc16.c b/lib/libc/locale/mbrtoc16.c
new file mode 100644
index 000000000000..a47514c3d93b
--- /dev/null
+++ b/lib/libc/locale/mbrtoc16.c
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <uchar.h>
+#include "xlocale_private.h"
+
+typedef struct {
+ char16_t trail_surrogate;
+ mbstate_t c32_mbstate;
+} _Char16State;
+
+size_t
+mbrtoc16_l(char16_t * __restrict pc16, const char * __restrict s, size_t n,
+ mbstate_t * __restrict ps, locale_t locale)
+{
+ _Char16State *cs;
+ char32_t c32;
+ ssize_t len;
+
+ FIX_LOCALE(locale);
+ if (ps == NULL)
+ ps = &locale->mbrtoc16;
+ cs = (_Char16State *)ps;
+
+ /*
+ * Call straight into mbrtoc32_l() if we don't need to return a
+ * character value. According to the spec, if s is a null
+ * pointer, the value of parameter pc16 is also ignored.
+ */
+ if (pc16 == NULL || s == NULL) {
+ cs->trail_surrogate = 0;
+ return (mbrtoc32_l(NULL, s, n, &cs->c32_mbstate, locale));
+ }
+
+ /* Return the trail surrogate from the previous invocation. */
+ if (cs->trail_surrogate >= 0xdc00 && cs->trail_surrogate <= 0xdfff) {
+ *pc16 = cs->trail_surrogate;
+ cs->trail_surrogate = 0;
+ return ((size_t)-3);
+ }
+
+ len = mbrtoc32_l(&c32, s, n, &cs->c32_mbstate, locale);
+ if (len >= 0) {
+ if (c32 < 0x10000) {
+ /* Fits in one UTF-16 character. */
+ *pc16 = c32;
+ } else {
+ /* Split up in a surrogate pair. */
+ c32 -= 0x10000;
+ *pc16 = 0xd800 | (c32 >> 10);
+ cs->trail_surrogate = 0xdc00 | (c32 & 0x3ff);
+ }
+ }
+ return (len);
+}
+
+size_t
+mbrtoc16(char16_t * __restrict pc16, const char * __restrict s, size_t n,
+ mbstate_t * __restrict ps)
+{
+
+ return (mbrtoc16_l(pc16, s, n, ps, __get_locale()));
+}
diff --git a/lib/libc/locale/mbrtoc16_iconv.c b/lib/libc/locale/mbrtoc16_iconv.c
new file mode 100644
index 000000000000..f1eaf1925496
--- /dev/null
+++ b/lib/libc/locale/mbrtoc16_iconv.c
@@ -0,0 +1,8 @@
+/* $FreeBSD$ */
+#define charXX_t char16_t
+#define mbrtocXX mbrtoc16
+#define mbrtocXX_l mbrtoc16_l
+#define DSTBUF_LEN 2
+#define UTF_XX_INTERNAL "UTF-16-INTERNAL"
+
+#include "mbrtocXX_iconv.h"
diff --git a/lib/libc/locale/mbrtoc32.c b/lib/libc/locale/mbrtoc32.c
new file mode 100644
index 000000000000..ee9e47d6a3e5
--- /dev/null
+++ b/lib/libc/locale/mbrtoc32.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <uchar.h>
+#include <wchar.h>
+#include "xlocale_private.h"
+
+size_t
+mbrtoc32_l(char32_t * __restrict pc32, const char * __restrict s, size_t n,
+ mbstate_t * __restrict ps, locale_t locale)
+{
+
+ FIX_LOCALE(locale);
+ if (ps == NULL)
+ ps = &locale->mbrtoc32;
+
+ /* Assume wchar_t uses UTF-32. */
+ return (mbrtowc_l(pc32, s, n, ps, locale));
+}
+
+size_t
+mbrtoc32(char32_t * __restrict pc32, const char * __restrict s, size_t n,
+ mbstate_t * __restrict ps)
+{
+
+ return (mbrtoc32_l(pc32, s, n, ps, __get_locale()));
+}
diff --git a/lib/libc/locale/mbrtoc32_iconv.c b/lib/libc/locale/mbrtoc32_iconv.c
new file mode 100644
index 000000000000..ec2c0145d9d6
--- /dev/null
+++ b/lib/libc/locale/mbrtoc32_iconv.c
@@ -0,0 +1,8 @@
+/* $FreeBSD$ */
+#define charXX_t char32_t
+#define mbrtocXX mbrtoc32
+#define mbrtocXX_l mbrtoc32_l
+#define DSTBUF_LEN 1
+#define UTF_XX_INTERNAL "UTF-32-INTERNAL"
+
+#include "mbrtocXX_iconv.h"
diff --git a/lib/libc/locale/mbrtocXX_iconv.h b/lib/libc/locale/mbrtocXX_iconv.h
new file mode 100644
index 000000000000..ac85a5a5a782
--- /dev/null
+++ b/lib/libc/locale/mbrtocXX_iconv.h
@@ -0,0 +1,159 @@
+/*-
+ * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/queue.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <langinfo.h>
+#include <limits.h>
+#include <string.h>
+#include <uchar.h>
+
+#include "../iconv/citrus_hash.h"
+#include "../iconv/citrus_module.h"
+#include "../iconv/citrus_iconv.h"
+#include "xlocale_private.h"
+
+typedef struct {
+ bool initialized;
+ struct _citrus_iconv iconv;
+ char srcbuf[MB_LEN_MAX];
+ size_t srcbuf_len;
+ union {
+ charXX_t widechar[DSTBUF_LEN];
+ char bytes[sizeof(charXX_t) * DSTBUF_LEN];
+ } dstbuf;
+ size_t dstbuf_len;
+} _ConversionState;
+_Static_assert(sizeof(_ConversionState) <= sizeof(mbstate_t),
+ "Size of _ConversionState must not exceed mbstate_t's size.");
+
+size_t
+mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n,
+ mbstate_t * __restrict ps, locale_t locale)
+{
+ _ConversionState *cs;
+ struct _citrus_iconv *handle;
+ size_t i, retval;
+ charXX_t retchar;
+
+ FIX_LOCALE(locale);
+ if (ps == NULL)
+ ps = &locale->mbrtocXX;
+ cs = (_ConversionState *)ps;
+ handle = &cs->iconv;
+
+ /* Reinitialize mbstate_t. */
+ if (s == NULL || !cs->initialized) {
+ if (_citrus_iconv_open(&handle,
+ nl_langinfo_l(CODESET, locale), UTF_XX_INTERNAL) != 0) {
+ cs->initialized = false;
+ errno = EINVAL;
+ return (-1);
+ }
+ handle->cv_shared->ci_discard_ilseq = true;
+ handle->cv_shared->ci_hooks = NULL;
+ cs->srcbuf_len = cs->dstbuf_len = 0;
+ cs->initialized = true;
+ if (s == NULL)
+ return (0);
+ }
+
+ /* See if we still have characters left from the previous invocation. */
+ if (cs->dstbuf_len > 0) {
+ retval = (size_t)-3;
+ goto return_char;
+ }
+
+ /* Fill up the read buffer as far as possible. */
+ if (n > sizeof(cs->srcbuf) - cs->srcbuf_len)
+ n = sizeof(cs->srcbuf) - cs->srcbuf_len;
+ memcpy(cs->srcbuf + cs->srcbuf_len, s, n);
+
+ /* Convert as few characters to the dst buffer as possible. */
+ for (i = 0; ; i++) {
+ const char *src;
+ char *dst;
+ size_t srcleft, dstleft, invlen;
+ int err;
+
+ src = cs->srcbuf;
+ srcleft = cs->srcbuf_len + n;
+ dst = cs->dstbuf.bytes;
+ dstleft = i * sizeof(charXX_t);
+ assert(srcleft <= sizeof(cs->srcbuf) &&
+ dstleft <= sizeof(cs->dstbuf.bytes));
+ err = _citrus_iconv_convert(handle, &src, &srcleft,
+ &dst, &dstleft, 0, &invlen);
+ cs->dstbuf_len = (dst - cs->dstbuf.bytes) / sizeof(charXX_t);
+
+ /* Got new character(s). Return the first. */
+ if (cs->dstbuf_len > 0) {
+ assert(src - cs->srcbuf > cs->srcbuf_len);
+ retval = src - cs->srcbuf - cs->srcbuf_len;
+ cs->srcbuf_len = 0;
+ goto return_char;
+ }
+
+ /* Increase dst buffer size, to obtain the surrogate pair. */
+ if (err == E2BIG)
+ continue;
+
+ /* Illegal sequence. */
+ if (invlen > 0) {
+ cs->srcbuf_len = 0;
+ errno = EILSEQ;
+ return ((size_t)-1);
+ }
+
+ /* Save unprocessed remainder for the next invocation. */
+ memmove(cs->srcbuf, src, srcleft);
+ cs->srcbuf_len = srcleft;
+ return ((size_t)-2);
+ }
+
+return_char:
+ retchar = cs->dstbuf.widechar[0];
+ memmove(&cs->dstbuf.widechar[0], &cs->dstbuf.widechar[1],
+ --cs->dstbuf_len * sizeof(charXX_t));
+ if (pc != NULL)
+ *pc = retchar;
+ if (retchar == 0)
+ return (0);
+ return (retval);
+}
+
+size_t
+mbrtocXX(charXX_t * __restrict pc, const char * __restrict s, size_t n,
+ mbstate_t * __restrict ps)
+{
+
+ return (mbrtocXX_l(pc, s, n, ps, __get_locale()));
+}
diff --git a/lib/libc/locale/mbrtowc.3 b/lib/libc/locale/mbrtowc.3
index 10160d1916fd..22b26cd2a244 100644
--- a/lib/libc/locale/mbrtowc.3
+++ b/lib/libc/locale/mbrtowc.3
@@ -24,11 +24,13 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 8, 2004
+.Dd May 21, 2013
.Dt MBRTOWC 3
.Os
.Sh NAME
-.Nm mbrtowc
+.Nm mbrtowc ,
+.Nm mbrtoc16 ,
+.Nm mbrtoc32
.Nd "convert a character to a wide-character code (restartable)"
.Sh LIBRARY
.Lb libc
@@ -36,35 +38,51 @@
.In wchar.h
.Ft size_t
.Fo mbrtowc
-.Fa "wchar_t * restrict pwc" "const char * restrict s" "size_t n"
+.Fa "wchar_t * restrict pc" "const char * restrict s" "size_t n"
+.Fa "mbstate_t * restrict ps"
+.Fc
+.In uchar.h
+.Ft size_t
+.Fo mbrtoc16
+.Fa "char16_t * restrict pc" "const char * restrict s" "size_t n"
+.Fa "mbstate_t * restrict ps"
+.Fc
+.Ft size_t
+.Fo mbrtoc32
+.Fa "char32_t * restrict pc" "const char * restrict s" "size_t n"
.Fa "mbstate_t * restrict ps"
.Fc
.Sh DESCRIPTION
The
-.Fn mbrtowc
-function inspects at most
+.Fn mbrtowc ,
+.Fn mbrtoc16
+and
+.Fn mbrtoc32
+functions inspect at most
.Fa n
bytes pointed to by
.Fa s
to determine the number of bytes needed to complete the next multibyte
character.
If a character can be completed, and
-.Fa pwc
+.Fa pc
is not
.Dv NULL ,
the wide character which is represented by
.Fa s
is stored in the
-.Vt wchar_t
+.Vt wchar_t ,
+.Vt char16_t
+or
+.Vt char32_t
it points to.
.Pp
If
.Fa s
is
.Dv NULL ,
-.Fn mbrtowc
-behaves as if
-.Fa pwc
+these functions behave as if
+.Fa pc
was
.Dv NULL ,
.Fa s
@@ -81,15 +99,24 @@ argument,
is used to keep track of the shift state.
If it is
.Dv NULL ,
-.Fn mbrtowc
-uses an internal, static
+these functions use an internal, static
.Vt mbstate_t
object, which is initialized to the initial conversion state
at program startup.
+.Pp
+As a single
+.Vt char16_t
+is not large enough to represent certain multibyte characters, the
+.Fn mbrtoc16
+function may need to be invoked multiple times to convert a single
+multibyte character sequence.
.Sh RETURN VALUES
The
-.Fn mbrtowc
-functions returns:
+.Fn mbrtowc ,
+.Fn mbrtoc16
+and
+.Fn mbrtoc32
+functions return:
.Bl -tag -width indent
.It 0
The next
@@ -100,10 +127,13 @@ represent the null wide character
.It >0
The next
.Fa n
-or fewer bytes
-represent a valid character,
-.Fn mbrtowc
-returns the number of bytes used to complete the multibyte character.
+or fewer bytes represent a valid character, these functions
+return the number of bytes used to complete the multibyte character.
+.It Po Vt size_t Pc Ns \-1
+An encoding error has occurred.
+The next
+.Fa n
+or fewer bytes do not contribute to a valid multibyte character.
.It Po Vt size_t Pc Ns \-2
The next
.Fa n
@@ -111,16 +141,23 @@ contribute to, but do not complete, a valid multibyte character sequence,
and all
.Fa n
bytes have been processed.
-.It Po Vt size_t Pc Ns \-1
-An encoding error has occurred.
-The next
-.Fa n
-or fewer bytes do not contribute to a valid multibyte character.
+.El
+.Pp
+The
+.Fn mbrtoc16
+function also returns:
+.Bl -tag -width indent
+.It Po Vt size_t Pc Ns \-3
+The next character resulting from a previous call has been stored.
+No bytes from the input have been consumed.
.El
.Sh ERRORS
The
-.Fn mbrtowc
-function will fail if:
+.Fn mbrtowc ,
+.Fn mbrtoc16
+and
+.Fn mbrtoc32
+functions will fail if:
.Bl -tag -width Er
.It Bq Er EILSEQ
An invalid multibyte sequence was detected.
@@ -134,6 +171,9 @@ The conversion state is invalid.
.Xr wcrtomb 3
.Sh STANDARDS
The
-.Fn mbrtowc
-function conforms to
-.St -isoC-99 .
+.Fn mbrtowc ,
+.Fn mbrtoc16
+and
+.Fn mbrtoc32
+functions conform to
+.St -isoC-2011 .
diff --git a/lib/libc/locale/newlocale.3 b/lib/libc/locale/newlocale.3
index e2d7ebbb0561..a639c372a6c6 100644
--- a/lib/libc/locale/newlocale.3
+++ b/lib/libc/locale/newlocale.3
@@ -26,7 +26,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
-.Dd September 17 2011
+.Dd September 17, 2011
.Dt NEWLOCALE 3
.Os
.Sh NAME
@@ -108,5 +108,5 @@ You must free the returned locale with
.Xr uselocale 3 ,
.Xr xlocale 3
.Sh STANDARDS
-This function, conforms to
-.St -p1003.1-2008
+This function conforms to
+.St -p1003.1-2008 .
diff --git a/lib/libc/locale/querylocale.3 b/lib/libc/locale/querylocale.3
index 4f9775595e5f..f90d626d1ac6 100644
--- a/lib/libc/locale/querylocale.3
+++ b/lib/libc/locale/querylocale.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 17 2011
+.Dd May 3, 2013
.Dt QUERYLOCALE 3
.Os
.Sh NAME
@@ -52,6 +52,3 @@ If more than one bit in the mask is set, the returned value is undefined.
.Xr newlocale 3 ,
.Xr uselocale 3 ,
.Xr xlocale 3
-.Sh STANDARDS
-This function, conforms to
-.St -p1003.1-2008
diff --git a/lib/libc/locale/uselocale.3 b/lib/libc/locale/uselocale.3
index 9b4f43038823..df29a625e17e 100644
--- a/lib/libc/locale/uselocale.3
+++ b/lib/libc/locale/uselocale.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 17 2011
+.Dd September 17, 2011
.Dt USELOCALE 3
.Os
.Sh NAME
@@ -57,4 +57,4 @@ or LC_GLOBAL_LOCALE if this thread has no locale associated with it.
.Xr xlocale 3
.Sh STANDARDS
This function conforms to
-.St -p1003.1-2008
+.St -p1003.1-2008 .
diff --git a/lib/libc/locale/wcrtomb.3 b/lib/libc/locale/wcrtomb.3
index c89614e2d34b..bc741740a249 100644
--- a/lib/libc/locale/wcrtomb.3
+++ b/lib/libc/locale/wcrtomb.3
@@ -24,24 +24,34 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 8, 2004
+.Dd May 21, 2013
.Dt WCRTOMB 3
.Os
.Sh NAME
-.Nm wcrtomb
+.Nm wcrtomb ,
+.Nm c16rtomb ,
+.Nm c32rtomb
.Nd "convert a wide-character code to a character (restartable)"
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In wchar.h
.Ft size_t
-.Fn wcrtomb "char * restrict s" "wchar_t wc" "mbstate_t * restrict ps"
+.Fn wcrtomb "char * restrict s" "wchar_t c" "mbstate_t * restrict ps"
+.In uchar.h
+.Ft size_t
+.Fn c16rtomb "char * restrict s" "char16_t c" "mbstate_t * restrict ps"
+.Ft size_t
+.Fn c32rtomb "char * restrict s" "char32_t c" "mbstate_t * restrict ps"
.Sh DESCRIPTION
The
-.Fn wcrtomb
-function stores a multibyte sequence representing the
+.Fn wcrtomb ,
+.Fn c16rtomb
+and
+.Fn c32rtomb
+functions store a multibyte sequence representing the
wide character
-.Fa wc ,
+.Fa c ,
including any necessary shift sequences, to the
character array
.Fa s ,
@@ -53,11 +63,10 @@ If
.Fa s
is
.Dv NULL ,
-.Fn wcrtomb
-behaves as if
+these functions behave as if
.Fa s
pointed to an internal buffer and
-.Fa wc
+.Fa c
was a null wide character (L'\e0').
.Pp
The
@@ -67,26 +76,32 @@ argument,
is used to keep track of the shift state.
If it is
.Dv NULL ,
-.Fn wcrtomb
-uses an internal, static
+these functions use an internal, static
.Vt mbstate_t
object, which is initialized to the initial conversion state
at program startup.
+.Pp
+As certain multibyte characters may only be represented by a series of
+16-bit characters, the
+.Fn c16rtomb
+may need to invoked multiple times before a multibyte sequence is
+returned.
.Sh RETURN VALUES
-The
-.Fn wcrtomb
-functions returns the length (in bytes) of the multibyte sequence
+These functions return the length (in bytes) of the multibyte sequence
needed to represent
-.Fa wc ,
+.Fa c ,
or
.Po Vt size_t Pc Ns \-1
if
-.Fa wc
+.Fa c
is not a valid wide character code.
.Sh ERRORS
The
-.Fn wcrtomb
-function will fail if:
+.Fn wcrtomb ,
+.Fn c16rtomb
+and
+.Fn c32rtomb
+functions will fail if:
.Bl -tag -width Er
.It Bq Er EILSEQ
An invalid wide character code was specified.
@@ -100,6 +115,9 @@ The conversion state is invalid.
.Xr wctomb 3
.Sh STANDARDS
The
-.Fn wcrtomb
-function conforms to
-.St -isoC-99 .
+.Fn wcrtomb ,
+.Fn c16rtomb
+and
+.Fn c32rtomb
+functions conform to
+.St -isoC-2011 .
diff --git a/lib/libc/locale/xlocale.3 b/lib/libc/locale/xlocale.3
index 9648cc7a7926..d467a1004f24 100644
--- a/lib/libc/locale/xlocale.3
+++ b/lib/libc/locale/xlocale.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 17 2011
+.Dd September 17, 2011
.Dt XLOCALE 3
.Os
.Sh NAME
diff --git a/lib/libc/locale/xlocale_private.h b/lib/libc/locale/xlocale_private.h
index 813f71994052..502b5486e684 100644
--- a/lib/libc/locale/xlocale_private.h
+++ b/lib/libc/locale/xlocale_private.h
@@ -109,6 +109,10 @@ struct _xlocale {
__mbstate_t mblen;
/** Persistent state used by mbrlen() calls. */
__mbstate_t mbrlen;
+ /** Persistent state used by mbrtoc16() calls. */
+ __mbstate_t mbrtoc16;
+ /** Persistent state used by mbrtoc32() calls. */
+ __mbstate_t mbrtoc32;
/** Persistent state used by mbrtowc() calls. */
__mbstate_t mbrtowc;
/** Persistent state used by mbsnrtowcs() calls. */
@@ -117,6 +121,10 @@ struct _xlocale {
__mbstate_t mbsrtowcs;
/** Persistent state used by mbtowc() calls. */
__mbstate_t mbtowc;
+ /** Persistent state used by c16rtomb() calls. */
+ __mbstate_t c16rtomb;
+ /** Persistent state used by c32rtomb() calls. */
+ __mbstate_t c32rtomb;
/** Persistent state used by wcrtomb() calls. */
__mbstate_t wcrtomb;
/** Persistent state used by wcsnrtombs() calls. */
diff --git a/lib/libc/mips/gen/getcontextx.c b/lib/libc/mips/gen/getcontextx.c
index 307978a466dd..54f851384811 100644
--- a/lib/libc/mips/gen/getcontextx.c
+++ b/lib/libc/mips/gen/getcontextx.c
@@ -40,6 +40,13 @@ __getcontextx_size(void)
}
int
+__fillcontextx2(char *ctx)
+{
+
+ return (0);
+}
+
+int
__fillcontextx(char *ctx)
{
ucontext_t *ucp;
diff --git a/lib/libc/mips/gen/longjmp.c b/lib/libc/mips/gen/longjmp.c
index ee01ad55002c..7c684706c042 100644
--- a/lib/libc/mips/gen/longjmp.c
+++ b/lib/libc/mips/gen/longjmp.c
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/mips/net/htonl.S b/lib/libc/mips/net/htonl.S
index 858892009edf..66c4f90fd65f 100644
--- a/lib/libc/mips/net/htonl.S
+++ b/lib/libc/mips/net/htonl.S
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/mips/net/htons.S b/lib/libc/mips/net/htons.S
index 592c44eeeb8b..0449c4d82e5c 100644
--- a/lib/libc/mips/net/htons.S
+++ b/lib/libc/mips/net/htons.S
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/mips/net/ntohl.S b/lib/libc/mips/net/ntohl.S
index bacda3eb6c19..39001aa86bbe 100644
--- a/lib/libc/mips/net/ntohl.S
+++ b/lib/libc/mips/net/ntohl.S
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/mips/net/ntohs.S b/lib/libc/mips/net/ntohs.S
index 28aac3dffdc6..4761371be1af 100644
--- a/lib/libc/mips/net/ntohs.S
+++ b/lib/libc/mips/net/ntohs.S
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/net/ether_addr.c b/lib/libc/net/ether_addr.c
index d769f2781a44..5d72606af050 100644
--- a/lib/libc/net/ether_addr.c
+++ b/lib/libc/net/ether_addr.c
@@ -148,7 +148,7 @@ ether_ntohost(char *hostname, const struct ether_addr *e)
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_ETHERS, "r")) == NULL)
+ if ((fp = fopen(_PATH_ETHERS, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
if (buf[0] == '#')
@@ -197,7 +197,7 @@ ether_hostton(const char *hostname, struct ether_addr *e)
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_ETHERS, "r")) == NULL)
+ if ((fp = fopen(_PATH_ETHERS, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
if (buf[0] == '#')
diff --git a/lib/libc/net/eui64.c b/lib/libc/net/eui64.c
index 50851674de69..d9ed76c915aa 100644
--- a/lib/libc/net/eui64.c
+++ b/lib/libc/net/eui64.c
@@ -227,7 +227,7 @@ eui64_ntohost(char *hostname, size_t len, const struct eui64 *id)
char eui64_a[24];
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_EUI64, "r")) == NULL)
+ if ((fp = fopen(_PATH_EUI64, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
@@ -277,7 +277,7 @@ eui64_hostton(const char *hostname, struct eui64 *id)
int resultlen;
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_EUI64, "r")) == NULL)
+ if ((fp = fopen(_PATH_EUI64, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3
index 3419809915f2..5d03aab2a42c 100644
--- a/lib/libc/net/getaddrinfo.3
+++ b/lib/libc/net/getaddrinfo.3
@@ -26,9 +26,9 @@
.Nm freeaddrinfo
.Nd socket address structure to host and service name
.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <netdb.h>
+.In sys/types.h
+.In sys/socket.h
+.In netdb.h
.Ft int
.Fo getaddrinfo
.Fa "const char *hostname" "const char *servname"
@@ -255,7 +255,7 @@ member points to a filled-in socket address structure of length
This implementation of
.Fn getaddrinfo
allows numeric IPv6 address notation with scope identifier,
-as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt.
+as documented in chapter 11 of RFC 4007.
By appending the percent character and scope identifier to addresses,
one can fill the
.Li sin6_scope_id
@@ -441,9 +441,8 @@ freeaddrinfo(res0);
.%A E. Nordmark
.%A B. Zill
.%T "IPv6 Scoped Address Architecture"
-.%R internet draft
-.%N draft-ietf-ipv6-scoping-arch-02.txt
-.%O work in progress material
+.%R RFC 4007
+.%D March 2005
.Re
.Rs
.%A Craig Metz
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index d11ff780d8bb..c6af6d8f6435 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -2240,7 +2240,7 @@ static void
_sethtent(FILE **hostf)
{
if (!*hostf)
- *hostf = fopen(_PATH_HOSTS, "r");
+ *hostf = fopen(_PATH_HOSTS, "re");
else
rewind(*hostf);
}
@@ -2264,7 +2264,7 @@ _gethtent(FILE **hostf, const char *name, const struct addrinfo *pai)
const char *addr;
char hostbuf[8*1024];
- if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "r")))
+ if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re")))
return (NULL);
again:
if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf)))
diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c
index 4253d4933d52..1468afb6304f 100644
--- a/lib/libc/net/gethostbyht.c
+++ b/lib/libc/net/gethostbyht.c
@@ -72,7 +72,7 @@ void
_sethosthtent(int f, struct hostent_data *hed)
{
if (!hed->hostf)
- hed->hostf = fopen(_PATH_HOSTS, "r");
+ hed->hostf = fopen(_PATH_HOSTS, "re");
else
rewind(hed->hostf);
hed->stayopen = f;
@@ -96,7 +96,7 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped,
int af, len;
char hostbuf[BUFSIZ + 1];
- if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "r"))) {
+ if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "re"))) {
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3
index 9b8c0b915333..35f031b5727a 100644
--- a/lib/libc/net/gethostbyname.3
+++ b/lib/libc/net/gethostbyname.3
@@ -51,7 +51,7 @@
.Ft struct hostent *
.Fn gethostbyname2 "const char *name" "int af"
.Ft struct hostent *
-.Fn gethostbyaddr "const void *addr" "socklen_t len" "int type"
+.Fn gethostbyaddr "const void *addr" "socklen_t len" "int af"
.Ft struct hostent *
.Fn gethostent void
.Ft void
@@ -107,7 +107,7 @@ in binary form
.Tn ASCII
form).
The
-.Fa type
+.Fa af
argument specifies the address family
(e.g.\&
.Dv AF_INET , AF_INET6 ,
diff --git a/lib/libc/net/getifaddrs.3 b/lib/libc/net/getifaddrs.3
index a12cd00bfb4c..ff3f77493a77 100644
--- a/lib/libc/net/getifaddrs.3
+++ b/lib/libc/net/getifaddrs.3
@@ -24,15 +24,13 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 12, 1995
+.Dd May 21, 2013
.Dt GETIFADDRS 3
.Os
.Sh NAME
.Nm getifaddrs
.Nd get interface addresses
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
.In ifaddrs.h
.Ft int
.Fn getifaddrs "struct ifaddrs **ifap"
diff --git a/lib/libc/net/getifmaddrs.3 b/lib/libc/net/getifmaddrs.3
index 2d2a93681297..14c40875439c 100644
--- a/lib/libc/net/getifmaddrs.3
+++ b/lib/libc/net/getifmaddrs.3
@@ -20,15 +20,13 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 14, 2003
+.Dd May 21, 2013
.Dt GETIFMADDRS 3
.Os
.Sh NAME
.Nm getifmaddrs
.Nd get multicast group memberships
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
.In ifaddrs.h
.Ft int
.Fn getifmaddrs "struct ifmaddrs **ifmap"
diff --git a/lib/libc/net/getifmaddrs.c b/lib/libc/net/getifmaddrs.c
index adbc4a5dde6e..c05d6de57b25 100644
--- a/lib/libc/net/getifmaddrs.c
+++ b/lib/libc/net/getifmaddrs.c
@@ -10,24 +10,18 @@
* 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 Bruce M. Simpson.
- * 4. Neither the name of Bruce M. Simpson nor the names of other
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY BRUCE M. SIMPSON AND AFFILIATES
- * ``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 BRUCE M. SIMPSON 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.
+ * 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 <sys/cdefs.h>
diff --git a/lib/libc/net/getnameinfo.3 b/lib/libc/net/getnameinfo.3
index e508e5ddbd84..0549ccd2219b 100644
--- a/lib/libc/net/getnameinfo.3
+++ b/lib/libc/net/getnameinfo.3
@@ -25,9 +25,9 @@
.Nm getnameinfo
.Nd socket address structure to hostname and service name
.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <netdb.h>
+.In sys/types.h
+.In sys/socket.h
+.In netdb.h
.Ft int
.Fo getnameinfo
.Fa "const struct sockaddr *sa" "socklen_t salen" "char *host"
@@ -191,10 +191,11 @@ printf("host=%s\en", hbuf);
.%A R. Gilligan
.%A S. Thomson
.%A J. Bound
+.%A J. McCann
.%A W. Stevens
.%T Basic Socket Interface Extensions for IPv6
-.%R RFC 2553
-.%D March 1999
+.%R RFC 3493
+.%D February 2003
.Re
.Rs
.%A S. Deering
@@ -203,9 +204,8 @@ printf("host=%s\en", hbuf);
.%A E. Nordmark
.%A B. Zill
.%T "IPv6 Scoped Address Architecture"
-.%R internet draft
-.%N draft-ietf-ipv6-scoping-arch-02.txt
-.%O work in progress material
+.%R RFC 4007
+.%D March 2005
.Re
.Rs
.%A Craig Metz
@@ -217,9 +217,9 @@ printf("host=%s\en", hbuf);
The
.Fn getnameinfo
function is defined by the
-.St -p1003.1g-2000
-draft specification and documented in
-.Tn "RFC 2553" ,
+.St -p1003.1-2004
+specification and documented in
+.Tn "RFC 3493" ,
.Dq Basic Socket Interface Extensions for IPv6 .
.Sh CAVEATS
.Fn getnameinfo
diff --git a/lib/libc/net/getnetbyht.c b/lib/libc/net/getnetbyht.c
index d2df570e7e28..bee00e807fe3 100644
--- a/lib/libc/net/getnetbyht.c
+++ b/lib/libc/net/getnetbyht.c
@@ -63,7 +63,7 @@ _setnethtent(int f, struct netent_data *ned)
{
if (ned->netf == NULL)
- ned->netf = fopen(_PATH_NETWORKS, "r");
+ ned->netf = fopen(_PATH_NETWORKS, "re");
else
rewind(ned->netf);
ned->stayopen |= f;
@@ -89,7 +89,7 @@ getnetent_p(struct netent *ne, struct netent_data *ned)
char line[BUFSIZ + 1];
if (ned->netf == NULL &&
- (ned->netf = fopen(_PATH_NETWORKS, "r")) == NULL)
+ (ned->netf = fopen(_PATH_NETWORKS, "re")) == NULL)
return (-1);
again:
p = fgets(line, sizeof line, ned->netf);
diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c
index 0cfca458898f..114069acc255 100644
--- a/lib/libc/net/getprotoent.c
+++ b/lib/libc/net/getprotoent.c
@@ -342,7 +342,7 @@ void
__setprotoent_p(int f, struct protoent_data *ped)
{
if (ped->fp == NULL)
- ped->fp = fopen(_PATH_PROTOCOLS, "r");
+ ped->fp = fopen(_PATH_PROTOCOLS, "re");
else
rewind(ped->fp);
ped->stayopen |= f;
@@ -365,7 +365,7 @@ __getprotoent_p(struct protoent *pe, struct protoent_data *ped)
char *cp, **q, *endp;
long l;
- if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "r")) == NULL)
+ if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "re")) == NULL)
return (-1);
again:
if ((p = fgets(ped->line, sizeof ped->line, ped->fp)) == NULL)
diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c
index 3228bdc2eea7..005de9870064 100644
--- a/lib/libc/net/getservent.c
+++ b/lib/libc/net/getservent.c
@@ -335,7 +335,7 @@ files_servent(void *retval, void *mdata, va_list ap)
if (st->fp == NULL)
st->compat_mode_active = 0;
- if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "r")) == NULL) {
+ if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "re")) == NULL) {
*errnop = errno;
return (NS_UNAVAIL);
}
@@ -449,7 +449,7 @@ files_setservent(void *retval, void *mdata, va_list ap)
case SETSERVENT:
f = va_arg(ap,int);
if (st->fp == NULL)
- st->fp = fopen(_PATH_SERVICES, "r");
+ st->fp = fopen(_PATH_SERVICES, "re");
else
rewind(st->fp);
st->stayopen |= f;
diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c
index 24137279d8f3..4258993a4368 100644
--- a/lib/libc/net/hesiod.c
+++ b/lib/libc/net/hesiod.c
@@ -286,7 +286,7 @@ read_config_file(ctx, filename)
ctx->classes[1] = C_HS;
/* Try to open the configuration file. */
- fp = fopen(filename, "r");
+ fp = fopen(filename, "re");
if (!fp) {
/* Use compiled in default domain names. */
ctx->lhs = strdup(DEF_LHS);
diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c
index f36016249602..118e033e128d 100644
--- a/lib/libc/net/name6.c
+++ b/lib/libc/net/name6.c
@@ -42,11 +42,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.
- * 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.
*
diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c
index f9d787a0fdff..4fbc9baa27eb 100644
--- a/lib/libc/net/nsdispatch.c
+++ b/lib/libc/net/nsdispatch.c
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -368,7 +361,7 @@ nss_configure(void)
if (result != 0)
goto fin2;
}
- _nsyyin = fopen(path, "r");
+ _nsyyin = fopen(path, "re");
if (_nsyyin == NULL)
goto fin;
VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap),
diff --git a/lib/libc/net/nslexer.l b/lib/libc/net/nslexer.l
index 0f705cf72dcf..3983fa257903 100644
--- a/lib/libc/net/nslexer.l
+++ b/lib/libc/net/nslexer.l
@@ -16,13 +16,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -53,11 +46,10 @@ static char *rcsid =
#include "nsparser.h"
-#define YY_NO_INPUT
-#define YY_NO_UNPUT
-
%}
+%option noinput
+%option nounput
%option yylineno
BLANK [ \t]
diff --git a/lib/libc/net/nsparser.y b/lib/libc/net/nsparser.y
index 2e57cd26dd3d..c1d84247bd8c 100644
--- a/lib/libc/net/nsparser.y
+++ b/lib/libc/net/nsparser.y
@@ -16,13 +16,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
index 990289a7edcc..2885dc331e08 100644
--- a/lib/libc/net/rcmd.c
+++ b/lib/libc/net/rcmd.c
@@ -458,7 +458,7 @@ iruserok_sa(ra, rlen, superuser, ruser, luser)
raddr = (struct sockaddr *)&ss;
first = 1;
- hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r");
+ hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re");
again:
if (hostf) {
if (__ivaliduser_sa(hostf, raddr, rlen, luser, ruser) == 0) {
@@ -481,7 +481,7 @@ again:
*/
uid = geteuid();
(void)seteuid(pwd->pw_uid);
- hostf = fopen(pbuf, "r");
+ hostf = fopen(pbuf, "re");
(void)seteuid(uid);
if (hostf == NULL)
diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c
index c8230d683b94..f71d4780bb7c 100644
--- a/lib/libc/net/recv.c
+++ b/lib/libc/net/recv.c
@@ -33,12 +33,10 @@ static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <stddef.h>
-#include "un-namespace.h"
ssize_t
recv(s, buf, len, flags)
@@ -46,5 +44,9 @@ recv(s, buf, len, flags)
size_t len;
void *buf;
{
- return (_recvfrom(s, buf, len, flags, NULL, 0));
+ /*
+ * POSIX says recv() shall be a cancellation point, so call the
+ * cancellation-enabled recvfrom() and not _recvfrom().
+ */
+ return (recvfrom(s, buf, len, flags, NULL, 0));
}
diff --git a/lib/libc/net/sctp_bindx.3 b/lib/libc/net/sctp_bindx.3
index 403cf7d1e758..263cb6398806 100644
--- a/lib/libc/net/sctp_bindx.3
+++ b/lib/libc/net/sctp_bindx.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_connectx.3 b/lib/libc/net/sctp_connectx.3
index 6ea1bb622f28..0c298e1ea00a 100644
--- a/lib/libc/net/sctp_connectx.3
+++ b/lib/libc/net/sctp_connectx.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_freepaddrs.3 b/lib/libc/net/sctp_freepaddrs.3
index 77a8488177a0..400f21d8d808 100644
--- a/lib/libc/net/sctp_freepaddrs.3
+++ b/lib/libc/net/sctp_freepaddrs.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_getaddrlen.3 b/lib/libc/net/sctp_getaddrlen.3
index 7259635f79fb..70e3688c74d6 100644
--- a/lib/libc/net/sctp_getaddrlen.3
+++ b/lib/libc/net/sctp_getaddrlen.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_getassocid.3 b/lib/libc/net/sctp_getassocid.3
index f347a1341c58..3c89fdc0c057 100644
--- a/lib/libc/net/sctp_getassocid.3
+++ b/lib/libc/net/sctp_getassocid.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_getpaddrs.3 b/lib/libc/net/sctp_getpaddrs.3
index 8bdf2ccf370a..0c7b8ecb5051 100644
--- a/lib/libc/net/sctp_getpaddrs.3
+++ b/lib/libc/net/sctp_getpaddrs.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_opt_info.3 b/lib/libc/net/sctp_opt_info.3
index 02b0f852156f..170692cfd3fc 100644
--- a/lib/libc/net/sctp_opt_info.3
+++ b/lib/libc/net/sctp_opt_info.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_recvmsg.3 b/lib/libc/net/sctp_recvmsg.3
index eda3e5cc34c4..e3ced9c42a96 100644
--- a/lib/libc/net/sctp_recvmsg.3
+++ b/lib/libc/net/sctp_recvmsg.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_send.3 b/lib/libc/net/sctp_send.3
index d195b7ab4899..37b0b7185b00 100644
--- a/lib/libc/net/sctp_send.3
+++ b/lib/libc/net/sctp_send.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_sendmsg.3 b/lib/libc/net/sctp_sendmsg.3
index 4158932ebc64..bc61061c2718 100644
--- a/lib/libc/net/sctp_sendmsg.3
+++ b/lib/libc/net/sctp_sendmsg.3
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c
index 6b938a4e7169..1b65b07325f0 100644
--- a/lib/libc/net/sctp_sys_calls.c
+++ b/lib/libc/net/sctp_sys_calls.c
@@ -274,6 +274,11 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size)
errno = EINVAL;
return (-1);
}
+ if ((id == SCTP_CURRENT_ASSOC) ||
+ (id == SCTP_ALL_ASSOC)) {
+ errno = EINVAL;
+ return (-1);
+ }
switch (opt) {
case SCTP_RTOINFO:
((struct sctp_rtoinfo *)arg)->srto_assoc_id = id;
@@ -338,6 +343,9 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size)
case SCTP_MAX_BURST:
((struct sctp_assoc_value *)arg)->assoc_id = id;
break;
+ case SCTP_ENABLE_STREAM_RESET:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
default:
break;
}
diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c
index 101b0ceb45ff..93cdfda17532 100644
--- a/lib/libc/net/send.c
+++ b/lib/libc/net/send.c
@@ -33,12 +33,10 @@ static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <stddef.h>
-#include "un-namespace.h"
ssize_t
send(s, msg, len, flags)
@@ -46,5 +44,9 @@ send(s, msg, len, flags)
size_t len;
const void *msg;
{
- return (_sendto(s, msg, len, flags, NULL, 0));
+ /*
+ * POSIX says send() shall be a cancellation point, so call the
+ * cancellation-enabled sendto() and not _sendto().
+ */
+ return (sendto(s, msg, len, flags, NULL, 0));
}
diff --git a/lib/libc/nls/C.msg b/lib/libc/nls/C.msg
index 2210df6cc463..d08c5719225e 100644
--- a/lib/libc/nls/C.msg
+++ b/lib/libc/nls/C.msg
@@ -191,6 +191,12 @@ $ EPROTO
92 Protocol error
$ ENOTCAPABLE
93 Capabilities insufficient
+$ ECAPMODE
+94 Not permitted in capability mode
+$ ENOTRECOVERABLE
+95 State not recoverable
+$ EOWNERDEAD
+96 Previous owner died
$
$ strsignal() support catalog
$
diff --git a/lib/libc/nls/fr_FR.ISO8859-1.msg b/lib/libc/nls/fr_FR.ISO8859-1.msg
index 35a8c4a46cb3..ebc1739ea28c 100644
--- a/lib/libc/nls/fr_FR.ISO8859-1.msg
+++ b/lib/libc/nls/fr_FR.ISO8859-1.msg
@@ -94,7 +94,7 @@ $ EPROTONOSUPPORT
$ ESOCKTNOSUPPORT
44 Type de socket non supporté
$ EOPNOTSUPP
-45 Opération non supporté
+45 Opération non supportée
$ EPFNOSUPPORT
46 Famille de protocole non supportée
$ EAFNOSUPPORT
diff --git a/lib/libc/posix1e/acl_is_trivial_np.3 b/lib/libc/posix1e/acl_is_trivial_np.3
index 4ad1a632291b..a9cd4dfe3549 100644
--- a/lib/libc/posix1e/acl_is_trivial_np.3
+++ b/lib/libc/posix1e/acl_is_trivial_np.3
@@ -52,7 +52,7 @@ will be set to 1, if the ACL
.Fa aclp
points to is trivial, or 0 if it's not.
.Pp
-ACL is trivial if it can be fully expressed as a file mode without loosing
+ACL is trivial if it can be fully expressed as a file mode without losing
any access rules.
For POSIX.1e ACLs, ACL is trivial if it has the three required entries,
one for owner, one for owning group, and one for other.
diff --git a/lib/libc/posix1e/mac.c b/lib/libc/posix1e/mac.c
index 62a74eee1944..6bc9b773c22a 100644
--- a/lib/libc/posix1e/mac.c
+++ b/lib/libc/posix1e/mac.c
@@ -179,7 +179,7 @@ mac_init_internal(int ignore_errors)
filename = getenv("MAC_CONFFILE");
else
filename = MAC_CONFFILE;
- file = fopen(filename, "r");
+ file = fopen(filename, "re");
if (file == NULL)
return (0);
diff --git a/lib/libc/powerpc/gen/getcontextx.c b/lib/libc/powerpc/gen/getcontextx.c
index 307978a466dd..54f851384811 100644
--- a/lib/libc/powerpc/gen/getcontextx.c
+++ b/lib/libc/powerpc/gen/getcontextx.c
@@ -40,6 +40,13 @@ __getcontextx_size(void)
}
int
+__fillcontextx2(char *ctx)
+{
+
+ return (0);
+}
+
+int
__fillcontextx(char *ctx)
{
ucontext_t *ucp;
diff --git a/lib/libc/powerpc64/gen/fpgetmask.c b/lib/libc/powerpc64/gen/fpgetmask.c
index aa7623b2706f..b67b1bcb4dc0 100644
--- a/lib/libc/powerpc64/gen/fpgetmask.c
+++ b/lib/libc/powerpc64/gen/fpgetmask.c
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/powerpc64/gen/fpgetround.c b/lib/libc/powerpc64/gen/fpgetround.c
index 538137827a8d..097e82aa9a41 100644
--- a/lib/libc/powerpc64/gen/fpgetround.c
+++ b/lib/libc/powerpc64/gen/fpgetround.c
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/powerpc64/gen/fpgetsticky.c b/lib/libc/powerpc64/gen/fpgetsticky.c
index feb2ccca43a1..57152ac50104 100644
--- a/lib/libc/powerpc64/gen/fpgetsticky.c
+++ b/lib/libc/powerpc64/gen/fpgetsticky.c
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/powerpc64/gen/fpsetmask.c b/lib/libc/powerpc64/gen/fpsetmask.c
index e1433a543192..81cd19e57f1b 100644
--- a/lib/libc/powerpc64/gen/fpsetmask.c
+++ b/lib/libc/powerpc64/gen/fpsetmask.c
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/powerpc64/gen/fpsetround.c b/lib/libc/powerpc64/gen/fpsetround.c
index b4f00d4e74bc..17f70a0cab64 100644
--- a/lib/libc/powerpc64/gen/fpsetround.c
+++ b/lib/libc/powerpc64/gen/fpsetround.c
@@ -15,13 +15,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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/lib/libc/powerpc64/gen/getcontextx.c b/lib/libc/powerpc64/gen/getcontextx.c
index 307978a466dd..54f851384811 100644
--- a/lib/libc/powerpc64/gen/getcontextx.c
+++ b/lib/libc/powerpc64/gen/getcontextx.c
@@ -40,6 +40,13 @@ __getcontextx_size(void)
}
int
+__fillcontextx2(char *ctx)
+{
+
+ return (0);
+}
+
+int
__fillcontextx(char *ctx)
{
ucontext_t *ucp;
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
index 661e880f37e4..5193c1d739e8 100644
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -304,7 +304,7 @@ __res_vinit(res_state statp, int preinit) {
line[sizeof(name) - 1] == '\t'))
nserv = 0;
- if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
+ if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
/* read the config file */
while (fgets(buf, sizeof(buf), fp) != NULL) {
/* skip comments */
diff --git a/lib/libc/resolv/res_query.c b/lib/libc/resolv/res_query.c
index 746a2be76b18..854909ccb136 100644
--- a/lib/libc/resolv/res_query.c
+++ b/lib/libc/resolv/res_query.c
@@ -457,7 +457,7 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) {
if (issetugid())
return (NULL);
file = getenv("HOSTALIASES");
- if (file == NULL || (fp = fopen(file, "r")) == NULL)
+ if (file == NULL || (fp = fopen(file, "re")) == NULL)
return (NULL);
setbuf(fp, NULL);
buf[sizeof(buf) - 1] = '\0';
diff --git a/lib/libc/sparc64/gen/getcontextx.c b/lib/libc/sparc64/gen/getcontextx.c
index 307978a466dd..54f851384811 100644
--- a/lib/libc/sparc64/gen/getcontextx.c
+++ b/lib/libc/sparc64/gen/getcontextx.c
@@ -40,6 +40,13 @@ __getcontextx_size(void)
}
int
+__fillcontextx2(char *ctx)
+{
+
+ return (0);
+}
+
+int
__fillcontextx(char *ctx)
{
ucontext_t *ucp;
diff --git a/lib/libc/sparc64/gen/makecontext.c b/lib/libc/sparc64/gen/makecontext.c
index 95795de992cf..42bcc8803060 100644
--- a/lib/libc/sparc64/gen/makecontext.c
+++ b/lib/libc/sparc64/gen/makecontext.c
@@ -54,12 +54,12 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
mc = &ucp->uc_mcontext;
if (ucp == NULL ||
- (mc->mc_flags & ((1L << _MC_VERSION_BITS) - 1)) != _MC_VERSION)
+ (mc->_mc_flags & ((1L << _MC_VERSION_BITS) - 1)) != _MC_VERSION)
return;
if ((argc < 0) || (argc > 6) ||
(ucp->uc_stack.ss_sp == NULL) ||
(ucp->uc_stack.ss_size < MINSIGSTKSZ)) {
- mc->mc_flags = 0;
+ mc->_mc_flags = 0;
return;
}
mc = &ucp->uc_mcontext;
@@ -71,8 +71,8 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
mc->mc_global[1] = (uint64_t)start;
mc->mc_global[2] = (uint64_t)ucp;
mc->mc_out[6] = sp - SPOFF - sizeof(struct frame);
- mc->mc_tnpc = (uint64_t)_ctx_start + 4;
- mc->mc_tpc = (uint64_t)_ctx_start;
+ mc->_mc_tnpc = (uint64_t)_ctx_start + 4;
+ mc->_mc_tpc = (uint64_t)_ctx_start;
}
void
@@ -82,7 +82,7 @@ _ctx_done(ucontext_t *ucp)
if (ucp->uc_link == NULL)
exit(0);
else {
- ucp->uc_mcontext.mc_flags = 0;
+ ucp->uc_mcontext._mc_flags = 0;
setcontext((const ucontext_t *)ucp->uc_link);
abort();
}
diff --git a/lib/libc/sparc64/gen/signalcontext.c b/lib/libc/sparc64/gen/signalcontext.c
index 622f36f5bd75..159184513807 100644
--- a/lib/libc/sparc64/gen/signalcontext.c
+++ b/lib/libc/sparc64/gen/signalcontext.c
@@ -52,7 +52,7 @@ __signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func)
mcontext_t *mc;
mc = &ucp->uc_mcontext;
- sfp = (struct sigframe *)(mc->mc_sp + SPOFF) - 1;
+ sfp = (struct sigframe *)(mc->_mc_sp + SPOFF) - 1;
fp = (struct frame *)sfp - 1;
bzero(fp, sizeof(*fp));
@@ -67,8 +67,8 @@ __signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func)
mc->mc_out[1] = (uint64_t)&sfp->sf_si;
mc->mc_out[2] = (uint64_t)&sfp->sf_uc;
mc->mc_out[6] = (uint64_t)fp - SPOFF;
- mc->mc_tnpc = (uint64_t)_ctx_start + 4;
- mc->mc_tpc = (uint64_t)_ctx_start;
+ mc->_mc_tnpc = (uint64_t)_ctx_start + 4;
+ mc->_mc_tpc = (uint64_t)_ctx_start;
ucp->uc_link = &sfp->sf_uc;
sigdelset(&ucp->uc_sigmask, sig);
diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc
index 0062d3dd8dd8..419d03194b76 100644
--- a/lib/libc/stdio/Makefile.inc
+++ b/lib/libc/stdio/Makefile.inc
@@ -60,7 +60,8 @@ MLINKS+=getc.3 fgetc.3 getc.3 getc_unlocked.3 getc.3 getchar.3 \
getc.3 getchar_unlocked.3 getc.3 getw.3
MLINKS+=getline.3 getdelim.3
MLINKS+=getwc.3 fgetwc.3 getwc.3 getwchar.3
-MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3 mktemp.3 mkstemps.3
+MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3 mktemp.3 mkstemps.3 \
+ mktemp.3 mkostemp.3 mktemp.3 mkostemps.3
MLINKS+=open_memstream.3 open_wmemstream.3
MLINKS+=printf.3 asprintf.3 printf.3 dprintf.3 printf.3 fprintf.3 \
printf.3 snprintf.3 printf.3 sprintf.3 \
diff --git a/lib/libc/stdio/Symbol.map b/lib/libc/stdio/Symbol.map
index 538b29aac4cb..d2a8c92b2411 100644
--- a/lib/libc/stdio/Symbol.map
+++ b/lib/libc/stdio/Symbol.map
@@ -158,6 +158,8 @@ FBSD_1.3 {
fmemopen;
open_memstream;
open_wmemstream;
+ mkostemp;
+ mkostemps;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c
index cd475cd2117e..242127f36025 100644
--- a/lib/libc/stdio/asprintf.c
+++ b/lib/libc/stdio/asprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/clrerr.c b/lib/libc/stdio/clrerr.c
index 1b318e6a85db..f161a6e1e802 100644
--- a/lib/libc/stdio/clrerr.c
+++ b/lib/libc/stdio/clrerr.c
@@ -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.
*
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
#undef clearerr_unlocked
void
-clearerr(fp)
- FILE *fp;
+clearerr(FILE *fp)
{
FLOCKFILE(fp);
__sclearerr(fp);
diff --git a/lib/libc/stdio/fclose.c b/lib/libc/stdio/fclose.c
index 3957b6a427e3..5ed8b2c548f6 100644
--- a/lib/libc/stdio/fclose.c
+++ b/lib/libc/stdio/fclose.c
@@ -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.
*
diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c
index 8fc90a438b99..2e19b9febcd8 100644
--- a/lib/libc/stdio/fdopen.c
+++ b/lib/libc/stdio/fdopen.c
@@ -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.
*
@@ -47,9 +47,7 @@ __FBSDID("$FreeBSD$");
#include "local.h"
FILE *
-fdopen(fd, mode)
- int fd;
- const char *mode;
+fdopen(int fd, const char *mode)
{
FILE *fp;
int flags, oflags, fdflags, tmp;
diff --git a/lib/libc/stdio/feof.c b/lib/libc/stdio/feof.c
index 502f1e5a3ada..b970248a3128 100644
--- a/lib/libc/stdio/feof.c
+++ b/lib/libc/stdio/feof.c
@@ -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.
*
diff --git a/lib/libc/stdio/ferror.c b/lib/libc/stdio/ferror.c
index d155ff0c3b4c..7e0f8f957165 100644
--- a/lib/libc/stdio/ferror.c
+++ b/lib/libc/stdio/ferror.c
@@ -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.
*
diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c
index c0237cf5a264..456b031dd01b 100644
--- a/lib/libc/stdio/fflush.c
+++ b/lib/libc/stdio/fflush.c
@@ -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.
*
diff --git a/lib/libc/stdio/fgetc.c b/lib/libc/stdio/fgetc.c
index 8024df152395..2ee4d7a78cb5 100644
--- a/lib/libc/stdio/fgetc.c
+++ b/lib/libc/stdio/fgetc.c
@@ -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.
*
@@ -43,8 +43,7 @@ __FBSDID("$FreeBSD$");
#include "local.h"
int
-fgetc(fp)
- FILE *fp;
+fgetc(FILE *fp)
{
int retval;
FLOCKFILE(fp);
diff --git a/lib/libc/stdio/fgetln.c b/lib/libc/stdio/fgetln.c
index 0cd04b8b6efc..1779de2ae559 100644
--- a/lib/libc/stdio/fgetln.c
+++ b/lib/libc/stdio/fgetln.c
@@ -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.
*
diff --git a/lib/libc/stdio/fgetpos.c b/lib/libc/stdio/fgetpos.c
index 9053be84a5de..f161f4325fd3 100644
--- a/lib/libc/stdio/fgetpos.c
+++ b/lib/libc/stdio/fgetpos.c
@@ -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.
*
diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c
index a0cc72452516..9abf559bf108 100644
--- a/lib/libc/stdio/fgets.c
+++ b/lib/libc/stdio/fgets.c
@@ -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.
*
@@ -49,10 +49,7 @@ __FBSDID("$FreeBSD$");
* Return first argument, or NULL if no characters were read.
*/
char *
-fgets(buf, n, fp)
- char *buf;
- int n;
- FILE *fp;
+fgets(char * __restrict buf, int n, FILE * __restrict fp)
{
size_t len;
char *s;
diff --git a/lib/libc/stdio/fileno.c b/lib/libc/stdio/fileno.c
index 1962bb79b8b5..3ac183010ef6 100644
--- a/lib/libc/stdio/fileno.c
+++ b/lib/libc/stdio/fileno.c
@@ -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.
*
diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c
index 6d0b673395f6..be196b73c687 100644
--- a/lib/libc/stdio/findfp.c
+++ b/lib/libc/stdio/findfp.c
@@ -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.
*
@@ -91,8 +91,7 @@ spinlock_t __stdio_thread_lock = _SPINLOCK_INITIALIZER;
#endif
static struct glue *
-moreglue(n)
- int n;
+moreglue(int n)
{
struct glue *g;
static FILE empty = { ._fl_mutex = PTHREAD_MUTEX_INITIALIZER };
diff --git a/lib/libc/stdio/flags.c b/lib/libc/stdio/flags.c
index e445fedd0794..1878c2f4e134 100644
--- a/lib/libc/stdio/flags.c
+++ b/lib/libc/stdio/flags.c
@@ -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.
*
@@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$");
* Return 0 on error.
*/
int
-__sflags(mode, optr)
- const char *mode;
- int *optr;
+__sflags(const char *mode, int *optr)
{
int ret, m, o;
diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c
index 6fe536a0c907..b08e3366ac68 100644
--- a/lib/libc/stdio/fopen.c
+++ b/lib/libc/stdio/fopen.c
@@ -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.
*
@@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$");
#include "local.h"
FILE *
-fopen(file, mode)
- const char * __restrict file;
- const char * __restrict mode;
+fopen(const char * __restrict file, const char * __restrict mode)
{
FILE *fp;
int f;
diff --git a/lib/libc/stdio/fprintf.c b/lib/libc/stdio/fprintf.c
index 169532d1cd1b..739e1f555e09 100644
--- a/lib/libc/stdio/fprintf.c
+++ b/lib/libc/stdio/fprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/fpurge.c b/lib/libc/stdio/fpurge.c
index 148e490eafe2..f205bdfc3bf5 100644
--- a/lib/libc/stdio/fpurge.c
+++ b/lib/libc/stdio/fpurge.c
@@ -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.
*
@@ -49,8 +49,7 @@ __FBSDID("$FreeBSD$");
* given FILE's buffer empty.
*/
int
-fpurge(fp)
- FILE *fp;
+fpurge(FILE *fp)
{
int retval;
FLOCKFILE(fp);
diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c
index 66d9a2f773cf..3b6101f92f4d 100644
--- a/lib/libc/stdio/fputc.c
+++ b/lib/libc/stdio/fputc.c
@@ -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.
*
@@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
int
-fputc(c, fp)
- int c;
- FILE *fp;
+fputc(int c, FILE *fp)
{
int retval;
FLOCKFILE(fp);
diff --git a/lib/libc/stdio/fputs.c b/lib/libc/stdio/fputs.c
index eb20f9eb4a1e..3b8f2c9d1b68 100644
--- a/lib/libc/stdio/fputs.c
+++ b/lib/libc/stdio/fputs.c
@@ -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,9 +48,7 @@ __FBSDID("$FreeBSD$");
* Write the given string to the given file.
*/
int
-fputs(s, fp)
- const char * __restrict s;
- FILE * __restrict fp;
+fputs(const char * __restrict s, FILE * __restrict fp)
{
int retval;
struct __suio uio;
diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c
index ad3ea29de3e0..c24df9914b48 100644
--- a/lib/libc/stdio/fread.c
+++ b/lib/libc/stdio/fread.c
@@ -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.
*
diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c
index 8d1ec917086a..dc5508d4d25b 100644
--- a/lib/libc/stdio/freopen.c
+++ b/lib/libc/stdio/freopen.c
@@ -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.
*
@@ -55,10 +55,8 @@ __FBSDID("$FreeBSD$");
* all possible, no matter what.
*/
FILE *
-freopen(file, mode, fp)
- const char * __restrict file;
- const char * __restrict mode;
- FILE *fp;
+freopen(const char * __restrict file, const char * __restrict mode,
+ FILE * __restrict fp)
{
int f;
int dflags, flags, isopen, oflags, sverrno, wantfd;
diff --git a/lib/libc/stdio/fscanf.c b/lib/libc/stdio/fscanf.c
index c5fa85f5629d..014f09415048 100644
--- a/lib/libc/stdio/fscanf.c
+++ b/lib/libc/stdio/fscanf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c
index c9343490e6b0..2897eebf9c88 100644
--- a/lib/libc/stdio/fseek.c
+++ b/lib/libc/stdio/fseek.c
@@ -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.
*
@@ -51,10 +51,7 @@ __FBSDID("$FreeBSD$");
#define POS_ERR (-(fpos_t)1)
int
-fseek(fp, offset, whence)
- FILE *fp;
- long offset;
- int whence;
+fseek(FILE *fp, long offset, int whence)
{
int ret;
int serrno = errno;
@@ -72,10 +69,7 @@ fseek(fp, offset, whence)
}
int
-fseeko(fp, offset, whence)
- FILE *fp;
- off_t offset;
- int whence;
+fseeko(FILE *fp, off_t offset, int whence)
{
int ret;
int serrno = errno;
@@ -97,11 +91,7 @@ fseeko(fp, offset, whence)
* `Whence' must be one of the three SEEK_* macros.
*/
int
-_fseeko(fp, offset, whence, ltest)
- FILE *fp;
- off_t offset;
- int whence;
- int ltest;
+_fseeko(FILE *fp, off_t offset, int whence, int ltest)
{
fpos_t (*seekfn)(void *, fpos_t, int);
fpos_t target, curoff, ret;
diff --git a/lib/libc/stdio/fsetpos.c b/lib/libc/stdio/fsetpos.c
index f9a742e53a04..c6b8b785918d 100644
--- a/lib/libc/stdio/fsetpos.c
+++ b/lib/libc/stdio/fsetpos.c
@@ -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.
*
@@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$");
* fsetpos: like fseek.
*/
int
-fsetpos(iop, pos)
- FILE *iop;
- const fpos_t *pos;
+fsetpos(FILE *iop, const fpos_t *pos)
{
return (fseeko(iop, (off_t)*pos, SEEK_SET));
}
diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c
index a9ff6ed5c37c..2c8800ccfe19 100644
--- a/lib/libc/stdio/ftell.c
+++ b/lib/libc/stdio/ftell.c
@@ -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.
*
@@ -49,8 +49,7 @@ __FBSDID("$FreeBSD$");
* standard ftell function.
*/
long
-ftell(fp)
- FILE *fp;
+ftell(FILE *fp)
{
off_t rv;
@@ -66,8 +65,7 @@ ftell(fp)
* ftello: return current offset.
*/
off_t
-ftello(fp)
- FILE *fp;
+ftello(FILE *fp)
{
fpos_t rv;
int ret;
@@ -85,9 +83,7 @@ ftello(fp)
}
int
-_ftello(fp, offset)
- FILE *fp;
- fpos_t *offset;
+_ftello(FILE *fp, fpos_t *offset)
{
fpos_t pos;
size_t n;
diff --git a/lib/libc/stdio/funopen.c b/lib/libc/stdio/funopen.c
index 573589f14d53..983fe5011902 100644
--- a/lib/libc/stdio/funopen.c
+++ b/lib/libc/stdio/funopen.c
@@ -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.
*
diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c
index 7206676869e6..1a28b6a79c01 100644
--- a/lib/libc/stdio/fvwrite.c
+++ b/lib/libc/stdio/fvwrite.c
@@ -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.
*
@@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$");
* to the three different kinds of output buffering is handled here.
*/
int
-__sfvwrite(fp, uio)
- FILE *fp;
- struct __suio *uio;
+__sfvwrite(FILE *fp, struct __suio *uio)
{
size_t len;
char *p;
diff --git a/lib/libc/stdio/fwalk.c b/lib/libc/stdio/fwalk.c
index cb200710de3b..151837b29025 100644
--- a/lib/libc/stdio/fwalk.c
+++ b/lib/libc/stdio/fwalk.c
@@ -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.
*
@@ -42,8 +42,7 @@ __FBSDID("$FreeBSD$");
#include "glue.h"
int
-_fwalk(function)
- int (*function)(FILE *);
+_fwalk(int (*function)(FILE *))
{
FILE *fp;
int n, ret;
diff --git a/lib/libc/stdio/fwrite.c b/lib/libc/stdio/fwrite.c
index acac94398ea4..5b57fab0b9e1 100644
--- a/lib/libc/stdio/fwrite.c
+++ b/lib/libc/stdio/fwrite.c
@@ -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.
*
@@ -50,10 +50,7 @@ __FBSDID("$FreeBSD$");
* Return the number of whole objects written.
*/
size_t
-fwrite(buf, size, count, fp)
- const void * __restrict buf;
- size_t size, count;
- FILE * __restrict fp;
+fwrite(const void * __restrict buf, size_t size, size_t count, FILE * __restrict fp)
{
size_t n;
struct __suio uio;
@@ -68,7 +65,7 @@ fwrite(buf, size, count, fp)
/*
* Check for integer overflow. As an optimization, first check that
* at least one of {count, size} is at least 2^16, since if both
- * values are less than that, their product can't possible overflow
+ * values are less than that, their product can't possibly overflow
* (size_t is always at least 32 bits on FreeBSD).
*/
if (((count | size) > 0xFFFF) &&
diff --git a/lib/libc/stdio/getc.c b/lib/libc/stdio/getc.c
index 5c94e6017149..4963c8ce68e7 100644
--- a/lib/libc/stdio/getc.c
+++ b/lib/libc/stdio/getc.c
@@ -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.
*
diff --git a/lib/libc/stdio/getchar.c b/lib/libc/stdio/getchar.c
index 90c84ab9fe44..21040bc8c416 100644
--- a/lib/libc/stdio/getchar.c
+++ b/lib/libc/stdio/getchar.c
@@ -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.
*
diff --git a/lib/libc/stdio/gets.c b/lib/libc/stdio/gets.c
index 6a617cec9974..c7c1c2fa38c8 100644
--- a/lib/libc/stdio/gets.c
+++ b/lib/libc/stdio/gets.c
@@ -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.
*
@@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$");
__warn_references(gets, "warning: this program uses gets(), which is unsafe.");
char *
-gets(buf)
- char *buf;
+gets(char *buf)
{
int c;
char *s;
diff --git a/lib/libc/stdio/getw.c b/lib/libc/stdio/getw.c
index d2c69426db3f..ed0313eb60c2 100644
--- a/lib/libc/stdio/getw.c
+++ b/lib/libc/stdio/getw.c
@@ -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.
*
@@ -39,8 +39,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
int
-getw(fp)
- FILE *fp;
+getw(FILE *fp)
{
int x;
diff --git a/lib/libc/stdio/makebuf.c b/lib/libc/stdio/makebuf.c
index 92e6c4be5618..a92087e0eae7 100644
--- a/lib/libc/stdio/makebuf.c
+++ b/lib/libc/stdio/makebuf.c
@@ -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.
*
@@ -55,8 +55,7 @@ __FBSDID("$FreeBSD$");
* optimisation) right after the _fstat() that finds the buffer size.
*/
void
-__smakebuf(fp)
- FILE *fp;
+__smakebuf(FILE *fp)
{
void *p;
int flags;
@@ -88,10 +87,7 @@ __smakebuf(fp)
* Internal routine to determine `proper' buffering for a file.
*/
int
-__swhatbuf(fp, bufsize, couldbetty)
- FILE *fp;
- size_t *bufsize;
- int *couldbetty;
+__swhatbuf(FILE *fp, size_t *bufsize, int *couldbetty)
{
struct stat st;
diff --git a/lib/libc/stdio/mktemp.3 b/lib/libc/stdio/mktemp.3
index b51a177b4cdc..816a6b6fcd08 100644
--- a/lib/libc/stdio/mktemp.3
+++ b/lib/libc/stdio/mktemp.3
@@ -28,7 +28,7 @@
.\" @(#)mktemp.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd March 4, 2012
+.Dd August 8, 2013
.Dt MKTEMP 3
.Os
.Sh NAME
@@ -37,15 +37,20 @@
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In unistd.h
+.In stdlib.h
.Ft char *
.Fn mktemp "char *template"
.Ft int
.Fn mkstemp "char *template"
.Ft int
-.Fn mkstemps "char *template" "int suffixlen"
+.Fn mkostemp "char *template" "int oflags"
+.Ft int
+.Fn mkostemps "char *template" "int suffixlen" "int oflags"
.Ft char *
.Fn mkdtemp "char *template"
+.In unistd.h
+.Ft int
+.Fn mkstemps "char *template" "int suffixlen"
.Sh DESCRIPTION
The
.Fn mktemp
@@ -84,16 +89,41 @@ This avoids the race between testing for a file's existence and opening it
for use.
.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_DIRECT ,
+.Dv O_SHLOCK ,
+.Dv O_EXLOCK ,
+.Dv O_SYNC
+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
+and
+.Fn mkostemps
function
-is told the length of the suffix string.
+are told the length of the suffix string.
.Pp
The
.Fn mkdtemp
@@ -109,9 +139,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
@@ -119,7 +151,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
@@ -132,8 +166,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 mkstemps
+.Fn mkostemp ,
+.Fn mkstemps ,
+.Fn mkostemps
and
.Fn mkdtemp
functions
@@ -144,9 +195,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,12 +233,39 @@ with an argument of
will result in a core dump due to
.Fn mkstemp
attempting to modify the string constant that was given.
+.Pp
+The
+.Fn mkdtemp ,
+.Fn mkstemp
+and
+.Fn mktemp
+function prototypes are also available from
+.In unistd.h .
.Sh SEE ALSO
.Xr chmod 2 ,
.Xr getpid 2 ,
.Xr mkdir 2 ,
.Xr open 2 ,
.Xr stat 2
+.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
@@ -207,6 +287,12 @@ function first appeared in
.Ox 2.4 ,
and later in
.Fx 3.4 .
+The
+.Fn mkostemp
+and
+.Fn mkostemps
+functions appeared in
+.Fx 10.0 .
.Sh BUGS
This family of functions produces filenames which can be guessed,
though the risk is minimized when large numbers of
@@ -223,6 +309,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
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index a30b930354e3..6fc552a18b2f 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -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.
*
@@ -47,60 +47,66 @@ __FBSDID("$FreeBSD$");
char *_mktemp(char *);
-static int _gettemp(char *, int *, int, int);
+static int _gettemp(char *, int *, int, int, int);
static const unsigned char padchar[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int
-mkstemps(path, slen)
- char *path;
- int slen;
+mkostemps(char *path, int slen, int oflags)
{
int fd;
- return (_gettemp(path, &fd, 0, slen) ? fd : -1);
+ return (_gettemp(path, &fd, 0, slen, oflags) ? fd : -1);
}
int
-mkstemp(path)
- char *path;
+mkstemps(char *path, int slen)
{
int fd;
- return (_gettemp(path, &fd, 0, 0) ? fd : -1);
+ return (_gettemp(path, &fd, 0, slen, 0) ? fd : -1);
+}
+
+int
+mkostemp(char *path, int oflags)
+{
+ int fd;
+
+ return (_gettemp(path, &fd, 0, 0, oflags) ? fd : -1);
+}
+
+int
+mkstemp(char *path)
+{
+ int fd;
+
+ return (_gettemp(path, &fd, 0, 0, 0) ? fd : -1);
}
char *
-mkdtemp(path)
- char *path;
+mkdtemp(char *path)
{
- return (_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL);
+ return (_gettemp(path, (int *)NULL, 1, 0, 0) ? path : (char *)NULL);
}
char *
-_mktemp(path)
- char *path;
+_mktemp(char *path)
{
- return (_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL);
+ return (_gettemp(path, (int *)NULL, 0, 0, 0) ? 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));
}
static int
-_gettemp(path, doopen, domkdir, slen)
- char *path;
- int *doopen;
- int domkdir;
- int slen;
+_gettemp(char *path, int *doopen, int domkdir, int slen, int oflags)
{
char *start, *trv, *suffp, *carryp;
char *pad;
@@ -109,7 +115,9 @@ _gettemp(path, doopen, domkdir, slen)
uint32_t rand;
char carrybuf[MAXPATHLEN];
- if ((doopen != NULL && domkdir) || slen < 0) {
+ if ((doopen != NULL && domkdir) || slen < 0 ||
+ (oflags & ~(O_APPEND | O_DIRECT | O_SHLOCK | O_EXLOCK | O_SYNC |
+ O_CLOEXEC)) != 0) {
errno = EINVAL;
return (0);
}
@@ -161,7 +169,8 @@ _gettemp(path, doopen, domkdir, slen)
for (;;) {
if (doopen) {
if ((*doopen =
- _open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
+ _open(path, O_CREAT|O_EXCL|O_RDWR|oflags, 0600)) >=
+ 0)
return (1);
if (errno != EEXIST)
return (0);
diff --git a/lib/libc/stdio/perror.c b/lib/libc/stdio/perror.c
index 9f1855196ffc..89c079818fb7 100644
--- a/lib/libc/stdio/perror.c
+++ b/lib/libc/stdio/perror.c
@@ -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.
*
@@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$");
#include "local.h"
void
-perror(s)
- const char *s;
+perror(const char *s)
{
char msgbuf[NL_TEXTMAX];
struct iovec *v;
diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c
index c42bd850786d..3a476496219c 100644
--- a/lib/libc/stdio/printf-pos.c
+++ b/lib/libc/stdio/printf-pos.c
@@ -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.
*
diff --git a/lib/libc/stdio/printf.c b/lib/libc/stdio/printf.c
index f623f2f94c25..83147b2314c1 100644
--- a/lib/libc/stdio/printf.c
+++ b/lib/libc/stdio/printf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/putc.c b/lib/libc/stdio/putc.c
index d0882f0d3b1e..aaffece49d76 100644
--- a/lib/libc/stdio/putc.c
+++ b/lib/libc/stdio/putc.c
@@ -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.
*
@@ -46,9 +46,7 @@ __FBSDID("$FreeBSD$");
#undef putc_unlocked
int
-putc(c, fp)
- int c;
- FILE *fp;
+putc(int c, FILE *fp)
{
int retval;
FLOCKFILE(fp);
diff --git a/lib/libc/stdio/putchar.c b/lib/libc/stdio/putchar.c
index d263970edff0..756155902f29 100644
--- a/lib/libc/stdio/putchar.c
+++ b/lib/libc/stdio/putchar.c
@@ -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.
*
@@ -49,8 +49,7 @@ __FBSDID("$FreeBSD$");
* A subroutine version of the macro putchar
*/
int
-putchar(c)
- int c;
+putchar(int c)
{
int retval;
FILE *so = stdout;
diff --git a/lib/libc/stdio/puts.c b/lib/libc/stdio/puts.c
index 2dc945b86b5c..5ee7fc1c63f0 100644
--- a/lib/libc/stdio/puts.c
+++ b/lib/libc/stdio/puts.c
@@ -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,8 +48,7 @@ __FBSDID("$FreeBSD$");
* Write the given string to stdout, appending a newline.
*/
int
-puts(s)
- char const *s;
+puts(char const *s)
{
int retval;
size_t c = strlen(s);
diff --git a/lib/libc/stdio/putw.c b/lib/libc/stdio/putw.c
index 8fc1b4da1a6e..0360cafc4052 100644
--- a/lib/libc/stdio/putw.c
+++ b/lib/libc/stdio/putw.c
@@ -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.
*
@@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
int
-putw(w, fp)
- int w;
- FILE *fp;
+putw(int w, FILE *fp)
{
int retval;
struct __suio uio;
diff --git a/lib/libc/stdio/refill.c b/lib/libc/stdio/refill.c
index f2a1f16f21e6..71eb2e53dab6 100644
--- a/lib/libc/stdio/refill.c
+++ b/lib/libc/stdio/refill.c
@@ -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.
*
diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c
index f08e47c4e8c8..2e984baf9360 100644
--- a/lib/libc/stdio/remove.c
+++ b/lib/libc/stdio/remove.c
@@ -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.
*
@@ -42,8 +42,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
int
-remove(file)
- const char *file;
+remove(const char *file)
{
struct stat sb;
diff --git a/lib/libc/stdio/rewind.c b/lib/libc/stdio/rewind.c
index 73ef2c657bfc..ff4c9072c76b 100644
--- a/lib/libc/stdio/rewind.c
+++ b/lib/libc/stdio/rewind.c
@@ -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.
*
diff --git a/lib/libc/stdio/rget.c b/lib/libc/stdio/rget.c
index 71c75e0ac9e1..bdc0311674e1 100644
--- a/lib/libc/stdio/rget.c
+++ b/lib/libc/stdio/rget.c
@@ -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.
*
diff --git a/lib/libc/stdio/scanf.c b/lib/libc/stdio/scanf.c
index ba33caae7988..e377724ac5be 100644
--- a/lib/libc/stdio/scanf.c
+++ b/lib/libc/stdio/scanf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/setbuf.c b/lib/libc/stdio/setbuf.c
index 0daef5422ec2..5c65f976c9de 100644
--- a/lib/libc/stdio/setbuf.c
+++ b/lib/libc/stdio/setbuf.c
@@ -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.
*
diff --git a/lib/libc/stdio/setbuffer.c b/lib/libc/stdio/setbuffer.c
index dd1caa01f806..af5eb3cabf6e 100644
--- a/lib/libc/stdio/setbuffer.c
+++ b/lib/libc/stdio/setbuffer.c
@@ -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.
*
@@ -39,10 +39,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
void
-setbuffer(fp, buf, size)
- FILE *fp;
- char *buf;
- int size;
+setbuffer(FILE *fp, char *buf, int size)
{
(void)setvbuf(fp, buf, buf ? _IOFBF : _IONBF, (size_t)size);
@@ -52,8 +49,7 @@ setbuffer(fp, buf, size)
* set line buffering
*/
int
-setlinebuf(fp)
- FILE *fp;
+setlinebuf(FILE *fp)
{
return (setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0));
diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c
index d897925fa363..d39696058616 100644
--- a/lib/libc/stdio/setvbuf.c
+++ b/lib/libc/stdio/setvbuf.c
@@ -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.
*
diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c
index d0ae5a663103..e2dd2ddd6c0c 100644
--- a/lib/libc/stdio/snprintf.c
+++ b/lib/libc/stdio/snprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/sprintf.c b/lib/libc/stdio/sprintf.c
index 6e20e04651e0..0f38d15cd2ce 100644
--- a/lib/libc/stdio/sprintf.c
+++ b/lib/libc/stdio/sprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/sscanf.c b/lib/libc/stdio/sscanf.c
index 1c339eb5069b..ae79451a47fc 100644
--- a/lib/libc/stdio/sscanf.c
+++ b/lib/libc/stdio/sscanf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c
index 2447d180ef56..44ee0ab41210 100644
--- a/lib/libc/stdio/stdio.c
+++ b/lib/libc/stdio/stdio.c
@@ -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.
*
@@ -50,10 +50,7 @@ __FBSDID("$FreeBSD$");
* Small standard I/O/seek/close functions.
*/
int
-__sread(cookie, buf, n)
- void *cookie;
- char *buf;
- int n;
+__sread(void *cookie, char *buf, int n)
{
FILE *fp = cookie;
@@ -61,10 +58,7 @@ __sread(cookie, buf, n)
}
int
-__swrite(cookie, buf, n)
- void *cookie;
- char const *buf;
- int n;
+__swrite(void *cookie, char const *buf, int n)
{
FILE *fp = cookie;
@@ -72,10 +66,7 @@ __swrite(cookie, buf, n)
}
fpos_t
-__sseek(cookie, offset, whence)
- void *cookie;
- fpos_t offset;
- int whence;
+__sseek(void *cookie, fpos_t offset, int whence)
{
FILE *fp = cookie;
@@ -83,8 +74,7 @@ __sseek(cookie, offset, whence)
}
int
-__sclose(cookie)
- void *cookie;
+__sclose(void *cookie)
{
return (_close(((FILE *)cookie)->_file));
@@ -94,10 +84,7 @@ __sclose(cookie)
* Higher level wrappers.
*/
int
-_sread(fp, buf, n)
- FILE *fp;
- char *buf;
- int n;
+_sread(FILE *fp, char *buf, int n)
{
int ret;
@@ -115,10 +102,7 @@ _sread(fp, buf, n)
}
int
-_swrite(fp, buf, n)
- FILE *fp;
- char const *buf;
- int n;
+_swrite(FILE *fp, char const *buf, int n)
{
int ret;
int serrno;
@@ -145,10 +129,7 @@ _swrite(fp, buf, n)
}
fpos_t
-_sseek(fp, offset, whence)
- FILE *fp;
- fpos_t offset;
- int whence;
+_sseek(FILE *fp, fpos_t offset, int whence)
{
fpos_t ret;
int serrno, errret;
diff --git a/lib/libc/stdio/tempnam.c b/lib/libc/stdio/tempnam.c
index ea4a2c8ca63a..e15746f31a4d 100644
--- a/lib/libc/stdio/tempnam.c
+++ b/lib/libc/stdio/tempnam.c
@@ -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.
*
@@ -47,8 +47,7 @@ __warn_references(tempnam,
extern char *_mktemp(char *);
char *
-tempnam(dir, pfx)
- const char *dir, *pfx;
+tempnam(const char *dir, const char *pfx)
{
int sverrno;
char *f, *name;
diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c
index 7ff297fe15d6..c67d1e456a34 100644
--- a/lib/libc/stdio/tmpfile.c
+++ b/lib/libc/stdio/tmpfile.c
@@ -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.
*
diff --git a/lib/libc/stdio/tmpnam.c b/lib/libc/stdio/tmpnam.c
index 05bcb5bad6c4..ce32dcc28149 100644
--- a/lib/libc/stdio/tmpnam.c
+++ b/lib/libc/stdio/tmpnam.c
@@ -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.
*
@@ -47,8 +47,7 @@ __warn_references(tmpnam,
extern char *_mktemp(char *);
char *
-tmpnam(s)
- char *s;
+tmpnam(char *s)
{
static u_long tmpcount;
static char buf[L_tmpnam];
diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c
index 1353b7ecd7a3..1695af772daa 100644
--- a/lib/libc/stdio/ungetc.c
+++ b/lib/libc/stdio/ungetc.c
@@ -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.
*
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 4ad0ee16b1ab..ea47d36ea14a 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index 8f9d3d0e32cb..50f0690b6678 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index cc96b63bd1e4..4350c48acafc 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c
index 28e2c036439b..63b5dd1be28a 100644
--- a/lib/libc/stdio/vfwscanf.c
+++ b/lib/libc/stdio/vfwscanf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/vprintf.c b/lib/libc/stdio/vprintf.c
index c15ef4d6cc77..f98f1107c872 100644
--- a/lib/libc/stdio/vprintf.c
+++ b/lib/libc/stdio/vprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/vscanf.c b/lib/libc/stdio/vscanf.c
index d56bb3b51639..8729c9ca6ba8 100644
--- a/lib/libc/stdio/vscanf.c
+++ b/lib/libc/stdio/vscanf.c
@@ -18,7 +18,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.
*
@@ -49,10 +49,7 @@ __FBSDID("$FreeBSD$");
#include "xlocale_private.h"
int
-vscanf_l(locale, fmt, ap)
- locale_t locale;
- const char * __restrict fmt;
- __va_list ap;
+vscanf_l(locale_t locale, const char * __restrict fmt, __va_list ap)
{
int retval;
FIX_LOCALE(locale);
@@ -63,9 +60,7 @@ vscanf_l(locale, fmt, ap)
return (retval);
}
int
-vscanf(fmt, ap)
- const char * __restrict fmt;
- __va_list ap;
+vscanf(const char * __restrict fmt, __va_list ap)
{
return vscanf_l(__get_locale(), fmt, ap);
}
diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c
index 82959d1d082c..8d13a5041cd3 100644
--- a/lib/libc/stdio/vsnprintf.c
+++ b/lib/libc/stdio/vsnprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/vsprintf.c b/lib/libc/stdio/vsprintf.c
index 04f2df3cca17..906a74c24b38 100644
--- a/lib/libc/stdio/vsprintf.c
+++ b/lib/libc/stdio/vsprintf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/vsscanf.c b/lib/libc/stdio/vsscanf.c
index 5668ab5b9825..4328fc15bfad 100644
--- a/lib/libc/stdio/vsscanf.c
+++ b/lib/libc/stdio/vsscanf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/vswscanf.c b/lib/libc/stdio/vswscanf.c
index f646e852c781..c4a10379c2fc 100644
--- a/lib/libc/stdio/vswscanf.c
+++ b/lib/libc/stdio/vswscanf.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c
index 58e2da569df5..3f697e287a1f 100644
--- a/lib/libc/stdio/wbuf.c
+++ b/lib/libc/stdio/wbuf.c
@@ -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.
*
@@ -47,9 +47,7 @@ __FBSDID("$FreeBSD$");
* Non-MT-safe
*/
int
-__swbuf(c, fp)
- int c;
- FILE *fp;
+__swbuf(int c, FILE *fp)
{
int n;
diff --git a/lib/libc/stdio/wsetup.c b/lib/libc/stdio/wsetup.c
index 37bfc58bc360..70f8247c076b 100644
--- a/lib/libc/stdio/wsetup.c
+++ b/lib/libc/stdio/wsetup.c
@@ -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.
*
@@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$");
* _wsetup returns 0 if OK to write; otherwise, it returns EOF and sets errno.
*/
int
-__swsetup(fp)
- FILE *fp;
+__swsetup(FILE *fp)
{
/* make sure stdio is set up */
if (!__sdidinit)
diff --git a/lib/libc/stdio/xprintf_errno.c b/lib/libc/stdio/xprintf_errno.c
index 0c2be46a6d70..3c831d129388 100644
--- a/lib/libc/stdio/xprintf_errno.c
+++ b/lib/libc/stdio/xprintf_errno.c
@@ -34,6 +34,7 @@
#include <vis.h>
#include <assert.h>
#include <sys/time.h>
+#include "errlst.h"
#include "printf.h"
int
@@ -54,7 +55,7 @@ __printf_render_errno(struct __printf_io *io, const struct printf_info *pi __unu
ret = 0;
error = *((const int *)arg[0]);
- if (error >= 0 && error < sys_nerr) {
+ if (error >= 0 && error < __hidden_sys_nerr) {
p = strerror(error);
return (__printf_out(io, pi, p, strlen(p)));
}
diff --git a/lib/libc/stdlib/abort.3 b/lib/libc/stdlib/abort.3
index b939e9c23ebf..e177137849a1 100644
--- a/lib/libc/stdlib/abort.3
+++ b/lib/libc/stdlib/abort.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index eba53e5afa13..b137e490eb2f 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -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.
*
diff --git a/lib/libc/stdlib/abs.3 b/lib/libc/stdlib/abs.3
index 4f0212253544..eca85e1e7a59 100644
--- a/lib/libc/stdlib/abs.3
+++ b/lib/libc/stdlib/abs.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/abs.c b/lib/libc/stdlib/abs.c
index 5ca9596cb226..87589474eb3c 100644
--- a/lib/libc/stdlib/abs.c
+++ b/lib/libc/stdlib/abs.c
@@ -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.
*
diff --git a/lib/libc/stdlib/alloca.3 b/lib/libc/stdlib/alloca.3
index 95594443b0a0..38f5aee3a797 100644
--- a/lib/libc/stdlib/alloca.3
+++ b/lib/libc/stdlib/alloca.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/atexit.3 b/lib/libc/stdlib/atexit.3
index 3a514b95a1e5..d6dab56e9cf2 100644
--- a/lib/libc/stdlib/atexit.3
+++ b/lib/libc/stdlib/atexit.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c
index 511172aef9ae..18c31c3b1ffb 100644
--- a/lib/libc/stdlib/atexit.c
+++ b/lib/libc/stdlib/atexit.c
@@ -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.
*
diff --git a/lib/libc/stdlib/atexit.h b/lib/libc/stdlib/atexit.h
index f34194f7b991..29610676edaa 100644
--- a/lib/libc/stdlib/atexit.h
+++ b/lib/libc/stdlib/atexit.h
@@ -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.
*
diff --git a/lib/libc/stdlib/atof.3 b/lib/libc/stdlib/atof.3
index abf5b7c97b6b..b02cf0277656 100644
--- a/lib/libc/stdlib/atof.3
+++ b/lib/libc/stdlib/atof.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c
index 746ceac385f2..3514ae3b6927 100644
--- a/lib/libc/stdlib/atof.c
+++ b/lib/libc/stdlib/atof.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/atoi.3 b/lib/libc/stdlib/atoi.3
index b0d1d383f3d0..025019f4bfea 100644
--- a/lib/libc/stdlib/atoi.3
+++ b/lib/libc/stdlib/atoi.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c
index 31a8676b98b9..564273e952cf 100644
--- a/lib/libc/stdlib/atoi.c
+++ b/lib/libc/stdlib/atoi.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/atol.3 b/lib/libc/stdlib/atol.3
index cc49fe2eecd0..e2ac0e54a35c 100644
--- a/lib/libc/stdlib/atol.3
+++ b/lib/libc/stdlib/atol.3
@@ -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.
.\"
@@ -32,7 +32,7 @@
.\" @(#)atol.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd February 1, 2009
+.Dd May 14, 2013
.Dt ATOL 3
.Os
.Sh NAME
@@ -88,13 +88,13 @@ and
functions are thin wrappers around
.Fn strtol
and
-.Fn stroll
+.Fn strtoll
respectively, so these functions will affect the value of
.Va errno
in the same way that the
.Fn strtol
and
-.Fn stroll
+.Fn strtoll
functions are able to.
This behavior of
.Fn atol
diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c
index 7ebbe01ec9e2..d30aa18a8398 100644
--- a/lib/libc/stdlib/atol.c
+++ b/lib/libc/stdlib/atol.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c
index cbb5459cb12a..af528382bd7c 100644
--- a/lib/libc/stdlib/atoll.c
+++ b/lib/libc/stdlib/atoll.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/bsearch.3 b/lib/libc/stdlib/bsearch.3
index 25be84206874..2fdf2c4842c0 100644
--- a/lib/libc/stdlib/bsearch.3
+++ b/lib/libc/stdlib/bsearch.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/bsearch.c b/lib/libc/stdlib/bsearch.c
index ff021688f306..4bcaaf3669dd 100644
--- a/lib/libc/stdlib/bsearch.c
+++ b/lib/libc/stdlib/bsearch.c
@@ -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.
*
diff --git a/lib/libc/stdlib/div.3 b/lib/libc/stdlib/div.3
index 46a145f39cf4..ddd92a008790 100644
--- a/lib/libc/stdlib/div.3
+++ b/lib/libc/stdlib/div.3
@@ -11,7 +11,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.
.\"
diff --git a/lib/libc/stdlib/div.c b/lib/libc/stdlib/div.c
index ef93d736f6cc..7dfe553f4a05 100644
--- a/lib/libc/stdlib/div.c
+++ b/lib/libc/stdlib/div.c
@@ -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.
*
diff --git a/lib/libc/stdlib/exit.3 b/lib/libc/stdlib/exit.3
index 4547efe60bd9..07ce0d77d106 100644
--- a/lib/libc/stdlib/exit.3
+++ b/lib/libc/stdlib/exit.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c
index 26c346ac072f..145eb9d7c7cb 100644
--- a/lib/libc/stdlib/exit.c
+++ b/lib/libc/stdlib/exit.c
@@ -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.
*
diff --git a/lib/libc/stdlib/getenv.3 b/lib/libc/stdlib/getenv.3
index 19496489457d..e662b86d214b 100644
--- a/lib/libc/stdlib/getenv.3
+++ b/lib/libc/stdlib/getenv.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c
index 47963d53dd62..845110388a20 100644
--- a/lib/libc/stdlib/getenv.c
+++ b/lib/libc/stdlib/getenv.c
@@ -505,9 +505,8 @@ __setenv(const char *name, size_t nameLen, const char *value, int overwrite)
envVars[envNdx].valueSize = valueLen;
/* Save name of name/value pair. */
- env = stpcpy(envVars[envNdx].name, name);
- if ((envVars[envNdx].name)[nameLen] != '=')
- env = stpcpy(env, "=");
+ env = stpncpy(envVars[envNdx].name, name, nameLen);
+ *env++ = '=';
}
else
env = envVars[envNdx].value;
diff --git a/lib/libc/stdlib/getopt.3 b/lib/libc/stdlib/getopt.3
index 3fe44533f1b7..03a63abb19c5 100644
--- a/lib/libc/stdlib/getopt.3
+++ b/lib/libc/stdlib/getopt.3
@@ -11,7 +11,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.
.\"
diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c
index 4d319a45ffc3..b9d2ae31fc64 100644
--- a/lib/libc/stdlib/getopt.c
+++ b/lib/libc/stdlib/getopt.c
@@ -12,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.
*
diff --git a/lib/libc/stdlib/getsubopt.3 b/lib/libc/stdlib/getsubopt.3
index 86894ebbc8f6..43ea2c2a9e2c 100644
--- a/lib/libc/stdlib/getsubopt.3
+++ b/lib/libc/stdlib/getsubopt.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/getsubopt.c b/lib/libc/stdlib/getsubopt.c
index 6d0ab75668d0..efff9dab54ac 100644
--- a/lib/libc/stdlib/getsubopt.c
+++ b/lib/libc/stdlib/getsubopt.c
@@ -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.
*
diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c
index f65687689c55..4bad8a768006 100644
--- a/lib/libc/stdlib/heapsort.c
+++ b/lib/libc/stdlib/heapsort.c
@@ -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.
*
diff --git a/lib/libc/stdlib/jemalloc/Symbol.map b/lib/libc/stdlib/jemalloc/Symbol.map
index b98d37ae5bf0..617194f87a46 100644
--- a/lib/libc/stdlib/jemalloc/Symbol.map
+++ b/lib/libc/stdlib/jemalloc/Symbol.map
@@ -26,6 +26,17 @@ FBSD_1.3 {
sallocm;
dallocm;
nallocm;
+ __malloc;
+ __calloc;
+ __realloc;
+ __free;
+ __posix_memalign;
+ __malloc_usable_size;
+ __allocm;
+ __rallocm;
+ __sallocm;
+ __dallocm;
+ __nallocm;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/stdlib/labs.3 b/lib/libc/stdlib/labs.3
index b714fe382a23..bbd32124f476 100644
--- a/lib/libc/stdlib/labs.3
+++ b/lib/libc/stdlib/labs.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/labs.c b/lib/libc/stdlib/labs.c
index d22975e24d42..816370eee2b2 100644
--- a/lib/libc/stdlib/labs.c
+++ b/lib/libc/stdlib/labs.c
@@ -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.
*
diff --git a/lib/libc/stdlib/ldiv.3 b/lib/libc/stdlib/ldiv.3
index 221e68d27d5a..ce4d01771b11 100644
--- a/lib/libc/stdlib/ldiv.3
+++ b/lib/libc/stdlib/ldiv.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/ldiv.c b/lib/libc/stdlib/ldiv.c
index 0311d06e086d..0ec98e65547d 100644
--- a/lib/libc/stdlib/ldiv.c
+++ b/lib/libc/stdlib/ldiv.c
@@ -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.
*
diff --git a/lib/libc/stdlib/lsearch.3 b/lib/libc/stdlib/lsearch.3
index 5e76724dc115..2a1a7312c3ac 100644
--- a/lib/libc/stdlib/lsearch.3
+++ b/lib/libc/stdlib/lsearch.3
@@ -8,7 +8,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 11, 2002
+.Dd April 21, 2013
.Dt LSEARCH 3
.Os
.Sh NAME
@@ -81,6 +81,47 @@ returns
Both functions return
.Dv NULL
if an error occurs.
+.Sh EXAMPLES
+.Bd -literal
+#include <search.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+element_compare(const void *p1, const void *p2)
+{
+ int left = *(const int *)p1;
+ int right = *(const int *)p2;
+
+ return (left - right);
+}
+
+int
+main(int argc, char **argv)
+{
+ const int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ size_t element_size = sizeof(array[0]);
+ size_t array_size = sizeof(array) / element_size;
+ int key;
+ void *element;
+
+ printf("Enter a number: ");
+ if (scanf("%d", &key) != 1) {
+ printf("Bad input\n");
+ return (EXIT_FAILURE);
+ }
+
+ element = lfind(&key, array, &array_size, element_size,
+ element_compare);
+
+ if (element != NULL)
+ printf("Element found: %d\n", *(int *)element);
+ else
+ printf("Element not found\n");
+
+ return (EXIT_SUCCESS);
+}
+.Ed
.Sh SEE ALSO
.Xr bsearch 3 ,
.Xr hsearch 3 ,
diff --git a/lib/libc/stdlib/memory.3 b/lib/libc/stdlib/memory.3
index 9f42fa6abdab..b78ddae8aab0 100644
--- a/lib/libc/stdlib/memory.3
+++ b/lib/libc/stdlib/memory.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c
index e1078e7ccacd..01a902854222 100644
--- a/lib/libc/stdlib/merge.c
+++ b/lib/libc/stdlib/merge.c
@@ -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.
*
diff --git a/lib/libc/stdlib/qsort.3 b/lib/libc/stdlib/qsort.3
index f34d260b7fc9..ac019121f537 100644
--- a/lib/libc/stdlib/qsort.3
+++ b/lib/libc/stdlib/qsort.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c
index 3687b0579ffd..93e22cdf9315 100644
--- a/lib/libc/stdlib/qsort.c
+++ b/lib/libc/stdlib/qsort.c
@@ -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.
*
diff --git a/lib/libc/stdlib/radixsort.3 b/lib/libc/stdlib/radixsort.3
index dfa65f1359b3..5b85bf85f81c 100644
--- a/lib/libc/stdlib/radixsort.3
+++ b/lib/libc/stdlib/radixsort.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c
index 82ff1bc673a7..8310e6dea16c 100644
--- a/lib/libc/stdlib/radixsort.c
+++ b/lib/libc/stdlib/radixsort.c
@@ -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.
*
diff --git a/lib/libc/stdlib/rand.3 b/lib/libc/stdlib/rand.3
index bf50e3d87e72..a8c4a4cb5686 100644
--- a/lib/libc/stdlib/rand.3
+++ b/lib/libc/stdlib/rand.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index 0cbd94883125..4f4aa8dc2d91 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -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.
*
@@ -67,15 +67,15 @@ do_rand(unsigned long *ctx)
*/
long hi, lo, x;
- /* Can't be initialized with 0, so use another value. */
- if (*ctx == 0)
- *ctx = 123459876;
+ /* Must be in [1, 0x7ffffffe] range at this point. */
hi = *ctx / 127773;
lo = *ctx % 127773;
x = 16807 * lo - 2836 * hi;
if (x < 0)
x += 0x7fffffff;
- return ((*ctx = x) % ((u_long)RAND_MAX + 1));
+ *ctx = x;
+ /* Transform to [0, 0x7ffffffd] range. */
+ return (x - 1);
#endif /* !USE_WEAK_SEEDING */
}
@@ -83,15 +83,32 @@ do_rand(unsigned long *ctx)
int
rand_r(unsigned int *ctx)
{
- u_long val = (u_long) *ctx;
- int r = do_rand(&val);
+ u_long val;
+ int r;
- *ctx = (unsigned int) val;
+#ifdef USE_WEAK_SEEDING
+ val = *ctx;
+#else
+ /* Transform to [1, 0x7ffffffe] range. */
+ val = (*ctx % 0x7ffffffe) + 1;
+#endif
+ r = do_rand(&val);
+
+#ifdef USE_WEAK_SEEDING
+ *ctx = (unsigned int)val;
+#else
+ *ctx = (unsigned int)(val - 1);
+#endif
return (r);
}
-static u_long next = 1;
+static u_long next =
+#ifdef USE_WEAK_SEEDING
+ 1;
+#else
+ 2;
+#endif
int
rand()
@@ -104,6 +121,10 @@ srand(seed)
u_int seed;
{
next = seed;
+#ifndef USE_WEAK_SEEDING
+ /* Transform to [1, 0x7ffffffe] range. */
+ next = (next % 0x7ffffffe) + 1;
+#endif
}
@@ -125,6 +146,10 @@ sranddev()
mib[0] = CTL_KERN;
mib[1] = KERN_ARND;
sysctl(mib, 2, (void *)&next, &len, NULL, 0);
+#ifndef USE_WEAK_SEEDING
+ /* Transform to [1, 0x7ffffffe] range. */
+ next = (next % 0x7ffffffe) + 1;
+#endif
}
diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3
index a1e585bbd24a..dc8e961d8cec 100644
--- a/lib/libc/stdlib/random.3
+++ b/lib/libc/stdlib/random.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c
index 4c88ecbbc881..580f26e32ce9 100644
--- a/lib/libc/stdlib/random.c
+++ b/lib/libc/stdlib/random.c
@@ -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.
*
diff --git a/lib/libc/stdlib/realpath.3 b/lib/libc/stdlib/realpath.3
index 33970fd946a5..c0a5770ac83f 100644
--- a/lib/libc/stdlib/realpath.3
+++ b/lib/libc/stdlib/realpath.3
@@ -12,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.
.\"
diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c
index 8fd5457af9c3..a2a93293172b 100644
--- a/lib/libc/stdlib/realpath.c
+++ b/lib/libc/stdlib/realpath.c
@@ -139,7 +139,7 @@ realpath(const char * __restrict path, char * __restrict resolved)
* Only the trailing slashes are not covered
* by other checks in the loop, but we verify
* the prefix for any (rare) "//" or "/\0"
- * occurence to not implement lookahead.
+ * occurrence to not implement lookahead.
*/
if (lstat(resolved, &sb) != 0) {
if (m)
diff --git a/lib/libc/stdlib/strtod.3 b/lib/libc/stdlib/strtod.3
index e19e5febb136..549c640f8358 100644
--- a/lib/libc/stdlib/strtod.3
+++ b/lib/libc/stdlib/strtod.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/strtoimax.c b/lib/libc/stdlib/strtoimax.c
index 9be773b00254..72903e8df00e 100644
--- a/lib/libc/stdlib/strtoimax.c
+++ b/lib/libc/stdlib/strtoimax.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/strtol.3 b/lib/libc/stdlib/strtol.3
index 02316f58e4f5..3b7af7d30f01 100644
--- a/lib/libc/stdlib/strtol.3
+++ b/lib/libc/stdlib/strtol.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c
index f80ecb440f83..e0c9978458e3 100644
--- a/lib/libc/stdlib/strtol.c
+++ b/lib/libc/stdlib/strtol.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c
index 67833275e3ae..16a8196a3562 100644
--- a/lib/libc/stdlib/strtoll.c
+++ b/lib/libc/stdlib/strtoll.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/strtonum.3 b/lib/libc/stdlib/strtonum.3
index b83aadda42e5..ed2699559bee 100644
--- a/lib/libc/stdlib/strtonum.3
+++ b/lib/libc/stdlib/strtonum.3
@@ -97,7 +97,7 @@ int iterations;
const char *errstr;
iterations = strtonum(optarg, 1, 64, &errstr);
-if (errstr)
+if (errstr != NULL)
errx(1, "number of iterations is %s: %s", errstr, optarg);
.Ed
.Pp
diff --git a/lib/libc/stdlib/strtoq.c b/lib/libc/stdlib/strtoq.c
index afad51fb80c0..7bc1c80a3a32 100644
--- a/lib/libc/stdlib/strtoq.c
+++ b/lib/libc/stdlib/strtoq.c
@@ -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.
*
diff --git a/lib/libc/stdlib/strtoul.3 b/lib/libc/stdlib/strtoul.3
index 2c0f348961df..6d269656ddf6 100644
--- a/lib/libc/stdlib/strtoul.3
+++ b/lib/libc/stdlib/strtoul.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c
index 0ae0661c2c08..ed58dd8ae662 100644
--- a/lib/libc/stdlib/strtoul.c
+++ b/lib/libc/stdlib/strtoul.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c
index 4b7f1c9082d7..dc40e0e98919 100644
--- a/lib/libc/stdlib/strtoull.c
+++ b/lib/libc/stdlib/strtoull.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/strtoumax.c b/lib/libc/stdlib/strtoumax.c
index d4362bb333c4..769967727ac5 100644
--- a/lib/libc/stdlib/strtoumax.c
+++ b/lib/libc/stdlib/strtoumax.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/stdlib/strtouq.c b/lib/libc/stdlib/strtouq.c
index 9638c1198ae2..9371680b9721 100644
--- a/lib/libc/stdlib/strtouq.c
+++ b/lib/libc/stdlib/strtouq.c
@@ -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.
*
diff --git a/lib/libc/stdlib/system.3 b/lib/libc/stdlib/system.3
index 3d13489bad85..3cea71ec79a9 100644
--- a/lib/libc/stdlib/system.3
+++ b/lib/libc/stdlib/system.3
@@ -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.
.\"
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 4f47edffe196..e018e6ff0b72 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -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.
*
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <signal.h>
#include <stdlib.h>
#include <stddef.h>
+#include <string.h>
#include <unistd.h>
#include <paths.h>
#include <errno.h>
@@ -56,37 +57,38 @@ __system(const char *command)
if (!command) /* just checking... */
return(1);
- /*
- * Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save
- * existing signal dispositions.
- */
- ign.sa_handler = SIG_IGN;
- (void)sigemptyset(&ign.sa_mask);
- ign.sa_flags = 0;
- (void)_sigaction(SIGINT, &ign, &intact);
- (void)_sigaction(SIGQUIT, &ign, &quitact);
(void)sigemptyset(&newsigblock);
(void)sigaddset(&newsigblock, SIGCHLD);
+ (void)sigaddset(&newsigblock, SIGINT);
+ (void)sigaddset(&newsigblock, SIGQUIT);
(void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
- switch(pid = fork()) {
+ switch(pid = vfork()) {
case -1: /* error */
- break;
+ (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
+ return (-1);
case 0: /* child */
/*
* Restore original signal dispositions and exec the command.
*/
- (void)_sigaction(SIGINT, &intact, NULL);
- (void)_sigaction(SIGQUIT, &quitact, NULL);
(void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL);
_exit(127);
- default: /* parent */
- savedpid = pid;
- do {
- pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0);
- } while (pid == -1 && errno == EINTR);
- break;
}
+ /*
+ * If we are running means that the child has either completed
+ * its execve, or has failed.
+ * Block SIGINT/QUIT because sh -c handles it and wait for
+ * it to clean up.
+ */
+ memset(&ign, 0, sizeof(ign));
+ ign.sa_handler = SIG_IGN;
+ (void)sigemptyset(&ign.sa_mask);
+ (void)_sigaction(SIGINT, &ign, &intact);
+ (void)_sigaction(SIGQUIT, &ign, &quitact);
+ savedpid = pid;
+ do {
+ pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0);
+ } while (pid == -1 && errno == EINTR);
(void)_sigaction(SIGINT, &intact, NULL);
(void)_sigaction(SIGQUIT, &quitact, NULL);
(void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
diff --git a/lib/libc/string/bcmp.3 b/lib/libc/string/bcmp.3
index d043c2cc1b62..fa5666c57ea0 100644
--- a/lib/libc/string/bcmp.3
+++ b/lib/libc/string/bcmp.3
@@ -11,7 +11,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.
.\"
diff --git a/lib/libc/string/bcmp.c b/lib/libc/string/bcmp.c
index 117a9a1d0cfc..f1178a660b2b 100644
--- a/lib/libc/string/bcmp.c
+++ b/lib/libc/string/bcmp.c
@@ -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.
*
diff --git a/lib/libc/string/bcopy.3 b/lib/libc/string/bcopy.3
index 23f7ac22a131..1608fad2d79f 100644
--- a/lib/libc/string/bcopy.3
+++ b/lib/libc/string/bcopy.3
@@ -12,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.
.\"
diff --git a/lib/libc/string/bcopy.c b/lib/libc/string/bcopy.c
index bb1209cdc575..c424de560f6c 100644
--- a/lib/libc/string/bcopy.c
+++ b/lib/libc/string/bcopy.c
@@ -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.
*
diff --git a/lib/libc/string/bstring.3 b/lib/libc/string/bstring.3
index b1aef1b5f9ef..b8ed0908c88a 100644
--- a/lib/libc/string/bstring.3
+++ b/lib/libc/string/bstring.3
@@ -11,7 +11,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.
.\"
diff --git a/lib/libc/string/bzero.3 b/lib/libc/string/bzero.3
index bc61d82b62af..029644a5b7bf 100644
--- a/lib/libc/string/bzero.3
+++ b/lib/libc/string/bzero.3
@@ -12,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.
.\"
diff --git a/lib/libc/string/ffs.3 b/lib/libc/string/ffs.3
index d8e11d80e406..192771ffaeea 100644
--- a/lib/libc/string/ffs.3
+++ b/lib/libc/string/ffs.3
@@ -11,7 +11,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.
.\"
diff --git a/lib/libc/string/ffs.c b/lib/libc/string/ffs.c
index 9c3e0b3182e7..42a94ef7383d 100644
--- a/lib/libc/string/ffs.c
+++ b/lib/libc/string/ffs.c
@@ -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.
*
diff --git a/lib/libc/string/ffsl.c b/lib/libc/string/ffsl.c
index 6a25afddc57b..3fd94521d623 100644
--- a/lib/libc/string/ffsl.c
+++ b/lib/libc/string/ffsl.c
@@ -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.
*
diff --git a/lib/libc/string/ffsll.c b/lib/libc/string/ffsll.c
index 59e03bcb23c0..e19df91d1f03 100644
--- a/lib/libc/string/ffsll.c
+++ b/lib/libc/string/ffsll.c
@@ -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.
*
diff --git a/lib/libc/string/fls.c b/lib/libc/string/fls.c
index 2a3a3f755a7f..7145b909f026 100644
--- a/lib/libc/string/fls.c
+++ b/lib/libc/string/fls.c
@@ -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.
*
diff --git a/lib/libc/string/flsl.c b/lib/libc/string/flsl.c
index 8f60e33edaaa..19485b2f787e 100644
--- a/lib/libc/string/flsl.c
+++ b/lib/libc/string/flsl.c
@@ -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.
*
diff --git a/lib/libc/string/flsll.c b/lib/libc/string/flsll.c
index ab5562782d2b..b12f12f2d0d7 100644
--- a/lib/libc/string/flsll.c
+++ b/lib/libc/string/flsll.c
@@ -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.
*
diff --git a/lib/libc/string/index.3 b/lib/libc/string/index.3
index 25f6f65ac493..dcce40031983 100644
--- a/lib/libc/string/index.3
+++ b/lib/libc/string/index.3
@@ -11,7 +11,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.
.\"
diff --git a/lib/libc/string/memccpy.3 b/lib/libc/string/memccpy.3
index 40a25be4361a..5bf323115746 100644
--- a/lib/libc/string/memccpy.3
+++ b/lib/libc/string/memccpy.3
@@ -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.
.\"
diff --git a/lib/libc/string/memccpy.c b/lib/libc/string/memccpy.c
index 539d33e4701f..6102a5bdedaf 100644
--- a/lib/libc/string/memccpy.c
+++ b/lib/libc/string/memccpy.c
@@ -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.
*
diff --git a/lib/libc/string/memchr.3 b/lib/libc/string/memchr.3
index 9f31fd156639..de571ca66e96 100644
--- a/lib/libc/string/memchr.3
+++ b/lib/libc/string/memchr.3
@@ -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.
.\"
diff --git a/lib/libc/string/memchr.c b/lib/libc/string/memchr.c
index d98d85317e5a..8020333dec3b 100644
--- a/lib/libc/string/memchr.c
+++ b/lib/libc/string/memchr.c
@@ -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.
*
diff --git a/lib/libc/string/memcmp.3 b/lib/libc/string/memcmp.3
index 88ed9a25934e..00e8e1a1d759 100644
--- a/lib/libc/string/memcmp.3
+++ b/lib/libc/string/memcmp.3
@@ -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.
.\"
diff --git a/lib/libc/string/memcmp.c b/lib/libc/string/memcmp.c
index 4a1b66e6548b..d2d0f27d35ef 100644
--- a/lib/libc/string/memcmp.c
+++ b/lib/libc/string/memcmp.c
@@ -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.
*
diff --git a/lib/libc/string/memcpy.3 b/lib/libc/string/memcpy.3
index 3f2e2ddf7586..25a6c359f1da 100644
--- a/lib/libc/string/memcpy.3
+++ b/lib/libc/string/memcpy.3
@@ -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.
.\"
diff --git a/lib/libc/string/memmove.3 b/lib/libc/string/memmove.3
index 8a1d52bcd959..8d1c33cd9d4e 100644
--- a/lib/libc/string/memmove.3
+++ b/lib/libc/string/memmove.3
@@ -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.
.\"
diff --git a/lib/libc/string/memset.3 b/lib/libc/string/memset.3
index 07bd7aa7d624..28d1919f706b 100644
--- a/lib/libc/string/memset.3
+++ b/lib/libc/string/memset.3
@@ -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.
.\"
diff --git a/lib/libc/string/memset.c b/lib/libc/string/memset.c
index 89f7e45a9be8..ad0d513933fe 100644
--- a/lib/libc/string/memset.c
+++ b/lib/libc/string/memset.c
@@ -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.
*
diff --git a/lib/libc/string/strcasecmp.3 b/lib/libc/string/strcasecmp.3
index 760b9d402720..598f76f80747 100644
--- a/lib/libc/string/strcasecmp.3
+++ b/lib/libc/string/strcasecmp.3
@@ -11,7 +11,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.
.\"
diff --git a/lib/libc/string/strcasecmp.c b/lib/libc/string/strcasecmp.c
index 65e042e42a42..c72a660508c4 100644
--- a/lib/libc/string/strcasecmp.c
+++ b/lib/libc/string/strcasecmp.c
@@ -15,7 +15,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.
*
diff --git a/lib/libc/string/strcasestr.c b/lib/libc/string/strcasestr.c
index 5f39648a69bd..cca16dc7bb63 100644
--- a/lib/libc/string/strcasestr.c
+++ b/lib/libc/string/strcasestr.c
@@ -18,7 +18,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.
*
diff --git a/lib/libc/string/strcat.3 b/lib/libc/string/strcat.3
index dfa55a470a09..14ce340955e7 100644
--- a/lib/libc/string/strcat.3
+++ b/lib/libc/string/strcat.3
@@ -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.
.\"
diff --git a/lib/libc/string/strcat.c b/lib/libc/string/strcat.c
index 1578276c1724..07a3c08c1a2f 100644
--- a/lib/libc/string/strcat.c
+++ b/lib/libc/string/strcat.c
@@ -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.
*
diff --git a/lib/libc/string/strchr.3 b/lib/libc/string/strchr.3
index 019b9236f425..6117831233a1 100644
--- a/lib/libc/string/strchr.3
+++ b/lib/libc/string/strchr.3
@@ -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.
.\"
diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c
index 1245f136b7ef..ab83b3995a44 100644
--- a/lib/libc/string/strchr.c
+++ b/lib/libc/string/strchr.c
@@ -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.
*
diff --git a/lib/libc/string/strcmp.3 b/lib/libc/string/strcmp.3
index 74d1a5c4d18d..a79852d2a240 100644
--- a/lib/libc/string/strcmp.3
+++ b/lib/libc/string/strcmp.3
@@ -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.
.\"
diff --git a/lib/libc/string/strcmp.c b/lib/libc/string/strcmp.c
index 95c778dc2296..9daf624acce0 100644
--- a/lib/libc/string/strcmp.c
+++ b/lib/libc/string/strcmp.c
@@ -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.
*
diff --git a/lib/libc/string/strcoll.3 b/lib/libc/string/strcoll.3
index 20f188896ad6..d53a23d11b2f 100644
--- a/lib/libc/string/strcoll.3
+++ b/lib/libc/string/strcoll.3
@@ -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.
.\"
diff --git a/lib/libc/string/strcpy.3 b/lib/libc/string/strcpy.3
index 395e2f9b7b57..efc95dfbdd22 100644
--- a/lib/libc/string/strcpy.3
+++ b/lib/libc/string/strcpy.3
@@ -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.
.\"
diff --git a/lib/libc/string/strcpy.c b/lib/libc/string/strcpy.c
index fec284e22525..8a48d0d0d732 100644
--- a/lib/libc/string/strcpy.c
+++ b/lib/libc/string/strcpy.c
@@ -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.
*
diff --git a/lib/libc/string/strcspn.3 b/lib/libc/string/strcspn.3
index d1df19813e4a..0331ca1b60c8 100644
--- a/lib/libc/string/strcspn.3
+++ b/lib/libc/string/strcspn.3
@@ -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.
.\"
diff --git a/lib/libc/string/strdup.3 b/lib/libc/string/strdup.3
index 04a2816ae6eb..f9ed5c208362 100644
--- a/lib/libc/string/strdup.3
+++ b/lib/libc/string/strdup.3
@@ -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.
.\"
diff --git a/lib/libc/string/strdup.c b/lib/libc/string/strdup.c
index 570ad838527d..8e90aa05fcb9 100644
--- a/lib/libc/string/strdup.c
+++ b/lib/libc/string/strdup.c
@@ -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.
*
diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3
index cc2560266e77..50b155530017 100644
--- a/lib/libc/string/strerror.3
+++ b/lib/libc/string/strerror.3
@@ -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.
.\"
diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c
index bfca871ad31a..1d7a385bd9ea 100644
--- a/lib/libc/string/strerror.c
+++ b/lib/libc/string/strerror.c
@@ -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.
*
@@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <stdio.h>
+#include "errlst.h"
+
#define UPREFIX "Unknown error"
/*
@@ -87,7 +89,7 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen)
catd = catopen("libc", NL_CAT_LOCALE);
#endif
- if (errnum < 0 || errnum >= sys_nerr) {
+ if (errnum < 0 || errnum >= __hidden_sys_nerr) {
errstr(errnum,
#if defined(NLS)
catgets(catd, 1, 0xffff, UPREFIX),
@@ -99,9 +101,9 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen)
} else {
if (strlcpy(strerrbuf,
#if defined(NLS)
- catgets(catd, 1, errnum, sys_errlist[errnum]),
+ catgets(catd, 1, errnum, __hidden_sys_errlist[errnum]),
#else
- sys_errlist[errnum],
+ __hidden_sys_errlist[errnum],
#endif
buflen) >= buflen)
retval = ERANGE;
diff --git a/lib/libc/string/string.3 b/lib/libc/string/string.3
index b0e25a9bc2dd..e9ef152bb8ee 100644
--- a/lib/libc/string/string.3
+++ b/lib/libc/string/string.3
@@ -11,7 +11,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.
.\"
diff --git a/lib/libc/string/strlen.3 b/lib/libc/string/strlen.3
index bdbf4ff2fa4d..fb2fa3cd2acb 100644
--- a/lib/libc/string/strlen.3
+++ b/lib/libc/string/strlen.3
@@ -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.
.\"
diff --git a/lib/libc/string/strmode.3 b/lib/libc/string/strmode.3
index 1a072d828644..e963d28b9cde 100644
--- a/lib/libc/string/strmode.3
+++ b/lib/libc/string/strmode.3
@@ -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.
.\"
diff --git a/lib/libc/string/strmode.c b/lib/libc/string/strmode.c
index 3aaa77e436da..a73dd0ede401 100644
--- a/lib/libc/string/strmode.c
+++ b/lib/libc/string/strmode.c
@@ -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.
*
diff --git a/lib/libc/string/strncat.c b/lib/libc/string/strncat.c
index fb2802c6110b..6a0e553daa3f 100644
--- a/lib/libc/string/strncat.c
+++ b/lib/libc/string/strncat.c
@@ -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.
*
diff --git a/lib/libc/string/strncmp.c b/lib/libc/string/strncmp.c
index 5bc3d5e61a85..4967a9483e64 100644
--- a/lib/libc/string/strncmp.c
+++ b/lib/libc/string/strncmp.c
@@ -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.
*
diff --git a/lib/libc/string/strncpy.c b/lib/libc/string/strncpy.c
index 980dbc7d58e8..39074035084c 100644
--- a/lib/libc/string/strncpy.c
+++ b/lib/libc/string/strncpy.c
@@ -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.
*
diff --git a/lib/libc/string/strndup.c b/lib/libc/string/strndup.c
index abb1e030eeec..2897e933193c 100644
--- a/lib/libc/string/strndup.c
+++ b/lib/libc/string/strndup.c
@@ -12,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.
*
diff --git a/lib/libc/string/strnstr.c b/lib/libc/string/strnstr.c
index 45be95d12a1d..4de757d5996f 100644
--- a/lib/libc/string/strnstr.c
+++ b/lib/libc/string/strnstr.c
@@ -14,7 +14,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.
*
diff --git a/lib/libc/string/strpbrk.3 b/lib/libc/string/strpbrk.3
index 7ed0ec709c71..bfa50990a71d 100644
--- a/lib/libc/string/strpbrk.3
+++ b/lib/libc/string/strpbrk.3
@@ -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.
.\"
diff --git a/lib/libc/string/strpbrk.c b/lib/libc/string/strpbrk.c
index 2069bee7233a..565ef82f11d3 100644
--- a/lib/libc/string/strpbrk.c
+++ b/lib/libc/string/strpbrk.c
@@ -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.
*
diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c
index be9f9781f6e9..f84ffb78c438 100644
--- a/lib/libc/string/strrchr.c
+++ b/lib/libc/string/strrchr.c
@@ -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.
*
diff --git a/lib/libc/string/strsep.3 b/lib/libc/string/strsep.3
index 9432a88380bd..4e9dad9db5ae 100644
--- a/lib/libc/string/strsep.3
+++ b/lib/libc/string/strsep.3
@@ -12,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.
.\"
diff --git a/lib/libc/string/strsep.c b/lib/libc/string/strsep.c
index 670ab04ae9f8..73c61af8115f 100644
--- a/lib/libc/string/strsep.c
+++ b/lib/libc/string/strsep.c
@@ -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.
*
diff --git a/lib/libc/string/strsignal.c b/lib/libc/string/strsignal.c
index 8fc1f851ca6f..7c461a3dbb80 100644
--- a/lib/libc/string/strsignal.c
+++ b/lib/libc/string/strsignal.c
@@ -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.
*
diff --git a/lib/libc/string/strspn.3 b/lib/libc/string/strspn.3
index 72a1d32941eb..2ba6a6b5575a 100644
--- a/lib/libc/string/strspn.3
+++ b/lib/libc/string/strspn.3
@@ -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.
.\"
diff --git a/lib/libc/string/strstr.3 b/lib/libc/string/strstr.3
index 376def6f2362..b1106b3c5759 100644
--- a/lib/libc/string/strstr.3
+++ b/lib/libc/string/strstr.3
@@ -14,7 +14,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.
.\"
diff --git a/lib/libc/string/strstr.c b/lib/libc/string/strstr.c
index 82b4c5a2085e..18e60d579881 100644
--- a/lib/libc/string/strstr.c
+++ b/lib/libc/string/strstr.c
@@ -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.
*
diff --git a/lib/libc/string/strtok.3 b/lib/libc/string/strtok.3
index e19579f8ece5..97a8b156b929 100644
--- a/lib/libc/string/strtok.3
+++ b/lib/libc/string/strtok.3
@@ -22,7 +22,7 @@
.\" disclaimer in the documentation and/or other materials provided
.\" with the distribution.
.\"
-.\" 4. Neither the name of Softweyr LLC, the University nor the names
+.\" 3. Neither the name of Softweyr LLC, 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.
diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c
index b0c428b770ce..063a554339a6 100644
--- a/lib/libc/string/strtok.c
+++ b/lib/libc/string/strtok.c
@@ -15,7 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notices, 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.
*
diff --git a/lib/libc/string/strxfrm.3 b/lib/libc/string/strxfrm.3
index da7c82ada5ce..f2750f4a385a 100644
--- a/lib/libc/string/strxfrm.3
+++ b/lib/libc/string/strxfrm.3
@@ -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.
.\"
diff --git a/lib/libc/string/swab.3 b/lib/libc/string/swab.3
index 0c9deea8463b..204b976ab1f4 100644
--- a/lib/libc/string/swab.3
+++ b/lib/libc/string/swab.3
@@ -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.
.\"
diff --git a/lib/libc/string/swab.c b/lib/libc/string/swab.c
index ec6cbf0f536f..84633094be3b 100644
--- a/lib/libc/string/swab.c
+++ b/lib/libc/string/swab.c
@@ -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.
*
diff --git a/lib/libc/string/wcscmp.c b/lib/libc/string/wcscmp.c
index 2d489149d066..c2abe4c797f7 100644
--- a/lib/libc/string/wcscmp.c
+++ b/lib/libc/string/wcscmp.c
@@ -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.
*
diff --git a/lib/libc/string/wcscoll.3 b/lib/libc/string/wcscoll.3
index 6a3eedbfec58..ba89fb3c268e 100644
--- a/lib/libc/string/wcscoll.3
+++ b/lib/libc/string/wcscoll.3
@@ -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.
.\"
diff --git a/lib/libc/string/wcsncmp.c b/lib/libc/string/wcsncmp.c
index 86d7a51cec43..8236d969feef 100644
--- a/lib/libc/string/wcsncmp.c
+++ b/lib/libc/string/wcsncmp.c
@@ -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.
*
diff --git a/lib/libc/string/wcsncpy.c b/lib/libc/string/wcsncpy.c
index 00d986b654b2..215e9a115156 100644
--- a/lib/libc/string/wcsncpy.c
+++ b/lib/libc/string/wcsncpy.c
@@ -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.
*
diff --git a/lib/libc/string/wcsstr.c b/lib/libc/string/wcsstr.c
index a9dc27bbf498..ce598a698969 100644
--- a/lib/libc/string/wcsstr.c
+++ b/lib/libc/string/wcsstr.c
@@ -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.
*
diff --git a/lib/libc/string/wcstok.c b/lib/libc/string/wcstok.c
index 5a77117f320e..441fbd444854 100644
--- a/lib/libc/string/wcstok.c
+++ b/lib/libc/string/wcstok.c
@@ -15,7 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notices, 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.
*
diff --git a/lib/libc/string/wcswidth.c b/lib/libc/string/wcswidth.c
index 4095c8d8cb17..bac979b5b9f0 100644
--- a/lib/libc/string/wcswidth.c
+++ b/lib/libc/string/wcswidth.c
@@ -23,7 +23,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.
*
diff --git a/lib/libc/string/wcsxfrm.3 b/lib/libc/string/wcsxfrm.3
index b5add9cebb45..ac30d38e1131 100644
--- a/lib/libc/string/wcsxfrm.3
+++ b/lib/libc/string/wcsxfrm.3
@@ -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.
.\"
diff --git a/lib/libc/string/wmemchr.3 b/lib/libc/string/wmemchr.3
index 30fb0917cf7f..37ba05031ca9 100644
--- a/lib/libc/string/wmemchr.3
+++ b/lib/libc/string/wmemchr.3
@@ -15,7 +15,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.
.\"
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index fef0f3c08e37..4cc87ae27860 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -85,6 +85,7 @@ MAN+= abort2.2 \
adjtime.2 \
aio_cancel.2 \
aio_error.2 \
+ aio_mlock.2 \
aio_read.2 \
aio_return.2 \
aio_suspend.2 \
@@ -270,6 +271,7 @@ MAN+= sctp_generic_recvmsg.2 \
wait.2 \
write.2
+MLINKS+=accept.2 accept4.2
MLINKS+=access.2 eaccess.2 \
access.2 faccessat.2
MLINKS+=brk.2 sbrk.2
@@ -351,6 +353,7 @@ MLINKS+=pathconf.2 lpathconf.2
MLINKS+=pdfork.2 pdgetpid.2\
pdfork.2 pdkill.2 \
pdfork.2 pdwait4.2
+MLINKS+=pipe.2 pipe2.2
MLINKS+=read.2 pread.2 \
read.2 preadv.2 \
read.2 readv.2
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
index 6faa0af50c50..222f5f0811f5 100644
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -363,7 +363,6 @@ FBSD_1.1 {
FBSD_1.2 {
cap_enter;
cap_getmode;
- cap_new;
getloginclass;
pdfork;
pdgetpid;
@@ -378,12 +377,14 @@ FBSD_1.2 {
};
FBSD_1.3 {
+ accept4;
+ aio_mlock;
bindat;
cap_fcntls_get;
cap_fcntls_limit;
cap_ioctls_get;
cap_ioctls_limit;
- cap_rights_get;
+ __cap_rights_get;
cap_rights_limit;
cap_sandboxed;
chflagsat;
@@ -392,6 +393,7 @@ FBSD_1.3 {
ffclock_getcounter;
ffclock_getestimate;
ffclock_setestimate;
+ pipe2;
posix_fadvise;
wait6;
};
@@ -461,6 +463,8 @@ FBSDprivate_1.0 {
__sys_abort2;
_accept;
__sys_accept;
+ _accept4;
+ __sys_accept4;
_access;
__sys_access;
_acct;
diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2
index 978b94801960..76fb463a1ef2 100644
--- a/lib/libc/sys/accept.2
+++ b/lib/libc/sys/accept.2
@@ -28,7 +28,7 @@
.\" @(#)accept.2 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd March 26, 2013
+.Dd May 1, 2013
.Dt ACCEPT 2
.Os
.Sh NAME
@@ -41,6 +41,8 @@
.In sys/socket.h
.Ft int
.Fn accept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen"
+.Ft int
+.Fn accept4 "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" "int flags"
.Sh DESCRIPTION
The argument
.Fa s
@@ -66,6 +68,26 @@ and
signals from the original socket
.Fa s .
.Pp
+The
+.Fn accept4
+system call is similar,
+but the
+.Dv O_NONBLOCK
+property of the new socket is instead determined by the
+.Dv SOCK_NONBLOCK
+flag in the
+.Fa flags
+argument,
+the
+.Dv O_ASYNC
+property is cleared,
+the signal destination is cleared
+and the close-on-exec flag on the new file descriptor can be set via the
+.Dv SOCK_CLOEXEC
+flag in the
+.Fa flags
+argument.
+.Pp
If no pending connections are
present on the queue, and the original socket
is not marked as non-blocking,
@@ -141,13 +163,15 @@ properties and the signal destination being inherited,
but should set them explicitly using
.Xr fcntl 2 .
.Sh RETURN VALUES
-The call returns \-1 on error.
-If it succeeds, it returns a non-negative
+These calls return \-1 on error.
+If they succeed, they return a non-negative
integer that is a descriptor for the accepted socket.
.Sh ERRORS
The
.Fn accept
-system call will fail if:
+and
+.Fn accept4
+system calls will fail if:
.Bl -tag -width Er
.It Bq Er EBADF
The descriptor is invalid.
@@ -164,10 +188,6 @@ The descriptor references a file, not a socket.
.It Bq Er EINVAL
.Xr listen 2
has not been called on the socket descriptor.
-.It Bq Er EINVAL
-The
-.Fa addrlen
-argument is negative.
.It Bq Er EFAULT
The
.Fa addr
@@ -180,6 +200,16 @@ are present to be accepted.
A connection arrived, but it was closed while waiting
on the listen queue.
.El
+.Pp
+The
+.Fn accept4
+system call will also fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa flags
+argument is invalid.
+.El
.Sh SEE ALSO
.Xr bind 2 ,
.Xr connect 2 ,
@@ -194,3 +224,8 @@ The
.Fn accept
system call appeared in
.Bx 4.2 .
+.Pp
+The
+.Fn accept4
+system call appeared in
+.Fx 10.0 .
diff --git a/lib/libc/sys/aio_mlock.2 b/lib/libc/sys/aio_mlock.2
new file mode 100644
index 000000000000..e24f95a191f5
--- /dev/null
+++ b/lib/libc/sys/aio_mlock.2
@@ -0,0 +1,133 @@
+.\" Copyright (c) 2013 Gleb Smirnoff <glebius@FreeBSD.org>
+.\" 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd June 3, 2013
+.Dt AIO_MLOCK 2
+.Os
+.Sh NAME
+.Nm aio_mlock
+.Nd asynchronous
+.Xr mlock 2
+operation
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In aio.h
+.Ft int
+.Fn aio_mlock "struct aiocb *iocb"
+.Sh DESCRIPTION
+The
+.Fn aio_mlock
+system call allows the calling process to lock into memory the
+physical pages associated with the virtual address range starting at
+.Fa iocb->aio_buf
+for
+.Fa iocb->aio_nbytes
+bytes.
+The call returns immediately after the locking request has
+been enqueued; the operation may or may not have completed at the time
+the call returns.
+.Pp
+The
+.Fa iocb
+pointer may be subsequently used as an argument to
+.Fn aio_return
+and
+.Fn aio_error
+in order to determine return or error status for the enqueued operation
+while it is in progress.
+.Pp
+If the request could not be enqueued (generally due to
+.Xr aio 4
+limits),
+then the call returns without having enqueued the request.
+.Sh RESTRICTIONS
+The Asynchronous I/O Control Block structure pointed to by
+.Fa iocb
+and the buffer that the
+.Fa iocb->aio_buf
+member of that structure references must remain valid until the
+operation has completed.
+For this reason, use of auto (stack) variables
+for these objects is discouraged.
+.Pp
+The asynchronous I/O control buffer
+.Fa iocb
+should be zeroed before the
+.Fn aio_mlock
+call to avoid passing bogus context information to the kernel.
+.Pp
+Modifications of the Asynchronous I/O Control Block structure or the
+buffer contents after the request has been enqueued, but before the
+request has completed, are not allowed.
+.Sh RETURN VALUES
+.Rv -std aio_mlock
+.Sh ERRORS
+The
+.Fn aio_read
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The request was not queued because of system resource limitations.
+.It Bq Er ENOSYS
+The
+.Fn aio_mlock
+system call is not supported.
+.El
+.Pp
+If the request is successfully enqueued, but subsequently cancelled
+or an error occurs, the value returned by the
+.Fn aio_return
+system call is per the
+.Xr mlock 2
+system call, and the value returned by the
+.Fn aio_error
+system call is one of the error returns from the
+.Xr mlock 2
+system call, or
+.Er ECANCELED
+if the request was explicitly cancelled via a call to
+.Fn aio_cancel .
+.Sh SEE ALSO
+.Xr aio_cancel 2 ,
+.Xr aio_error 2 ,
+.Xr aio_return 2 ,
+.Xr mlock 2 ,
+.Xr aio 4
+.Sh PORTABILITY
+The
+.Fn aio_mlock
+system call is a
+.Fx
+extension, and should not be used in portable code.
+.Sh HISTORY
+The
+.Fn aio_mlock
+system call first appeared in
+.Fx 10.0 .
+.Sh AUTHORS
+The system call was introduced by
+.An Gleb Smirnoff Aq glebius@FreeBSD.org .
diff --git a/lib/libc/sys/cap_ioctls_limit.2 b/lib/libc/sys/cap_ioctls_limit.2
index 2c21211956cf..771736acebb9 100644
--- a/lib/libc/sys/cap_ioctls_limit.2
+++ b/lib/libc/sys/cap_ioctls_limit.2
@@ -99,10 +99,10 @@ argument.
.Rv -std cap_ioctls_limit
.Pp
The
-.Fn cap_ioctls_limit
+.Fn cap_ioctls_get
function, if successfull, returns the total number of allowed ioctl commands or
the value
-.Dv INT_MAX
+.Dv CAP_IOCTLS_ALL
if all ioctls commands are allowed.
On failure the value
.Va -1
diff --git a/lib/libc/sys/cap_rights_limit.2 b/lib/libc/sys/cap_rights_limit.2
index 2e18dd2d306e..225efad1df94 100644
--- a/lib/libc/sys/cap_rights_limit.2
+++ b/lib/libc/sys/cap_rights_limit.2
@@ -77,7 +77,9 @@ The following rights may be specified in a rights mask:
.Bl -tag -width CAP_EXTATTR_DELETE
.It Dv CAP_ACCEPT
Permit
-.Xr accept 2 .
+.Xr accept 2
+and
+.Xr accept4 2 .
.It Dv CAP_ACL_CHECK
Permit checking of an ACL on a file descriptor; there is no cross-reference
for this system call.
diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2
index 5bc2ba225e6c..2fcc89f2f46c 100644
--- a/lib/libc/sys/chflags.2
+++ b/lib/libc/sys/chflags.2
@@ -112,26 +112,61 @@ The flags specified are formed by
the following values
.Pp
.Bl -tag -width ".Dv SF_IMMUTABLE" -compact -offset indent
-.It Dv UF_NODUMP
-Do not dump the file.
-.It Dv UF_IMMUTABLE
-The file may not be changed.
-.It Dv UF_APPEND
+.It Dv SF_APPEND
The file may only be appended to.
-.It Dv UF_NOUNLINK
-The file may not be renamed or deleted.
-.It Dv UF_OPAQUE
-The directory is opaque when viewed through a union stack.
.It Dv SF_ARCHIVED
-The file may be archived.
+The file has been archived.
+This flag means the opposite of the DOS, Windows and CIFS
+FILE_ATTRIBUTE_ARCHIVE attribute.
+This flag has been deprecated, and may be removed in a future release.
.It Dv SF_IMMUTABLE
The file may not be changed.
-.It Dv SF_APPEND
-The file may only be appended to.
.It Dv SF_NOUNLINK
The file may not be renamed or deleted.
.It Dv SF_SNAPSHOT
The file is a snapshot file.
+.It Dv UF_APPEND
+The file may only be appended to.
+.It Dv UF_ARCHIVE
+The file needs to be archived.
+This flag has the same meaning as the DOS, Windows and CIFS
+FILE_ATTRIBUTE_ARCHIVE attribute.
+Filesystems in FreeBSD may or may not have special handling for this flag.
+For instance, ZFS tracks changes to files and will set this bit when a
+file is updated.
+UFS only stores the flag, and relies on the application to change it when
+needed.
+.It Dv UF_HIDDEN
+The file may be hidden from directory listings at the application's
+discretion.
+The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_HIDDEN attribute.
+.It Dv UF_IMMUTABLE
+The file may not be changed.
+.It Dv UF_NODUMP
+Do not dump the file.
+.It Dv UF_NOUNLINK
+The file may not be renamed or deleted.
+.It Dv UF_OFFLINE
+The file is offline, or has the Windows and CIFS FILE_ATTRIBUTE_OFFLINE
+attribute.
+Filesystems in FreeBSD store and display this flag, but do not provide any
+special handling when it is set.
+.It Dv UF_OPAQUE
+The directory is opaque when viewed through a union stack.
+.It Dv UF_READONLY
+The file is read only, and may not be written or appended.
+Filesystems may use this flag to maintain compatibility with the DOS, Windows
+and CIFS FILE_ATTRIBUTE_READONLY attribute.
+.It Dv UF_REPARSE
+The file contains a Windows reparse point and has the Windows and CIFS
+FILE_ATTRIBUTE_REPARSE_POINT attribute.
+.It Dv UF_SPARSE
+The file has the Windows FILE_ATTRIBUTE_SPARSE_FILE attribute.
+This may also be used by a filesystem to indicate a sparse file.
+.It Dv UF_SYSTEM
+The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_SYSTEM attribute.
+Filesystems in FreeBSD may store and display this flag, but do not provide
+any special handling when it is set.
.El
.Pp
If one of
@@ -162,6 +197,13 @@ the system is in single-user mode.
.Xr init 8
for details.)
.Pp
+The implementation of all flags is filesystem-dependent.
+See the description of the
+.Dv UF_ARCHIVE
+flag above for one example of the differences in behavior.
+Care should be exercised when writing applications to account for
+support or lack of support of these flags in various filesystems.
+.Pp
The
.Dv SF_SNAPSHOT
flag is maintained by the system and cannot be toggled.
diff --git a/lib/libc/sys/cpuset.2 b/lib/libc/sys/cpuset.2
index 652d3aea7738..5a1d6955c984 100644
--- a/lib/libc/sys/cpuset.2
+++ b/lib/libc/sys/cpuset.2
@@ -216,7 +216,6 @@ for allocation.
.Xr cpuset 1 ,
.Xr cpuset_getaffinity 2 ,
.Xr cpuset_setaffinity 2 ,
-.Xr CPU_SET 3 ,
.Xr pthread_affinity_np 3 ,
.Xr pthread_attr_affinity_np 3
.Sh HISTORY
diff --git a/lib/libc/sys/cpuset_getaffinity.2 b/lib/libc/sys/cpuset_getaffinity.2
index 4fbbc4e851e2..93cfe95dae22 100644
--- a/lib/libc/sys/cpuset_getaffinity.2
+++ b/lib/libc/sys/cpuset_getaffinity.2
@@ -26,7 +26,7 @@
.\" $FreeBSD$
.\"
.Dd September 10, 2010
-.Dt CPUSET 2
+.Dt CPUSET_GETAFFINITY 2
.Os
.Sh NAME
.Nm cpuset_getaffinity ,
@@ -69,7 +69,7 @@ All resources, however, have a mask which may be manipulated with
Masks of type
.Ft cpuset_t
are composed using the
-.Xr CPU_SET 2
+.Dv CPU_SET
macros.
The kernel tolerates large sets as long as all CPUs specified
in the set exist.
@@ -152,7 +152,6 @@ operation.
.Xr cpuset 2 ,
.Xr cpuset_getid 2 ,
.Xr cpuset_setid 2 ,
-.Xr CPU_SET 3 ,
.Xr pthread_affinity_np 3 ,
.Xr pthread_attr_affinity_np 3
.Sh HISTORY
diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2
index 6e1de206470e..f21c93b5868b 100644
--- a/lib/libc/sys/dup.2
+++ b/lib/libc/sys/dup.2
@@ -28,7 +28,7 @@
.\" @(#)dup.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd August 14, 2011
+.Dd June 1, 2013
.Dt DUP 2
.Os
.Sh NAME
@@ -56,9 +56,6 @@ The argument
.Fa oldd
is a small non-negative integer index in
the per-process descriptor table.
-The value must be less
-than the size of the table, which is returned by
-.Xr getdtablesize 2 .
The new descriptor returned by the call
is the lowest numbered descriptor
currently not in use by the process.
@@ -116,10 +113,11 @@ is a valid descriptor, then
.Fn dup2
is successful, and does nothing.
.Sh RETURN VALUES
-The value -1 is returned if an error occurs in either call.
-The external variable
+These calls return the new file descriptor if successful;
+otherwise the value -1 is returned and
+the external variable
.Va errno
-indicates the cause of the error.
+is set to indicate the cause of the error.
.Sh ERRORS
The
.Fn dup
@@ -153,7 +151,8 @@ argument is negative or exceeds the maximum allowable descriptor number
.Xr open 2 ,
.Xr pipe 2 ,
.Xr socket 2 ,
-.Xr socketpair 2
+.Xr socketpair 2 ,
+.Xr dup3 3
.Sh STANDARDS
The
.Fn dup
diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2
index 4a8a646edb4a..1ad2052ff069 100644
--- a/lib/libc/sys/fork.2
+++ b/lib/libc/sys/fork.2
@@ -28,7 +28,7 @@
.\" @(#)fork.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd May 31, 2013
.Dt FORK 2
.Os
.Sh NAME
@@ -37,7 +37,6 @@
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In sys/types.h
.In unistd.h
.Ft pid_t
.Fn fork void
@@ -74,6 +73,17 @@ are set to 0; see
.It
All interval timers are cleared; see
.Xr setitimer 2 .
+.It
+The child process has only one thread,
+corresponding to the calling thread in the parent process.
+If the process has more than one thread,
+locks and other resources held by the other threads are not released
+and therefore only async-signal-safe functions
+(see
+.Xr sigaction 2 )
+are guaranteed to work in the child process until a call to
+.Xr execve 2
+or a similar function.
.El
.Sh RETURN VALUES
Upon successful completion,
@@ -125,6 +135,7 @@ There is insufficient swap space for the new process.
.Xr rfork 2 ,
.Xr setitimer 2 ,
.Xr setrlimit 2 ,
+.Xr sigaction 2 ,
.Xr vfork 2 ,
.Xr wait 2
.Sh HISTORY
diff --git a/lib/libc/sys/getdtablesize.2 b/lib/libc/sys/getdtablesize.2
index 916b91ef356d..d52da83000a3 100644
--- a/lib/libc/sys/getdtablesize.2
+++ b/lib/libc/sys/getdtablesize.2
@@ -28,12 +28,12 @@
.\" @(#)getdtablesize.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd April 24, 2013
.Dt GETDTABLESIZE 2
.Os
.Sh NAME
.Nm getdtablesize
-.Nd get descriptor table size
+.Nd get file descriptor limit
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
@@ -41,18 +41,20 @@
.Ft int
.Fn getdtablesize void
.Sh DESCRIPTION
-Each process has a fixed size descriptor table,
-which is guaranteed to have at least 20 slots.
-The entries in
-the descriptor table are numbered with small integers starting at 0.
The
.Fn getdtablesize
-system call returns the size of this table.
+system call returns the maximum number of file descriptors
+that the current process may open.
+The maximum file descriptor number that the system may assign
+is the return value minus one.
+Existing file descriptor numbers may be higher
+if the limit was lowered after they were opened.
.Sh SEE ALSO
.Xr close 2 ,
+.Xr closefrom 2 ,
.Xr dup 2 ,
-.Xr open 2 ,
-.Xr select 2
+.Xr getrlimit 2 ,
+.Xr sysconf 2
.Sh HISTORY
The
.Fn getdtablesize
diff --git a/lib/libc/sys/intro.2 b/lib/libc/sys/intro.2
index 1a22ea2d7ba2..bc10b1de59de 100644
--- a/lib/libc/sys/intro.2
+++ b/lib/libc/sys/intro.2
@@ -28,7 +28,7 @@
.\" @(#)intro.2 8.5 (Berkeley) 2/27/95
.\" $FreeBSD$
.\"
-.Dd February 27, 1995
+.Dd May 4, 2013
.Dt INTRO 2
.Os
.Sh NAME
@@ -189,12 +189,13 @@ or a
.Xr kill 2
system call).
.It Er 23 ENFILE Em "Too many open files in system" .
-Maximum number of file descriptors allowable on the system
-has been reached and a requests for an open cannot be satisfied
+Maximum number of open files allowable on the system
+has been reached and requests for an open cannot be satisfied
until at least one has been closed.
.It Er 24 EMFILE Em "Too many open files" .
-(As released, the limit on the number of
-open files per process is 64.)
+Maximum number of file descriptors allowable in the process
+has been reached and requests for an open cannot be satisfied
+until at least one has been closed.
The
.Xr getdtablesize 2
system call will obtain the current limit.
@@ -469,6 +470,10 @@ An operation on a capability file descriptor requires greater privilege than
the capability allows.
.It Er 94 ECAPMODE Em "Not permitted in capability mode" .
The system call or operation is not permitted for capability mode processes.
+.It Er 95 ENOTRECOVERABLE Em "State not recoverable" .
+The state protected by a robust mutex is not recoverable.
+.It Er 96 EOWNERDEAD Em "Previous owner died" .
+The owner of a robust mutex terminated while holding the mutex lock.
.El
.Sh DEFINITIONS
.Bl -tag -width Ds
diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
index 6ae79143d621..ed3a8adfa730 100644
--- a/lib/libc/sys/kqueue.2
+++ b/lib/libc/sys/kqueue.2
@@ -388,20 +388,25 @@ The process has called
.It NOTE_EXEC
The process has executed a new process via
.Xr execve 2
-or similar call.
+or a similar call.
.It NOTE_TRACK
Follow a process across
.Fn fork
calls.
-The parent process will return with NOTE_TRACK set in the
+The parent process registers a new kevent to monitor the child process
+using the same
.Va fflags
-field, while the child process will return with NOTE_CHILD set in
+as the original event.
+The child process will signal an event with NOTE_CHILD set in
.Va fflags
and the parent PID in
.Va data .
-.It NOTE_TRACKERR
-This flag is returned if the system was unable to attach an event to
-the child process, usually due to resource limitations.
+.Pp
+If the parent process fails to register a new kevent
+.Pq usually due to resource limitations ,
+it will signal an event with NOTE_TRACKERR set in
+.Va fflags ,
+and the child process will not signal a NOTE_CHILD event.
.El
.Pp
On return,
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2
index 73ffb2ead67b..130f70bcaa88 100644
--- a/lib/libc/sys/mmap.2
+++ b/lib/libc/sys/mmap.2
@@ -28,7 +28,7 @@
.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95
.\" $FreeBSD$
.\"
-.Dd March 18, 2012
+.Dd August 16, 2013
.Dt MMAP 2
.Os
.Sh NAME
@@ -97,7 +97,30 @@ Sharing, mapping type and options are specified in the
argument by
.Em or Ns 'ing
the following values:
-.Bl -tag -width MAP_HASSEMAPHORE
+.Bl -tag -width MAP_PREFAULT_READ
+.It Dv MAP_ALIGNED Ns Pq Fa n
+Align the region on a requested boundary.
+If a suitable region cannot be found,
+.Fn mmap
+will fail.
+The
+.Fa n
+argument specifies the binary logarithm of the desired alignment.
+.It Dv MAP_ALIGNED_SUPER
+Align the region to maximize the potential use of large
+.Pq Dq super
+pages.
+If a suitable region cannot be found,
+.Fn mmap
+will fail.
+The system will choose a suitable page size based on the size of
+mapping.
+The page size used as well as the alignment of the region may both be
+affected by properties of the file being mapped.
+In particular,
+the physical address of existing pages of a file may require a specific
+alignment.
+The region is not guaranteed to be aligned on any specific boundary.
.It Dv MAP_ANON
Map anonymous memory not associated with any specific file.
The file descriptor used for creating
@@ -274,6 +297,25 @@ Although this implementation does not impose any alignment restrictions on
the
.Fa offset
argument, a portable program must only use page-aligned values.
+.Pp
+Large page mappings require that the pages backing an object be
+aligned in matching blocks in both the virtual address space and RAM.
+The system will automatically attempt to use large page mappings when
+mapping an object that is already backed by large pages in RAM by
+aligning the mapping request in the virtual address space to match the
+alignment of the large physical pages.
+The system may also use large page mappings when mapping portions of an
+object that are not yet backed by pages in RAM.
+The
+.Dv MAP_ALIGNED_SUPER
+flag is an optimization that will align the mapping request to the
+size of a large page similar to
+.Dv MAP_ALIGNED ,
+except that the system will override this alignment if an object already
+uses large pages so that the mapping will be consistent with the existing
+large pages.
+This flag is mostly useful for maximizing the use of large pages on the
+first mapping of objects that do not yet have pages present in RAM.
.Sh RETURN VALUES
Upon successful completion,
.Fn mmap
@@ -325,6 +367,10 @@ The
argument
was equal to zero.
.It Bq Er EINVAL
+.Dv MAP_ALIGNED
+was specified and the desired alignment was either larger than the
+virtual address size of the machine or smaller than a page.
+.It Bq Er EINVAL
.Dv MAP_ANON
was specified and the
.Fa fd
@@ -356,7 +402,8 @@ was specified and insufficient memory was available.
.Xr msync 2 ,
.Xr munlock 2 ,
.Xr munmap 2 ,
-.Xr getpagesize 3
+.Xr getpagesize 3 ,
+.Xr getpagesizes 3
.Sh BUGS
The
.Fa len
diff --git a/lib/libc/sys/pdfork.2 b/lib/libc/sys/pdfork.2
index ad33566cc096..26d0eb0fe363 100644
--- a/lib/libc/sys/pdfork.2
+++ b/lib/libc/sys/pdfork.2
@@ -1,10 +1,14 @@
.\"
-.\" Copyright (c) 2009-2010, 2012 Robert N. M. Watson
+.\" Copyright (c) 2009-2010, 2012-2013 Robert N. M. Watson
.\" All rights reserved.
.\"
.\" This software was developed at the University of Cambridge Computer
.\" Laboratory with support from a grant from Google, Inc.
.\"
+.\" This software was developed by SRI International and the University of
+.\" Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+.\" ("CTSRD"), as part of the DARPA CRASH research programme.
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -28,7 +32,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 25, 2012
+.Dd August 28, 2013
.Dt PDFORK 2
.Os
.Sh NAME
@@ -71,7 +75,9 @@ Instead of the default terminate-on-close behaviour, allow the process to
live until it is explicitly killed with
.Xr kill 2 .
.Pp
-This option is not permitted in Capsicum capability mode (see
+This option is not permitted in
+.Xr capsicum 4
+capability mode (see
.Xr cap_enter 2 ) .
.El
.Pp
@@ -119,6 +125,12 @@ is set; if the process is still alive and this is
the last reference to the process descriptor, the process will be terminated
with the signal
.Dv SIGKILL .
+.Pp
+.Nm
+and associated functions depend on
+.Cd "options PROCDESC"
+described in
+.Xr procdesc 4 .
.Sh RETURN VALUES
.Fn pdfork
returns a PID, 0 or -1, as
@@ -156,7 +168,9 @@ for
.Xr fstat 2 ,
.Xr kill 2 ,
.Xr poll 2 ,
-.Xr wait4 2
+.Xr wait4 2 ,
+.Xr capsicum 4 ,
+.Xr procdesc 4
.Sh HISTORY
The
.Fn pdfork ,
diff --git a/lib/libc/sys/pipe.2 b/lib/libc/sys/pipe.2
index 92d137fda091..6ea0f14136ad 100644
--- a/lib/libc/sys/pipe.2
+++ b/lib/libc/sys/pipe.2
@@ -28,7 +28,7 @@
.\" @(#)pipe.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd January 30, 2006
+.Dd May 1, 2013
.Dt PIPE 2
.Os
.Sh NAME
@@ -40,6 +40,8 @@
.In unistd.h
.Ft int
.Fn pipe "int fildes[2]"
+.Ft int
+.Fn pipe2 "int fildes[2]" "int flags"
.Sh DESCRIPTION
The
.Fn pipe
@@ -50,6 +52,29 @@ which is an object allowing
bidirectional data flow,
and allocates a pair of file descriptors.
.Pp
+The
+.Fn pipe2
+system call allows control over the attributes of the file descriptors
+via the
+.Fa flags
+argument.
+Values for
+.Fa flags
+are constructed by a bitwise-inclusive OR of flags from the following
+list, defined in
+.In fcntl.h :
+.Bl -tag -width ".Dv O_NONBLOCK"
+.It Dv O_CLOEXEC
+Set the close-on-exec flag for the new file descriptors.
+.It Dv O_NONBLOCK
+Set the non-blocking flag for the ends of the pipe.
+.El
+.Pp
+If the
+.Fa flags
+argument is 0, the behavior is identical to a call to
+.Fn pipe .
+.Pp
By convention, the first descriptor is normally used as the
.Em read end
of the pipe,
@@ -88,7 +113,9 @@ pipe in one direction.
.Sh ERRORS
The
.Fn pipe
-system call will fail if:
+and
+.Fn pipe2
+system calls will fail if:
.Bl -tag -width Er
.It Bq Er EMFILE
Too many descriptors are active.
@@ -97,6 +124,16 @@ The system file table is full.
.It Bq Er ENOMEM
Not enough kernel memory to establish a pipe.
.El
+.Pp
+The
+.Fn pipe2
+system call will also fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa flags
+argument is invalid.
+.El
.Sh SEE ALSO
.Xr sh 1 ,
.Xr fork 2 ,
@@ -111,3 +148,8 @@ function appeared in
.Pp
Bidirectional pipes were first used on
.At V.4 .
+.Pp
+The
+.Fn pipe2
+function appeared in
+.Fx 10.0 .
diff --git a/lib/libc/sys/pselect.2 b/lib/libc/sys/pselect.2
index cf784a5dcd7f..ed66aade1cde 100644
--- a/lib/libc/sys/pselect.2
+++ b/lib/libc/sys/pselect.2
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 27, 2009
+.Dd August 16, 2013
.Dt PSELECT 2
.Os
.Sh NAME
@@ -104,7 +104,8 @@ and (if a signal mask is provided)
.Xr kqueue 2 ,
.Xr poll 2 ,
.Xr select 2 ,
-.Xr sigprocmask 2
+.Xr sigprocmask 2 ,
+.Xr sigsuspend 2
.Sh STANDARDS
The
.Fn pselect
diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2
index 90c45442561e..458ad8dbaf3d 100644
--- a/lib/libc/sys/ptrace.2
+++ b/lib/libc/sys/ptrace.2
@@ -2,7 +2,7 @@
.\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
.\"
.\" This file is in the public domain.
-.Dd February 7, 2013
+.Dd July 22, 2013
.Dt PTRACE 2
.Os
.Sh NAME
@@ -556,6 +556,14 @@ was attempted on a process with no valid register set.
was given an invalid value for
.Fa pve_entry .
This can also be caused by changes to the VM map of the process.
+.It
+The size (in
+.Fa data )
+provided to
+.Dv PT_LWPINFO
+was less than or equal to zero, or larger than the
+.Vt ptrace_lwpinfo
+structure known to the kernel.
.El
.It Bq Er EBUSY
.Bl -bullet -compact
diff --git a/lib/libc/sys/sctp_generic_recvmsg.2 b/lib/libc/sys/sctp_generic_recvmsg.2
index d6fd1b564de2..8ee3d36f90e9 100644
--- a/lib/libc/sys/sctp_generic_recvmsg.2
+++ b/lib/libc/sys/sctp_generic_recvmsg.2
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/sys/sctp_generic_sendmsg.2 b/lib/libc/sys/sctp_generic_sendmsg.2
index 1a2b12866d97..bf54e95473d5 100644
--- a/lib/libc/sys/sctp_generic_sendmsg.2
+++ b/lib/libc/sys/sctp_generic_sendmsg.2
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/sys/sctp_peeloff.2 b/lib/libc/sys/sctp_peeloff.2
index 40a026d8139d..9964586c9e9e 100644
--- a/lib/libc/sys/sctp_peeloff.2
+++ b/lib/libc/sys/sctp_peeloff.2
@@ -9,11 +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.
-.\" 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.
.\"
diff --git a/lib/libc/sys/setfib.2 b/lib/libc/sys/setfib.2
index bf23c7a97792..d759109fa39e 100644
--- a/lib/libc/sys/setfib.2
+++ b/lib/libc/sys/setfib.2
@@ -64,10 +64,13 @@ with
where
.Em N
is an integer.
-However, this maximum is capped at 16 due to the implementation storing
-the fib number in a 4-bit field in
+This maximum is capped at 65536 due to the implementation storing
+the fib number in a 16-bit field in the
.Xr mbuf 9
-flags.
+packet header, however it is not suggested that one use such a large number
+as memory is allocated for every FIB regardless of whether it is used, and
+there are places where all FIBs are iterated over.
+.Pp
The default fib of the process will be applied to all protocol families
that support multiple fibs, and ignored by those that do not.
The default fib for a process may be overridden for a socket with the use
diff --git a/lib/libc/sys/sigaction.2 b/lib/libc/sys/sigaction.2
index e161bf2000bf..d975ef931653 100644
--- a/lib/libc/sys/sigaction.2
+++ b/lib/libc/sys/sigaction.2
@@ -28,7 +28,7 @@
.\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94
.\" $FreeBSD$
.\"
-.Dd September 27, 2012
+.Dd June 8, 2013
.Dt SIGACTION 2
.Os
.Sh NAME
@@ -346,13 +346,19 @@ Any attempt to do so will be silently ignored.
The following functions are either reentrant or not interruptible
by signals and are async-signal safe.
Therefore applications may
-invoke them, without restriction, from signal-catching functions:
+invoke them, without restriction, from signal-catching functions
+or from a child process after calling
+.Xr fork 2
+in a multi-threaded process:
.Pp
Base Interfaces:
.Pp
+.Fn _Exit ,
.Fn _exit ,
+.Fn accept ,
.Fn access ,
.Fn alarm ,
+.Fn bind ,
.Fn cfgetispeed ,
.Fn cfgetospeed ,
.Fn cfsetispeed ,
@@ -361,41 +367,76 @@ Base Interfaces:
.Fn chmod ,
.Fn chown ,
.Fn close ,
+.Fn connect ,
.Fn creat ,
.Fn dup ,
.Fn dup2 ,
+.Fn execl ,
.Fn execle ,
+.Fn execv ,
.Fn execve ,
+.Fn faccessat ,
+.Fn fchdir ,
+.Fn fchmod ,
+.Fn fchmodat ,
+.Fn fchown ,
+.Fn fchownat ,
.Fn fcntl ,
.Fn fork ,
-.Fn fpathconf ,
.Fn fstat ,
+.Fn fstatat ,
.Fn fsync ,
+.Fn ftruncate ,
.Fn getegid ,
.Fn geteuid ,
.Fn getgid ,
.Fn getgroups ,
+.Fn getpeername ,
.Fn getpgrp ,
.Fn getpid ,
.Fn getppid ,
+.Fn getsockname ,
+.Fn getsockopt ,
.Fn getuid ,
.Fn kill ,
.Fn link ,
+.Fn linkat ,
+.Fn listen ,
.Fn lseek ,
+.Fn lstat ,
.Fn mkdir ,
+.Fn mkdirat ,
.Fn mkfifo ,
+.Fn mkfifoat ,
+.Fn mknod ,
+.Fn mknodat ,
.Fn open ,
-.Fn pathconf ,
+.Fn openat ,
.Fn pause ,
.Fn pipe ,
+.Fn poll ,
+.Fn pselect ,
+.Fn pthread_sigmask ,
.Fn raise ,
.Fn read ,
+.Fn readlink ,
+.Fn readlinkat ,
+.Fn recv ,
+.Fn recvfrom ,
+.Fn recvmsg ,
.Fn rename ,
+.Fn renameat ,
.Fn rmdir ,
+.Fn select ,
+.Fn send ,
+.Fn sendmsg ,
+.Fn sendto ,
.Fn setgid ,
.Fn setpgid ,
.Fn setsid ,
+.Fn setsockopt ,
.Fn setuid ,
+.Fn shutdown ,
.Fn sigaction ,
.Fn sigaddset ,
.Fn sigdelset ,
@@ -407,8 +448,12 @@ Base Interfaces:
.Fn sigprocmask ,
.Fn sigsuspend ,
.Fn sleep ,
+.Fn sockatmark ,
+.Fn socket ,
+.Fn socketpair ,
.Fn stat ,
-.Fn sysconf ,
+.Fn symlink ,
+.Fn symlinkat ,
.Fn tcdrain ,
.Fn tcflow ,
.Fn tcflush ,
@@ -422,16 +467,22 @@ Base Interfaces:
.Fn umask ,
.Fn uname ,
.Fn unlink ,
+.Fn unlinkat ,
.Fn utime ,
.Fn wait ,
.Fn waitpid ,
.Fn write .
.Pp
+X/Open Systems Interfaces:
+.Pp
+.Fn sigpause ,
+.Fn sigset ,
+.Fn utimes .
+.Pp
Realtime Interfaces:
.Pp
.Fn aio_error ,
.Fn clock_gettime ,
-.Fn sigpause ,
.Fn timer_getoverrun ,
.Fn aio_return ,
.Fn fdatasync ,
@@ -439,27 +490,98 @@ Realtime Interfaces:
.Fn timer_gettime ,
.Fn aio_suspend ,
.Fn sem_post ,
-.Fn sigset ,
.Fn timer_settime .
.Pp
-.Tn ANSI C
-Interfaces:
+Base Interfaces not specified as async-signal safe by
+.Tn POSIX :
.Pp
-.Fn strcpy ,
+.Fn fpathconf ,
+.Fn pathconf ,
+.Fn sysconf .
+.Pp
+Base Interfaces not specified as async-signal safe by
+.Tn POSIX ,
+but planned to be:
+.Pp
+.Fn ffs ,
+.Fn htonl ,
+.Fn htons ,
+.Fn memccpy ,
+.Fn memchr ,
+.Fn memcmp ,
+.Fn memcpy ,
+.Fn memmove ,
+.Fn memset ,
+.Fn ntohl ,
+.Fn ntohs ,
+.Fn stpcpy ,
+.Fn stpncpy ,
.Fn strcat ,
-.Fn strncpy ,
+.Fn strchr ,
+.Fn strcmp ,
+.Fn strcpy ,
+.Fn strcspn ,
+.Fn strlen ,
.Fn strncat ,
-and perhaps some others.
+.Fn strncmp ,
+.Fn strncpy ,
+.Fn strnlen ,
+.Fn strpbrk ,
+.Fn strrchr ,
+.Fn strspn ,
+.Fn strstr ,
+.Fn strtok_r ,
+.Fn wcpcpy ,
+.Fn wcpncpy ,
+.Fn wcscat ,
+.Fn wcschr ,
+.Fn wcscmp ,
+.Fn wcscpy ,
+.Fn wcscspn ,
+.Fn wcslen ,
+.Fn wcsncat ,
+.Fn wcsncmp ,
+.Fn wcsncpy ,
+.Fn wcsnlen ,
+.Fn wcspbrk ,
+.Fn wcsrchr ,
+.Fn wcsspn ,
+.Fn wcsstr ,
+.Fn wcstok ,
+.Fn wmemchr ,
+.Fn wmemcmp ,
+.Fn wmemcpy ,
+.Fn wmemmove ,
+.Fn wmemset .
.Pp
Extension Interfaces:
.Pp
-.Fn strlcpy ,
+.Fn accept4 ,
+.Fn bindat ,
+.Fn closefrom ,
+.Fn connectat ,
+.Fn eaccess ,
+.Fn ffsl ,
+.Fn ffsll ,
+.Fn flock ,
+.Fn fls ,
+.Fn flsl ,
+.Fn flsll ,
+.Fn futimesat ,
+.Fn pipe2 ,
.Fn strlcat .
+.Fn strlcpy ,
+.Fn strsep .
+.Pp
+In addition, reading or writing
+.Va errno
+is async-signal safe.
.Pp
All functions not in the above lists are considered to be unsafe
with respect to signals.
That is to say, the behaviour of such
-functions when called from a signal handler is undefined.
+functions is undefined when they are called from a signal handler
+that interrupted an unsafe function.
In general though, signal handlers should do little more than set a
flag; most other actions are not safe.
.Pp
diff --git a/lib/libc/sys/sigreturn.2 b/lib/libc/sys/sigreturn.2
index 02d75a83b6ed..13d76f68d48b 100644
--- a/lib/libc/sys/sigreturn.2
+++ b/lib/libc/sys/sigreturn.2
@@ -56,10 +56,6 @@ Execution resumes at the specified pc.
This system call is used by the trampoline code and
.Xr longjmp 3
when returning from a signal to the previously executing program.
-.Sh NOTES
-This system call is not available in
-.Bx 4.2
-hence it should not be used if backward compatibility is needed.
.Sh RETURN VALUES
If successful, the system call does not return.
Otherwise, a value of -1 is returned and
diff --git a/lib/libc/sys/sigsuspend.2 b/lib/libc/sys/sigsuspend.2
index 3a67b53374d4..0ffc11dc4f3e 100644
--- a/lib/libc/sys/sigsuspend.2
+++ b/lib/libc/sys/sigsuspend.2
@@ -28,7 +28,7 @@
.\" @(#)sigsuspend.2 8.2 (Berkeley) 5/16/95
.\" $FreeBSD$
.\"
-.Dd May 16, 1995
+.Dd August 16, 2013
.Dt SIGSUSPEND 2
.Os
.Sh NAME
@@ -70,9 +70,13 @@ always terminates by being interrupted, returning -1 with
set to
.Er EINTR .
.Sh SEE ALSO
+.Xr pselect 2 ,
.Xr sigaction 2 ,
.Xr sigpending 2 ,
.Xr sigprocmask 2 ,
+.Xr sigtimedwait 2 ,
+.Xr sigwait 2 ,
+.Xr sigwaitinfo 2 ,
.Xr sigsetops 3
.Sh STANDARDS
The
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c
index ae35fb969c17..cd5992286054 100644
--- a/lib/libcam/camlib.c
+++ b/lib/libcam/camlib.c
@@ -633,7 +633,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
"%s: %s", func_name, func_name, strerror(errno));
goto crod_bailout;
}
- if (ccb.cts.protocol == XPORT_SPI) {
+ if (ccb.cts.transport == XPORT_SPI) {
struct ccb_trans_settings_spi *spi =
&ccb.cts.xport_specific.spi;
device->sync_period = spi->sync_period;
diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile
index a9daada4742f..8c560d7b3681 100644
--- a/lib/libcompiler_rt/Makefile
+++ b/lib/libcompiler_rt/Makefile
@@ -28,6 +28,7 @@ SRCF= absvdi2 \
ashlti3 \
ashrdi3 \
ashrti3 \
+ clear_cache \
clzdi2 \
clzsi2 \
clzti2 \
@@ -125,11 +126,6 @@ SRCF= absvdi2 \
umoddi3 \
umodti3
-# Don't build clear_cache on ARM with clang as it is a builtin there.
-.if ${MACHINE_CPUARCH} != "arm" || ${COMPILER_TYPE} != "clang"
-SRCF+= clear_cache
-.endif
-
# These are already shipped by libc.a on arm and mips
.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
SRCF+= adddf3 \
@@ -156,25 +152,16 @@ SRCF+= divsi3 \
umodsi3
.endif
-# FreeBSD-specific atomic intrinsics. Clang provides them as a builtin.
-.if (${MACHINE_CPUARCH} == "arm" && ${COMPILER_TYPE} != "clang") || \
- ${MACHINE_CPUARCH} == "mips"
-SRCF+= __sync_fetch_and_add_4 \
- __sync_fetch_and_and_4 \
- __sync_fetch_and_or_4 \
- __sync_fetch_and_sub_4 \
- __sync_fetch_and_xor_4 \
- __sync_lock_test_and_set_4 \
- __sync_val_compare_and_swap_4
-.endif
-.if ${MACHINE_ARCH:Mmips64*} != ""
-SRCF+= __sync_fetch_and_add_8 \
- __sync_fetch_and_and_8 \
- __sync_fetch_and_or_8 \
- __sync_fetch_and_sub_8 \
- __sync_fetch_and_xor_8 \
- __sync_lock_test_and_set_8 \
- __sync_val_compare_and_swap_8
+# FreeBSD-specific atomic intrinsics.
+.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "armv6"
+.PATH: ${.CURDIR}/../../sys/arm/arm
+
+SRCF+= stdatomic
+CFLAGS+= -DEMIT_SYNC_ATOMICS
+.elif ${MACHINE_CPUARCH} == "mips"
+.PATH: ${.CURDIR}/../../sys/mips/mips
+
+SRCF+= stdatomic
.endif
.for file in ${SRCF}
@@ -196,13 +183,11 @@ SRCS+= aeabi_idivmod.S \
aeabi_uldivmod.S
.endif
-.if ${MACHINE_CPUARCH} != "mips"
-. if ${MK_INSTALLLIB} != "no"
+.if ${MK_INSTALLLIB} != "no"
SYMLINKS+=libcompiler_rt.a ${LIBDIR}/libgcc.a
-. endif
-. if ${MK_PROFILE} != "no"
+.endif
+.if ${MK_PROFILE} != "no"
SYMLINKS+=libcompiler_rt_p.a ${LIBDIR}/libgcc_p.a
-. endif
.endif
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || \
diff --git a/lib/libcompiler_rt/__sync_fetch_and_add_4.c b/lib/libcompiler_rt/__sync_fetch_and_add_4.c
deleted file mode 100644
index 3c11a3b87dd1..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_add_4.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_add_4
-#define TYPE uint32_t
-#define FETCHADD(x, y) atomic_fetchadd_32(x, y)
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_add_8.c b/lib/libcompiler_rt/__sync_fetch_and_add_8.c
deleted file mode 100644
index 6157c151767a..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_add_8.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_add_8
-#define TYPE uint64_t
-#define FETCHADD(x, y) atomic_fetchadd_64(x, y)
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_and_4.c b/lib/libcompiler_rt/__sync_fetch_and_and_4.c
deleted file mode 100644
index 1a488ec27887..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_and_4.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_and_4
-#define TYPE uint32_t
-#define CMPSET atomic_cmpset_32
-#define EXPRESSION t & value
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_and_8.c b/lib/libcompiler_rt/__sync_fetch_and_and_8.c
deleted file mode 100644
index 9923e31158bd..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_and_8.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_and_8
-#define TYPE uint64_t
-#define CMPSET atomic_cmpset_64
-#define EXPRESSION t & value
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_or_4.c b/lib/libcompiler_rt/__sync_fetch_and_or_4.c
deleted file mode 100644
index 1feeeb17a1d6..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_or_4.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_or_4
-#define TYPE uint32_t
-#define CMPSET atomic_cmpset_32
-#define EXPRESSION t | value
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_or_8.c b/lib/libcompiler_rt/__sync_fetch_and_or_8.c
deleted file mode 100644
index 7cb9403bed17..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_or_8.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_or_8
-#define TYPE uint64_t
-#define CMPSET atomic_cmpset_64
-#define EXPRESSION t | value
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_sub_4.c b/lib/libcompiler_rt/__sync_fetch_and_sub_4.c
deleted file mode 100644
index a251adde54f0..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_sub_4.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_sub_4
-#define TYPE uint32_t
-#define FETCHADD(x, y) atomic_fetchadd_32(x, -(y))
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_sub_8.c b/lib/libcompiler_rt/__sync_fetch_and_sub_8.c
deleted file mode 100644
index 5a93f977ec89..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_sub_8.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_sub_8
-#define TYPE uint64_t
-#define FETCHADD(x, y) atomic_fetchadd_64(x, -(y))
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_xor_4.c b/lib/libcompiler_rt/__sync_fetch_and_xor_4.c
deleted file mode 100644
index d5f732d65f6b..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_xor_4.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_xor_4
-#define TYPE uint32_t
-#define CMPSET atomic_cmpset_32
-#define EXPRESSION t ^ value
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_fetch_and_xor_8.c b/lib/libcompiler_rt/__sync_fetch_and_xor_8.c
deleted file mode 100644
index 610037ef28bc..000000000000
--- a/lib/libcompiler_rt/__sync_fetch_and_xor_8.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_fetch_and_xor_8
-#define TYPE uint64_t
-#define CMPSET atomic_cmpset_64
-#define EXPRESSION t ^ value
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_lock_test_and_set_4.c b/lib/libcompiler_rt/__sync_lock_test_and_set_4.c
deleted file mode 100644
index d4965f96484f..000000000000
--- a/lib/libcompiler_rt/__sync_lock_test_and_set_4.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_lock_test_and_set_4
-#define TYPE uint32_t
-#define CMPSET atomic_cmpset_32
-#define EXPRESSION value
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_lock_test_and_set_8.c b/lib/libcompiler_rt/__sync_lock_test_and_set_8.c
deleted file mode 100644
index 1e02203d2be5..000000000000
--- a/lib/libcompiler_rt/__sync_lock_test_and_set_8.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_lock_test_and_set_8
-#define TYPE uint64_t
-#define CMPSET atomic_cmpset_64
-#define EXPRESSION value
-
-#include "__sync_fetch_and_op_n.h"
diff --git a/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c b/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c
deleted file mode 100644
index e0ab11515efd..000000000000
--- a/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_val_compare_and_swap_4
-#define TYPE uint32_t
-#define CMPSET atomic_cmpset_32
-
-#include "__sync_val_compare_and_swap_n.h"
diff --git a/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c b/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c
deleted file mode 100644
index c6f1101a72c0..000000000000
--- a/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* $FreeBSD$ */
-#define NAME __sync_val_compare_and_swap_8
-#define TYPE uint64_t
-#define CMPSET atomic_cmpset_64
-
-#include "__sync_val_compare_and_swap_n.h"
diff --git a/lib/libdwarf/dwarf_init.c b/lib/libdwarf/dwarf_init.c
index 6ebc7d90d688..ce8536337b2f 100644
--- a/lib/libdwarf/dwarf_init.c
+++ b/lib/libdwarf/dwarf_init.c
@@ -192,7 +192,7 @@ dwarf_read_sleb128(Elf_Data **dp, uint64_t *offsetp)
shift += 7;
} while ((b & 0x80) != 0);
- if (shift < 32 && (b & 0x40) != 0)
+ if (shift < 64 && (b & 0x40) != 0)
ret |= (-1 << shift);
return ret;
diff --git a/lib/libdwarf/dwarf_loc.c b/lib/libdwarf/dwarf_loc.c
index 6449706c2cc5..12d4cab6249e 100644
--- a/lib/libdwarf/dwarf_loc.c
+++ b/lib/libdwarf/dwarf_loc.c
@@ -46,7 +46,7 @@ dwarf_decode_sleb128(uint8_t **dp)
shift += 7;
} while ((b & 0x80) != 0);
- if (shift < 32 && (b & 0x40) != 0)
+ if (shift < 64 && (b & 0x40) != 0)
ret |= (-1 << shift);
*dp = src;
diff --git a/lib/libelf/libelf_data.c b/lib/libelf/libelf_data.c
index 3fbb067eaee9..17808ef9acd2 100644
--- a/lib/libelf/libelf_data.c
+++ b/lib/libelf/libelf_data.c
@@ -84,13 +84,21 @@ _libelf_xlate_shtype(uint32_t sht)
case SHT_SUNW_dof:
return (ELF_T_BYTE);
#endif
+ case SHT_ARM_PREEMPTMAP:
+ /* FALLTHROUGH */
+ case SHT_ARM_ATTRIBUTES:
+ /* FALLTHROUGH */
+ case SHT_ARM_DEBUGOVERLAY:
+ /* FALLTHROUGH */
+ case SHT_ARM_OVERLAYSECTION:
+ /* FALLTHROUGH */
case SHT_MIPS_DWARF:
/* FALLTHROUGH */
case SHT_MIPS_REGINFO:
/* FALLTHROUGH */
case SHT_MIPS_OPTIONS:
/* FALLTHROUGH */
- case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND */
+ case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND == SHT_ARM_EXIDX */
return (ELF_T_BYTE);
default:
return (-1);
diff --git a/lib/libexecinfo/Makefile b/lib/libexecinfo/Makefile
new file mode 100644
index 000000000000..81fa82a44a59
--- /dev/null
+++ b/lib/libexecinfo/Makefile
@@ -0,0 +1,23 @@
+# $FreeBSD$
+
+LIBEXECINFO= ${.CURDIR}/../../contrib/libexecinfo
+
+LIB= execinfo
+SHLIB_MAJOR= 1
+
+.PATH: ${LIBEXECINFO}
+
+INCS= execinfo.h
+SRCS= backtrace.c symtab.c unwind.c
+
+DPADD= ${LIBELF}
+LDADD= -lelf
+
+MAN= backtrace.3
+
+MLINKS+= backtrace.3 backtrace_symbols.3
+MLINKS+= backtrace.3 backtrace_symbols_fmt.3
+MLINKS+= backtrace.3 backtrace_symbols_fd.3
+MLINKS+= backtrace.3 backtrace_symbols_fd_fmt.3
+
+.include <bsd.lib.mk>
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index 425b6de13145..15d5a25de83b 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 1998-2011 Dag-Erling Smørgrav
+ * Copyright (c) 2013 Michael Gmelin <freebsd@grem.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,6 +48,10 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
+#ifdef WITH_SSL
+#include <openssl/x509v3.h>
+#endif
+
#include "fetch.h"
#include "common.h"
@@ -317,15 +322,488 @@ fetch_connect(const char *host, int port, int af, int verbose)
return (conn);
}
+#ifdef WITH_SSL
+/*
+ * Convert characters A-Z to lowercase (intentionally avoid any locale
+ * specific conversions).
+ */
+static char
+fetch_ssl_tolower(char in)
+{
+ if (in >= 'A' && in <= 'Z')
+ return (in + 32);
+ else
+ return (in);
+}
+
+/*
+ * isalpha implementation that intentionally avoids any locale specific
+ * conversions.
+ */
+static int
+fetch_ssl_isalpha(char in)
+{
+ return ((in >= 'A' && in <= 'Z') || (in >= 'a' && in <= 'z'));
+}
+
+/*
+ * Check if passed hostnames a and b are equal.
+ */
+static int
+fetch_ssl_hname_equal(const char *a, size_t alen, const char *b,
+ size_t blen)
+{
+ size_t i;
+
+ if (alen != blen)
+ return (0);
+ for (i = 0; i < alen; ++i) {
+ if (fetch_ssl_tolower(a[i]) != fetch_ssl_tolower(b[i]))
+ return (0);
+ }
+ return (1);
+}
+
+/*
+ * Check if domain label is traditional, meaning that only A-Z, a-z, 0-9
+ * and '-' (hyphen) are allowed. Hyphens have to be surrounded by alpha-
+ * numeric characters. Double hyphens (like they're found in IDN a-labels
+ * 'xn--') are not allowed. Empty labels are invalid.
+ */
+static int
+fetch_ssl_is_trad_domain_label(const char *l, size_t len, int wcok)
+{
+ size_t i;
+
+ if (!len || l[0] == '-' || l[len-1] == '-')
+ return (0);
+ for (i = 0; i < len; ++i) {
+ if (!isdigit(l[i]) &&
+ !fetch_ssl_isalpha(l[i]) &&
+ !(l[i] == '*' && wcok) &&
+ !(l[i] == '-' && l[i - 1] != '-'))
+ return (0);
+ }
+ return (1);
+}
+
+/*
+ * Check if host name consists only of numbers. This might indicate an IP
+ * address, which is not a good idea for CN wildcard comparison.
+ */
+static int
+fetch_ssl_hname_is_only_numbers(const char *hostname, size_t len)
+{
+ size_t i;
+
+ for (i = 0; i < len; ++i) {
+ if (!((hostname[i] >= '0' && hostname[i] <= '9') ||
+ hostname[i] == '.'))
+ return (0);
+ }
+ return (1);
+}
+
+/*
+ * Check if the host name h passed matches the pattern passed in m which
+ * is usually part of subjectAltName or CN of a certificate presented to
+ * the client. This includes wildcard matching. The algorithm is based on
+ * RFC6125, sections 6.4.3 and 7.2, which clarifies RFC2818 and RFC3280.
+ */
+static int
+fetch_ssl_hname_match(const char *h, size_t hlen, const char *m,
+ size_t mlen)
+{
+ int delta, hdotidx, mdot1idx, wcidx;
+ const char *hdot, *mdot1, *mdot2;
+ const char *wc; /* wildcard */
+
+ if (!(h && *h && m && *m))
+ return (0);
+ if ((wc = strnstr(m, "*", mlen)) == NULL)
+ return (fetch_ssl_hname_equal(h, hlen, m, mlen));
+ wcidx = wc - m;
+ /* hostname should not be just dots and numbers */
+ if (fetch_ssl_hname_is_only_numbers(h, hlen))
+ return (0);
+ /* only one wildcard allowed in pattern */
+ if (strnstr(wc + 1, "*", mlen - wcidx - 1) != NULL)
+ return (0);
+ /*
+ * there must be at least two more domain labels and
+ * wildcard has to be in the leftmost label (RFC6125)
+ */
+ mdot1 = strnstr(m, ".", mlen);
+ if (mdot1 == NULL || mdot1 < wc || (mlen - (mdot1 - m)) < 4)
+ return (0);
+ mdot1idx = mdot1 - m;
+ mdot2 = strnstr(mdot1 + 1, ".", mlen - mdot1idx - 1);
+ if (mdot2 == NULL || (mlen - (mdot2 - m)) < 2)
+ return (0);
+ /* hostname must contain a dot and not be the 1st char */
+ hdot = strnstr(h, ".", hlen);
+ if (hdot == NULL || hdot == h)
+ return (0);
+ hdotidx = hdot - h;
+ /*
+ * host part of hostname must be at least as long as
+ * pattern it's supposed to match
+ */
+ if (hdotidx < mdot1idx)
+ return (0);
+ /*
+ * don't allow wildcards in non-traditional domain names
+ * (IDN, A-label, U-label...)
+ */
+ if (!fetch_ssl_is_trad_domain_label(h, hdotidx, 0) ||
+ !fetch_ssl_is_trad_domain_label(m, mdot1idx, 1))
+ return (0);
+ /* match domain part (part after first dot) */
+ if (!fetch_ssl_hname_equal(hdot, hlen - hdotidx, mdot1,
+ mlen - mdot1idx))
+ return (0);
+ /* match part left of wildcard */
+ if (!fetch_ssl_hname_equal(h, wcidx, m, wcidx))
+ return (0);
+ /* match part right of wildcard */
+ delta = mdot1idx - wcidx - 1;
+ if (!fetch_ssl_hname_equal(hdot - delta, delta,
+ mdot1 - delta, delta))
+ return (0);
+ /* all tests succeded, it's a match */
+ return (1);
+}
+
+/*
+ * Get numeric host address info - returns NULL if host was not an IP
+ * address. The caller is responsible for deallocation using
+ * freeaddrinfo(3).
+ */
+static struct addrinfo *
+fetch_ssl_get_numeric_addrinfo(const char *hostname, size_t len)
+{
+ struct addrinfo hints, *res;
+ char *host;
+
+ host = (char *)malloc(len + 1);
+ memcpy(host, hostname, len);
+ host[len] = '\0';
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = 0;
+ hints.ai_flags = AI_NUMERICHOST;
+ /* port is not relevant for this purpose */
+ getaddrinfo(host, "443", &hints, &res);
+ free(host);
+ return res;
+}
+
+/*
+ * Compare ip address in addrinfo with address passes.
+ */
+static int
+fetch_ssl_ipaddr_match_bin(const struct addrinfo *lhost, const char *rhost,
+ size_t rhostlen)
+{
+ const void *left;
+
+ if (lhost->ai_family == AF_INET && rhostlen == 4) {
+ left = (void *)&((struct sockaddr_in*)(void *)
+ lhost->ai_addr)->sin_addr.s_addr;
+#ifdef INET6
+ } else if (lhost->ai_family == AF_INET6 && rhostlen == 16) {
+ left = (void *)&((struct sockaddr_in6 *)(void *)
+ lhost->ai_addr)->sin6_addr;
+#endif
+ } else
+ return (0);
+ return (!memcmp(left, (const void *)rhost, rhostlen) ? 1 : 0);
+}
+
+/*
+ * Compare ip address in addrinfo with host passed. If host is not an IP
+ * address, comparison will fail.
+ */
+static int
+fetch_ssl_ipaddr_match(const struct addrinfo *laddr, const char *r,
+ size_t rlen)
+{
+ struct addrinfo *raddr;
+ int ret;
+ char *rip;
+
+ ret = 0;
+ if ((raddr = fetch_ssl_get_numeric_addrinfo(r, rlen)) == NULL)
+ return 0; /* not a numeric host */
+
+ if (laddr->ai_family == raddr->ai_family) {
+ if (laddr->ai_family == AF_INET) {
+ rip = (char *)&((struct sockaddr_in *)(void *)
+ raddr->ai_addr)->sin_addr.s_addr;
+ ret = fetch_ssl_ipaddr_match_bin(laddr, rip, 4);
+#ifdef INET6
+ } else if (laddr->ai_family == AF_INET6) {
+ rip = (char *)&((struct sockaddr_in6 *)(void *)
+ raddr->ai_addr)->sin6_addr;
+ ret = fetch_ssl_ipaddr_match_bin(laddr, rip, 16);
+#endif
+ }
+
+ }
+ freeaddrinfo(raddr);
+ return (ret);
+}
+
+/*
+ * Verify server certificate by subjectAltName.
+ */
+static int
+fetch_ssl_verify_altname(STACK_OF(GENERAL_NAME) *altnames,
+ const char *host, struct addrinfo *ip)
+{
+ const GENERAL_NAME *name;
+ size_t nslen;
+ int i;
+ const char *ns;
+
+ for (i = 0; i < sk_GENERAL_NAME_num(altnames); ++i) {
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
+ /*
+ * This is a workaround, since the following line causes
+ * alignment issues in clang:
+ * name = sk_GENERAL_NAME_value(altnames, i);
+ * OpenSSL explicitly warns not to use those macros
+ * directly, but there isn't much choice (and there
+ * shouldn't be any ill side effects)
+ */
+ name = (GENERAL_NAME *)SKM_sk_value(void, altnames, i);
+#else
+ name = sk_GENERAL_NAME_value(altnames, i);
+#endif
+ ns = (const char *)ASN1_STRING_data(name->d.ia5);
+ nslen = (size_t)ASN1_STRING_length(name->d.ia5);
+
+ if (name->type == GEN_DNS && ip == NULL &&
+ fetch_ssl_hname_match(host, strlen(host), ns, nslen))
+ return (1);
+ else if (name->type == GEN_IPADD && ip != NULL &&
+ fetch_ssl_ipaddr_match_bin(ip, ns, nslen))
+ return (1);
+ }
+ return (0);
+}
+
+/*
+ * Verify server certificate by CN.
+ */
+static int
+fetch_ssl_verify_cn(X509_NAME *subject, const char *host,
+ struct addrinfo *ip)
+{
+ ASN1_STRING *namedata;
+ X509_NAME_ENTRY *nameentry;
+ int cnlen, lastpos, loc, ret;
+ unsigned char *cn;
+
+ ret = 0;
+ lastpos = -1;
+ loc = -1;
+ cn = NULL;
+ /* get most specific CN (last entry in list) and compare */
+ while ((lastpos = X509_NAME_get_index_by_NID(subject,
+ NID_commonName, lastpos)) != -1)
+ loc = lastpos;
+
+ if (loc > -1) {
+ nameentry = X509_NAME_get_entry(subject, loc);
+ namedata = X509_NAME_ENTRY_get_data(nameentry);
+ cnlen = ASN1_STRING_to_UTF8(&cn, namedata);
+ if (ip == NULL &&
+ fetch_ssl_hname_match(host, strlen(host), cn, cnlen))
+ ret = 1;
+ else if (ip != NULL && fetch_ssl_ipaddr_match(ip, cn, cnlen))
+ ret = 1;
+ OPENSSL_free(cn);
+ }
+ return (ret);
+}
+
+/*
+ * Verify that server certificate subjectAltName/CN matches
+ * hostname. First check, if there are alternative subject names. If yes,
+ * those have to match. Only if those don't exist it falls back to
+ * checking the subject's CN.
+ */
+static int
+fetch_ssl_verify_hname(X509 *cert, const char *host)
+{
+ struct addrinfo *ip;
+ STACK_OF(GENERAL_NAME) *altnames;
+ X509_NAME *subject;
+ int ret;
+
+ ret = 0;
+ ip = fetch_ssl_get_numeric_addrinfo(host, strlen(host));
+ altnames = X509_get_ext_d2i(cert, NID_subject_alt_name,
+ NULL, NULL);
+
+ if (altnames != NULL) {
+ ret = fetch_ssl_verify_altname(altnames, host, ip);
+ } else {
+ subject = X509_get_subject_name(cert);
+ if (subject != NULL)
+ ret = fetch_ssl_verify_cn(subject, host, ip);
+ }
+
+ if (ip != NULL)
+ freeaddrinfo(ip);
+ if (altnames != NULL)
+ GENERAL_NAMES_free(altnames);
+ return (ret);
+}
+
+/*
+ * Configure transport security layer based on environment.
+ */
+static void
+fetch_ssl_setup_transport_layer(SSL_CTX *ctx, int verbose)
+{
+ long ssl_ctx_options;
+
+ ssl_ctx_options = SSL_OP_ALL | SSL_OP_NO_TICKET;
+ if (getenv("SSL_ALLOW_SSL2") == NULL)
+ ssl_ctx_options |= SSL_OP_NO_SSLv2;
+ if (getenv("SSL_NO_SSL3") != NULL)
+ ssl_ctx_options |= SSL_OP_NO_SSLv3;
+ if (getenv("SSL_NO_TLS1") != NULL)
+ ssl_ctx_options |= SSL_OP_NO_TLSv1;
+ if (verbose)
+ fetch_info("SSL options: %x", ssl_ctx_options);
+ SSL_CTX_set_options(ctx, ssl_ctx_options);
+}
+
+
+/*
+ * Configure peer verification based on environment.
+ */
+static int
+fetch_ssl_setup_peer_verification(SSL_CTX *ctx, int verbose)
+{
+ X509_LOOKUP *crl_lookup;
+ X509_STORE *crl_store;
+ const char *ca_cert_file, *ca_cert_path, *crl_file;
+
+ if (getenv("SSL_NO_VERIFY_PEER") == NULL) {
+ ca_cert_file = getenv("SSL_CA_CERT_FILE") != NULL ?
+ getenv("SSL_CA_CERT_FILE") : "/etc/ssl/cert.pem";
+ ca_cert_path = getenv("SSL_CA_CERT_PATH");
+ if (verbose) {
+ fetch_info("Peer verification enabled");
+ if (ca_cert_file != NULL)
+ fetch_info("Using CA cert file: %s",
+ ca_cert_file);
+ if (ca_cert_path != NULL)
+ fetch_info("Using CA cert path: %s",
+ ca_cert_path);
+ }
+ SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER,
+ fetch_ssl_cb_verify_crt);
+ SSL_CTX_load_verify_locations(ctx, ca_cert_file,
+ ca_cert_path);
+ if ((crl_file = getenv("SSL_CRL_FILE")) != NULL) {
+ if (verbose)
+ fetch_info("Using CRL file: %s", crl_file);
+ crl_store = SSL_CTX_get_cert_store(ctx);
+ crl_lookup = X509_STORE_add_lookup(crl_store,
+ X509_LOOKUP_file());
+ if (crl_lookup == NULL ||
+ !X509_load_crl_file(crl_lookup, crl_file,
+ X509_FILETYPE_PEM)) {
+ fprintf(stderr,
+ "Could not load CRL file %s\n",
+ crl_file);
+ return (0);
+ }
+ X509_STORE_set_flags(crl_store,
+ X509_V_FLAG_CRL_CHECK |
+ X509_V_FLAG_CRL_CHECK_ALL);
+ }
+ }
+ return (1);
+}
+
+/*
+ * Configure client certificate based on environment.
+ */
+static int
+fetch_ssl_setup_client_certificate(SSL_CTX *ctx, int verbose)
+{
+ const char *client_cert_file, *client_key_file;
+
+ if ((client_cert_file = getenv("SSL_CLIENT_CERT_FILE")) != NULL) {
+ client_key_file = getenv("SSL_CLIENT_KEY_FILE") != NULL ?
+ getenv("SSL_CLIENT_KEY_FILE") : client_cert_file;
+ if (verbose) {
+ fetch_info("Using client cert file: %s",
+ client_cert_file);
+ fetch_info("Using client key file: %s",
+ client_key_file);
+ }
+ if (SSL_CTX_use_certificate_chain_file(ctx,
+ client_cert_file) != 1) {
+ fprintf(stderr,
+ "Could not load client certificate %s\n",
+ client_cert_file);
+ return (0);
+ }
+ if (SSL_CTX_use_PrivateKey_file(ctx, client_key_file,
+ SSL_FILETYPE_PEM) != 1) {
+ fprintf(stderr,
+ "Could not load client key %s\n",
+ client_key_file);
+ return (0);
+ }
+ }
+ return (1);
+}
+
+/*
+ * Callback for SSL certificate verification, this is called on server
+ * cert verification. It takes no decision, but informs the user in case
+ * verification failed.
+ */
+int
+fetch_ssl_cb_verify_crt(int verified, X509_STORE_CTX *ctx)
+{
+ X509 *crt;
+ X509_NAME *name;
+ char *str;
+
+ str = NULL;
+ if (!verified) {
+ if ((crt = X509_STORE_CTX_get_current_cert(ctx)) != NULL &&
+ (name = X509_get_subject_name(crt)) != NULL)
+ str = X509_NAME_oneline(name, 0, 0);
+ fprintf(stderr, "Certificate verification failed for %s\n",
+ str != NULL ? str : "no relevant certificate");
+ OPENSSL_free(str);
+ }
+ return (verified);
+}
+
+#endif
/*
* Enable SSL on a connection.
*/
int
-fetch_ssl(conn_t *conn, int verbose)
+fetch_ssl(conn_t *conn, const struct url *URL, int verbose)
{
#ifdef WITH_SSL
int ret, ssl_err;
+ X509_NAME *name;
+ char *str;
/* Init the SSL library and context */
if (!SSL_library_init()){
@@ -339,8 +817,14 @@ fetch_ssl(conn_t *conn, int verbose)
conn->ssl_ctx = SSL_CTX_new(conn->ssl_meth);
SSL_CTX_set_mode(conn->ssl_ctx, SSL_MODE_AUTO_RETRY);
+ fetch_ssl_setup_transport_layer(conn->ssl_ctx, verbose);
+ if (!fetch_ssl_setup_peer_verification(conn->ssl_ctx, verbose))
+ return (-1);
+ if (!fetch_ssl_setup_client_certificate(conn->ssl_ctx, verbose))
+ return (-1);
+
conn->ssl = SSL_new(conn->ssl_ctx);
- if (conn->ssl == NULL){
+ if (conn->ssl == NULL) {
fprintf(stderr, "SSL context creation failed\n");
return (-1);
}
@@ -353,22 +837,35 @@ fetch_ssl(conn_t *conn, int verbose)
return (-1);
}
}
+ conn->ssl_cert = SSL_get_peer_certificate(conn->ssl);
- if (verbose) {
- X509_NAME *name;
- char *str;
+ if (conn->ssl_cert == NULL) {
+ fprintf(stderr, "No server SSL certificate\n");
+ return (-1);
+ }
+
+ if (getenv("SSL_NO_VERIFY_HOSTNAME") == NULL) {
+ if (verbose)
+ fetch_info("Verify hostname");
+ if (!fetch_ssl_verify_hname(conn->ssl_cert, URL->host)) {
+ fprintf(stderr,
+ "SSL certificate subject doesn't match host %s\n",
+ URL->host);
+ return (-1);
+ }
+ }
- fprintf(stderr, "SSL connection established using %s\n",
+ if (verbose) {
+ fetch_info("SSL connection established using %s",
SSL_get_cipher(conn->ssl));
- conn->ssl_cert = SSL_get_peer_certificate(conn->ssl);
name = X509_get_subject_name(conn->ssl_cert);
str = X509_NAME_oneline(name, 0, 0);
- printf("Certificate subject: %s\n", str);
- free(str);
+ fetch_info("Certificate subject: %s", str);
+ OPENSSL_free(str);
name = X509_get_issuer_name(conn->ssl_cert);
str = X509_NAME_oneline(name, 0, 0);
- printf("Certificate issuer: %s\n", str);
- free(str);
+ fetch_info("Certificate issuer: %s", str);
+ OPENSSL_free(str);
}
return (0);
@@ -726,6 +1223,22 @@ fetch_close(conn_t *conn)
if (--conn->ref > 0)
return (0);
+#ifdef WITH_SSL
+ if (conn->ssl) {
+ SSL_shutdown(conn->ssl);
+ SSL_set_connect_state(conn->ssl);
+ SSL_free(conn->ssl);
+ conn->ssl = NULL;
+ }
+ if (conn->ssl_ctx) {
+ SSL_CTX_free(conn->ssl_ctx);
+ conn->ssl_ctx = NULL;
+ }
+ if (conn->ssl_cert) {
+ X509_free(conn->ssl_cert);
+ conn->ssl_cert = NULL;
+ }
+#endif
ret = close(conn->sd);
free(conn->cache.buf);
free(conn->buf);
diff --git a/lib/libfetch/common.h b/lib/libfetch/common.h
index fe591d3ea0df..1d543a616d00 100644
--- a/lib/libfetch/common.h
+++ b/lib/libfetch/common.h
@@ -87,7 +87,10 @@ int fetch_bind(int, int, const char *);
conn_t *fetch_connect(const char *, int, int, int);
conn_t *fetch_reopen(int);
conn_t *fetch_ref(conn_t *);
-int fetch_ssl(conn_t *, int);
+#ifdef WITH_SSL
+int fetch_ssl_cb_verify_crt(int, X509_STORE_CTX*);
+#endif
+int fetch_ssl(conn_t *, const struct url *, int);
ssize_t fetch_read(conn_t *, char *, size_t);
int fetch_getln(conn_t *);
ssize_t fetch_write(conn_t *, const char *, size_t);
diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3
index 30372f21fdc0..6b2e4c00b50b 100644
--- a/lib/libfetch/fetch.3
+++ b/lib/libfetch/fetch.3
@@ -1,5 +1,6 @@
.\"-
-.\" Copyright (c) 1998-2011 Dag-Erling Smørgrav
+.\" Copyright (c) 1998-2013 Dag-Erling Smørgrav
+.\" Copyright (c) 2013 Michael Gmelin <freebsd@grem.de>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -25,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 27, 2011
+.Dd July 30, 2013
.Dt FETCH 3
.Os
.Sh NAME
@@ -392,6 +393,60 @@ method in a manner consistent with the rest of the
library,
.Fn fetchPutHTTP
is currently unimplemented.
+.Sh HTTPS SCHEME
+Based on HTTP SCHEME.
+By default the peer is verified using the CA bundle located in
+.Pa /etc/ssl/cert.pem .
+The file may contain multiple CA certificates.
+A common source of a current CA bundle is
+.Pa \%security/ca_root_nss .
+.Pp
+The CA bundle used for peer verification can be changed by setting the
+environment variables
+.Ev SSL_CA_CERT_FILE
+to point to a concatenated bundle of trusted certificates and
+.Ev SSL_CA_CERT_PATH
+to point to a directory containing hashes of trusted CAs (see
+.Xr verify 1 ) .
+.Pp
+A certificate revocation list (CRL) can be used by setting the
+environment variable
+.Ev SSL_CRL_FILE
+(see
+.Xr crl 1 ) .
+.Pp
+Peer verification can be disabled by setting the environment variable
+.Ev SSL_NO_VERIFY_PEER .
+Note that this also disables CRL checking.
+.Pp
+By default the service identity is verified according to the rules
+detailed in RFC6125 (also known as hostname verification).
+This feature can be disabled by setting the environment variable
+.Ev SSL_NO_VERIFY_HOSTNAME .
+.Pp
+Client certificate based authentication is supported.
+The environment variable
+.Ev SSL_CLIENT_CERT_FILE
+should be set to point to a file containing key and client certificate
+to be used in PEM format. In case the key is stored in a separate
+file, the environment variable
+.Ev SSL_CLIENT_KEY_FILE
+can be set to point to the key in PEM format.
+In case the key uses a password, the user will be prompted on standard
+input (see
+.Xr PEM 3 ) .
+.Pp
+By default
+.Nm libfetch
+allows SSLv3 and TLSv1 when negotiating the connecting with the remote
+peer.
+You can change this behavior by setting the environment variable
+.Ev SSL_ALLOW_SSL2
+to allow SSLv2 (not recommended) and
+.Ev SSL_NO_SSL3
+or
+.Ev SSL_NO_TLS1
+to disable the respective methods.
.Sh AUTHENTICATION
Apart from setting the appropriate environment variables and
specifying the user name and password in the URL or the
@@ -516,6 +571,15 @@ variable is set.
Same as
.Ev FTP_PROXY ,
for compatibility.
+.It Ev HTTP_ACCEPT
+Specifies the value of the
+.Va Accept
+header for HTTP requests.
+If empty, no
+.Va Accept
+header is sent.
+The default is
+.Dq */* .
.It Ev HTTP_AUTH
Specifies HTTP authorization parameters as a colon-separated list of
items.
@@ -579,6 +643,31 @@ which proxies should not be used.
Same as
.Ev NO_PROXY ,
for compatibility.
+.It Ev SSL_ALLOW_SSL2
+Allow SSL version 2 when negotiating the connection (not recommended).
+.It Ev SSL_CA_CERT_FILE
+CA certificate bundle containing trusted CA certificates.
+Default value:
+.Pa /etc/ssl/cert.pem .
+.It Ev SSL_CA_CERT_PATH
+Path containing trusted CA hashes.
+.It Ev SSL_CLIENT_CERT_FILE
+PEM encoded client certificate/key which will be used in
+client certificate authentication.
+.It Ev SSL_CLIENT_KEY_FILE
+PEM encoded client key in case key and client certificate
+are stored separately.
+.It Ev SSL_CRL_FILE
+File containing certificate revocation list.
+.It Ev SSL_NO_SSL3
+Don't allow SSL version 3 when negotiating the connection.
+.It Ev SSL_NO_TLS1
+Don't allow TLV version 1 when negotiating the connection.
+.It Ev SSL_NO_VERIFY_HOSTNAME
+If set, do not verify that the hostname matches the subject of the
+certificate presented by the server.
+.It Ev SSL_NO_VERIFY_PEER
+If set, do not verify the peer certificate against trusted CAs.
.El
.Sh EXAMPLES
To access a proxy server on
@@ -610,6 +699,19 @@ as follows:
.Bd -literal -offset indent
NO_PROXY=localhost,127.0.0.1
.Ed
+.Pp
+Access HTTPS website without any certificate verification whatsoever:
+.Bd -literal -offset indent
+SSL_NO_VERIFY_PEER=1
+SSL_NO_VERIFY_HOSTNAME=1
+.Ed
+.Pp
+Access HTTPS website using client certificate based authentication
+and a private CA:
+.Bd -literal -offset indent
+SSL_CLIENT_CERT_FILE=/path/to/client.pem
+SSL_CA_CERT_FILE=/path/to/myca.pem
+.Ed
.Sh SEE ALSO
.Xr fetch 1 ,
.Xr ftpio 3 ,
@@ -678,7 +780,8 @@ with numerous suggestions and contributions from
.An Hajimu Umemoto Aq ume@FreeBSD.org ,
.An Henry Whincup Aq henry@techiebod.com ,
.An Jukka A. Ukkonen Aq jau@iki.fi ,
-.An Jean-Fran\(,cois Dockes Aq jf@dockes.org
+.An Jean-Fran\(,cois Dockes Aq jf@dockes.org ,
+.An Michael Gmelin Aq freebsd@grem.de
and others.
It replaces the older
.Nm ftpio
@@ -688,7 +791,9 @@ and
.An Jordan K. Hubbard Aq jkh@FreeBSD.org .
.Pp
This manual page was written by
-.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
+.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
+and
+.An Michael Gmelin Aq freebsd@grem.de .
.Sh BUGS
Some parts of the library are not yet implemented.
The most notable
@@ -717,6 +822,10 @@ implemented, superfluous at this site" in an FTP context and
.Fn fetchStatFTP
does not check that the result of an MDTM command is a valid date.
.Pp
+In case password protected keys are used for client certificate based
+authentication the user is prompted for the password on each and every
+fetch operation.
+.Pp
The man page is incomplete, poorly written and produces badly
formatted text.
.Pp
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index a081520143e5..8d92bbcb7808 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -376,7 +376,7 @@ fetchParseURL(const char *URL)
/* password */
if (*q == ':')
- q = fetch_pctdecode(u->pwd, ++q, URL_PWDLEN);
+ q = fetch_pctdecode(u->pwd, q + 1, URL_PWDLEN);
p++;
} else {
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index abf79a301f17..87535f001698 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2000-2011 Dag-Erling Smørgrav
+ * Copyright (c) 2000-2013 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1373,6 +1373,7 @@ http_authorize(conn_t *conn, const char *hdr, http_auth_challenges_t *cs,
static conn_t *
http_connect(struct url *URL, struct url *purl, const char *flags)
{
+ struct url *curl;
conn_t *conn;
int verbose;
int af, val;
@@ -1391,19 +1392,25 @@ http_connect(struct url *URL, struct url *purl, const char *flags)
af = AF_INET6;
#endif
- if (purl && strcasecmp(URL->scheme, SCHEME_HTTPS) != 0) {
- URL = purl;
- } else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) {
- /* can't talk http to an ftp server */
- /* XXX should set an error code */
- return (NULL);
- }
+ curl = (purl != NULL) ? purl : URL;
- if ((conn = fetch_connect(URL->host, URL->port, af, verbose)) == NULL)
+ if ((conn = fetch_connect(curl->host, curl->port, af, verbose)) == NULL)
/* fetch_connect() has already set an error code */
return (NULL);
+ if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && purl) {
+ http_cmd(conn, "CONNECT %s:%d HTTP/1.1",
+ URL->host, URL->port);
+ http_cmd(conn, "Host: %s:%d",
+ URL->host, URL->port);
+ http_cmd(conn, "");
+ if (http_get_reply(conn) != HTTP_OK) {
+ fetch_close(conn);
+ return (NULL);
+ }
+ http_get_reply(conn);
+ }
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 &&
- fetch_ssl(conn, verbose) == -1) {
+ fetch_ssl(conn, URL, verbose) == -1) {
fetch_close(conn);
/* grrr */
errno = EAUTH;
@@ -1576,7 +1583,7 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
if (verbose)
fetch_info("requesting %s://%s%s",
url->scheme, host, url->doc);
- if (purl) {
+ if (purl && strcasecmp(URL->scheme, SCHEME_HTTPS) != 0) {
http_cmd(conn, "%s %s://%s%s HTTP/1.1",
op, url->scheme, host, url->doc);
} else {
@@ -1659,6 +1666,12 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
}
/* other headers */
+ if ((p = getenv("HTTP_ACCEPT")) != NULL) {
+ if (*p != '\0')
+ http_cmd(conn, "Accept: %s", p);
+ } else {
+ http_cmd(conn, "Accept: */*");
+ }
if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') {
if (strcasecmp(p, "auto") == 0)
http_cmd(conn, "Referer: %s://%s%s",
diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c
index 02be01991c1e..2874cd0abd9c 100644
--- a/lib/libgeom/geom_xml2tree.c
+++ b/lib/libgeom/geom_xml2tree.c
@@ -282,7 +282,9 @@ EndElement(void *userData, const char *name)
}
if (p != NULL) {
+#if DEBUG_LIBGEOM > 0
printf("Unexpected XML: name=%s data=\"%s\"\n", name, p);
+#endif
free(p);
}
diff --git a/lib/libgeom/libgeom.h b/lib/libgeom/libgeom.h
index c951f25babfe..73d43352ee84 100644
--- a/lib/libgeom/libgeom.h
+++ b/lib/libgeom/libgeom.h
@@ -40,6 +40,10 @@
__BEGIN_DECLS
+#ifndef DEBUG_LIBGEOM
+#define DEBUG_LIBGEOM 0
+#endif
+
void geom_stats_close(void);
void geom_stats_resync(void);
int geom_stats_open(void);
diff --git a/lib/libiconv_compat/Makefile b/lib/libiconv_compat/Makefile
new file mode 100644
index 000000000000..3d4483ae02ee
--- /dev/null
+++ b/lib/libiconv_compat/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+LIB= iconv
+SHLIB_MAJOR= 3
+SRCS= stub.c
+
+WARNS?= 0
+
+.include <bsd.lib.mk>
diff --git a/lib/libiconv_compat/stub.c b/lib/libiconv_compat/stub.c
new file mode 100644
index 000000000000..b4e56a2353e2
--- /dev/null
+++ b/lib/libiconv_compat/stub.c
@@ -0,0 +1,8 @@
+/*
+ * Hacks to support things like the dlopen() in libkiconv.so or
+ * ports that want to hard-code -liconv.
+ *
+ * $FreeBSD$
+ */
+
+int __libiconv_stub__;
diff --git a/lib/libiconv_modules/BIG5/citrus_big5.c b/lib/libiconv_modules/BIG5/citrus_big5.c
index b6ece4622012..1d7d8f8235b7 100644
--- a/lib/libiconv_modules/BIG5/citrus_big5.c
+++ b/lib/libiconv_modules/BIG5/citrus_big5.c
@@ -268,12 +268,12 @@ static int
/*ARGSUSED*/
_citrus_BIG5_mbrtowc_priv(_BIG5EncodingInfo * __restrict ei,
wchar_t * __restrict pwc,
- char ** __restrict s, size_t n,
+ const char ** __restrict s, size_t n,
_BIG5State * __restrict psenc,
size_t * __restrict nresult)
{
wchar_t wchar;
- char *s0;
+ const char *s0;
int c, chlenbak;
s0 = *s;
diff --git a/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c b/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
index 0801ac97bf83..9d1d394c4e5d 100644
--- a/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
+++ b/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
@@ -163,10 +163,10 @@ is_94charset(int c)
static int
/*ARGSUSED*/
_citrus_DECHanyu_mbrtowc_priv(_DECHanyuEncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s, size_t n,
+ wchar_t * __restrict pwc, const char ** __restrict s, size_t n,
_DECHanyuState * __restrict psenc, size_t * __restrict nresult)
{
- char *s0;
+ const char *s0;
wchar_t wc;
int ch;
diff --git a/lib/libiconv_modules/EUC/citrus_euc.c b/lib/libiconv_modules/EUC/citrus_euc.c
index 708473bf7641..c153bef69eb2 100644
--- a/lib/libiconv_modules/EUC/citrus_euc.c
+++ b/lib/libiconv_modules/EUC/citrus_euc.c
@@ -188,12 +188,12 @@ _citrus_EUC_unpack_state(_EUCEncodingInfo *ei __unused, _EUCState *s,
}
static int
-_citrus_EUC_mbrtowc_priv(_EUCEncodingInfo *ei, wchar_t *pwc, char **s,
+_citrus_EUC_mbrtowc_priv(_EUCEncodingInfo *ei, wchar_t *pwc, const char **s,
size_t n, _EUCState *psenc, size_t *nresult)
{
wchar_t wchar;
int c, chlenbak, cs, len;
- char *s0, *s1 = NULL;
+ const char *s0, *s1 = NULL;
s0 = *s;
diff --git a/lib/libiconv_modules/EUCTW/citrus_euctw.c b/lib/libiconv_modules/EUCTW/citrus_euctw.c
index 79aa9fa90d30..f1f8a497f5f1 100644
--- a/lib/libiconv_modules/EUCTW/citrus_euctw.c
+++ b/lib/libiconv_modules/EUCTW/citrus_euctw.c
@@ -174,10 +174,10 @@ _citrus_EUCTW_encoding_module_uninit(_EUCTWEncodingInfo *ei __unused)
static int
_citrus_EUCTW_mbrtowc_priv(_EUCTWEncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s,
+ wchar_t * __restrict pwc, const char ** __restrict s,
size_t n, _EUCTWState * __restrict psenc, size_t * __restrict nresult)
{
- char *s0;
+ const char *s0;
wchar_t wchar;
int c, chlenbak, cs;
diff --git a/lib/libiconv_modules/GBK2K/citrus_gbk2k.c b/lib/libiconv_modules/GBK2K/citrus_gbk2k.c
index ff31725d110a..8da5c7c5e5bc 100644
--- a/lib/libiconv_modules/GBK2K/citrus_gbk2k.c
+++ b/lib/libiconv_modules/GBK2K/citrus_gbk2k.c
@@ -147,10 +147,10 @@ _mb_count(wchar_t v)
static int
_citrus_GBK2K_mbrtowc_priv(_GBK2KEncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s, size_t n,
+ wchar_t * __restrict pwc, const char ** __restrict s, size_t n,
_GBK2KState * __restrict psenc, size_t * __restrict nresult)
{
- char *s0, *s1;
+ const char *s0, *s1;
wchar_t wc;
int chlenbak, len;
diff --git a/lib/libiconv_modules/HZ/citrus_hz.c b/lib/libiconv_modules/HZ/citrus_hz.c
index 3775ea626279..9bc7a5b5d60c 100644
--- a/lib/libiconv_modules/HZ/citrus_hz.c
+++ b/lib/libiconv_modules/HZ/citrus_hz.c
@@ -173,13 +173,13 @@ _citrus_HZ_unpack_state(_HZEncodingInfo * __restrict ei __unused,
static int
_citrus_HZ_mbrtowc_priv(_HZEncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s, size_t n,
+ wchar_t * __restrict pwc, const char ** __restrict s, size_t n,
_HZState * __restrict psenc, size_t * __restrict nresult)
{
escape_t *candidate, *init;
graphic_t *graphic;
const range_t *range;
- char *s0;
+ const char *s0;
wchar_t wc;
int bit, ch, head, len, tail;
diff --git a/lib/libiconv_modules/ISO2022/citrus_iso2022.c b/lib/libiconv_modules/ISO2022/citrus_iso2022.c
index 82ad7c365eec..2ae8df6ce844 100644
--- a/lib/libiconv_modules/ISO2022/citrus_iso2022.c
+++ b/lib/libiconv_modules/ISO2022/citrus_iso2022.c
@@ -572,7 +572,7 @@ terminate:
static wchar_t
_ISO2022_sgetwchar(_ISO2022EncodingInfo * __restrict ei __unused,
- char * __restrict string, size_t n, char ** __restrict result,
+ const char * __restrict string, size_t n, const char ** __restrict result,
_ISO2022State * __restrict psenc)
{
const struct seqtable *sp;
@@ -840,10 +840,10 @@ asis:
static int
_citrus_ISO2022_mbrtowc_priv(_ISO2022EncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s,
+ wchar_t * __restrict pwc, const char ** __restrict s,
size_t n, _ISO2022State * __restrict psenc, size_t * __restrict nresult)
{
- char *p, *result, *s0;
+ const char *p, *result, *s0;
wchar_t wchar;
int c, chlenbak;
diff --git a/lib/libiconv_modules/JOHAB/citrus_johab.c b/lib/libiconv_modules/JOHAB/citrus_johab.c
index 35c35f3384b9..0365379dbd04 100644
--- a/lib/libiconv_modules/JOHAB/citrus_johab.c
+++ b/lib/libiconv_modules/JOHAB/citrus_johab.c
@@ -143,10 +143,10 @@ ishanja(int l, int t)
static int
/*ARGSUSED*/
_citrus_JOHAB_mbrtowc_priv(_JOHABEncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s, size_t n,
+ wchar_t * __restrict pwc, const char ** __restrict s, size_t n,
_JOHABState * __restrict psenc, size_t * __restrict nresult)
{
- char *s0;
+ const char *s0;
int l, t;
if (*s == NULL) {
diff --git a/lib/libiconv_modules/MSKanji/citrus_mskanji.c b/lib/libiconv_modules/MSKanji/citrus_mskanji.c
index e6554484d991..fc0f13f36271 100644
--- a/lib/libiconv_modules/MSKanji/citrus_mskanji.c
+++ b/lib/libiconv_modules/MSKanji/citrus_mskanji.c
@@ -151,10 +151,10 @@ _citrus_MSKanji_unpack_state(_MSKanjiEncodingInfo * __restrict ei __unused,
static int
/*ARGSUSED*/
_citrus_MSKanji_mbrtowc_priv(_MSKanjiEncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s, size_t n,
+ wchar_t * __restrict pwc, const char ** __restrict s, size_t n,
_MSKanjiState * __restrict psenc, size_t * __restrict nresult)
{
- char *s0;
+ const char *s0;
wchar_t wchar;
int chlenbak, len;
diff --git a/lib/libiconv_modules/UES/citrus_ues.c b/lib/libiconv_modules/UES/citrus_ues.c
index 1c4bc83a3c50..872cc1f64a1d 100644
--- a/lib/libiconv_modules/UES/citrus_ues.c
+++ b/lib/libiconv_modules/UES/citrus_ues.c
@@ -183,10 +183,10 @@ is_basic(wchar_t wc)
static int
_citrus_UES_mbrtowc_priv(_UESEncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s, size_t n,
+ wchar_t * __restrict pwc, const char ** __restrict s, size_t n,
_UESState * __restrict psenc, size_t * __restrict nresult)
{
- char *s0;
+ const char *s0;
int ch, head, num, tail;
wchar_t hi, wc;
diff --git a/lib/libiconv_modules/UTF1632/citrus_utf1632.c b/lib/libiconv_modules/UTF1632/citrus_utf1632.c
index 6682ab279692..4ef4db19d73a 100644
--- a/lib/libiconv_modules/UTF1632/citrus_utf1632.c
+++ b/lib/libiconv_modules/UTF1632/citrus_utf1632.c
@@ -97,9 +97,9 @@ _citrus_UTF1632_init_state(_UTF1632EncodingInfo *ei __unused,
static int
_citrus_UTF1632_mbrtowc_priv(_UTF1632EncodingInfo *ei, wchar_t *pwc,
- char **s, size_t n, _UTF1632State *psenc, size_t *nresult)
+ const char **s, size_t n, _UTF1632State *psenc, size_t *nresult)
{
- char *s0;
+ const char *s0;
size_t result;
wchar_t wc = L'\0';
int chlenbak, endian, needlen;
diff --git a/lib/libiconv_modules/UTF7/citrus_utf7.c b/lib/libiconv_modules/UTF7/citrus_utf7.c
index e99f980c321c..925be6d228eb 100644
--- a/lib/libiconv_modules/UTF7/citrus_utf7.c
+++ b/lib/libiconv_modules/UTF7/citrus_utf7.c
@@ -149,11 +149,11 @@ static const char spaces[] = " \t\r\n";
static int
_citrus_UTF7_mbtoutf16(_UTF7EncodingInfo * __restrict ei,
- uint16_t * __restrict u16, char ** __restrict s, size_t n,
+ uint16_t * __restrict u16, const char ** __restrict s, size_t n,
_UTF7State * __restrict psenc, size_t * __restrict nresult)
{
_UTF7State sv;
- char *s0;
+ const char *s0;
int done, i, len;
s0 = *s;
@@ -238,10 +238,10 @@ ilseq:
static int
_citrus_UTF7_mbrtowc_priv(_UTF7EncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s, size_t n,
+ wchar_t * __restrict pwc, const char ** __restrict s, size_t n,
_UTF7State * __restrict psenc, size_t * __restrict nresult)
{
- char *s0;
+ const char *s0;
uint32_t u32;
uint16_t hi, lo;
size_t nr, siz;
diff --git a/lib/libiconv_modules/UTF8/citrus_utf8.c b/lib/libiconv_modules/UTF8/citrus_utf8.c
index 2bd8d81847a0..cdbc53c49e37 100644
--- a/lib/libiconv_modules/UTF8/citrus_utf8.c
+++ b/lib/libiconv_modules/UTF8/citrus_utf8.c
@@ -175,10 +175,10 @@ _citrus_UTF8_unpack_state(_UTF8EncodingInfo *ei __unused, _UTF8State *s,
}
static int
-_citrus_UTF8_mbrtowc_priv(_UTF8EncodingInfo *ei, wchar_t *pwc, char **s,
+_citrus_UTF8_mbrtowc_priv(_UTF8EncodingInfo *ei, wchar_t *pwc, const char **s,
size_t n, _UTF8State *psenc, size_t *nresult)
{
- char *s0;
+ const char *s0;
wchar_t wchar;
int i;
uint8_t c;
diff --git a/lib/libiconv_modules/VIQR/citrus_viqr.c b/lib/libiconv_modules/VIQR/citrus_viqr.c
index bd26749865f2..20175a3b6bea 100644
--- a/lib/libiconv_modules/VIQR/citrus_viqr.c
+++ b/lib/libiconv_modules/VIQR/citrus_viqr.c
@@ -250,11 +250,11 @@ _citrus_VIQR_unpack_state(_VIQREncodingInfo * __restrict ei __unused,
static int
_citrus_VIQR_mbrtowc_priv(_VIQREncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char ** __restrict s, size_t n,
+ wchar_t * __restrict pwc, const char ** __restrict s, size_t n,
_VIQRState * __restrict psenc, size_t * __restrict nresult)
{
mnemonic_t *m, *m0;
- char *s0;
+ const char *s0;
wchar_t wc;
ssize_t i;
int ch, escape;
diff --git a/lib/libiconv_modules/ZW/citrus_zw.c b/lib/libiconv_modules/ZW/citrus_zw.c
index d57661f1649c..b9dc10b091f7 100644
--- a/lib/libiconv_modules/ZW/citrus_zw.c
+++ b/lib/libiconv_modules/ZW/citrus_zw.c
@@ -105,10 +105,10 @@ _citrus_ZW_unpack_state(_ZWEncodingInfo * __restrict ei __unused,
static int
_citrus_ZW_mbrtowc_priv(_ZWEncodingInfo * __restrict ei,
- wchar_t * __restrict pwc, char **__restrict s, size_t n,
+ wchar_t * __restrict pwc, const char **__restrict s, size_t n,
_ZWState * __restrict psenc, size_t * __restrict nresult)
{
- char *s0;
+ const char *s0;
wchar_t wc;
int ch, len;
diff --git a/lib/libiconv_modules/iconv_none/citrus_iconv_none.c b/lib/libiconv_modules/iconv_none/citrus_iconv_none.c
index d9230cb26f3e..76bb06f539d0 100644
--- a/lib/libiconv_modules/iconv_none/citrus_iconv_none.c
+++ b/lib/libiconv_modules/iconv_none/citrus_iconv_none.c
@@ -97,7 +97,7 @@ _citrus_iconv_none_iconv_uninit_context(struct _citrus_iconv *cv __unused)
static int
/*ARGSUSED*/
_citrus_iconv_none_iconv_convert(struct _citrus_iconv * __restrict ci __unused,
- char * __restrict * __restrict in, size_t * __restrict inbytes,
+ const char * __restrict * __restrict in, size_t * __restrict inbytes,
char * __restrict * __restrict out, size_t * __restrict outbytes,
uint32_t flags __unused, size_t * __restrict invalids)
{
diff --git a/lib/libiconv_modules/iconv_std/citrus_iconv_std.c b/lib/libiconv_modules/iconv_std/citrus_iconv_std.c
index 8349c46819c6..b30f09928ae8 100644
--- a/lib/libiconv_modules/iconv_std/citrus_iconv_std.c
+++ b/lib/libiconv_modules/iconv_std/citrus_iconv_std.c
@@ -104,7 +104,7 @@ init_encoding_state(struct _citrus_iconv_std_encoding *se)
static __inline int
mbtocsx(struct _citrus_iconv_std_encoding *se,
- _csid_t *csid, _index_t *idx, char **s, size_t n, size_t *nresult,
+ _csid_t *csid, _index_t *idx, const char **s, size_t n, size_t *nresult,
struct iconv_hooks *hooks)
{
@@ -461,7 +461,7 @@ _citrus_iconv_std_iconv_uninit_context(struct _citrus_iconv *cv)
static int
_citrus_iconv_std_iconv_convert(struct _citrus_iconv * __restrict cv,
- char * __restrict * __restrict in, size_t * __restrict inbytes,
+ const char * __restrict * __restrict in, size_t * __restrict inbytes,
char * __restrict * __restrict out, size_t * __restrict outbytes,
uint32_t flags, size_t * __restrict invalids)
{
@@ -469,7 +469,7 @@ _citrus_iconv_std_iconv_convert(struct _citrus_iconv * __restrict cv,
struct _citrus_iconv_std_context *sc = cv->cv_closure;
_csid_t csid;
_index_t idx;
- char *tmpin;
+ const char *tmpin;
size_t inval, szrin, szrout;
int ret, state = 0;
diff --git a/lib/libipsec/policy_token.l b/lib/libipsec/policy_token.l
index 2a79d5e4bcbb..219cce446b65 100644
--- a/lib/libipsec/policy_token.l
+++ b/lib/libipsec/policy_token.l
@@ -139,8 +139,8 @@ void
__policy__strbuffer__init__(msg)
char *msg;
{
- if (yy_current_buffer)
- yy_delete_buffer(yy_current_buffer);
+ if (YY_CURRENT_BUFFER)
+ yy_delete_buffer(YY_CURRENT_BUFFER);
strbuffer = (YY_BUFFER_STATE)yy_scan_string(msg);
yy_switch_to_buffer(strbuffer);
diff --git a/lib/libkiconv/xlat16_iconv.c b/lib/libkiconv/xlat16_iconv.c
index f402b784d85b..fee3c77a73af 100644
--- a/lib/libkiconv/xlat16_iconv.c
+++ b/lib/libkiconv/xlat16_iconv.c
@@ -49,8 +49,6 @@
#include "quirks.h"
-typedef void *iconv_t;
-
struct xlat16_table {
uint32_t * idx[0x200];
void * data;
@@ -61,6 +59,7 @@ static struct xlat16_table kiconv_xlat16_open(const char *, const char *, int);
static int chklocale(int, const char *);
#ifdef ICONV_DLOPEN
+typedef void *iconv_t;
static int my_iconv_init(void);
static iconv_t (*my_iconv_open)(const char *, const char *);
static size_t (*my_iconv)(iconv_t, const char **, size_t *, char **, size_t *);
diff --git a/lib/libkvm/Makefile b/lib/libkvm/Makefile
index 5b5ad43bd2d9..f21a1bfc11c5 100644
--- a/lib/libkvm/Makefile
+++ b/lib/libkvm/Makefile
@@ -3,6 +3,7 @@
LIB= kvm
SHLIBDIR?= /lib
+SHLIB_MAJOR= 6
CFLAGS+=-DLIBC_SCCS -I${.CURDIR}
.if exists(${.CURDIR}/kvm_${MACHINE_ARCH}.c)
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index 6c19a1440d22..9181a491bafe 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -166,7 +166,7 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, int flag, char *errout)
if (mf == 0)
mf = _PATH_MEM;
- if ((kd->pmfd = open(mf, flag, 0)) < 0) {
+ if ((kd->pmfd = open(mf, flag | O_CLOEXEC, 0)) < 0) {
_kvm_syserr(kd, kd->program, "%s", mf);
goto failed;
}
@@ -179,10 +179,6 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, int flag, char *errout)
_kvm_syserr(kd, kd->program, "empty file");
goto failed;
}
- if (fcntl(kd->pmfd, F_SETFD, FD_CLOEXEC) < 0) {
- _kvm_syserr(kd, kd->program, "%s", mf);
- goto failed;
- }
if (S_ISCHR(st.st_mode)) {
/*
* If this is a character special device, then check that
@@ -191,14 +187,11 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, int flag, char *errout)
* case you're working with a live kernel.)
*/
if (strcmp(mf, _PATH_DEVNULL) == 0) {
- kd->vmfd = open(_PATH_DEVNULL, O_RDONLY);
+ kd->vmfd = open(_PATH_DEVNULL, O_RDONLY | O_CLOEXEC);
return (kd);
} else if (strcmp(mf, _PATH_MEM) == 0) {
- if ((kd->vmfd = open(_PATH_KMEM, flag)) < 0) {
- _kvm_syserr(kd, kd->program, "%s", _PATH_KMEM);
- goto failed;
- }
- if (fcntl(kd->vmfd, F_SETFD, FD_CLOEXEC) < 0) {
+ if ((kd->vmfd = open(_PATH_KMEM, flag | O_CLOEXEC)) <
+ 0) {
_kvm_syserr(kd, kd->program, "%s", _PATH_KMEM);
goto failed;
}
@@ -210,11 +203,7 @@ _kvm_open(kvm_t *kd, const char *uf, const char *mf, int flag, char *errout)
* Initialize the virtual address translation machinery,
* but first setup the namelist fd.
*/
- if ((kd->nlfd = open(uf, O_RDONLY, 0)) < 0) {
- _kvm_syserr(kd, kd->program, "%s", uf);
- goto failed;
- }
- if (fcntl(kd->nlfd, F_SETFD, FD_CLOEXEC) < 0) {
+ if ((kd->nlfd = open(uf, O_RDONLY | O_CLOEXEC, 0)) < 0) {
_kvm_syserr(kd, kd->program, "%s", uf);
goto failed;
}
diff --git a/lib/libkvm/kvm.h b/lib/libkvm/kvm.h
index 43b0551f6e66..d2ee8fa442ec 100644
--- a/lib/libkvm/kvm.h
+++ b/lib/libkvm/kvm.h
@@ -89,8 +89,6 @@ kvm_t *kvm_openfiles
(const char *, const char *, const char *, int, char *);
ssize_t kvm_read(kvm_t *, unsigned long, void *, size_t);
ssize_t kvm_read_zpcpu(kvm_t *, void *, u_long, size_t, int);
-ssize_t kvm_uread
- (kvm_t *, const struct kinfo_proc *, unsigned long, char *, size_t);
ssize_t kvm_write(kvm_t *, unsigned long, const void *, size_t);
__END_DECLS
diff --git a/lib/libkvm/kvm_mips.c b/lib/libkvm/kvm_mips.c
index ad0834be37d3..56e7fbf372d3 100644
--- a/lib/libkvm/kvm_mips.c
+++ b/lib/libkvm/kvm_mips.c
@@ -10,22 +10,18 @@
* 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 Bruce M. Simpson.
- * 4. The name of Bruce M. Simpson may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY BRUCE M. SIMPSON ``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 BRUCE M. SIMPSON 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.
+ * 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.
*/
/*
diff --git a/lib/libldns/Makefile b/lib/libldns/Makefile
index c0b30b0f3634..a46c3ab72847 100644
--- a/lib/libldns/Makefile
+++ b/lib/libldns/Makefile
@@ -3,42 +3,20 @@
# Vendor sources and generated files
LDNSDIR = ${.CURDIR}/../../contrib/ldns
-.PATH: ${LDNSDIR}
-
-LIB = ldns
-INTERNALLIB = true
-
-CFLAGS += -I${LDNSDIR}
-
-SRCS += buffer.c
-SRCS += dane.c
-SRCS += dname.c
-SRCS += dnssec.c
-SRCS += dnssec_sign.c
-SRCS += dnssec_verify.c
-SRCS += dnssec_zone.c
-SRCS += duration.c
-SRCS += error.c
-SRCS += higher.c
-SRCS += host2str.c
-SRCS += host2wire.c
-SRCS += keys.c
-SRCS += net.c
-SRCS += packet.c
-SRCS += parse.c
-SRCS += rbtree.c
-SRCS += rdata.c
-SRCS += resolver.c
-SRCS += rr.c
-SRCS += rr_functions.c
-SRCS += sha1.c
-SRCS += sha2.c
-SRCS += str2host.c
-SRCS += tsig.c
-SRCS += update.c
-SRCS += util.c
-SRCS += wire2host.c
-SRCS += zone.c
+.PATH: ${LDNSDIR} ${LDNSDIR}/compat
+
+LIB= ldns
+INTERNALLIB= true
+
+CFLAGS+= -I${LDNSDIR}
+
+SRCS= buffer.c dane.c dname.c dnssec.c dnssec_sign.c dnssec_verify.c \
+ dnssec_zone.c duration.c error.c higher.c host2str.c host2wire.c \
+ keys.c net.c packet.c parse.c rbtree.c rdata.c resolver.c rr.c \
+ rr_functions.c sha1.c sha2.c str2host.c tsig.c update.c util.c \
+ wire2host.c zone.c
+
+SRCS+= b32_ntop.c b32_pton.c b64_ntop.c b64_pton.c
WARNS ?= 3
diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c
index 040198c88a8c..b8ff3a1f2c03 100644
--- a/lib/libmemstat/memstat_uma.c
+++ b/lib/libmemstat/memstat_uma.c
@@ -446,7 +446,7 @@ skip_percpu:
kz.uk_ipers;
mtp->mt_byteslimit = mtp->mt_countlimit * mtp->mt_size;
mtp->mt_count = mtp->mt_numallocs - mtp->mt_numfrees;
- for (ubp = LIST_FIRST(&uz.uz_full_bucket); ubp !=
+ for (ubp = LIST_FIRST(&uz.uz_buckets); ubp !=
NULL; ubp = LIST_NEXT(&ub, ub_link)) {
ret = kread(kvm, ubp, &ub, sizeof(ub), 0);
mtp->mt_zonefree += ub.ub_cnt;
diff --git a/lib/libpam/Makefile.inc b/lib/libpam/Makefile.inc
index 923d7bd7bac2..d2d1d426360d 100644
--- a/lib/libpam/Makefile.inc
+++ b/lib/libpam/Makefile.inc
@@ -24,9 +24,7 @@
#
# $FreeBSD$
-.ifdef PAM_DEBUG
-DEBUG_FLAGS+= -DDEBUG
-.endif
+CFLAGS+= -DOPENPAM_DEBUG
SHLIB_MAJOR= 5
PAM_MOD_DIR= ${LIBDIR}
diff --git a/lib/libpam/libpam/pam_std_option.c b/lib/libpam/libpam/pam_std_option.c
deleted file mode 100644
index a9ddfba51a26..000000000000
--- a/lib/libpam/libpam/pam_std_option.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, 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 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <stdio.h>
-#include <string.h>
-#include <syslog.h>
-
-#include <security/pam_appl.h>
-#include <security/pam_mod_misc.h>
-
-/* Everyone has to have these options. It is not an error to
- * specify them and then not use them.
- */
-struct opttab std_options[PAM_MAX_OPTIONS] = {
- { "debug", PAM_OPT_DEBUG },
- { "no_warn", PAM_OPT_NO_WARN },
- { "echo_pass", PAM_OPT_ECHO_PASS },
- { "use_first_pass", PAM_OPT_USE_FIRST_PASS },
- { "try_first_pass", PAM_OPT_TRY_FIRST_PASS },
- { "use_mapped_pass", PAM_OPT_USE_MAPPED_PASS },
- { "try_mapped_pass", PAM_OPT_TRY_MAPPED_PASS },
- { "expose_account", PAM_OPT_EXPOSE_ACCOUNT },
- { NULL, 0 }
-};
-
-/* Populate the options structure, syslogging all errors */
-void
-pam_std_option(struct options *options, struct opttab other_options[],
- int argc, const char *argv[])
-{
- struct opttab *oo;
- int i, j, std, extra, arglen, found;
-
- std = 1;
- extra = 1;
- oo = other_options;
- for (i = 0; i < PAM_MAX_OPTIONS; i++) {
- if (std && std_options[i].name == NULL)
- std = 0;
- else if (extra && (oo == NULL || oo->name == NULL))
- extra = 0;
-
- if (std)
- options->opt[i].name = std_options[i].name;
- else if (extra) {
- if (oo->value != i)
- syslog(LOG_DEBUG, "Extra option fault: %d %d",
- oo->value, i);
- options->opt[i].name = oo->name;
- oo++;
- }
- else
- options->opt[i].name = NULL;
-
- options->opt[i].bool = 0;
- options->opt[i].arg = NULL;
- }
-
- for (j = 0; j < argc; j++) {
-#ifdef DEBUG
- syslog(LOG_DEBUG, "Doing arg %s", argv[j]);
-#endif
- found = 0;
- for (i = 0; i < PAM_MAX_OPTIONS; i++) {
- if (options->opt[i].name == NULL)
- break;
- arglen = strlen(options->opt[i].name);
- if (strcmp(argv[j], options->opt[i].name) == 0) {
- options->opt[i].bool = 1;
- found = 1;
- break;
- }
- else if (strncmp(argv[j], options->opt[i].name, arglen)
- == 0 && argv[j][arglen] == '=') {
- options->opt[i].bool = 1;
- options->opt[i].arg
- = strdup(&argv[j][arglen + 1]);
- found = 1;
- break;
- }
- }
- if (!found)
- syslog(LOG_WARNING, "PAM option: %s invalid", argv[j]);
- }
-}
-
-/* Test if option is set in options */
-int
-pam_test_option(struct options *options, enum opt option, char **arg)
-{
- if (arg != NULL)
- *arg = options->opt[option].arg;
- return options->opt[option].bool;
-}
-
-/* Set option in options, errors to syslog */
-void
-pam_set_option(struct options *options, enum opt option)
-{
- if (option < PAM_OPT_STD_MAX)
- options->opt[option].bool = 1;
-#ifdef DEBUG
- else
- syslog(LOG_DEBUG, "PAM options: attempt to set option %d",
- option);
-#endif
-}
-
-/* Clear option in options, errors to syslog */
-void
-pam_clear_option(struct options *options, enum opt option)
-{
- if (option < PAM_OPT_STD_MAX)
- options->opt[option].bool = 0;
-#ifdef DEBUG
- else
- syslog(LOG_DEBUG, "PAM options: attempt to clear option %d",
- option);
-#endif
-}
-
-#ifdef DEBUG1
-enum { PAM_OPT_FOO=PAM_OPT_STD_MAX, PAM_OPT_BAR, PAM_OPT_BAZ, PAM_OPT_QUX };
-
-struct opttab other_options[] = {
- { "foo", PAM_OPT_FOO },
- { "bar", PAM_OPT_BAR },
- { "baz", PAM_OPT_BAZ },
- { "qux", PAM_OPT_QUX },
- { NULL, 0 }
-};
-
-int
-main(int argc, const char *argv[])
-{
- struct options options;
- int i, opt;
- char *arg;
-
- pam_std_option(&options, other_options, argc, argv);
- for (i = 0; i < PAM_MAX_OPTIONS; i++) {
- opt = pam_test_option(&options, i, &arg);
- if (opt) {
- if (arg == NULL)
- printf("%d []\n", i);
- else
- printf("%d [%s]\n", i, arg);
- }
- }
- return 0;
-}
-#endif
diff --git a/lib/libpam/modules/pam_passwdqc/Makefile b/lib/libpam/modules/pam_passwdqc/Makefile
index 905afe1c7eb6..c9cc30e52342 100644
--- a/lib/libpam/modules/pam_passwdqc/Makefile
+++ b/lib/libpam/modules/pam_passwdqc/Makefile
@@ -7,7 +7,7 @@ LIB= pam_passwdqc
SRCS= pam_passwdqc.c passwdqc_check.c passwdqc_random.c wordset_4k.c
MAN= pam_passwdqc.8
-WARNS?= 0
+WARNS?= 2
CFLAGS+= -I${SRCDIR}
DPADD= ${LIBCRYPT}
diff --git a/lib/libpcap/config.h b/lib/libpcap/config.h
index 379772b86546..79cb3d228ce4 100644
--- a/lib/libpcap/config.h
+++ b/lib/libpcap/config.h
@@ -62,6 +62,15 @@
/* if libnl exists and is version 2.x */
/* #undef HAVE_LIBNL_2_x */
+/* if libnl exists and is version 3.x */
+/* #undef HAVE_LIBNL_3_x */
+
+/* libnl has NLE_FAILURE */
+/* #undef HAVE_LIBNL_NLE */
+
+/* libnl has new-style socket api */
+/* #undef HAVE_LIBNL_SOCKETS */
+
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
@@ -217,11 +226,14 @@
/* path for device for USB sniffing */
/* #undef LINUX_USB_MON_DEV */
+/* if we need a pcap_parse wrapper around yyparse */
+#define NEED_YYPARSE_WRAPPER
+
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
/* #undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON */
/* Define to 1 if netinet/if_ether.h declares `ether_hostton' */
-#define NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON /**/
+#define NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON
/* do not use protochain */
/* #undef NO_PROTOCHAIN */
@@ -238,9 +250,6 @@
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
@@ -265,6 +274,9 @@
/* include ACN support */
/* #undef SITA */
+/* if struct sockaddr_hci has hci_channel member */
+/* #undef SOCKADDR_HCI_HAS_HCI_CHANNEL */
+
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
diff --git a/lib/libpmc/Makefile b/lib/libpmc/Makefile
index dde87bb3ab6b..d9ac0b97b623 100644
--- a/lib/libpmc/Makefile
+++ b/lib/libpmc/Makefile
@@ -23,35 +23,31 @@ MAN+= pmclog.3
MAN+= pmc.soft.3
# PMC-dependent manual pages
-.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
MAN+= pmc.atom.3
MAN+= pmc.core.3
MAN+= pmc.core2.3
+MAN+= pmc.corei7.3
+MAN+= pmc.corei7uc.3
MAN+= pmc.haswell.3
MAN+= pmc.haswelluc.3
MAN+= pmc.iaf.3
MAN+= pmc.ivybridge.3
MAN+= pmc.ivybridgexeon.3
-MAN+= pmc.ucf.3
MAN+= pmc.k7.3
MAN+= pmc.k8.3
+MAN+= pmc.mips24k.3
+MAN+= pmc.octeon.3
MAN+= pmc.p4.3
MAN+= pmc.p5.3
MAN+= pmc.p6.3
-MAN+= pmc.corei7.3
-MAN+= pmc.corei7uc.3
MAN+= pmc.sandybridge.3
-MAN+= pmc.sandybridgeuc.3
-MAN+= pmc.sandybridgexeon.3
+MAN+= pmc.sandybridgeuc.3
+MAN+= pmc.sandybridgexeon.3
+MAN+= pmc.tsc.3
+MAN+= pmc.ucf.3
MAN+= pmc.westmere.3
MAN+= pmc.westmereuc.3
-MAN+= pmc.tsc.3
-.elif ${MACHINE_CPUARCH} == "arm"
MAN+= pmc.xscale.3
-.elif ${MACHINE_CPUARCH} == "mips"
-MAN+= pmc.mips24k.3
-MAN+= pmc.octeon.3
-.endif
MLINKS+= \
pmc_allocate.3 pmc_release.3 \
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c
index 4bef7f0f7e83..2dd21fee5648 100644
--- a/lib/libproc/proc_sym.c
+++ b/lib/libproc/proc_sym.c
@@ -299,6 +299,7 @@ proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name,
* the function.
*/
symcopy->st_value = rsym;
+ error = 0;
goto out;
}
}
diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile
index a29afc7a7d8d..af5a775d7d05 100644
--- a/lib/libprocstat/Makefile
+++ b/lib/libprocstat/Makefile
@@ -6,8 +6,10 @@ LIB= procstat
SRCS= cd9660.c \
common_kvm.c \
+ core.c \
libprocstat.c \
msdosfs.c \
+ smbfs.c \
udf.c
VERSION_DEF= ${.CURDIR}/Versions.def
@@ -17,8 +19,8 @@ INCS= libprocstat.h
CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE
SHLIB_MAJOR= 1
-DPADD= ${LIBKVM} ${LIBUTIL}
-LDADD= -lkvm -lutil
+DPADD= ${LIBELF} ${LIBKVM} ${LIBUTIL}
+LDADD= -lelf -lkvm -lutil
MAN= libprocstat.3
diff --git a/lib/libprocstat/Symbol.map b/lib/libprocstat/Symbol.map
index 0509066369f0..1495bfc28c66 100644
--- a/lib/libprocstat/Symbol.map
+++ b/lib/libprocstat/Symbol.map
@@ -16,5 +16,23 @@ FBSD_1.2 {
};
FBSD_1.3 {
+ procstat_freeargv;
+ procstat_freeauxv;
+ procstat_freeenvv;
+ procstat_freegroups;
+ procstat_freekstack;
+ procstat_freevmmap;
+ procstat_get_sem_info;
procstat_get_shm_info;
+ procstat_getargv;
+ procstat_getauxv;
+ procstat_getenvv;
+ procstat_getgroups;
+ procstat_getkstack;
+ procstat_getosrel;
+ procstat_getpathname;
+ procstat_getrlimit;
+ procstat_getumask;
+ procstat_getvmmap;
+ procstat_open_core;
};
diff --git a/lib/libprocstat/common_kvm.h b/lib/libprocstat/common_kvm.h
index d5e08e1cfc09..06627bff448c 100644
--- a/lib/libprocstat/common_kvm.h
+++ b/lib/libprocstat/common_kvm.h
@@ -41,6 +41,7 @@ int devfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int isofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int msdosfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int nfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
+int smbfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int udf_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int ufs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
diff --git a/lib/libprocstat/core.c b/lib/libprocstat/core.c
new file mode 100644
index 000000000000..70ab86df5b0b
--- /dev/null
+++ b/lib/libprocstat/core.c
@@ -0,0 +1,433 @@
+/*-
+ * Copyright (c) 2013 Mikolaj Golub <trociny@FreeBSD.org>
+ * 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 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/elf.h>
+#include <sys/exec.h>
+#include <sys/user.h>
+
+#include <assert.h>
+#include <err.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <libelf.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "core.h"
+
+#define PROCSTAT_CORE_MAGIC 0x012DADB8
+struct procstat_core
+{
+ int pc_magic;
+ int pc_fd;
+ Elf *pc_elf;
+ GElf_Ehdr pc_ehdr;
+ GElf_Phdr pc_phdr;
+};
+
+static bool core_offset(struct procstat_core *core, off_t offset);
+static bool core_read(struct procstat_core *core, void *buf, size_t len);
+static ssize_t core_read_mem(struct procstat_core *core, void *buf,
+ size_t len, vm_offset_t addr, bool readall);
+static void *get_args(struct procstat_core *core, vm_offset_t psstrings,
+ enum psc_type type, void *buf, size_t *lenp);
+
+struct procstat_core *
+procstat_core_open(const char *filename)
+{
+ struct procstat_core *core;
+ Elf *e;
+ GElf_Ehdr ehdr;
+ GElf_Phdr phdr;
+ size_t nph;
+ int fd, i;
+
+ if (elf_version(EV_CURRENT) == EV_NONE) {
+ warnx("ELF library too old");
+ return (NULL);
+ }
+ fd = open(filename, O_RDONLY, 0);
+ if (fd == -1) {
+ warn("open(%s)", filename);
+ return (NULL);
+ }
+ e = elf_begin(fd, ELF_C_READ, NULL);
+ if (e == NULL) {
+ warnx("elf_begin: %s", elf_errmsg(-1));
+ goto fail;
+ }
+ if (elf_kind(e) != ELF_K_ELF) {
+ warnx("%s is not an ELF object", filename);
+ goto fail;
+ }
+ if (gelf_getehdr(e, &ehdr) == NULL) {
+ warnx("gelf_getehdr: %s", elf_errmsg(-1));
+ goto fail;
+ }
+ if (ehdr.e_type != ET_CORE) {
+ warnx("%s is not a CORE file", filename);
+ goto fail;
+ }
+ if (elf_getphnum(e, &nph) == 0) {
+ warnx("program headers not found");
+ goto fail;
+ }
+ for (i = 0; i < ehdr.e_phnum; i++) {
+ if (gelf_getphdr(e, i, &phdr) != &phdr) {
+ warnx("gelf_getphdr: %s", elf_errmsg(-1));
+ goto fail;
+ }
+ if (phdr.p_type == PT_NOTE)
+ break;
+ }
+ if (i == ehdr.e_phnum) {
+ warnx("NOTE program header not found");
+ goto fail;
+ }
+ core = malloc(sizeof(struct procstat_core));
+ if (core == NULL) {
+ warn("malloc(%zu)", sizeof(struct procstat_core));
+ goto fail;
+ }
+ core->pc_magic = PROCSTAT_CORE_MAGIC;
+ core->pc_fd = fd;
+ core->pc_elf = e;
+ core->pc_ehdr = ehdr;
+ core->pc_phdr = phdr;
+
+ return (core);
+fail:
+ if (e != NULL)
+ elf_end(e);
+ close(fd);
+
+ return (NULL);
+}
+
+void
+procstat_core_close(struct procstat_core *core)
+{
+
+ assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+ elf_end(core->pc_elf);
+ close(core->pc_fd);
+ free(core);
+}
+
+void *
+procstat_core_get(struct procstat_core *core, enum psc_type type, void *buf,
+ size_t *lenp)
+{
+ Elf_Note nhdr;
+ off_t offset, eoffset;
+ vm_offset_t psstrings;
+ void *freebuf;
+ size_t len;
+ u_int32_t n_type;
+ int cstructsize, structsize;
+ char nbuf[8];
+
+ assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+ switch(type) {
+ case PSC_TYPE_PROC:
+ n_type = NT_PROCSTAT_PROC;
+ structsize = sizeof(struct kinfo_proc);
+ break;
+ case PSC_TYPE_FILES:
+ n_type = NT_PROCSTAT_FILES;
+ structsize = sizeof(struct kinfo_file);
+ break;
+ case PSC_TYPE_VMMAP:
+ n_type = NT_PROCSTAT_VMMAP;
+ structsize = sizeof(struct kinfo_vmentry);
+ break;
+ case PSC_TYPE_GROUPS:
+ n_type = NT_PROCSTAT_GROUPS;
+ structsize = sizeof(gid_t);
+ break;
+ case PSC_TYPE_UMASK:
+ n_type = NT_PROCSTAT_UMASK;
+ structsize = sizeof(u_short);
+ break;
+ case PSC_TYPE_RLIMIT:
+ n_type = NT_PROCSTAT_RLIMIT;
+ structsize = sizeof(struct rlimit) * RLIM_NLIMITS;
+ break;
+ case PSC_TYPE_OSREL:
+ n_type = NT_PROCSTAT_OSREL;
+ structsize = sizeof(int);
+ break;
+ case PSC_TYPE_PSSTRINGS:
+ case PSC_TYPE_ARGV:
+ case PSC_TYPE_ENVV:
+ n_type = NT_PROCSTAT_PSSTRINGS;
+ structsize = sizeof(vm_offset_t);
+ break;
+ case PSC_TYPE_AUXV:
+ n_type = NT_PROCSTAT_AUXV;
+ structsize = sizeof(Elf_Auxinfo);
+ break;
+ default:
+ warnx("unknown core stat type: %d", type);
+ return (NULL);
+ }
+
+ offset = core->pc_phdr.p_offset;
+ eoffset = offset + core->pc_phdr.p_filesz;
+
+ while (offset < eoffset) {
+ if (!core_offset(core, offset))
+ return (NULL);
+ if (!core_read(core, &nhdr, sizeof(nhdr)))
+ return (NULL);
+
+ offset += sizeof(nhdr) +
+ roundup2(nhdr.n_namesz, sizeof(Elf32_Size)) +
+ roundup2(nhdr.n_descsz, sizeof(Elf32_Size));
+
+ if (nhdr.n_namesz == 0 && nhdr.n_descsz == 0)
+ break;
+ if (nhdr.n_type != n_type)
+ continue;
+ if (nhdr.n_namesz != 8)
+ continue;
+ if (!core_read(core, nbuf, sizeof(nbuf)))
+ return (NULL);
+ if (strcmp(nbuf, "FreeBSD") != 0)
+ continue;
+ if (nhdr.n_descsz < sizeof(cstructsize)) {
+ warnx("corrupted core file");
+ return (NULL);
+ }
+ if (!core_read(core, &cstructsize, sizeof(cstructsize)))
+ return (NULL);
+ if (cstructsize != structsize) {
+ warnx("version mismatch");
+ return (NULL);
+ }
+ len = nhdr.n_descsz - sizeof(cstructsize);
+ if (len == 0)
+ return (NULL);
+ if (buf != NULL) {
+ len = MIN(len, *lenp);
+ freebuf = NULL;
+ } else {
+ freebuf = buf = malloc(len);
+ if (buf == NULL) {
+ warn("malloc(%zu)", len);
+ return (NULL);
+ }
+ }
+ if (!core_read(core, buf, len)) {
+ free(freebuf);
+ return (NULL);
+ }
+ if (type == PSC_TYPE_ARGV || type == PSC_TYPE_ENVV) {
+ if (len < sizeof(psstrings)) {
+ free(freebuf);
+ return (NULL);
+ }
+ psstrings = *(vm_offset_t *)buf;
+ if (freebuf == NULL)
+ len = *lenp;
+ else
+ buf = NULL;
+ free(freebuf);
+ buf = get_args(core, psstrings, type, buf, &len);
+ }
+ *lenp = len;
+ return (buf);
+ }
+
+ return (NULL);
+}
+
+static bool
+core_offset(struct procstat_core *core, off_t offset)
+{
+
+ assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+ if (lseek(core->pc_fd, offset, SEEK_SET) == -1) {
+ warn("core: lseek(%jd)", (intmax_t)offset);
+ return (false);
+ }
+ return (true);
+}
+
+static bool
+core_read(struct procstat_core *core, void *buf, size_t len)
+{
+ ssize_t n;
+
+ assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+ n = read(core->pc_fd, buf, len);
+ if (n == -1) {
+ warn("core: read");
+ return (false);
+ }
+ if (n < (ssize_t)len) {
+ warnx("core: short read");
+ return (false);
+ }
+ return (true);
+}
+
+static ssize_t
+core_read_mem(struct procstat_core *core, void *buf, size_t len,
+ vm_offset_t addr, bool readall)
+{
+ GElf_Phdr phdr;
+ off_t offset;
+ int i;
+
+ assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+ for (i = 0; i < core->pc_ehdr.e_phnum; i++) {
+ if (gelf_getphdr(core->pc_elf, i, &phdr) != &phdr) {
+ warnx("gelf_getphdr: %s", elf_errmsg(-1));
+ return (-1);
+ }
+ if (phdr.p_type != PT_LOAD)
+ continue;
+ if (addr < phdr.p_vaddr || addr > phdr.p_vaddr + phdr.p_memsz)
+ continue;
+ offset = phdr.p_offset + (addr - phdr.p_vaddr);
+ if ((phdr.p_vaddr + phdr.p_memsz) - addr < len) {
+ if (readall) {
+ warnx("format error: "
+ "attempt to read out of segment");
+ return (-1);
+ }
+ len = (phdr.p_vaddr + phdr.p_memsz) - addr;
+ }
+ if (!core_offset(core, offset))
+ return (-1);
+ if (!core_read(core, buf, len))
+ return (-1);
+ return (len);
+ }
+ warnx("format error: address %ju not found", (uintmax_t)addr);
+ return (-1);
+}
+
+#define ARGS_CHUNK_SZ 256 /* Chunk size (bytes) for get_args operations. */
+
+static void *
+get_args(struct procstat_core *core, vm_offset_t psstrings, enum psc_type type,
+ void *args, size_t *lenp)
+{
+ struct ps_strings pss;
+ void *freeargs;
+ vm_offset_t addr;
+ char **argv, *p;
+ size_t chunksz, done, len, nchr, size;
+ ssize_t n;
+ u_int i, nstr;
+
+ assert(type == PSC_TYPE_ARGV || type == PSC_TYPE_ENVV);
+
+ if (core_read_mem(core, &pss, sizeof(pss), psstrings, true) == -1)
+ return (NULL);
+ if (type == PSC_TYPE_ARGV) {
+ addr = (vm_offset_t)pss.ps_argvstr;
+ nstr = pss.ps_nargvstr;
+ } else /* type == PSC_TYPE_ENVV */ {
+ addr = (vm_offset_t)pss.ps_envstr;
+ nstr = pss.ps_nenvstr;
+ }
+ if (addr == 0 || nstr == 0)
+ return (NULL);
+ if (nstr > ARG_MAX) {
+ warnx("format error");
+ return (NULL);
+ }
+ size = nstr * sizeof(char *);
+ argv = malloc(size);
+ if (argv == NULL) {
+ warn("malloc(%zu)", size);
+ return (NULL);
+ }
+ done = 0;
+ freeargs = NULL;
+ if (core_read_mem(core, argv, size, addr, true) == -1)
+ goto fail;
+ if (args != NULL) {
+ nchr = MIN(ARG_MAX, *lenp);
+ } else {
+ nchr = ARG_MAX;
+ freeargs = args = malloc(nchr);
+ if (args == NULL) {
+ warn("malloc(%zu)", nchr);
+ goto fail;
+ }
+ }
+ p = args;
+ for (i = 0; ; i++) {
+ if (i == nstr)
+ goto done;
+ /*
+ * The program may have scribbled into its argv array, e.g. to
+ * remove some arguments. If that has happened, break out
+ * before trying to read from NULL.
+ */
+ if (argv[i] == NULL)
+ goto done;
+ for (addr = (vm_offset_t)argv[i]; ; addr += chunksz) {
+ chunksz = MIN(ARGS_CHUNK_SZ, nchr - 1 - done);
+ if (chunksz <= 0)
+ goto done;
+ n = core_read_mem(core, p, chunksz, addr, false);
+ if (n == -1)
+ goto fail;
+ len = strnlen(p, chunksz);
+ p += len;
+ done += len;
+ if (len != chunksz)
+ break;
+ }
+ *p++ = '\0';
+ done++;
+ }
+fail:
+ free(freeargs);
+ args = NULL;
+done:
+ *lenp = done;
+ free(argv);
+ return (args);
+}
diff --git a/lib/libprocstat/core.h b/lib/libprocstat/core.h
new file mode 100644
index 000000000000..6639abce174d
--- /dev/null
+++ b/lib/libprocstat/core.h
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2013 Mikolaj Golub <trociny@FreeBSD.org>
+ * 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 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$
+ */
+
+#ifndef _CORE_H
+#define _CORE_H
+
+enum psc_type {
+ PSC_TYPE_PROC,
+ PSC_TYPE_FILES,
+ PSC_TYPE_VMMAP,
+ PSC_TYPE_GROUPS,
+ PSC_TYPE_UMASK,
+ PSC_TYPE_RLIMIT,
+ PSC_TYPE_OSREL,
+ PSC_TYPE_PSSTRINGS,
+ PSC_TYPE_ARGV,
+ PSC_TYPE_ENVV,
+ PSC_TYPE_AUXV,
+};
+
+struct procstat_core;
+
+void procstat_core_close(struct procstat_core *core);
+void *procstat_core_get(struct procstat_core *core, enum psc_type type,
+ void * buf, size_t *lenp);
+struct procstat_core *procstat_core_open(const char *filename);
+
+#endif /* !_CORE_H_ */
diff --git a/lib/libprocstat/libprocstat.3 b/lib/libprocstat/libprocstat.3
index dd163c214cd0..b472900dd8b9 100644
--- a/lib/libprocstat/libprocstat.3
+++ b/lib/libprocstat/libprocstat.3
@@ -24,19 +24,36 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 1, 2012
+.Dd May 3, 2013
.Dt LIBPROCSTAT 3
.Os
.Sh NAME
+.Nm procstat_open_core ,
.Nm procstat_open_kvm ,
.Nm procstat_open_sysctl ,
.Nm procstat_close ,
+.Nm procstat_getargv ,
+.Nm procstat_getauxv ,
+.Nm procstat_getenvv ,
.Nm procstat_getfiles ,
+.Nm procstat_getgroups ,
+.Nm procstat_getkstack ,
+.Nm procstat_getosrel ,
+.Nm procstat_getpathname ,
.Nm procstat_getprocs ,
+.Nm procstat_getumask ,
+.Nm procstat_getvmmap ,
+.Nm procstat_freeargv ,
+.Nm procstat_freeauxv ,
+.Nm procstat_freeenvv ,
.Nm procstat_freefiles ,
+.Nm procstat_freegroups ,
+.Nm procstat_freekstack ,
.Nm procstat_freeprocs ,
+.Nm procstat_freevmmap ,
.Nm procstat_get_pipe_info ,
.Nm procstat_get_pts_info ,
+.Nm procstat_get_sem_info ,
.Nm procstat_get_shm_info ,
.Nm procstat_get_socket_info ,
.Nm procstat_get_vnode_info
@@ -50,12 +67,40 @@
.Ft void
.Fn procstat_close "struct procstat *procstat"
.Ft void
+.Fo procstat_freeargv
+.Fa "struct procstat *procstat"
+.Fc
+.Ft void
+.Fo procstat_freeauxv
+.Fa "struct procstat *procstat"
+.Fa "Elf_Auxinfo *auxv"
+.Fc
+.Ft void
+.Fo procstat_freeenvv
+.Fa "struct procstat *procstat"
+.Fc
+.Ft void
.Fo procstat_freefiles
.Fa "struct procstat *procstat"
.Fa "struct filestat_list *head"
.Fc
.Ft void
+.Fo procstat_freegroups
+.Fa "struct procstat *procstat"
+.Fa "gid_t *groups"
+.Fc
+.Ft void
+.Fo procstat_freekstack
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_kstack *kkstp"
+.Fc
+.Ft void
.Fn procstat_freeprocs "struct procstat *procstat" "struct kinfo_proc *p"
+.Ft void
+.Fo procstat_freevmmap
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_vmentry *vmmap"
+.Fc
.Ft int
.Fo procstat_get_pipe_info
.Fa "struct procstat *procstat"
@@ -71,6 +116,13 @@
.Fa "char *errbuf"
.Fc
.Ft int
+.Fo procstat_get_sem_info
+.Fa "struct procstat *procstat"
+.Fa "struct filestat *fst"
+.Fa "struct semstat *sem"
+.Fa "char *errbuf"
+.Fc
+.Ft int
.Fo procstat_get_shm_info
.Fa "struct procstat *procstat"
.Fa "struct filestat *fst"
@@ -91,12 +143,50 @@
.Fa "struct vnstat *vn"
.Fa "char *errbuf"
.Fc
+.Ft "char **"
+.Fo procstat_getargv
+.Fa "struct procstat *procstat"
+.Fa "const struct kinfo_proc *kp"
+.Fa "size_t nchr"
+.Fa "char *errbuf"
+.Fc
+.Ft "Elf_Auxinfo *"
+.Fo procstat_getauxv
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Fc
+.Ft "char **"
+.Fo procstat_getenvv
+.Fa "struct procstat *procstat"
+.Fa "const struct kinfo_proc *kp"
+.Fa "size_t nchr"
+.Fa "char *errbuf"
+.Fc
.Ft "struct filestat_list *"
.Fo procstat_getfiles
.Fa "struct procstat *procstat"
.Fa "struct kinfo_proc *kp"
.Fa "int mmapped"
.Fc
+.Ft "gid_t *"
+.Fo procstat_getgroups
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Fc
+.Ft int
+.Fo procstat_getosrel
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "int *osrelp"
+.Fc
+.Ft "struct kinfo_kstack *"
+.Fo procstat_getkstack
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Fc
.Ft "struct kinfo_proc *"
.Fo procstat_getprocs
.Fa "struct procstat *procstat"
@@ -104,6 +194,34 @@
.Fa "int arg"
.Fa "unsigned int *count"
.Fc
+.Ft "int"
+.Fo procstat_getpathname
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "char *pathname"
+.Fa "size_t maxlen"
+.Fc
+.Ft "int"
+.Fo procstat_getrlimit
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "int which"
+.Fa "struct rlimit* rlimit"
+.Fc
+.Ft "int"
+.Fo procstat_getumask
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned short *maskp"
+.Fc
+.Ft "struct kinfo_vmentry *"
+.Fo procstat_getvmmap
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Fc
+.Ft "struct procstat *"
+.Fn procstat_open_core "const char *filename"
.Ft "struct procstat *"
.Fn procstat_open_kvm "const char *nlistf" "const char *memf"
.Ft "struct procstat *"
@@ -116,7 +234,11 @@ retrieval from the running kernel via the
.Xr sysctl 3
library backend, and for post-mortem analysis via the
.Xr kvm 3
-library backend.
+library backend, or from the process
+.Xr core 5
+file, searching for statistics in special
+.Xr elf 3
+note sections.
.Pp
The
.Fn procstat_open_kvm
@@ -129,6 +251,16 @@ or
library routines, respectively, to access kernel state information
used to retrieve processes and files states.
The
+.Fn procstat_open_core
+uses
+.Xr elf 3
+routines to access statistics stored as a set of notes in a process
+.Xr core 5
+file, written by the kernel at the moment of the process abnormal termination.
+The
+.Fa filename
+argument is the process core file name.
+The
.Fa nlistf
argument is the executable image of the kernel being examined.
If this argument is
@@ -145,7 +277,7 @@ is assumed.
See
.Xr kvm_open 3
for more details.
-Both functions dynamically allocate and return a
+The functions dynamically allocate and return a
.Vt procstat
structure pointer used in the rest of the
.Nm libprocstat
@@ -179,6 +311,63 @@ The caller is responsible to free the allocated memory with a subsequent
function call.
.Pp
The
+.Fn procstat_getargv
+function gets a pointer to the
+.Vt procstat
+structure from one of the
+.Fn procstat_open_*
+functions, a pointer to
+.Vt kinfo_proc
+structure from the array obtained from the
+.Fn kvm_getprocs
+function, and returns a null-terminated argument vector that corresponds to
+the command line arguments passed to the process.
+The
+.Fa nchr
+argument indicates the maximum number of characters, including null bytes,
+to use in building the strings.
+If this amount is exceeded, the string causing the overflow is truncated and
+the partial result is returned.
+This is handy for programs that print only a one line summary of a
+command and should not copy out large amounts of text only to ignore it.
+If
+.Fa nchr
+is zero, no limit is imposed and all argument strings are returned.
+The values of the returned argument vector refer the strings stored
+in the
+.Vt procstat
+internal buffer.
+A subsequent call of the function with the same
+.Vt procstat
+argument will reuse the buffer.
+To free the allocated memory
+.Fn procstat_freeargv
+function call can be used, or it will be released on
+.Fn procstat_close .
+.Pp
+The
+.Fn procstat_getenvv
+function is similar to
+.Fn procstat_getargv
+but returns the vector of environment strings.
+The caller may free the allocated memory with a subsequent
+.Fn procstat_freeenv
+function call.
+.Pp
+The
+.Fn procstat_getauxv
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and returns the auxiliary vector as a dynamically allocated array of
+.Vt Elf_Auxinfo
+elements.
+The caller is responsible to free the allocated memory with a subsequent
+.Fn procstat_freeauxv
+function call.
+.Pp
+The
.Fn procstat_getfiles
function gets a pointer to the
.Vt procstat
@@ -197,14 +386,98 @@ The caller is responsible to free the allocated memory with a subsequent
function call.
.Pp
The
+.Fn procstat_getgroups
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and returns the process groups as a dynamically allocated array of
+.Vt gid_t
+elements.
+The caller is responsible to free the allocated memory with a subsequent
+.Fn procstat_freegroups
+function call.
+.Pp
+The
+.Fn procstat_getkstack
+function gets a pointer to the
+.Vt procstat
+structure initialized with one of the
+.Fn procstat_open_*
+functions, a pointer to
+.Vt kinfo_proc
+structure, and returns kernel stacks of the process as a dynamically allocated
+array of
+.Vt kinfo_kstack
+structures.
+The caller is responsible to free the allocated memory with a subsequent
+.Fn procstat_freekstack
+function call.
+.Pp
+The
+.Fn procstat_getosrel
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and returns osrel date in the 3rd reference parameter.
+.Pp
+The
+.Fn procstat_getpathname
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and copies the path of the process executable to
+.Fa pathname
+buffer, limiting to
+.Fa maxlen
+characters.
+.Pp
+The
+.Fn procstat_getrlimit
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, resource index
+.Fa which ,
+and returns the actual resource limit in the 4th reference parameter.
+.Pp
+The
+.Fn procstat_getumask
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and returns the process umask in the 3rd reference parameter.
+.Pp
+The
+.Fn procstat_getvmmap
+function gets a pointer to the
+.Vt procstat
+structure initialized with one of the
+.Fn procstat_open_*
+functions, a pointer to
+.Vt kinfo_proc
+structure, and returns VM layout of the process as a dynamically allocated
+array of
+.Vt kinfo_vmentry
+structures.
+The caller is responsible to free the allocated memory with a subsequent
+.Fn procstat_freevmmap
+function call.
+.Pp
+The
.Fn procstat_get_pipe_info ,
.Fn procstat_get_pts_info ,
+.Fn procstat_get_sem_info ,
.Fn procstat_get_shm_info ,
.Fn procstat_get_socket_info
and
.Fn procstat_get_vnode_info
functions are used to retrieve information about pipes, pseudo-terminals,
-shared memory objects,
+semaphores, shared memory objects,
sockets, and vnodes, respectively.
Each of them have a similar interface API.
The
@@ -241,6 +514,8 @@ argument indicates an actual error message in case of failure.
.Nm procstat_get_pipe_info
.It Li PS_FST_TYPE_PTS
.Nm procstat_get_pts_info
+.It Li PS_FST_TYPE_SEM
+.Nm procstat_get_sem_info
.It Li PS_FST_TYPE_SHM
.Nm procstat_get_shm_info
.El
@@ -250,10 +525,13 @@ argument indicates an actual error message in case of failure.
.Xr pipe 2 ,
.Xr shm_open 2 ,
.Xr socket 2 ,
+.Xr elf 3 ,
.Xr kvm 3 ,
.Xr queue 3 ,
+.Xr sem_open 3 ,
.Xr sysctl 3 ,
.Xr pts 4 ,
+.Xr core 5 ,
.Xr vnode 9
.Sh HISTORY
The
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
index f23ec96dfa2f..9056151e2b4d 100644
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -36,7 +36,12 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/elf.h>
#include <sys/time.h>
+#include <sys/resourcevar.h>
+#define _WANT_UCRED
+#include <sys/ucred.h>
+#undef _WANT_UCRED
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/stat.h>
@@ -54,6 +59,7 @@ __FBSDID("$FreeBSD$");
#define _WANT_FILE
#include <sys/file.h>
#include <sys/conf.h>
+#include <sys/ksem.h>
#include <sys/mman.h>
#define _KERNEL
#include <sys/mount.h>
@@ -96,13 +102,22 @@ __FBSDID("$FreeBSD$");
#include <libprocstat.h>
#include "libprocstat_internal.h"
#include "common_kvm.h"
+#include "core.h"
int statfs(const char *, struct statfs *); /* XXX */
#define PROCSTAT_KVM 1
#define PROCSTAT_SYSCTL 2
+#define PROCSTAT_CORE 3
+static char **getargv(struct procstat *procstat, struct kinfo_proc *kp,
+ size_t nchr, int env);
static char *getmnton(kvm_t *kd, struct mount *m);
+static struct kinfo_vmentry * kinfo_getvmmap_core(struct procstat_core *core,
+ int *cntp);
+static Elf_Auxinfo *procstat_getauxv_core(struct procstat_core *core,
+ unsigned int *cntp);
+static Elf_Auxinfo *procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp);
static struct filestat_list *procstat_getfiles_kvm(
struct procstat *procstat, struct kinfo_proc *kp, int mmapped);
static struct filestat_list *procstat_getfiles_sysctl(
@@ -115,6 +130,10 @@ static int procstat_get_pts_info_sysctl(struct filestat *fst,
struct ptsstat *pts, char *errbuf);
static int procstat_get_pts_info_kvm(kvm_t *kd, struct filestat *fst,
struct ptsstat *pts, char *errbuf);
+static int procstat_get_sem_info_sysctl(struct filestat *fst,
+ struct semstat *sem, char *errbuf);
+static int procstat_get_sem_info_kvm(kvm_t *kd, struct filestat *fst,
+ struct semstat *sem, char *errbuf);
static int procstat_get_shm_info_sysctl(struct filestat *fst,
struct shmstat *shm, char *errbuf);
static int procstat_get_shm_info_kvm(kvm_t *kd, struct filestat *fst,
@@ -128,6 +147,33 @@ static int procstat_get_vnode_info_kvm(kvm_t *kd, struct filestat *fst,
struct vnstat *vn, char *errbuf);
static int procstat_get_vnode_info_sysctl(struct filestat *fst,
struct vnstat *vn, char *errbuf);
+static gid_t *procstat_getgroups_core(struct procstat_core *core,
+ unsigned int *count);
+static gid_t * procstat_getgroups_kvm(kvm_t *kd, struct kinfo_proc *kp,
+ unsigned int *count);
+static gid_t *procstat_getgroups_sysctl(pid_t pid, unsigned int *count);
+static struct kinfo_kstack *procstat_getkstack_sysctl(pid_t pid,
+ int *cntp);
+static int procstat_getosrel_core(struct procstat_core *core,
+ int *osrelp);
+static int procstat_getosrel_kvm(kvm_t *kd, struct kinfo_proc *kp,
+ int *osrelp);
+static int procstat_getosrel_sysctl(pid_t pid, int *osrelp);
+static int procstat_getpathname_core(struct procstat_core *core,
+ char *pathname, size_t maxlen);
+static int procstat_getpathname_sysctl(pid_t pid, char *pathname,
+ size_t maxlen);
+static int procstat_getrlimit_core(struct procstat_core *core, int which,
+ struct rlimit* rlimit);
+static int procstat_getrlimit_kvm(kvm_t *kd, struct kinfo_proc *kp,
+ int which, struct rlimit* rlimit);
+static int procstat_getrlimit_sysctl(pid_t pid, int which,
+ struct rlimit* rlimit);
+static int procstat_getumask_core(struct procstat_core *core,
+ unsigned short *maskp);
+static int procstat_getumask_kvm(kvm_t *kd, struct kinfo_proc *kp,
+ unsigned short *maskp);
+static int procstat_getumask_sysctl(pid_t pid, unsigned short *maskp);
static int vntype2psfsttype(int type);
void
@@ -137,6 +183,10 @@ procstat_close(struct procstat *procstat)
assert(procstat);
if (procstat->type == PROCSTAT_KVM)
kvm_close(procstat->kd);
+ else if (procstat->type == PROCSTAT_CORE)
+ procstat_core_close(procstat->core);
+ procstat_freeargv(procstat);
+ procstat_freeenvv(procstat);
free(procstat);
}
@@ -177,12 +227,33 @@ procstat_open_kvm(const char *nlistf, const char *memf)
return (procstat);
}
+struct procstat *
+procstat_open_core(const char *filename)
+{
+ struct procstat *procstat;
+ struct procstat_core *core;
+
+ procstat = calloc(1, sizeof(*procstat));
+ if (procstat == NULL) {
+ warn("malloc()");
+ return (NULL);
+ }
+ core = procstat_core_open(filename);
+ if (core == NULL) {
+ free(procstat);
+ return (NULL);
+ }
+ procstat->type = PROCSTAT_CORE;
+ procstat->core = core;
+ return (procstat);
+}
+
struct kinfo_proc *
procstat_getprocs(struct procstat *procstat, int what, int arg,
unsigned int *count)
{
struct kinfo_proc *p0, *p;
- size_t len;
+ size_t len, olen;
int name[4];
int cnt;
int error;
@@ -219,18 +290,31 @@ procstat_getprocs(struct procstat *procstat, int what, int arg,
warnx("no processes?");
goto fail;
}
- p = malloc(len);
- if (p == NULL) {
- warnx("malloc(%zu)", len);
- goto fail;
- }
- error = sysctl(name, 4, p, &len, NULL, 0);
+ do {
+ len += len / 10;
+ p = reallocf(p, len);
+ if (p == NULL) {
+ warnx("reallocf(%zu)", len);
+ goto fail;
+ }
+ olen = len;
+ error = sysctl(name, 4, p, &len, NULL, 0);
+ } while (error < 0 && errno == ENOMEM && olen == len);
if (error < 0 && errno != EPERM) {
warn("sysctl(kern.proc)");
goto fail;
}
/* Perform simple consistency checks. */
if ((len % sizeof(*p)) != 0 || p->ki_structsize != sizeof(*p)) {
+ warnx("kinfo_proc structure size mismatch (len = %zu)", len);
+ goto fail;
+ }
+ *count = len / sizeof(*p);
+ return (p);
+ } else if (procstat->type == PROCSTAT_CORE) {
+ p = procstat_core_get(procstat->core, PSC_TYPE_PROC, NULL,
+ &len);
+ if ((len % sizeof(*p)) != 0 || p->ki_structsize != sizeof(*p)) {
warnx("kinfo_proc structure size mismatch");
goto fail;
}
@@ -258,13 +342,17 @@ procstat_freeprocs(struct procstat *procstat __unused, struct kinfo_proc *p)
struct filestat_list *
procstat_getfiles(struct procstat *procstat, struct kinfo_proc *kp, int mmapped)
{
-
- if (procstat->type == PROCSTAT_SYSCTL)
- return (procstat_getfiles_sysctl(procstat, kp, mmapped));
- else if (procstat->type == PROCSTAT_KVM)
+
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
return (procstat_getfiles_kvm(procstat, kp, mmapped));
- else
+ case PROCSTAT_SYSCTL:
+ case PROCSTAT_CORE:
+ return (procstat_getfiles_sysctl(procstat, kp, mmapped));
+ default:
+ warnx("unknown access method: %d", procstat->type);
return (NULL);
+ }
}
void
@@ -290,7 +378,7 @@ procstat_freefiles(struct procstat *procstat, struct filestat_list *head)
static struct filestat *
filestat_new_entry(void *typedep, int type, int fd, int fflags, int uflags,
- int refcount, off_t offset, char *path, cap_rights_t cap_rights)
+ int refcount, off_t offset, char *path, cap_rights_t *cap_rightsp)
{
struct filestat *entry;
@@ -307,7 +395,7 @@ filestat_new_entry(void *typedep, int type, int fd, int fflags, int uflags,
entry->fs_ref_count = refcount;
entry->fs_offset = offset;
entry->fs_path = path;
- entry->fs_cap_rights = cap_rights;
+ entry->fs_cap_rights = *cap_rightsp;
return (entry);
}
@@ -477,6 +565,10 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
data = file.f_data;
break;
#endif
+ case DTYPE_SEM:
+ type = PS_FST_TYPE_SEM;
+ data = file.f_data;
+ break;
case DTYPE_SHM:
type = PS_FST_TYPE_SHM;
data = file.f_data;
@@ -646,8 +738,62 @@ kinfo_uflags2fst(int fd)
return (0);
}
+static struct kinfo_file *
+kinfo_getfile_core(struct procstat_core *core, int *cntp)
+{
+ int cnt;
+ size_t len;
+ char *buf, *bp, *eb;
+ struct kinfo_file *kif, *kp, *kf;
+
+ buf = procstat_core_get(core, PSC_TYPE_FILES, NULL, &len);
+ if (buf == NULL)
+ return (NULL);
+ /*
+ * XXXMG: The code below is just copy&past from libutil.
+ * The code duplication can be avoided if libutil
+ * is extended to provide something like:
+ * struct kinfo_file *kinfo_getfile_from_buf(const char *buf,
+ * size_t len, int *cntp);
+ */
+
+ /* Pass 1: count items */
+ cnt = 0;
+ bp = buf;
+ eb = buf + len;
+ while (bp < eb) {
+ kf = (struct kinfo_file *)(uintptr_t)bp;
+ bp += kf->kf_structsize;
+ cnt++;
+ }
+
+ kif = calloc(cnt, sizeof(*kif));
+ if (kif == NULL) {
+ free(buf);
+ return (NULL);
+ }
+ bp = buf;
+ eb = buf + len;
+ kp = kif;
+ /* Pass 2: unpack */
+ while (bp < eb) {
+ kf = (struct kinfo_file *)(uintptr_t)bp;
+ /* Copy/expand into pre-zeroed buffer */
+ memcpy(kp, kf, kf->kf_structsize);
+ /* Advance to next packed record */
+ bp += kf->kf_structsize;
+ /* Set field size to fixed length, advance */
+ kp->kf_structsize = sizeof(*kp);
+ kp++;
+ }
+ free(buf);
+ *cntp = cnt;
+ return (kif); /* Caller must free() return value */
+}
+
static struct filestat_list *
-procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp, int mmapped)
+procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp,
+ int mmapped)
{
struct kinfo_file *kif, *files;
struct kinfo_vmentry *kve, *vmentries;
@@ -663,8 +809,16 @@ procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp, int m
assert(kp);
if (kp->ki_fd == NULL)
return (NULL);
-
- files = kinfo_getfile(kp->ki_pid, &cnt);
+ switch(procstat->type) {
+ case PROCSTAT_SYSCTL:
+ files = kinfo_getfile(kp->ki_pid, &cnt);
+ break;
+ case PROCSTAT_CORE:
+ files = kinfo_getfile_core(procstat->core, &cnt);
+ break;
+ default:
+ assert(!"invalid type");
+ }
if (files == NULL && errno != EPERM) {
warn("kinfo_getfile()");
return (NULL);
@@ -697,12 +851,12 @@ procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp, int m
* Create filestat entry.
*/
entry = filestat_new_entry(kif, type, fd, fflags, uflags,
- refcount, offset, path, cap_rights);
+ refcount, offset, path, &cap_rights);
if (entry != NULL)
STAILQ_INSERT_TAIL(head, entry, next);
}
if (mmapped != 0) {
- vmentries = kinfo_getvmmap(kp->ki_pid, &cnt);
+ vmentries = procstat_getvmmap(procstat, kp, &cnt);
procstat->vmentries = vmentries;
if (vmentries == NULL || cnt == 0)
goto fail;
@@ -742,11 +896,13 @@ procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst,
if (procstat->type == PROCSTAT_KVM) {
return (procstat_get_pipe_info_kvm(procstat->kd, fst, ps,
errbuf));
- } else if (procstat->type == PROCSTAT_SYSCTL) {
+ } else if (procstat->type == PROCSTAT_SYSCTL ||
+ procstat->type == PROCSTAT_CORE) {
return (procstat_get_pipe_info_sysctl(fst, ps, errbuf));
} else {
warnx("unknown access method: %d", procstat->type);
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
}
@@ -775,7 +931,8 @@ procstat_get_pipe_info_kvm(kvm_t *kd, struct filestat *fst,
return (0);
fail:
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -806,11 +963,13 @@ procstat_get_pts_info(struct procstat *procstat, struct filestat *fst,
if (procstat->type == PROCSTAT_KVM) {
return (procstat_get_pts_info_kvm(procstat->kd, fst, pts,
errbuf));
- } else if (procstat->type == PROCSTAT_SYSCTL) {
+ } else if (procstat->type == PROCSTAT_SYSCTL ||
+ procstat->type == PROCSTAT_CORE) {
return (procstat_get_pts_info_sysctl(fst, pts, errbuf));
} else {
warnx("unknown access method: %d", procstat->type);
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
}
@@ -838,7 +997,8 @@ procstat_get_pts_info_kvm(kvm_t *kd, struct filestat *fst,
return (0);
fail:
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -860,6 +1020,89 @@ procstat_get_pts_info_sysctl(struct filestat *fst, struct ptsstat *pts,
}
int
+procstat_get_sem_info(struct procstat *procstat, struct filestat *fst,
+ struct semstat *sem, char *errbuf)
+{
+
+ assert(sem);
+ if (procstat->type == PROCSTAT_KVM) {
+ return (procstat_get_sem_info_kvm(procstat->kd, fst, sem,
+ errbuf));
+ } else if (procstat->type == PROCSTAT_SYSCTL ||
+ procstat->type == PROCSTAT_CORE) {
+ return (procstat_get_sem_info_sysctl(fst, sem, errbuf));
+ } else {
+ warnx("unknown access method: %d", procstat->type);
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ return (1);
+ }
+}
+
+static int
+procstat_get_sem_info_kvm(kvm_t *kd, struct filestat *fst,
+ struct semstat *sem, char *errbuf)
+{
+ struct ksem ksem;
+ void *ksemp;
+ char *path;
+ int i;
+
+ assert(kd);
+ assert(sem);
+ assert(fst);
+ bzero(sem, sizeof(*sem));
+ ksemp = fst->fs_typedep;
+ if (ksemp == NULL)
+ goto fail;
+ if (!kvm_read_all(kd, (unsigned long)ksemp, &ksem,
+ sizeof(struct ksem))) {
+ warnx("can't read ksem at %p", (void *)ksemp);
+ goto fail;
+ }
+ sem->mode = S_IFREG | ksem.ks_mode;
+ sem->value = ksem.ks_value;
+ if (fst->fs_path == NULL && ksem.ks_path != NULL) {
+ path = malloc(MAXPATHLEN);
+ for (i = 0; i < MAXPATHLEN - 1; i++) {
+ if (!kvm_read_all(kd, (unsigned long)ksem.ks_path + i,
+ path + i, 1))
+ break;
+ if (path[i] == '\0')
+ break;
+ }
+ path[i] = '\0';
+ if (i == 0)
+ free(path);
+ else
+ fst->fs_path = path;
+ }
+ return (0);
+
+fail:
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ return (1);
+}
+
+static int
+procstat_get_sem_info_sysctl(struct filestat *fst, struct semstat *sem,
+ char *errbuf __unused)
+{
+ struct kinfo_file *kif;
+
+ assert(sem);
+ assert(fst);
+ bzero(sem, sizeof(*sem));
+ kif = fst->fs_typedep;
+ if (kif == NULL)
+ return (0);
+ sem->value = kif->kf_un.kf_sem.kf_sem_value;
+ sem->mode = kif->kf_un.kf_sem.kf_sem_mode;
+ return (0);
+}
+
+int
procstat_get_shm_info(struct procstat *procstat, struct filestat *fst,
struct shmstat *shm, char *errbuf)
{
@@ -868,11 +1111,13 @@ procstat_get_shm_info(struct procstat *procstat, struct filestat *fst,
if (procstat->type == PROCSTAT_KVM) {
return (procstat_get_shm_info_kvm(procstat->kd, fst, shm,
errbuf));
- } else if (procstat->type == PROCSTAT_SYSCTL) {
+ } else if (procstat->type == PROCSTAT_SYSCTL ||
+ procstat->type == PROCSTAT_CORE) {
return (procstat_get_shm_info_sysctl(fst, shm, errbuf));
} else {
warnx("unknown access method: %d", procstat->type);
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
}
@@ -918,7 +1163,8 @@ procstat_get_shm_info_kvm(kvm_t *kd, struct filestat *fst,
return (0);
fail:
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -948,11 +1194,13 @@ procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
if (procstat->type == PROCSTAT_KVM) {
return (procstat_get_vnode_info_kvm(procstat->kd, fst, vn,
errbuf));
- } else if (procstat->type == PROCSTAT_SYSCTL) {
+ } else if (procstat->type == PROCSTAT_SYSCTL ||
+ procstat->type == PROCSTAT_CORE) {
return (procstat_get_vnode_info_sysctl(fst, vn, errbuf));
} else {
warnx("unknown access method: %d", procstat->type);
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
}
@@ -972,6 +1220,7 @@ procstat_get_vnode_info_kvm(kvm_t *kd, struct filestat *fst,
FSTYPE(isofs),
FSTYPE(msdosfs),
FSTYPE(nfs),
+ FSTYPE(smbfs),
FSTYPE(udf),
FSTYPE(ufs),
#ifdef LIBPROCSTAT_ZFS
@@ -1019,7 +1268,8 @@ procstat_get_vnode_info_kvm(kvm_t *kd, struct filestat *fst,
break;
}
if (i == NTYPES) {
- snprintf(errbuf, _POSIX2_LINE_MAX, "?(%s)", tagstr);
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "?(%s)", tagstr);
return (1);
}
vn->vn_mntdir = getmnton(kd, vnode.v_mount);
@@ -1033,7 +1283,8 @@ procstat_get_vnode_info_kvm(kvm_t *kd, struct filestat *fst,
return (0);
fail:
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -1114,7 +1365,10 @@ procstat_get_vnode_info_sysctl(struct filestat *fst, struct vnstat *vn,
if (vntype == PS_FST_VTYPE_VNON || vntype == PS_FST_VTYPE_VBAD)
return (0);
if ((status & KF_ATTR_VALID) == 0) {
- snprintf(errbuf, _POSIX2_LINE_MAX, "? (no info available)");
+ if (errbuf != NULL) {
+ snprintf(errbuf, _POSIX2_LINE_MAX,
+ "? (no info available)");
+ }
return (1);
}
if (path && *path) {
@@ -1150,11 +1404,13 @@ procstat_get_socket_info(struct procstat *procstat, struct filestat *fst,
if (procstat->type == PROCSTAT_KVM) {
return (procstat_get_socket_info_kvm(procstat->kd, fst, sock,
errbuf));
- } else if (procstat->type == PROCSTAT_SYSCTL) {
+ } else if (procstat->type == PROCSTAT_SYSCTL ||
+ procstat->type == PROCSTAT_CORE) {
return (procstat_get_socket_info_sysctl(fst, sock, errbuf));
} else {
warnx("unknown access method: %d", procstat->type);
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
}
@@ -1252,7 +1508,8 @@ procstat_get_socket_info_kvm(kvm_t *kd, struct filestat *fst,
return (0);
fail:
- snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ if (errbuf != NULL)
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
return (1);
}
@@ -1401,3 +1658,868 @@ getmnton(kvm_t *kd, struct mount *m)
mhead = mt;
return (mt->mntonname);
}
+
+/*
+ * Auxiliary structures and functions to get process environment or
+ * command line arguments.
+ */
+struct argvec {
+ char *buf;
+ size_t bufsize;
+ char **argv;
+ size_t argc;
+};
+
+static struct argvec *
+argvec_alloc(size_t bufsize)
+{
+ struct argvec *av;
+
+ av = malloc(sizeof(*av));
+ if (av == NULL)
+ return (NULL);
+ av->bufsize = bufsize;
+ av->buf = malloc(av->bufsize);
+ if (av->buf == NULL) {
+ free(av);
+ return (NULL);
+ }
+ av->argc = 32;
+ av->argv = malloc(sizeof(char *) * av->argc);
+ if (av->argv == NULL) {
+ free(av->buf);
+ free(av);
+ return (NULL);
+ }
+ return av;
+}
+
+static void
+argvec_free(struct argvec * av)
+{
+
+ free(av->argv);
+ free(av->buf);
+ free(av);
+}
+
+static char **
+getargv(struct procstat *procstat, struct kinfo_proc *kp, size_t nchr, int env)
+{
+ int error, name[4], argc, i;
+ struct argvec *av, **avp;
+ enum psc_type type;
+ size_t len;
+ char *p, **argv;
+
+ assert(procstat);
+ assert(kp);
+ if (procstat->type == PROCSTAT_KVM) {
+ warnx("can't use kvm access method");
+ return (NULL);
+ }
+ if (procstat->type != PROCSTAT_SYSCTL &&
+ procstat->type != PROCSTAT_CORE) {
+ warnx("unknown access method: %d", procstat->type);
+ return (NULL);
+ }
+
+ if (nchr == 0 || nchr > ARG_MAX)
+ nchr = ARG_MAX;
+
+ avp = (struct argvec **)(env ? &procstat->argv : &procstat->envv);
+ av = *avp;
+
+ if (av == NULL)
+ {
+ av = argvec_alloc(nchr);
+ if (av == NULL)
+ {
+ warn("malloc(%zu)", nchr);
+ return (NULL);
+ }
+ *avp = av;
+ } else if (av->bufsize < nchr) {
+ av->buf = reallocf(av->buf, nchr);
+ if (av->buf == NULL) {
+ warn("malloc(%zu)", nchr);
+ return (NULL);
+ }
+ }
+ if (procstat->type == PROCSTAT_SYSCTL) {
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
+ name[3] = kp->ki_pid;
+ len = nchr;
+ error = sysctl(name, 4, av->buf, &len, NULL, 0);
+ if (error != 0 && errno != ESRCH && errno != EPERM)
+ warn("sysctl(kern.proc.%s)", env ? "env" : "args");
+ if (error != 0 || len == 0)
+ return (NULL);
+ } else /* procstat->type == PROCSTAT_CORE */ {
+ type = env ? PSC_TYPE_ENVV : PSC_TYPE_ARGV;
+ len = nchr;
+ if (procstat_core_get(procstat->core, type, av->buf, &len)
+ == NULL) {
+ return (NULL);
+ }
+ }
+
+ argv = av->argv;
+ argc = av->argc;
+ i = 0;
+ for (p = av->buf; p < av->buf + len; p += strlen(p) + 1) {
+ argv[i++] = p;
+ if (i < argc)
+ continue;
+ /* Grow argv. */
+ argc += argc;
+ argv = realloc(argv, sizeof(char *) * argc);
+ if (argv == NULL) {
+ warn("malloc(%zu)", sizeof(char *) * argc);
+ return (NULL);
+ }
+ av->argv = argv;
+ av->argc = argc;
+ }
+ argv[i] = NULL;
+
+ return (argv);
+}
+
+/*
+ * Return process command line arguments.
+ */
+char **
+procstat_getargv(struct procstat *procstat, struct kinfo_proc *p, size_t nchr)
+{
+
+ return (getargv(procstat, p, nchr, 0));
+}
+
+/*
+ * Free the buffer allocated by procstat_getargv().
+ */
+void
+procstat_freeargv(struct procstat *procstat)
+{
+
+ if (procstat->argv != NULL) {
+ argvec_free(procstat->argv);
+ procstat->argv = NULL;
+ }
+}
+
+/*
+ * Return process environment.
+ */
+char **
+procstat_getenvv(struct procstat *procstat, struct kinfo_proc *p, size_t nchr)
+{
+
+ return (getargv(procstat, p, nchr, 1));
+}
+
+/*
+ * Free the buffer allocated by procstat_getenvv().
+ */
+void
+procstat_freeenvv(struct procstat *procstat)
+{
+ if (procstat->envv != NULL) {
+ argvec_free(procstat->envv);
+ procstat->envv = NULL;
+ }
+}
+
+static struct kinfo_vmentry *
+kinfo_getvmmap_core(struct procstat_core *core, int *cntp)
+{
+ int cnt;
+ size_t len;
+ char *buf, *bp, *eb;
+ struct kinfo_vmentry *kiv, *kp, *kv;
+
+ buf = procstat_core_get(core, PSC_TYPE_VMMAP, NULL, &len);
+ if (buf == NULL)
+ return (NULL);
+
+ /*
+ * XXXMG: The code below is just copy&past from libutil.
+ * The code duplication can be avoided if libutil
+ * is extended to provide something like:
+ * struct kinfo_vmentry *kinfo_getvmmap_from_buf(const char *buf,
+ * size_t len, int *cntp);
+ */
+
+ /* Pass 1: count items */
+ cnt = 0;
+ bp = buf;
+ eb = buf + len;
+ while (bp < eb) {
+ kv = (struct kinfo_vmentry *)(uintptr_t)bp;
+ bp += kv->kve_structsize;
+ cnt++;
+ }
+
+ kiv = calloc(cnt, sizeof(*kiv));
+ if (kiv == NULL) {
+ free(buf);
+ return (NULL);
+ }
+ bp = buf;
+ eb = buf + len;
+ kp = kiv;
+ /* Pass 2: unpack */
+ while (bp < eb) {
+ kv = (struct kinfo_vmentry *)(uintptr_t)bp;
+ /* Copy/expand into pre-zeroed buffer */
+ memcpy(kp, kv, kv->kve_structsize);
+ /* Advance to next packed record */
+ bp += kv->kve_structsize;
+ /* Set field size to fixed length, advance */
+ kp->kve_structsize = sizeof(*kp);
+ kp++;
+ }
+ free(buf);
+ *cntp = cnt;
+ return (kiv); /* Caller must free() return value */
+}
+
+struct kinfo_vmentry *
+procstat_getvmmap(struct procstat *procstat, struct kinfo_proc *kp,
+ unsigned int *cntp)
+{
+
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
+ warnx("kvm method is not supported");
+ return (NULL);
+ case PROCSTAT_SYSCTL:
+ return (kinfo_getvmmap(kp->ki_pid, cntp));
+ case PROCSTAT_CORE:
+ return (kinfo_getvmmap_core(procstat->core, cntp));
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (NULL);
+ }
+}
+
+void
+procstat_freevmmap(struct procstat *procstat __unused,
+ struct kinfo_vmentry *vmmap)
+{
+
+ free(vmmap);
+}
+
+static gid_t *
+procstat_getgroups_kvm(kvm_t *kd, struct kinfo_proc *kp, unsigned int *cntp)
+{
+ struct proc proc;
+ struct ucred ucred;
+ gid_t *groups;
+ size_t len;
+
+ assert(kd != NULL);
+ assert(kp != NULL);
+ if (!kvm_read_all(kd, (unsigned long)kp->ki_paddr, &proc,
+ sizeof(proc))) {
+ warnx("can't read proc struct at %p for pid %d",
+ kp->ki_paddr, kp->ki_pid);
+ return (NULL);
+ }
+ if (proc.p_ucred == NOCRED)
+ return (NULL);
+ if (!kvm_read_all(kd, (unsigned long)proc.p_ucred, &ucred,
+ sizeof(ucred))) {
+ warnx("can't read ucred struct at %p for pid %d",
+ proc.p_ucred, kp->ki_pid);
+ return (NULL);
+ }
+ len = ucred.cr_ngroups * sizeof(gid_t);
+ groups = malloc(len);
+ if (groups == NULL) {
+ warn("malloc(%zu)", len);
+ return (NULL);
+ }
+ if (!kvm_read_all(kd, (unsigned long)ucred.cr_groups, groups, len)) {
+ warnx("can't read groups at %p for pid %d",
+ ucred.cr_groups, kp->ki_pid);
+ free(groups);
+ return (NULL);
+ }
+ *cntp = ucred.cr_ngroups;
+ return (groups);
+}
+
+static gid_t *
+procstat_getgroups_sysctl(pid_t pid, unsigned int *cntp)
+{
+ int mib[4];
+ size_t len;
+ gid_t *groups;
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_GROUPS;
+ mib[3] = pid;
+ len = (sysconf(_SC_NGROUPS_MAX) + 1) * sizeof(gid_t);
+ groups = malloc(len);
+ if (groups == NULL) {
+ warn("malloc(%zu)", len);
+ return (NULL);
+ }
+ if (sysctl(mib, 4, groups, &len, NULL, 0) == -1) {
+ warn("sysctl: kern.proc.groups: %d", pid);
+ free(groups);
+ return (NULL);
+ }
+ *cntp = len / sizeof(gid_t);
+ return (groups);
+}
+
+static gid_t *
+procstat_getgroups_core(struct procstat_core *core, unsigned int *cntp)
+{
+ size_t len;
+ gid_t *groups;
+
+ groups = procstat_core_get(core, PSC_TYPE_GROUPS, NULL, &len);
+ if (groups == NULL)
+ return (NULL);
+ *cntp = len / sizeof(gid_t);
+ return (groups);
+}
+
+gid_t *
+procstat_getgroups(struct procstat *procstat, struct kinfo_proc *kp,
+ unsigned int *cntp)
+{
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
+ return (procstat_getgroups_kvm(procstat->kd, kp, cntp));
+ case PROCSTAT_SYSCTL:
+ return (procstat_getgroups_sysctl(kp->ki_pid, cntp));
+ case PROCSTAT_CORE:
+ return (procstat_getgroups_core(procstat->core, cntp));
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (NULL);
+ }
+}
+
+void
+procstat_freegroups(struct procstat *procstat __unused, gid_t *groups)
+{
+
+ free(groups);
+}
+
+static int
+procstat_getumask_kvm(kvm_t *kd, struct kinfo_proc *kp, unsigned short *maskp)
+{
+ struct filedesc fd;
+
+ assert(kd != NULL);
+ assert(kp != NULL);
+ if (kp->ki_fd == NULL)
+ return (-1);
+ if (!kvm_read_all(kd, (unsigned long)kp->ki_fd, &fd, sizeof(fd))) {
+ warnx("can't read filedesc at %p for pid %d", kp->ki_fd,
+ kp->ki_pid);
+ return (-1);
+ }
+ *maskp = fd.fd_cmask;
+ return (0);
+}
+
+static int
+procstat_getumask_sysctl(pid_t pid, unsigned short *maskp)
+{
+ int error;
+ int mib[4];
+ size_t len;
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_UMASK;
+ mib[3] = pid;
+ len = sizeof(*maskp);
+ error = sysctl(mib, 4, maskp, &len, NULL, 0);
+ if (error != 0 && errno != ESRCH)
+ warn("sysctl: kern.proc.umask: %d", pid);
+ return (error);
+}
+
+static int
+procstat_getumask_core(struct procstat_core *core, unsigned short *maskp)
+{
+ size_t len;
+ unsigned short *buf;
+
+ buf = procstat_core_get(core, PSC_TYPE_UMASK, NULL, &len);
+ if (buf == NULL)
+ return (-1);
+ if (len < sizeof(*maskp)) {
+ free(buf);
+ return (-1);
+ }
+ *maskp = *buf;
+ free(buf);
+ return (0);
+}
+
+int
+procstat_getumask(struct procstat *procstat, struct kinfo_proc *kp,
+ unsigned short *maskp)
+{
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
+ return (procstat_getumask_kvm(procstat->kd, kp, maskp));
+ case PROCSTAT_SYSCTL:
+ return (procstat_getumask_sysctl(kp->ki_pid, maskp));
+ case PROCSTAT_CORE:
+ return (procstat_getumask_core(procstat->core, maskp));
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (-1);
+ }
+}
+
+static int
+procstat_getrlimit_kvm(kvm_t *kd, struct kinfo_proc *kp, int which,
+ struct rlimit* rlimit)
+{
+ struct proc proc;
+ unsigned long offset;
+
+ assert(kd != NULL);
+ assert(kp != NULL);
+ assert(which >= 0 && which < RLIM_NLIMITS);
+ if (!kvm_read_all(kd, (unsigned long)kp->ki_paddr, &proc,
+ sizeof(proc))) {
+ warnx("can't read proc struct at %p for pid %d",
+ kp->ki_paddr, kp->ki_pid);
+ return (-1);
+ }
+ if (proc.p_limit == NULL)
+ return (-1);
+ offset = (unsigned long)proc.p_limit + sizeof(struct rlimit) * which;
+ if (!kvm_read_all(kd, offset, rlimit, sizeof(*rlimit))) {
+ warnx("can't read rlimit struct at %p for pid %d",
+ (void *)offset, kp->ki_pid);
+ return (-1);
+ }
+ return (0);
+}
+
+static int
+procstat_getrlimit_sysctl(pid_t pid, int which, struct rlimit* rlimit)
+{
+ int error, name[5];
+ size_t len;
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_RLIMIT;
+ name[3] = pid;
+ name[4] = which;
+ len = sizeof(struct rlimit);
+ error = sysctl(name, 5, rlimit, &len, NULL, 0);
+ if (error < 0 && errno != ESRCH) {
+ warn("sysctl: kern.proc.rlimit: %d", pid);
+ return (-1);
+ }
+ if (error < 0 || len != sizeof(struct rlimit))
+ return (-1);
+ return (0);
+}
+
+static int
+procstat_getrlimit_core(struct procstat_core *core, int which,
+ struct rlimit* rlimit)
+{
+ size_t len;
+ struct rlimit* rlimits;
+
+ if (which < 0 || which >= RLIM_NLIMITS) {
+ errno = EINVAL;
+ warn("getrlimit: which");
+ return (-1);
+ }
+ rlimits = procstat_core_get(core, PSC_TYPE_RLIMIT, NULL, &len);
+ if (rlimits == NULL)
+ return (-1);
+ if (len < sizeof(struct rlimit) * RLIM_NLIMITS) {
+ free(rlimits);
+ return (-1);
+ }
+ *rlimit = rlimits[which];
+ return (0);
+}
+
+int
+procstat_getrlimit(struct procstat *procstat, struct kinfo_proc *kp, int which,
+ struct rlimit* rlimit)
+{
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
+ return (procstat_getrlimit_kvm(procstat->kd, kp, which,
+ rlimit));
+ case PROCSTAT_SYSCTL:
+ return (procstat_getrlimit_sysctl(kp->ki_pid, which, rlimit));
+ case PROCSTAT_CORE:
+ return (procstat_getrlimit_core(procstat->core, which, rlimit));
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (-1);
+ }
+}
+
+static int
+procstat_getpathname_sysctl(pid_t pid, char *pathname, size_t maxlen)
+{
+ int error, name[4];
+ size_t len;
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_PATHNAME;
+ name[3] = pid;
+ len = maxlen;
+ error = sysctl(name, 4, pathname, &len, NULL, 0);
+ if (error != 0 && errno != ESRCH)
+ warn("sysctl: kern.proc.pathname: %d", pid);
+ if (len == 0)
+ pathname[0] = '\0';
+ return (error);
+}
+
+static int
+procstat_getpathname_core(struct procstat_core *core, char *pathname,
+ size_t maxlen)
+{
+ struct kinfo_file *files;
+ int cnt, i, result;
+
+ files = kinfo_getfile_core(core, &cnt);
+ if (files == NULL)
+ return (-1);
+ result = -1;
+ for (i = 0; i < cnt; i++) {
+ if (files[i].kf_fd != KF_FD_TYPE_TEXT)
+ continue;
+ strncpy(pathname, files[i].kf_path, maxlen);
+ result = 0;
+ break;
+ }
+ free(files);
+ return (result);
+}
+
+int
+procstat_getpathname(struct procstat *procstat, struct kinfo_proc *kp,
+ char *pathname, size_t maxlen)
+{
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
+ /* XXX: Return empty string. */
+ if (maxlen > 0)
+ pathname[0] = '\0';
+ return (0);
+ case PROCSTAT_SYSCTL:
+ return (procstat_getpathname_sysctl(kp->ki_pid, pathname,
+ maxlen));
+ case PROCSTAT_CORE:
+ return (procstat_getpathname_core(procstat->core, pathname,
+ maxlen));
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (-1);
+ }
+}
+
+static int
+procstat_getosrel_kvm(kvm_t *kd, struct kinfo_proc *kp, int *osrelp)
+{
+ struct proc proc;
+
+ assert(kd != NULL);
+ assert(kp != NULL);
+ if (!kvm_read_all(kd, (unsigned long)kp->ki_paddr, &proc,
+ sizeof(proc))) {
+ warnx("can't read proc struct at %p for pid %d",
+ kp->ki_paddr, kp->ki_pid);
+ return (-1);
+ }
+ *osrelp = proc.p_osrel;
+ return (0);
+}
+
+static int
+procstat_getosrel_sysctl(pid_t pid, int *osrelp)
+{
+ int error, name[4];
+ size_t len;
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_OSREL;
+ name[3] = pid;
+ len = sizeof(*osrelp);
+ error = sysctl(name, 4, osrelp, &len, NULL, 0);
+ if (error != 0 && errno != ESRCH)
+ warn("sysctl: kern.proc.osrel: %d", pid);
+ return (error);
+}
+
+static int
+procstat_getosrel_core(struct procstat_core *core, int *osrelp)
+{
+ size_t len;
+ int *buf;
+
+ buf = procstat_core_get(core, PSC_TYPE_OSREL, NULL, &len);
+ if (buf == NULL)
+ return (-1);
+ if (len < sizeof(*osrelp)) {
+ free(buf);
+ return (-1);
+ }
+ *osrelp = *buf;
+ free(buf);
+ return (0);
+}
+
+int
+procstat_getosrel(struct procstat *procstat, struct kinfo_proc *kp, int *osrelp)
+{
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
+ return (procstat_getosrel_kvm(procstat->kd, kp, osrelp));
+ case PROCSTAT_SYSCTL:
+ return (procstat_getosrel_sysctl(kp->ki_pid, osrelp));
+ case PROCSTAT_CORE:
+ return (procstat_getosrel_core(procstat->core, osrelp));
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (-1);
+ }
+}
+
+#define PROC_AUXV_MAX 256
+
+#if __ELF_WORD_SIZE == 64
+static const char *elf32_sv_names[] = {
+ "Linux ELF32",
+ "FreeBSD ELF32",
+};
+
+static int
+is_elf32_sysctl(pid_t pid)
+{
+ int error, name[4];
+ size_t len, i;
+ static char sv_name[256];
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_SV_NAME;
+ name[3] = pid;
+ len = sizeof(sv_name);
+ error = sysctl(name, 4, sv_name, &len, NULL, 0);
+ if (error != 0 || len == 0)
+ return (0);
+ for (i = 0; i < sizeof(elf32_sv_names) / sizeof(*elf32_sv_names); i++) {
+ if (strncmp(sv_name, elf32_sv_names[i], sizeof(sv_name)) == 0)
+ return (1);
+ }
+ return (0);
+}
+
+static Elf_Auxinfo *
+procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp)
+{
+ Elf_Auxinfo *auxv;
+ Elf32_Auxinfo *auxv32;
+ void *ptr;
+ size_t len;
+ unsigned int i, count;
+ int name[4];
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_AUXV;
+ name[3] = pid;
+ len = PROC_AUXV_MAX * sizeof(Elf32_Auxinfo);
+ auxv = NULL;
+ auxv32 = malloc(len);
+ if (auxv32 == NULL) {
+ warn("malloc(%zu)", len);
+ goto out;
+ }
+ if (sysctl(name, 4, auxv32, &len, NULL, 0) == -1) {
+ if (errno != ESRCH && errno != EPERM)
+ warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
+ goto out;
+ }
+ count = len / sizeof(Elf_Auxinfo);
+ auxv = malloc(count * sizeof(Elf_Auxinfo));
+ if (auxv == NULL) {
+ warn("malloc(%zu)", count * sizeof(Elf_Auxinfo));
+ goto out;
+ }
+ for (i = 0; i < count; i++) {
+ /*
+ * XXX: We expect that values for a_type on a 32-bit platform
+ * are directly mapped to values on 64-bit one, which is not
+ * necessarily true.
+ */
+ auxv[i].a_type = auxv32[i].a_type;
+ ptr = &auxv32[i].a_un;
+ auxv[i].a_un.a_val = *((uint32_t *)ptr);
+ }
+ *cntp = count;
+out:
+ free(auxv32);
+ return (auxv);
+}
+#endif /* __ELF_WORD_SIZE == 64 */
+
+static Elf_Auxinfo *
+procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp)
+{
+ Elf_Auxinfo *auxv;
+ int name[4];
+ size_t len;
+
+#if __ELF_WORD_SIZE == 64
+ if (is_elf32_sysctl(pid))
+ return (procstat_getauxv32_sysctl(pid, cntp));
+#endif
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_AUXV;
+ name[3] = pid;
+ len = PROC_AUXV_MAX * sizeof(Elf_Auxinfo);
+ auxv = malloc(len);
+ if (auxv == NULL) {
+ warn("malloc(%zu)", len);
+ return (NULL);
+ }
+ if (sysctl(name, 4, auxv, &len, NULL, 0) == -1) {
+ if (errno != ESRCH && errno != EPERM)
+ warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
+ free(auxv);
+ return (NULL);
+ }
+ *cntp = len / sizeof(Elf_Auxinfo);
+ return (auxv);
+}
+
+static Elf_Auxinfo *
+procstat_getauxv_core(struct procstat_core *core, unsigned int *cntp)
+{
+ Elf_Auxinfo *auxv;
+ size_t len;
+
+ auxv = procstat_core_get(core, PSC_TYPE_AUXV, NULL, &len);
+ if (auxv == NULL)
+ return (NULL);
+ *cntp = len / sizeof(Elf_Auxinfo);
+ return (auxv);
+}
+
+Elf_Auxinfo *
+procstat_getauxv(struct procstat *procstat, struct kinfo_proc *kp,
+ unsigned int *cntp)
+{
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
+ warnx("kvm method is not supported");
+ return (NULL);
+ case PROCSTAT_SYSCTL:
+ return (procstat_getauxv_sysctl(kp->ki_pid, cntp));
+ case PROCSTAT_CORE:
+ return (procstat_getauxv_core(procstat->core, cntp));
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (NULL);
+ }
+}
+
+void
+procstat_freeauxv(struct procstat *procstat __unused, Elf_Auxinfo *auxv)
+{
+
+ free(auxv);
+}
+
+static struct kinfo_kstack *
+procstat_getkstack_sysctl(pid_t pid, int *cntp)
+{
+ struct kinfo_kstack *kkstp;
+ int error, name[4];
+ size_t len;
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_KSTACK;
+ name[3] = pid;
+
+ len = 0;
+ error = sysctl(name, 4, NULL, &len, NULL, 0);
+ if (error < 0 && errno != ESRCH && errno != EPERM && errno != ENOENT) {
+ warn("sysctl: kern.proc.kstack: %d", pid);
+ return (NULL);
+ }
+ if (error == -1 && errno == ENOENT) {
+ warnx("sysctl: kern.proc.kstack unavailable"
+ " (options DDB or options STACK required in kernel)");
+ return (NULL);
+ }
+ if (error == -1)
+ return (NULL);
+ kkstp = malloc(len);
+ if (kkstp == NULL) {
+ warn("malloc(%zu)", len);
+ return (NULL);
+ }
+ if (sysctl(name, 4, kkstp, &len, NULL, 0) == -1) {
+ warn("sysctl: kern.proc.pid: %d", pid);
+ free(kkstp);
+ return (NULL);
+ }
+ *cntp = len / sizeof(*kkstp);
+
+ return (kkstp);
+}
+
+struct kinfo_kstack *
+procstat_getkstack(struct procstat *procstat, struct kinfo_proc *kp,
+ unsigned int *cntp)
+{
+ switch(procstat->type) {
+ case PROCSTAT_KVM:
+ warnx("kvm method is not supported");
+ return (NULL);
+ case PROCSTAT_SYSCTL:
+ return (procstat_getkstack_sysctl(kp->ki_pid, cntp));
+ case PROCSTAT_CORE:
+ warnx("core method is not supported");
+ return (NULL);
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (NULL);
+ }
+}
+
+void
+procstat_freekstack(struct procstat *procstat __unused,
+ struct kinfo_kstack *kkstp)
+{
+
+ free(kkstp);
+}
diff --git a/lib/libprocstat/libprocstat.h b/lib/libprocstat/libprocstat.h
index 1c55aa756200..7af6ccba14a2 100644
--- a/lib/libprocstat/libprocstat.h
+++ b/lib/libprocstat/libprocstat.h
@@ -30,6 +30,15 @@
#define _LIBPROCSTAT_H_
/*
+ * XXX: sys/elf.h conflicts with zfs_context.h. Workaround this by not
+ * including conflicting parts when building zfs code.
+ */
+#ifndef ZFS
+#include <sys/elf.h>
+#endif
+#include <sys/caprights.h>
+
+/*
* Vnode types.
*/
#define PS_FST_VTYPE_VNON 1
@@ -89,7 +98,10 @@
#define PS_FST_FFLAG_EXEC 0x2000
#define PS_FST_FFLAG_HASLOCK 0x4000
+struct kinfo_kstack;
+struct kinfo_vmentry;
struct procstat;
+struct rlimit;
struct filestat {
int fs_type; /* Descriptor type. */
int fs_flags; /* filestat specific flags. */
@@ -122,6 +134,10 @@ struct pipestat {
uint64_t addr;
uint64_t peer;
};
+struct semstat {
+ uint32_t value;
+ uint16_t mode;
+};
struct shmstat {
uint64_t size;
uint16_t mode;
@@ -145,9 +161,19 @@ STAILQ_HEAD(filestat_list, filestat);
__BEGIN_DECLS
void procstat_close(struct procstat *procstat);
+void procstat_freeargv(struct procstat *procstat);
+#ifndef ZFS
+void procstat_freeauxv(struct procstat *procstat, Elf_Auxinfo *auxv);
+#endif
+void procstat_freeenvv(struct procstat *procstat);
+void procstat_freegroups(struct procstat *procstat, gid_t *groups);
+void procstat_freekstack(struct procstat *procstat,
+ struct kinfo_kstack *kkstp);
void procstat_freeprocs(struct procstat *procstat, struct kinfo_proc *p);
void procstat_freefiles(struct procstat *procstat,
struct filestat_list *head);
+void procstat_freevmmap(struct procstat *procstat,
+ struct kinfo_vmentry *vmmap);
struct filestat_list *procstat_getfiles(struct procstat *procstat,
struct kinfo_proc *kp, int mmapped);
struct kinfo_proc *procstat_getprocs(struct procstat *procstat,
@@ -156,12 +182,37 @@ int procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst,
struct pipestat *pipe, char *errbuf);
int procstat_get_pts_info(struct procstat *procstat, struct filestat *fst,
struct ptsstat *pts, char *errbuf);
+int procstat_get_sem_info(struct procstat *procstat, struct filestat *fst,
+ struct semstat *sem, char *errbuf);
int procstat_get_shm_info(struct procstat *procstat, struct filestat *fst,
struct shmstat *shm, char *errbuf);
int procstat_get_socket_info(struct procstat *procstat, struct filestat *fst,
struct sockstat *sock, char *errbuf);
int procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
struct vnstat *vn, char *errbuf);
+char **procstat_getargv(struct procstat *procstat, struct kinfo_proc *p,
+ size_t nchr);
+#ifndef ZFS
+Elf_Auxinfo *procstat_getauxv(struct procstat *procstat,
+ struct kinfo_proc *kp, unsigned int *cntp);
+#endif
+char **procstat_getenvv(struct procstat *procstat, struct kinfo_proc *p,
+ size_t nchr);
+gid_t *procstat_getgroups(struct procstat *procstat, struct kinfo_proc *kp,
+ unsigned int *count);
+struct kinfo_kstack *procstat_getkstack(struct procstat *procstat,
+ struct kinfo_proc *kp, unsigned int *count);
+int procstat_getosrel(struct procstat *procstat, struct kinfo_proc *kp,
+ int *osrelp);
+int procstat_getpathname(struct procstat *procstat, struct kinfo_proc *kp,
+ char *pathname, size_t maxlen);
+int procstat_getrlimit(struct procstat *procstat, struct kinfo_proc *kp,
+ int which, struct rlimit* rlimit);
+int procstat_getumask(struct procstat *procstat, struct kinfo_proc *kp,
+ unsigned short* umask);
+struct kinfo_vmentry *procstat_getvmmap(struct procstat *procstat,
+ struct kinfo_proc *kp, unsigned int *count);
+struct procstat *procstat_open_core(const char *filename);
struct procstat *procstat_open_sysctl(void);
struct procstat *procstat_open_kvm(const char *nlistf, const char *memf);
__END_DECLS
diff --git a/lib/libprocstat/libprocstat_internal.h b/lib/libprocstat/libprocstat_internal.h
index 1c1d84284701..6ca3197cbc4e 100644
--- a/lib/libprocstat/libprocstat_internal.h
+++ b/lib/libprocstat/libprocstat_internal.h
@@ -34,6 +34,9 @@ struct procstat {
kvm_t *kd;
void *vmentries;
void *files;
+ void *argv;
+ void *envv;
+ struct procstat_core *core;
};
#endif /* !_LIBPROCSTAT_INTERNAL_H_ */
diff --git a/lib/libradius/radius.conf.5 b/lib/libradius/radius.conf.5
index 6f89c3ae2df3..1673a4890ec9 100644
--- a/lib/libradius/radius.conf.5
+++ b/lib/libradius/radius.conf.5
@@ -162,7 +162,9 @@ But an alternate pathname may be specified in the call to
Since the file contains sensitive information in the form of the
shared secrets, it should not be readable except by root.
.Sh FILES
-.Pa /etc/radius.conf
+.Bl -tag -width Pa
+.It Pa /etc/radius.conf
+.El
.Sh EXAMPLES
.Bd -literal
# A simple entry using all the defaults:
diff --git a/lib/librt/sigev_thread.c b/lib/librt/sigev_thread.c
index 0246c0c339cb..2677a8e50589 100644
--- a/lib/librt/sigev_thread.c
+++ b/lib/librt/sigev_thread.c
@@ -28,13 +28,13 @@
*/
#include <sys/types.h>
-#include <machine/atomic.h>
#include "namespace.h"
#include <err.h>
#include <errno.h>
#include <ucontext.h>
#include <sys/thr.h>
+#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -51,7 +51,7 @@ LIST_HEAD(sigev_list_head, sigev_node);
static struct sigev_list_head sigev_hash[HASH_QUEUES];
static struct sigev_list_head sigev_all;
static LIST_HEAD(,sigev_thread) sigev_threads;
-static unsigned int sigev_generation;
+static atomic_int sigev_generation;
static pthread_mutex_t *sigev_list_mtx;
static pthread_once_t sigev_once = PTHREAD_ONCE_INIT;
static pthread_once_t sigev_once_default = PTHREAD_ONCE_INIT;
@@ -196,7 +196,8 @@ __sigev_alloc(int type, const struct sigevent *evp, struct sigev_node *prev,
if (sn != NULL) {
sn->sn_value = evp->sigev_value;
sn->sn_func = evp->sigev_notify_function;
- sn->sn_gen = atomic_fetchadd_int(&sigev_generation, 1);
+ sn->sn_gen = atomic_fetch_add_explicit(&sigev_generation, 1,
+ memory_order_relaxed);
sn->sn_type = type;
_pthread_attr_init(&sn->sn_attr);
_pthread_attr_setdetachstate(&sn->sn_attr, PTHREAD_CREATE_DETACHED);
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile
index 2886e927fab4..506b564d57b5 100644
--- a/lib/libstand/Makefile
+++ b/lib/libstand/Makefile
@@ -36,6 +36,9 @@ CFLAGS+= -m32 -I.
.if ${MACHINE_CPUARCH} == "arm"
CFLAGS+= -msoft-float -D_STANDALONE
.endif
+.if ${MACHINE_CPUARCH} == "mips"
+CFLAGS+= -G0 -fno-pic -mno-abicalls
+.endif
# standalone components and stuff we have modified locally
SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
@@ -51,9 +54,7 @@ SRCS+= ntoh.c
# string functions from libc
.PATH: ${.CURDIR}/../libc/string
-.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "powerpc" || \
- ${MACHINE_CPUARCH} == "sparc64" || ${MACHINE_CPUARCH} == "amd64" || \
- ${MACHINE_CPUARCH} == "arm"
+.if ${MACHINE_CPUARCH} != "ia64"
SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \
memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \
diff --git a/lib/libstand/arm/_setjmp.S b/lib/libstand/arm/_setjmp.S
deleted file mode 100644
index 631213f217e1..000000000000
--- a/lib/libstand/arm/_setjmp.S
+++ /dev/null
@@ -1,106 +0,0 @@
-/* $NetBSD: _setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */
-
-/*
- * Copyright (c) 1997 Mark Brinicombe
- * 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 Mark Brinicombe
- * 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 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 <machine/asm.h>
-__FBSDID("$FreeBSD$");
-
-#define SOFTFLOAT /* XXX */
-/*
- * C library -- _setjmp, _longjmp
- *
- * _longjmp(a,v)
- * will generate a "return(v)" from the last call to
- * _setjmp(a)
- * by restoring registers from the stack.
- * The previous signal state is NOT restored.
- *
- * Note: r0 is the return value
- * r1-r3 are scratch registers in functions
- */
-
-ENTRY(_setjmp)
- ldr r1, .L_setjmp_magic
- str r1, [r0], #4
-#ifdef SOFTFLOAT
- add r0, r0, #52
-#else
- /* Store fp registers */
- sfm f4, 4, [r0], #48
- /* Store fpsr */
- rfs r1
- str r1, [r0], #0x0004
-#endif /* SOFTFLOAT */
- /* Store integer registers */
- stmia r0, {r4-r14}
-
- mov r0, #0x00000000
- mov r15, r14
-
-.L_setjmp_magic:
- .word _JB_MAGIC__SETJMP
-
-ENTRY(_longjmp)
- ldr r2, .L_setjmp_magic
- ldr r3, [r0], #4
- teq r2, r3
- bne botch
-
-#ifdef SOFTFLOAT
- add r0, r0, #52
-#else
- /* Restore fp registers */
- lfm f4, 4, [r0], #48
- /* Restore fpsr */
- ldr r4, [r0], #0x0004
- wfs r4
-#endif /* SOFTFLOAT */
- /* Restore integer registers */
- ldmia r0, {r4-r14}
-
- /* Validate sp and r14 */
- teq sp, #0
- teqne r14, #0
- beq botch
-
- /* Set return value */
- mov r0, r1
- teq r0, #0x00000000
- moveq r0, #0x00000001
- mov r15, r14
-
- /* validation failed, die die die. */
-botch:
- bl PIC_SYM(_C_LABEL(longjmperror), PLT)
- bl PIC_SYM(_C_LABEL(abort), PLT)
- b . - 8 /* Cannot get here */
diff --git a/lib/libstand/ext2fs.c b/lib/libstand/ext2fs.c
index 1bd78e20acb1..e0afb3eddd6d 100644
--- a/lib/libstand/ext2fs.c
+++ b/lib/libstand/ext2fs.c
@@ -536,6 +536,7 @@ ext2fs_open(const char *upath, struct open_file *f)
* Found terminal component.
*/
error = 0;
+ fp->f_seekp = 0;
out:
if (buf)
free(buf);
@@ -584,6 +585,7 @@ read_inode(ino_t inumber, struct open_file *f)
for (level = 0; level < NIADDR; level++)
fp->f_blkno[level] = -1;
fp->f_buf_blkno = -1;
+ fp->f_seekp = 0;
out:
free(buf);
diff --git a/lib/libstand/mips/_setjmp.S b/lib/libstand/mips/_setjmp.S
index 2ec7516bac5f..0289b0ec9274 100644
--- a/lib/libstand/mips/_setjmp.S
+++ b/lib/libstand/mips/_setjmp.S
@@ -59,33 +59,19 @@
LEAF(_setjmp)
.set noreorder
- li v0, 0xACEDBADE # sigcontext magic number
- sw ra, (2 * 4)(a0) # sc_pc = return address
- sw v0, (3 * 4)(a0) # saved in sc_regs[0]
- sw s0, ((S0 + 3) * 4)(a0)
- sw s1, ((S1 + 3) * 4)(a0)
- sw s2, ((S2 + 3) * 4)(a0)
- sw s3, ((S3 + 3) * 4)(a0)
- sw s4, ((S4 + 3) * 4)(a0)
- sw s5, ((S5 + 3) * 4)(a0)
- sw s6, ((S6 + 3) * 4)(a0)
- sw s7, ((S7 + 3) * 4)(a0)
- sw sp, ((SP + 3) * 4)(a0)
- sw s8, ((S8 + 3) * 4)(a0)
- cfc1 v0, $31 # too bad cant check if FP used
- swc1 $f20, ((20 + 38) * 4)(a0)
- swc1 $f21, ((21 + 38) * 4)(a0)
- swc1 $f22, ((22 + 38) * 4)(a0)
- swc1 $f23, ((23 + 38) * 4)(a0)
- swc1 $f24, ((24 + 38) * 4)(a0)
- swc1 $f25, ((25 + 38) * 4)(a0)
- swc1 $f26, ((26 + 38) * 4)(a0)
- swc1 $f27, ((27 + 38) * 4)(a0)
- swc1 $f28, ((28 + 38) * 4)(a0)
- swc1 $f29, ((29 + 38) * 4)(a0)
- swc1 $f30, ((30 + 38) * 4)(a0)
- swc1 $f31, ((31 + 38) * 4)(a0)
- sw v0, ((32 + 38) * 4)(a0)
+ REG_LI v0, 0xACEDBADE # sigcontext magic number
+ REG_S ra, (2 * SZREG)(a0) # sc_pc = return address
+ REG_S v0, (3 * SZREG)(a0) # saved in sc_regs[0]
+ REG_S s0, ((S0 + 3) * SZREG)(a0)
+ REG_S s1, ((S1 + 3) * SZREG)(a0)
+ REG_S s2, ((S2 + 3) * SZREG)(a0)
+ REG_S s3, ((S3 + 3) * SZREG)(a0)
+ REG_S s4, ((S4 + 3) * SZREG)(a0)
+ REG_S s5, ((S5 + 3) * SZREG)(a0)
+ REG_S s6, ((S6 + 3) * SZREG)(a0)
+ REG_S s7, ((S7 + 3) * SZREG)(a0)
+ REG_S sp, ((SP + 3) * SZREG)(a0)
+ REG_S s8, ((S8 + 3) * SZREG)(a0)
j ra
move v0, zero
END(_setjmp)
@@ -96,38 +82,21 @@ LEAF(_longjmp)
.cprestore 16
#endif
.set noreorder
- lw v0, (3 * 4)(a0) # get magic number
- lw ra, (2 * 4)(a0)
+ REG_L v0, (3 * SZREG)(a0) # get magic number
+ REG_L ra, (2 * SZREG)(a0)
bne v0, 0xACEDBADE, botch # jump if error
addu sp, sp, 32 # does not matter, sanity
- lw s0, ((S0 + 3) * 4)(a0)
- lw s1, ((S1 + 3) * 4)(a0)
- lw s2, ((S2 + 3) * 4)(a0)
- lw s3, ((S3 + 3) * 4)(a0)
- lw s4, ((S4 + 3) * 4)(a0)
- lw s5, ((S5 + 3) * 4)(a0)
- lw s6, ((S6 + 3) * 4)(a0)
- lw s7, ((S7 + 3) * 4)(a0)
- lw v0, ((32 + 38) * 4)(a0) # get fpu status
- lw sp, ((SP + 3) * 4)(a0)
- lw s8, ((S8 + 3) * 4)(a0)
-/* Octeon does not have an FPU */
-#if !defined(_MIPS_ARCH_OCTEON)
- ctc1 v0, $31
- lwc1 $f20, ((20 + 38) * 4)(a0)
- lwc1 $f21, ((21 + 38) * 4)(a0)
- lwc1 $f22, ((22 + 38) * 4)(a0)
- lwc1 $f23, ((23 + 38) * 4)(a0)
- lwc1 $f24, ((24 + 38) * 4)(a0)
- lwc1 $f25, ((25 + 38) * 4)(a0)
- lwc1 $f26, ((26 + 38) * 4)(a0)
- lwc1 $f27, ((27 + 38) * 4)(a0)
- lwc1 $f28, ((28 + 38) * 4)(a0)
- lwc1 $f29, ((29 + 38) * 4)(a0)
- lwc1 $f30, ((30 + 38) * 4)(a0)
- lwc1 $f31, ((31 + 38) * 4)(a0)
-#endif /* _MIPS_ARCH_OCTEON */
+ REG_L s0, ((S0 + 3) * SZREG)(a0)
+ REG_L s1, ((S1 + 3) * SZREG)(a0)
+ REG_L s2, ((S2 + 3) * SZREG)(a0)
+ REG_L s3, ((S3 + 3) * SZREG)(a0)
+ REG_L s4, ((S4 + 3) * SZREG)(a0)
+ REG_L s5, ((S5 + 3) * SZREG)(a0)
+ REG_L s6, ((S6 + 3) * SZREG)(a0)
+ REG_L s7, ((S7 + 3) * SZREG)(a0)
+ REG_L sp, ((SP + 3) * SZREG)(a0)
+ REG_L s8, ((S8 + 3) * SZREG)(a0)
j ra
move v0, a1
diff --git a/lib/libstand/nfs.c b/lib/libstand/nfs.c
index a7a7ccb7e9fd..adb0a11f176d 100644
--- a/lib/libstand/nfs.c
+++ b/lib/libstand/nfs.c
@@ -1465,8 +1465,9 @@ nfs_readdir(struct open_file *f, struct dirent *d)
d->d_name[d->d_namlen] = '\0';
pos = roundup(d->d_namlen, sizeof(uint32_t)) / sizeof(uint32_t);
- fp->off = cookie = ((uint64_t)ntohl(rent->nameplus[pos++]) << 32) |
- ntohl(rent->nameplus[pos++]);
+ fp->off = cookie = ((uint64_t)ntohl(rent->nameplus[pos]) << 32) |
+ ntohl(rent->nameplus[pos + 1]);
+ pos += 2;
buf = (u_char *)&rent->nameplus[pos];
return (0);
}
diff --git a/lib/libtacplus/libtacplus.3 b/lib/libtacplus/libtacplus.3
index 40ec6a26246d..688e618c63ee 100644
--- a/lib/libtacplus/libtacplus.3
+++ b/lib/libtacplus/libtacplus.3
@@ -513,7 +513,9 @@ without recording an error message.
.Fn tac_open
.El
.Sh FILES
-.Pa /etc/tacplus.conf
+.Bl -tag -width Pa
+.It Pa /etc/tacplus.conf
+.El
.Sh SEE ALSO
.Xr tacplus.conf 5
.Rs
diff --git a/lib/libtacplus/tacplus.conf.5 b/lib/libtacplus/tacplus.conf.5
index e68982d3d627..ecabaf6f61ec 100644
--- a/lib/libtacplus/tacplus.conf.5
+++ b/lib/libtacplus/tacplus.conf.5
@@ -111,7 +111,9 @@ An alternate pathname may be specified in the call to
Since the file contains sensitive information in the form of the
shared secrets, it should not be readable except by root.
.Sh FILES
-.Pa /etc/tacplus.conf
+.Bl -tag -width Pa
+.It Pa /etc/tacplus.conf
+.El
.Sh EXAMPLES
.Bd -literal
# A simple entry using all the defaults:
diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map
index 355edeafb96c..bbbd930e7a27 100644
--- a/lib/libthr/pthread.map
+++ b/lib/libthr/pthread.map
@@ -181,6 +181,7 @@ FBSDprivate_1.0 {
___wait;
___waitpid;
__accept;
+ __accept4;
__aio_suspend;
__close;
__connect;
@@ -408,3 +409,7 @@ FBSD_1.2 {
setcontext;
swapcontext;
};
+
+FBSD_1.3 {
+ accept4;
+};
diff --git a/lib/libthr/thread/thr_cancel.c b/lib/libthr/thread/thr_cancel.c
index 89f0ee14e635..beae707cacdc 100644
--- a/lib/libthr/thread/thr_cancel.c
+++ b/lib/libthr/thread/thr_cancel.c
@@ -87,7 +87,8 @@ _pthread_setcancelstate(int state, int *oldstate)
break;
case PTHREAD_CANCEL_ENABLE:
curthread->cancel_enable = 1;
- testcancel(curthread);
+ if (curthread->cancel_async)
+ testcancel(curthread);
break;
default:
return (EINVAL);
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index fb762908784e..83a02b554f12 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -746,7 +746,6 @@ void _thr_ref_delete(struct pthread *, struct pthread *) __hidden;
void _thr_ref_delete_unlocked(struct pthread *, struct pthread *) __hidden;
int _thr_find_thread(struct pthread *, struct pthread *, int) __hidden;
void _thr_rtld_init(void) __hidden;
-void _thr_rtld_fini(void) __hidden;
void _thr_rtld_postfork_child(void) __hidden;
int _thr_stack_alloc(struct pthread_attr *) __hidden;
void _thr_stack_free(struct pthread_attr *) __hidden;
diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c
index d9dd94d52f13..fd379d615b73 100644
--- a/lib/libthr/thread/thr_rtld.c
+++ b/lib/libthr/thread/thr_rtld.c
@@ -213,14 +213,3 @@ _thr_rtld_init(void)
_rtld_thread_init(&li);
_thr_signal_unblock(curthread);
}
-
-void
-_thr_rtld_fini(void)
-{
- struct pthread *curthread;
-
- curthread = _get_curthread();
- _thr_signal_block(curthread);
- _rtld_thread_init(NULL);
- _thr_signal_unblock(curthread);
-}
diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c
index a99395fd1b38..415ddb004dac 100644
--- a/lib/libthr/thread/thr_sig.c
+++ b/lib/libthr/thread/thr_sig.c
@@ -205,9 +205,9 @@ handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp)
curthread->in_sigsuspend = 0;
/*
- * if thread is in deferred cancellation mode, disable cancellation
+ * If thread is in deferred cancellation mode, disable cancellation
* in signal handler.
- * if user signal handler calls a cancellation point function, e.g,
+ * If user signal handler calls a cancellation point function, e.g,
* it calls write() to write data to file, because write() is a
* cancellation point, the thread is immediately cancelled if
* cancellation is pending, to avoid this problem while thread is in
@@ -229,7 +229,7 @@ handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp)
* We have already reset cancellation point flags, so if user's code
* longjmp()s out of its signal handler, wish its jmpbuf was set
* outside of a cancellation point, in most cases, this would be
- * true. however, ther is no way to save cancel_enable in jmpbuf,
+ * true. However, there is no way to save cancel_enable in jmpbuf,
* so after setjmps() returns once more, the user code may need to
* re-set cancel_enable flag by calling pthread_setcancelstate().
*/
@@ -318,33 +318,23 @@ check_deferred_signal(struct pthread *curthread)
ucontext_t *uc;
struct sigaction act;
siginfo_t info;
+ int uc_len;
if (__predict_true(curthread->deferred_siginfo.si_signo == 0))
return;
-#if defined(__amd64__) || defined(__i386__)
- uc = alloca(__getcontextx_size());
- __fillcontextx((char *)uc);
-#else
- ucontext_t ucv;
- uc = &ucv;
+ uc_len = __getcontextx_size();
+ uc = alloca(uc_len);
getcontext(uc);
-#endif
- if (curthread->deferred_siginfo.si_signo != 0) {
- act = curthread->deferred_sigact;
- uc->uc_sigmask = curthread->deferred_sigmask;
- memcpy(&info, &curthread->deferred_siginfo, sizeof(siginfo_t));
- /* remove signal */
- curthread->deferred_siginfo.si_signo = 0;
- if (act.sa_flags & SA_RESETHAND) {
- struct sigaction tact;
-
- tact = act;
- tact.sa_handler = SIG_DFL;
- _sigaction(info.si_signo, &tact, NULL);
- }
- handle_signal(&act, info.si_signo, &info, uc);
- }
+ if (curthread->deferred_siginfo.si_signo == 0)
+ return;
+ __fillcontextx2((char *)uc);
+ act = curthread->deferred_sigact;
+ uc->uc_sigmask = curthread->deferred_sigmask;
+ memcpy(&info, &curthread->deferred_siginfo, sizeof(siginfo_t));
+ /* remove signal */
+ curthread->deferred_siginfo.si_signo = 0;
+ handle_signal(&act, info.si_signo, &info, uc);
}
static void
@@ -732,9 +722,31 @@ _setcontext(const ucontext_t *ucp)
{
ucontext_t uc;
+ if (ucp == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if (!SIGISMEMBER(uc.uc_sigmask, SIGCANCEL))
+ return __sys_setcontext(ucp);
(void) memcpy(&uc, ucp, sizeof(uc));
- remove_thr_signals(&uc.uc_sigmask);
+ SIGDELSET(uc.uc_sigmask, SIGCANCEL);
return __sys_setcontext(&uc);
}
-__weak_reference(__sys_swapcontext, swapcontext);
+__weak_reference(_swapcontext, swapcontext);
+int
+_swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
+{
+ ucontext_t uc;
+
+ if (oucp == NULL || ucp == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if (SIGISMEMBER(ucp->uc_sigmask, SIGCANCEL)) {
+ (void) memcpy(&uc, ucp, sizeof(uc));
+ SIGDELSET(uc.uc_sigmask, SIGCANCEL);
+ ucp = &uc;
+ }
+ return __sys_swapcontext(oucp, ucp);
+}
diff --git a/lib/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c
index 86dc79430f15..46a61059aebb 100644
--- a/lib/libthr/thread/thr_spec.c
+++ b/lib/libthr/thread/thr_spec.c
@@ -70,7 +70,7 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
/* Unlock the key table: */
THR_LOCK_RELEASE(curthread, &_keytable_lock);
- *key = i;
+ *key = i + 1;
return (0);
}
@@ -81,9 +81,10 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
}
int
-_pthread_key_delete(pthread_key_t key)
+_pthread_key_delete(pthread_key_t userkey)
{
struct pthread *curthread = _get_curthread();
+ int key = userkey - 1;
int ret = 0;
if ((unsigned int)key < PTHREAD_KEYS_MAX) {
@@ -178,9 +179,10 @@ pthread_key_allocate_data(void)
}
int
-_pthread_setspecific(pthread_key_t key, const void *value)
+_pthread_setspecific(pthread_key_t userkey, const void *value)
{
struct pthread *pthread;
+ pthread_key_t key = userkey - 1;
int ret = 0;
/* Point to the running thread: */
@@ -209,9 +211,10 @@ _pthread_setspecific(pthread_key_t key, const void *value)
}
void *
-_pthread_getspecific(pthread_key_t key)
+_pthread_getspecific(pthread_key_t userkey)
{
struct pthread *pthread;
+ pthread_key_t key = userkey - 1;
const void *data;
/* Point to the running thread: */
diff --git a/lib/libthr/thread/thr_syscalls.c b/lib/libthr/thread/thr_syscalls.c
index 2327d7484e6e..7a08302d4a9c 100644
--- a/lib/libthr/thread/thr_syscalls.c
+++ b/lib/libthr/thread/thr_syscalls.c
@@ -101,6 +101,7 @@ extern pid_t __waitpid(pid_t, int *, int);
extern int __sys_aio_suspend(const struct aiocb * const[], int,
const struct timespec *);
extern int __sys_accept(int, struct sockaddr *, socklen_t *);
+extern int __sys_accept4(int, struct sockaddr *, socklen_t *, int);
extern int __sys_connect(int, const struct sockaddr *, socklen_t);
extern int __sys_fsync(int);
extern int __sys_msync(void *, size_t, int);
@@ -129,6 +130,7 @@ int ___usleep(useconds_t useconds);
pid_t ___wait(int *);
pid_t ___waitpid(pid_t, int *, int);
int __accept(int, struct sockaddr *, socklen_t *);
+int __accept4(int, struct sockaddr *, socklen_t *, int);
int __aio_suspend(const struct aiocb * const iocbs[], int,
const struct timespec *);
int __close(int);
@@ -176,6 +178,26 @@ __accept(int s, struct sockaddr *addr, socklen_t *addrlen)
return (ret);
}
+__weak_reference(__accept4, accept4);
+
+/*
+ * Cancellation behavior:
+ * If thread is canceled, no socket is created.
+ */
+int
+__accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
+{
+ struct pthread *curthread;
+ int ret;
+
+ curthread = _get_curthread();
+ _thr_cancel_enter(curthread);
+ ret = __sys_accept4(s, addr, addrlen, flags);
+ _thr_cancel_leave(curthread, ret == -1);
+
+ return (ret);
+}
+
__weak_reference(__aio_suspend, aio_suspend);
int
diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h
index f3d95f156fe3..2c289a7e6367 100644
--- a/lib/libthr/thread/thr_umtx.h
+++ b/lib/libthr/thread/thr_umtx.h
@@ -56,7 +56,7 @@ int _thr_umtx_timedwait_uint(volatile u_int *mtx, u_int exp, int clockid,
const struct timespec *timeout, int shared) __hidden;
int _thr_umtx_wake(volatile void *mtx, int count, int shared) __hidden;
int _thr_ucond_wait(struct ucond *cv, struct umutex *m,
- const struct timespec *timeout, int check_unpaking) __hidden;
+ const struct timespec *timeout, int flags) __hidden;
void _thr_ucond_init(struct ucond *cv) __hidden;
int _thr_ucond_signal(struct ucond *cv) __hidden;
int _thr_ucond_broadcast(struct ucond *cv) __hidden;
diff --git a/lib/libthread_db/arch/arm/libpthread_md.c b/lib/libthread_db/arch/arm/libpthread_md.c
index 6e4b2bddfc74..a72df2e4bb2d 100644
--- a/lib/libthread_db/arch/arm/libpthread_md.c
+++ b/lib/libthread_db/arch/arm/libpthread_md.c
@@ -90,7 +90,7 @@ pt_fpreg_to_ucontext(const struct fpreg *r __unused, ucontext_t *uc)
mcontext_t *mc = &uc->uc_mcontext;
/* XXX */
- memset(&mc->__fpu.__fpregs, 0, sizeof(__fpregset_t));
+ memset(&mc->__fpu, 0, sizeof(mc->__fpu));
}
void
diff --git a/lib/libthread_db/arch/sparc64/libpthread_md.c b/lib/libthread_db/arch/sparc64/libpthread_md.c
index 6a84518fa479..ffa67e9fde48 100644
--- a/lib/libthread_db/arch/sparc64/libpthread_md.c
+++ b/lib/libthread_db/arch/sparc64/libpthread_md.c
@@ -57,9 +57,9 @@ pt_fpreg_to_ucontext(const struct fpreg* r, ucontext_t *uc)
memcpy(mc->mc_fp, r->fr_regs, MIN(sizeof(mc->mc_fp),
sizeof(r->fr_regs)));
- mc->mc_fsr = r->fr_fsr;
- mc->mc_gsr = r->fr_gsr;
- mc->mc_fprs |= FPRS_FEF;
+ mc->_mc_fsr = r->fr_fsr;
+ mc->_mc_gsr = r->fr_gsr;
+ mc->_mc_fprs |= FPRS_FEF;
}
void
@@ -67,11 +67,11 @@ pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
{
const mcontext_t *mc = &uc->uc_mcontext;
- if ((mc->mc_fprs & FPRS_FEF) != 0) {
+ if ((mc->_mc_fprs & FPRS_FEF) != 0) {
memcpy(r->fr_regs, mc->mc_fp, MIN(sizeof(mc->mc_fp),
sizeof(r->fr_regs)));
- r->fr_fsr = mc->mc_fsr;
- r->fr_gsr = mc->mc_gsr;
+ r->fr_fsr = mc->_mc_fsr;
+ r->fr_gsr = mc->_mc_gsr;
} else
memset(r, 0, sizeof(*r));
}
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
index 66dd7959caf4..99bdfc2b9fc9 100644
--- a/lib/libusb/Makefile
+++ b/lib/libusb/Makefile
@@ -15,11 +15,12 @@ INCS+= libusb20_desc.h
MAN= libusb.3 libusb20.3
MKLINT= no
NOGCCERROR=
+PTHREAD_LIBS?= -lpthread
WARNS?= 2
DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LDADD= ${PTHREAD_LIBS}
MLINKS+= libusb.3 usb.3
@@ -37,12 +38,30 @@ SRCS+= libusb10_io.c
CFLAGS+= -DCOMPAT_32BIT
.endif
+beforeinstall:
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${.CURDIR}/libusb-0.1.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${.CURDIR}/libusb-1.0.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${.CURDIR}/libusb-2.0.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
+
#
# Cross platform support
#
# Examples:
# make LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h
-# make COMPAT_32BIT=YES LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h
+# make COMPAT_32BIT=YES \
+# LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \
+# DEBUG_FLAGS="-g"
+#
+# From Ubuntu 10.04:
+# freebsd-make LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \
+# PTHREAD_LIBS="-lpthread -lrt"
+# freebsd-make COMPAT32_BIT=YES \
+# LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \
+# PTHREAD_LIBS="-lpthread -lrt"
+#
#
.if defined(LIBUSB_GLOBAL_INCLUDE_FILE)
CFLAGS+= -DLIBUSB_GLOBAL_INCLUDE_FILE=\"${LIBUSB_GLOBAL_INCLUDE_FILE}\"
@@ -203,6 +222,7 @@ MLINKS += libusb20.3 libusb20_dev_reset.3
MLINKS += libusb20.3 libusb20_dev_check_connected.3
MLINKS += libusb20.3 libusb20_dev_set_power_mode.3
MLINKS += libusb20.3 libusb20_dev_get_power_mode.3
+MLINKS += libusb20.3 libusb20_dev_get_port_path.3
MLINKS += libusb20.3 libusb20_dev_get_power_usage.3
MLINKS += libusb20.3 libusb20_dev_set_alt_index.3
MLINKS += libusb20.3 libusb20_dev_get_device_desc.3
diff --git a/lib/libusb/libusb-0.1.pc b/lib/libusb/libusb-0.1.pc
new file mode 100644
index 000000000000..afd7a9960798
--- /dev/null
+++ b/lib/libusb/libusb-0.1.pc
@@ -0,0 +1,11 @@
+# $FreeBSD$
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libusb-0.1
+Description: Library that abstracts ways to access USB devices (v0.1)
+Version: 0.1.0
+Libs: -L${libdir} -lusb
+Cflags: -I${includedir}
diff --git a/lib/libusb/libusb-1.0.pc b/lib/libusb/libusb-1.0.pc
new file mode 100644
index 000000000000..bed98de3f99c
--- /dev/null
+++ b/lib/libusb/libusb-1.0.pc
@@ -0,0 +1,11 @@
+# $FreeBSD$
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libusb-1.0
+Description: Library that abstracts ways to access USB devices (v1.0)
+Version: 1.0.9
+Libs: -L${libdir} -lusb
+Cflags: -I${includedir}
diff --git a/lib/libusb/libusb-2.0.pc b/lib/libusb/libusb-2.0.pc
new file mode 100644
index 000000000000..34eabb88ab17
--- /dev/null
+++ b/lib/libusb/libusb-2.0.pc
@@ -0,0 +1,11 @@
+# $FreeBSD$
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libusb-2.0
+Description: Library that abstracts ways to access USB devices (v2.0)
+Version: 2.0.0
+Libs: -L${libdir} -lusb
+Cflags: -I${includedir}
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index ffc761b72202..b50981cf5d5c 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 7, 2012
+.Dd June 7, 2013
.Dt LIBUSB 3
.Os
.Sh NAME
@@ -102,6 +102,19 @@ counter decremented once.
Returns the number of the bus contained by the device
.Fa dev .
.Pp
+.Ft int
+.Fn libusb_get_port_numbers "libusb_device *dev" "uint8_t *buf" "uint8_t bufsize"
+Stores, in the buffer
+.Fa buf
+of size
+.Fa bufsize ,
+the list of all port numbers from root for the device
+.Fa dev .
+.Pp
+.Ft int
+.Fn libusb_get_port_path "libusb_context *ctx" "libusb_device *dev" "uint8_t *buf" "uint8_t bufsize"
+Deprecated function equivalent to libusb_get_port_numbers.
+.Pp
.Ft uint8_t
.Fn libusb_get_device_address "libusb_device *dev"
Returns the device_address contained by the device
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
index 225b539e907a..b14990eda50d 100644
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -369,6 +369,8 @@ void libusb_exit(struct libusb_context *ctx);
ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list);
void libusb_free_device_list(libusb_device ** list, int unref_devices);
uint8_t libusb_get_bus_number(libusb_device * dev);
+int libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize);
+int libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *buf, uint8_t bufsize);
uint8_t libusb_get_device_address(libusb_device * dev);
enum libusb_speed libusb_get_device_speed(libusb_device * dev);
int libusb_clear_halt(libusb_device_handle *devh, uint8_t endpoint);
@@ -441,7 +443,7 @@ int libusb_handle_events(libusb_context * ctx);
int libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv);
int libusb_get_next_timeout(libusb_context * ctx, struct timeval *tv);
void libusb_set_pollfd_notifiers(libusb_context * ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data);
-struct libusb_pollfd **libusb_get_pollfds(libusb_context * ctx);
+const struct libusb_pollfd **libusb_get_pollfds(libusb_context * ctx);
/* Synchronous device I/O */
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index 021229669119..79a570ed543f 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -290,6 +290,19 @@ libusb_get_bus_number(libusb_device *dev)
return (libusb20_dev_get_bus_number(dev->os_priv));
}
+int
+libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize)
+{
+ return (libusb20_dev_get_port_path(dev->os_priv, buf, bufsize));
+}
+
+int
+libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *buf,
+ uint8_t bufsize)
+{
+ return (libusb20_dev_get_port_path(dev->os_priv, buf, bufsize));
+}
+
uint8_t
libusb_get_device_address(libusb_device *dev)
{
diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c
index 489ceb76caed..9aa31c484224 100644
--- a/lib/libusb/libusb10_io.c
+++ b/lib/libusb/libusb10_io.c
@@ -397,7 +397,7 @@ libusb_set_pollfd_notifiers(libusb_context *ctx,
ctx->fd_cb_user_data = user_data;
}
-struct libusb_pollfd **
+const struct libusb_pollfd **
libusb_get_pollfds(libusb_context *ctx)
{
struct libusb_super_pollfd *pollfd;
@@ -423,7 +423,7 @@ libusb_get_pollfds(libusb_context *ctx)
done:
CTX_UNLOCK(ctx);
- return (ret);
+ return ((const struct libusb_pollfd **)ret);
}
diff --git a/lib/libusb/libusb20.3 b/lib/libusb/libusb20.3
index 8d286f13723f..f6004a534fdb 100644
--- a/lib/libusb/libusb20.3
+++ b/lib/libusb/libusb20.3
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 14, 2013
+.Dd May 3, 2013
.Dt LIBUSB20 3
.Os
.Sh NAME
@@ -114,6 +114,8 @@ USB access library (libusb -lusb)
.Ft const char *
.Fn libusb20_dev_get_backend_name "struct libusb20_device *"
.Ft int
+.Fn libusb20_dev_get_port_path "struct libusb20_device *pdev" "uint8_t *buf" "uint8_t bufsize"
+.Ft int
.Fn libusb20_dev_get_info "struct libusb20_device *pdev" "struct usb_device_info *pinfo"
.Ft int
.Fn libusb20_dev_get_iface_desc "struct libusb20_device *pdev" "uint8_t iface_index" "char *buf" "uint8_t len"
@@ -552,6 +554,20 @@ returns a zero terminated string describing the backend used.
.
.Pp
.
+.Fn libusb20_dev_get_port_path
+retrieves the list of USB port numbers which the datastream for a given USB device follows.
+The first port number is the Root HUB port number.
+Then children port numbers follow.
+The Root HUB device itself has a port path length of zero.
+Valid port numbers start at one and range until and including 255.
+Typically there should not be more than 16 levels, due to electrical and protocol limitations.
+This functions returns the number of actual port levels upon success
+else a LIBUSB20_ERROR value is returned which are always negative.
+If the actual number of port levels is greater than the maximum
+specified, a LIBUSB20_ERROR value is returned.
+.
+.Pp
+.
.Fn libusb20_dev_get_info
retrieves the BSD specific usb_device_info structure into the memory location given by
.Fa pinfo .
@@ -1033,9 +1049,9 @@ argument.
This function does not return NULL.
.
.Sh FILES
-.
-.
-/dev/usb
+.Bl -tag -width Pa
+.It Pa /dev/usb
+.El
.Sh SEE ALSO
.Xr usb 4 ,
.Xr libusb 3 ,
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index 644eda4f5498..1de3a265125a 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -75,6 +75,7 @@ dummy_callback(struct libusb20_transfer *xfer)
#define dummy_check_connected (void *)dummy_int
#define dummy_set_power_mode (void *)dummy_int
#define dummy_get_power_mode (void *)dummy_int
+#define dummy_get_port_path (void *)dummy_int
#define dummy_get_power_usage (void *)dummy_int
#define dummy_kernel_driver_active (void *)dummy_int
#define dummy_detach_kernel_driver (void *)dummy_int
@@ -722,6 +723,12 @@ libusb20_dev_get_power_mode(struct libusb20_device *pdev)
return (power_mode);
}
+int
+libusb20_dev_get_port_path(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize)
+{
+ return (pdev->methods->get_port_path(pdev, buf, bufsize));
+}
+
uint16_t
libusb20_dev_get_power_usage(struct libusb20_device *pdev)
{
@@ -1195,27 +1202,13 @@ libusb20_be_alloc(const struct libusb20_backend_methods *methods)
struct libusb20_backend *
libusb20_be_alloc_linux(void)
{
- struct libusb20_backend *pbe;
-
-#ifdef __linux__
- pbe = libusb20_be_alloc(&libusb20_linux_backend);
-#else
- pbe = NULL;
-#endif
- return (pbe);
+ return (NULL);
}
struct libusb20_backend *
libusb20_be_alloc_ugen20(void)
{
- struct libusb20_backend *pbe;
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- pbe = libusb20_be_alloc(&libusb20_ugen20_backend);
-#else
- pbe = NULL;
-#endif
- return (pbe);
+ return (libusb20_be_alloc(&libusb20_ugen20_backend));
}
struct libusb20_backend *
@@ -1223,10 +1216,12 @@ libusb20_be_alloc_default(void)
{
struct libusb20_backend *pbe;
+#ifdef __linux__
pbe = libusb20_be_alloc_linux();
if (pbe) {
return (pbe);
}
+#endif
pbe = libusb20_be_alloc_ugen20();
if (pbe) {
return (pbe);
diff --git a/lib/libusb/libusb20.h b/lib/libusb/libusb20.h
index 4a57b49710f6..6d1613e3e649 100644
--- a/lib/libusb/libusb20.h
+++ b/lib/libusb/libusb20.h
@@ -251,6 +251,7 @@ int libusb20_dev_reset(struct libusb20_device *pdev);
int libusb20_dev_check_connected(struct libusb20_device *pdev);
int libusb20_dev_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode);
uint8_t libusb20_dev_get_power_mode(struct libusb20_device *pdev);
+int libusb20_dev_get_port_path(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize);
uint16_t libusb20_dev_get_power_usage(struct libusb20_device *pdev);
int libusb20_dev_set_alt_index(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index);
int libusb20_dev_get_info(struct libusb20_device *pdev, struct usb_device_info *pinfo);
diff --git a/lib/libusb/libusb20_int.h b/lib/libusb/libusb20_int.h
index 6705c630c868..27adf008dea5 100644
--- a/lib/libusb/libusb20_int.h
+++ b/lib/libusb/libusb20_int.h
@@ -105,6 +105,7 @@ typedef int (libusb20_process_t)(struct libusb20_device *pdev);
typedef int (libusb20_reset_device_t)(struct libusb20_device *pdev);
typedef int (libusb20_set_power_mode_t)(struct libusb20_device *pdev, uint8_t power_mode);
typedef int (libusb20_get_power_mode_t)(struct libusb20_device *pdev, uint8_t *power_mode);
+typedef int (libusb20_get_port_path_t)(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize);
typedef int (libusb20_get_power_usage_t)(struct libusb20_device *pdev, uint16_t *power_usage);
typedef int (libusb20_set_alt_index_t)(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index);
typedef int (libusb20_set_config_index_t)(struct libusb20_device *pdev, uint8_t index);
@@ -128,6 +129,7 @@ typedef void (libusb20_tr_cancel_async_t)(struct libusb20_transfer *xfer);
m(n, check_connected) \
m(n, set_power_mode) \
m(n, get_power_mode) \
+ m(n, get_port_path) \
m(n, get_power_usage) \
m(n, set_alt_index) \
m(n, set_config_index) \
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index 0846eb4b7d52..e40bc07e61e0 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -46,6 +46,10 @@
#include "libusb20_desc.h"
#include "libusb20_int.h"
+#ifndef IOUSB
+#define IOUSB(a) a
+#endif
+
static libusb20_init_backend_t ugen20_init_backend;
static libusb20_open_device_t ugen20_open_device;
static libusb20_close_device_t ugen20_close_device;
@@ -73,6 +77,7 @@ static libusb20_reset_device_t ugen20_reset_device;
static libusb20_check_connected_t ugen20_check_connected;
static libusb20_set_power_mode_t ugen20_set_power_mode;
static libusb20_get_power_mode_t ugen20_get_power_mode;
+static libusb20_get_port_path_t ugen20_get_port_path;
static libusb20_get_power_usage_t ugen20_get_power_usage;
static libusb20_kernel_driver_active_t ugen20_kernel_driver_active;
static libusb20_detach_kernel_driver_t ugen20_detach_kernel_driver;
@@ -144,14 +149,14 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
if (f < 0) {
return (LIBUSB20_ERROR_OTHER);
}
- if (ioctl(f, USB_GET_PLUGTIME, &plugtime)) {
+ if (ioctl(f, IOUSB(USB_GET_PLUGTIME), &plugtime)) {
error = LIBUSB20_ERROR_OTHER;
goto done;
}
/* store when the device was plugged */
pdev->session_data.plugtime = plugtime;
- if (ioctl(f, USB_GET_DEVICE_DESC, &ddesc)) {
+ if (ioctl(f, IOUSB(USB_GET_DEVICE_DESC), &ddesc)) {
error = LIBUSB20_ERROR_OTHER;
goto done;
}
@@ -166,7 +171,7 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
error = LIBUSB20_ERROR_OTHER;
goto done;
}
- if (ioctl(f, USB_GET_DEVICEINFO, &devinfo)) {
+ if (ioctl(f, IOUSB(USB_GET_DEVICEINFO), &devinfo)) {
error = LIBUSB20_ERROR_OTHER;
goto done;
}
@@ -240,7 +245,7 @@ repeat:
st->urd.urd_maxlen = sizeof(st->buf);
st->nparsed = 0;
- if (ioctl(st->f, USB_READ_DIR, &st->urd)) {
+ if (ioctl(st->f, IOUSB(USB_READ_DIR), &st->urd)) {
return (EINVAL);
}
st->ptr = st->buf;
@@ -312,7 +317,7 @@ ugen20_tr_release(struct libusb20_device *pdev)
/* release all pending USB transfers */
if (pdev->privBeData != NULL) {
memset(&fs_uninit, 0, sizeof(fs_uninit));
- if (ioctl(pdev->file, USB_FS_UNINIT, &fs_uninit)) {
+ if (ioctl(pdev->file, IOUSB(USB_FS_UNINIT), &fs_uninit)) {
/* ignore any errors of this kind */
}
}
@@ -352,7 +357,7 @@ ugen20_tr_renew(struct libusb20_device *pdev)
fs_init.pEndpoints = libusb20_pass_ptr(pdev->privBeData);
fs_init.ep_index_max = nMaxTransfer;
- if (ioctl(pdev->file, USB_FS_INIT, &fs_init)) {
+ if (ioctl(pdev->file, IOUSB(USB_FS_INIT), &fs_init)) {
error = LIBUSB20_ERROR_OTHER;
goto done;
}
@@ -386,7 +391,7 @@ ugen20_open_device(struct libusb20_device *pdev, uint16_t nMaxTransfer)
close(g);
return (LIBUSB20_ERROR_NO_DEVICE);
}
- if (ioctl(f, USB_GET_PLUGTIME, &plugtime)) {
+ if (ioctl(f, IOUSB(USB_GET_PLUGTIME), &plugtime)) {
error = LIBUSB20_ERROR_OTHER;
goto done;
}
@@ -429,7 +434,7 @@ ugen20_close_device(struct libusb20_device *pdev)
if (pdev->privBeData) {
memset(&fs_uninit, 0, sizeof(fs_uninit));
- if (ioctl(pdev->file, USB_FS_UNINIT, &fs_uninit)) {
+ if (ioctl(pdev->file, IOUSB(USB_FS_UNINIT), &fs_uninit)) {
/* ignore this error */
}
free(pdev->privBeData);
@@ -467,7 +472,7 @@ ugen20_get_config_desc_full(struct libusb20_device *pdev,
gen_desc.ugd_maxlen = sizeof(cdesc);
gen_desc.ugd_config_index = cfg_index;
- error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
+ error = ioctl(pdev->file_ctrl, IOUSB(USB_GET_FULL_DESC), &gen_desc);
if (error) {
return (LIBUSB20_ERROR_OTHER);
}
@@ -487,7 +492,7 @@ ugen20_get_config_desc_full(struct libusb20_device *pdev,
gen_desc.ugd_data = libusb20_pass_ptr(ptr);
gen_desc.ugd_maxlen = len;
- error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
+ error = ioctl(pdev->file_ctrl, IOUSB(USB_GET_FULL_DESC), &gen_desc);
if (error) {
free(ptr);
return (LIBUSB20_ERROR_OTHER);
@@ -506,7 +511,7 @@ ugen20_get_config_index(struct libusb20_device *pdev, uint8_t *pindex)
{
int temp;
- if (ioctl(pdev->file_ctrl, USB_GET_CONFIG, &temp)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_CONFIG), &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
*pindex = temp;
@@ -522,7 +527,7 @@ ugen20_set_config_index(struct libusb20_device *pdev, uint8_t cfg_index)
/* release all active USB transfers */
ugen20_tr_release(pdev);
- if (ioctl(pdev->file_ctrl, USB_SET_CONFIG, &temp)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_SET_CONFIG), &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
return (ugen20_tr_renew(pdev));
@@ -542,7 +547,7 @@ ugen20_set_alt_index(struct libusb20_device *pdev,
/* release all active USB transfers */
ugen20_tr_release(pdev);
- if (ioctl(pdev->file_ctrl, USB_SET_ALTINTERFACE, &alt_iface)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_SET_ALTINTERFACE), &alt_iface)) {
return (LIBUSB20_ERROR_OTHER);
}
return (ugen20_tr_renew(pdev));
@@ -556,7 +561,7 @@ ugen20_reset_device(struct libusb20_device *pdev)
/* release all active USB transfers */
ugen20_tr_release(pdev);
- if (ioctl(pdev->file_ctrl, USB_DEVICEENUMERATE, &temp)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_DEVICEENUMERATE), &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
return (ugen20_tr_renew(pdev));
@@ -568,7 +573,7 @@ ugen20_check_connected(struct libusb20_device *pdev)
uint32_t plugtime;
int error = 0;
- if (ioctl(pdev->file_ctrl, USB_GET_PLUGTIME, &plugtime)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_PLUGTIME), &plugtime)) {
error = LIBUSB20_ERROR_NO_DEVICE;
goto done;
}
@@ -605,7 +610,7 @@ ugen20_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode)
default:
return (LIBUSB20_ERROR_INVALID_PARAM);
}
- if (ioctl(pdev->file_ctrl, USB_SET_POWER_MODE, &temp)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_SET_POWER_MODE), &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
return (0);
@@ -616,7 +621,7 @@ ugen20_get_power_mode(struct libusb20_device *pdev, uint8_t *power_mode)
{
int temp;
- if (ioctl(pdev->file_ctrl, USB_GET_POWER_MODE, &temp)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_POWER_MODE), &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
switch (temp) {
@@ -644,11 +649,27 @@ ugen20_get_power_mode(struct libusb20_device *pdev, uint8_t *power_mode)
}
static int
+ugen20_get_port_path(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize)
+{
+ struct usb_device_port_path udpp;
+
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_DEV_PORT_PATH), &udpp))
+ return (LIBUSB20_ERROR_OTHER);
+
+ if (udpp.udp_port_level > bufsize)
+ return (LIBUSB20_ERROR_OVERFLOW);
+
+ memcpy(buf, udpp.udp_port_no, udpp.udp_port_level);
+
+ return (udpp.udp_port_level); /* success */
+}
+
+static int
ugen20_get_power_usage(struct libusb20_device *pdev, uint16_t *power_usage)
{
int temp;
- if (ioctl(pdev->file_ctrl, USB_GET_POWER_USAGE, &temp)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_POWER_USAGE), &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
*power_usage = temp;
@@ -661,7 +682,7 @@ ugen20_kernel_driver_active(struct libusb20_device *pdev,
{
int temp = iface_index;
- if (ioctl(pdev->file_ctrl, USB_IFACE_DRIVER_ACTIVE, &temp)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_IFACE_DRIVER_ACTIVE), &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
return (0); /* kernel driver is active */
@@ -673,10 +694,10 @@ ugen20_detach_kernel_driver(struct libusb20_device *pdev,
{
int temp = iface_index;
- if (ioctl(pdev->file_ctrl, USB_IFACE_DRIVER_DETACH, &temp)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_IFACE_DRIVER_DETACH), &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
- return (0); /* kernel driver is active */
+ return (0); /* kernel driver is detached */
}
static int
@@ -696,14 +717,14 @@ ugen20_do_request_sync(struct libusb20_device *pdev,
sizeof(req.ucr_request), setup)) {
/* ignore */
}
- if (ioctl(pdev->file_ctrl, USB_DO_REQUEST, &req)) {
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_DO_REQUEST), &req)) {
return (LIBUSB20_ERROR_OTHER);
}
if (pactlen) {
/* get actual length */
*pactlen = req.ucr_actlen;
}
- return (0); /* kernel driver is active */
+ return (0); /* request was successful */
}
static int
@@ -715,7 +736,7 @@ ugen20_process(struct libusb20_device *pdev)
while (1) {
- if (ioctl(pdev->file, USB_FS_COMPLETE, &temp)) {
+ if (ioctl(pdev->file, IOUSB(USB_FS_COMPLETE), &temp)) {
if (errno == EBUSY) {
break;
} else {
@@ -783,10 +804,10 @@ ugen20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
if (stream_id != 0) {
temp.fs_open_stream.stream_id = stream_id;
- if (ioctl(xfer->pdev->file, USB_FS_OPEN_STREAM, &temp.fs_open_stream))
+ if (ioctl(xfer->pdev->file, IOUSB(USB_FS_OPEN_STREAM), &temp.fs_open_stream))
return (LIBUSB20_ERROR_INVALID_PARAM);
} else {
- if (ioctl(xfer->pdev->file, USB_FS_OPEN, &temp.fs_open))
+ if (ioctl(xfer->pdev->file, IOUSB(USB_FS_OPEN), &temp.fs_open))
return (LIBUSB20_ERROR_INVALID_PARAM);
}
/* maximums might have changed - update */
@@ -812,7 +833,7 @@ ugen20_tr_close(struct libusb20_transfer *xfer)
temp.ep_index = xfer->trIndex;
- if (ioctl(xfer->pdev->file, USB_FS_CLOSE, &temp)) {
+ if (ioctl(xfer->pdev->file, IOUSB(USB_FS_CLOSE), &temp)) {
return (LIBUSB20_ERROR_INVALID_PARAM);
}
return (0); /* success */
@@ -829,7 +850,7 @@ ugen20_tr_clear_stall_sync(struct libusb20_transfer *xfer)
temp.ep_index = xfer->trIndex;
- if (ioctl(xfer->pdev->file, USB_FS_CLEAR_STALL_SYNC, &temp)) {
+ if (ioctl(xfer->pdev->file, IOUSB(USB_FS_CLEAR_STALL_SYNC), &temp)) {
return (LIBUSB20_ERROR_INVALID_PARAM);
}
return (0); /* success */
@@ -868,7 +889,7 @@ ugen20_tr_submit(struct libusb20_transfer *xfer)
temp.ep_index = xfer->trIndex;
- if (ioctl(xfer->pdev->file, USB_FS_START, &temp)) {
+ if (ioctl(xfer->pdev->file, IOUSB(USB_FS_START), &temp)) {
/* ignore any errors - should never happen */
}
return; /* success */
@@ -883,7 +904,7 @@ ugen20_tr_cancel_async(struct libusb20_transfer *xfer)
temp.ep_index = xfer->trIndex;
- if (ioctl(xfer->pdev->file, USB_FS_STOP, &temp)) {
+ if (ioctl(xfer->pdev->file, IOUSB(USB_FS_STOP), &temp)) {
/* ignore any errors - should never happen */
}
return;
@@ -922,7 +943,7 @@ ugen20_dev_get_iface_desc(struct libusb20_device *pdev,
ugd.ugd_maxlen = len;
ugd.ugd_iface_index = iface_index;
- if (ioctl(pdev->file, USB_GET_IFACE_DRIVER, &ugd)) {
+ if (ioctl(pdev->file, IOUSB(USB_GET_IFACE_DRIVER), &ugd)) {
return (LIBUSB20_ERROR_INVALID_PARAM);
}
return (0);
@@ -932,7 +953,7 @@ static int
ugen20_dev_get_info(struct libusb20_device *pdev,
struct usb_device_info *pinfo)
{
- if (ioctl(pdev->file, USB_GET_DEVICEINFO, pinfo)) {
+ if (ioctl(pdev->file, IOUSB(USB_GET_DEVICEINFO), pinfo)) {
return (LIBUSB20_ERROR_INVALID_PARAM);
}
return (0);
@@ -949,7 +970,7 @@ ugen20_root_get_dev_quirk(struct libusb20_backend *pbe,
q.index = quirk_index;
- error = ugen20_be_ioctl(USB_DEV_QUIRK_GET, &q);
+ error = ugen20_be_ioctl(IOUSB(USB_DEV_QUIRK_GET), &q);
if (error) {
if (errno == EINVAL) {
@@ -976,7 +997,7 @@ ugen20_root_get_quirk_name(struct libusb20_backend *pbe, uint16_t quirk_index,
q.index = quirk_index;
- error = ugen20_be_ioctl(USB_QUIRK_NAME_GET, &q);
+ error = ugen20_be_ioctl(IOUSB(USB_QUIRK_NAME_GET), &q);
if (error) {
if (errno == EINVAL) {
@@ -1003,7 +1024,7 @@ ugen20_root_add_dev_quirk(struct libusb20_backend *pbe,
q.bcdDeviceHigh = pq->bcdDeviceHigh;
strlcpy(q.quirkname, pq->quirkname, sizeof(q.quirkname));
- error = ugen20_be_ioctl(USB_DEV_QUIRK_ADD, &q);
+ error = ugen20_be_ioctl(IOUSB(USB_DEV_QUIRK_ADD), &q);
if (error) {
if (errno == ENOMEM) {
return (LIBUSB20_ERROR_NO_MEM);
@@ -1027,7 +1048,7 @@ ugen20_root_remove_dev_quirk(struct libusb20_backend *pbe,
q.bcdDeviceHigh = pq->bcdDeviceHigh;
strlcpy(q.quirkname, pq->quirkname, sizeof(q.quirkname));
- error = ugen20_be_ioctl(USB_DEV_QUIRK_REMOVE, &q);
+ error = ugen20_be_ioctl(IOUSB(USB_DEV_QUIRK_REMOVE), &q);
if (error) {
if (errno == EINVAL) {
return (LIBUSB20_ERROR_NOT_FOUND);
@@ -1039,11 +1060,11 @@ ugen20_root_remove_dev_quirk(struct libusb20_backend *pbe,
static int
ugen20_root_set_template(struct libusb20_backend *pbe, int temp)
{
- return (ugen20_be_ioctl(USB_SET_TEMPLATE, &temp));
+ return (ugen20_be_ioctl(IOUSB(USB_SET_TEMPLATE), &temp));
}
static int
ugen20_root_get_template(struct libusb20_backend *pbe, int *ptemp)
{
- return (ugen20_be_ioctl(USB_GET_TEMPLATE, ptemp));
+ return (ugen20_be_ioctl(IOUSB(USB_GET_TEMPLATE), ptemp));
}
diff --git a/lib/libusb/libusb_global_linux.h b/lib/libusb/libusb_global_linux.h
index cbdd2c6b818d..13d344a92ea0 100644
--- a/lib/libusb/libusb_global_linux.h
+++ b/lib/libusb/libusb_global_linux.h
@@ -29,7 +29,9 @@
#define _XOPEN_SOURCE
#define _BSD_SOURCE
+#ifdef __linux__
#define _POSIX_SOURCE
+#endif
#define _POSIX_C_SOURCE 200809
#include <ctype.h>
@@ -39,10 +41,13 @@
#include <stdint.h>
#include <time.h>
#include <unistd.h>
+#ifdef __linux__
#include <alloca.h>
+#endif
#include <string.h>
#include <fcntl.h>
#include <limits.h>
+#include <setjmp.h>
#include <pthread.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
@@ -51,6 +56,10 @@
#include <dev/usb/usb_endian.h>
#include <dev/usb/usb_freebsd.h>
+#include <compat/linux/linux_ioctl.h>
+
+#define IOUSB(a) FBSD_L##a
+
#ifndef __aligned
#define __aligned(x) __attribute__((__aligned__(x)))
#endif
diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c
index 5d55884d9ac5..24bcc39a35e9 100644
--- a/lib/libutil/expand_number.c
+++ b/lib/libutil/expand_number.c
@@ -35,31 +35,24 @@ __FBSDID("$FreeBSD$");
#include <libutil.h>
#include <stdint.h>
-/*
- * Convert an expression of the following forms to a uint64_t.
- * 1) A positive decimal number.
- * 2) A positive decimal number followed by a 'b' or 'B' (mult by 1).
- * 3) A positive decimal number followed by a 'k' or 'K' (mult by 1 << 10).
- * 4) A positive decimal number followed by a 'm' or 'M' (mult by 1 << 20).
- * 5) A positive decimal number followed by a 'g' or 'G' (mult by 1 << 30).
- * 6) A positive decimal number followed by a 't' or 'T' (mult by 1 << 40).
- * 7) A positive decimal number followed by a 'p' or 'P' (mult by 1 << 50).
- * 8) A positive decimal number followed by a 'e' or 'E' (mult by 1 << 60).
- */
int
expand_number(const char *buf, uint64_t *num)
{
+ char *endptr;
+ uintmax_t umaxval;
uint64_t number;
unsigned shift;
- char *endptr;
-
- number = strtoumax(buf, &endptr, 0);
+ int serrno;
- if (endptr == buf) {
- /* No valid digits. */
- errno = EINVAL;
+ serrno = errno;
+ errno = 0;
+ umaxval = strtoumax(buf, &endptr, 0);
+ if (umaxval > UINT64_MAX)
+ errno = ERANGE;
+ if (errno != 0)
return (-1);
- }
+ errno = serrno;
+ number = umaxval;
switch (tolower((unsigned char)*endptr)) {
case 'e':
@@ -95,7 +88,6 @@ expand_number(const char *buf, uint64_t *num)
errno = ERANGE;
return (-1);
}
-
*num = number << shift;
return (0);
}
diff --git a/lib/libutil/login_auth.c b/lib/libutil/login_auth.c
index ce9a2e47c316..1fc7e73d6bc3 100644
--- a/lib/libutil/login_auth.c
+++ b/lib/libutil/login_auth.c
@@ -98,7 +98,7 @@ auth_cat(const char *file)
int fd, count;
char buf[BUFSIZ];
- if ((fd = open(file, O_RDONLY)) < 0)
+ if ((fd = open(file, O_RDONLY | O_CLOEXEC)) < 0)
return 0;
while ((count = read(fd, buf, sizeof(buf))) > 0)
(void)write(fileno(stdout), buf, count);
diff --git a/lib/libutil/login_cap.c b/lib/libutil/login_cap.c
index 8fee76050b04..8915d0af279e 100644
--- a/lib/libutil/login_cap.c
+++ b/lib/libutil/login_cap.c
@@ -239,7 +239,7 @@ login_getclassbyname(char const *name, const struct passwd *pwd)
break; /* Don't retry default on 'me' */
if (i == 0)
r = -1;
- else if ((r = open(login_dbarray[0], O_RDONLY)) >= 0)
+ else if ((r = open(login_dbarray[0], O_RDONLY | O_CLOEXEC)) >= 0)
close(r);
/*
* If there's at least one login class database,
diff --git a/lib/libutil/login_times.c b/lib/libutil/login_times.c
index e2c7bf2341f2..d13ed9970618 100644
--- a/lib/libutil/login_times.c
+++ b/lib/libutil/login_times.c
@@ -96,7 +96,7 @@ parse_lt(const char *str)
else
m.lt_start = 0;
if (*p == '-')
- p = parse_time(++p, &m.lt_end);
+ p = parse_time(p + 1, &m.lt_end);
else
m.lt_end = 1440;
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index 7949e9e9a034..3a5e5121c147 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -73,7 +73,7 @@ pidfile_read(const char *path, pid_t *pidptr)
char buf[16], *endptr;
int error, fd, i;
- fd = open(path, O_RDONLY);
+ fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd == -1)
return (errno);
diff --git a/lib/libutil/quotafile.c b/lib/libutil/quotafile.c
index 03e3de4e4937..6b5a44d9cdf7 100644
--- a/lib/libutil/quotafile.c
+++ b/lib/libutil/quotafile.c
@@ -137,7 +137,7 @@ quota_open(struct fstab *fs, int quotatype, int openflags)
goto error;
}
qf->accmode = openflags & O_ACCMODE;
- if ((qf->fd = open(qf->qfname, qf->accmode)) < 0 &&
+ if ((qf->fd = open(qf->qfname, qf->accmode|O_CLOEXEC)) < 0 &&
(openflags & O_CREAT) != O_CREAT)
goto error;
/* File open worked, so process it */
@@ -168,7 +168,8 @@ quota_open(struct fstab *fs, int quotatype, int openflags)
/* not reached */
}
/* open failed, but O_CREAT was specified, so create a new file */
- if ((qf->fd = open(qf->qfname, O_RDWR|O_CREAT|O_TRUNC, 0)) < 0)
+ if ((qf->fd = open(qf->qfname, O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC, 0)) <
+ 0)
goto error;
qf->wordsize = 64;
memset(&dqh, 0, sizeof(dqh));
@@ -534,7 +535,8 @@ quota_convert(struct quotafile *qf, int wordsize)
free(newqf);
return (-1);
}
- if ((newqf->fd = open(qf->qfname, O_RDWR|O_CREAT|O_TRUNC, 0)) < 0) {
+ if ((newqf->fd = open(qf->qfname, O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC,
+ 0)) < 0) {
serrno = errno;
goto error;
}
diff --git a/lib/libutil/uucplock.c b/lib/libutil/uucplock.c
index afbfaa4d0537..424ac26651e1 100644
--- a/lib/libutil/uucplock.c
+++ b/lib/libutil/uucplock.c
@@ -76,7 +76,8 @@ uu_lock(const char *tty_name)
pid);
(void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT,
tty_name);
- if ((tmpfd = creat(lcktmpname, 0664)) < 0)
+ if ((tmpfd = open(lcktmpname, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC,
+ 0664)) < 0)
GORET(0, UU_LOCK_CREAT_ERR);
for (i = 0; i < MAXTRIES; i++) {
@@ -88,7 +89,7 @@ uu_lock(const char *tty_name)
* check to see if the process holding the lock
* still exists
*/
- if ((fd = open(lckname, O_RDONLY)) < 0)
+ if ((fd = open(lckname, O_RDONLY | O_CLOEXEC)) < 0)
GORET(1, UU_LOCK_OPEN_ERR);
if ((pid_old = get_pid (fd, &err)) == -1)
@@ -132,7 +133,7 @@ uu_lock_txfr(const char *tty_name, pid_t pid)
snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, tty_name);
- if ((fd = open(lckname, O_RDWR)) < 0)
+ if ((fd = open(lckname, O_RDWR | O_CLOEXEC)) < 0)
return UU_LOCK_OWNER_ERR;
if (get_pid(fd, &err) != getpid())
err = UU_LOCK_OWNER_ERR;
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 6982ba3c7790..95be94a21cc3 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -123,30 +123,6 @@ vm_destroy(struct vmctx *vm)
free(vm);
}
-size_t
-vmm_get_mem_total(void)
-{
- size_t mem_total = 0;
- size_t oldlen = sizeof(mem_total);
- int error;
- error = sysctlbyname("hw.vmm.mem_total", &mem_total, &oldlen, NULL, 0);
- if (error)
- return -1;
- return mem_total;
-}
-
-size_t
-vmm_get_mem_free(void)
-{
- size_t mem_free = 0;
- size_t oldlen = sizeof(mem_free);
- int error;
- error = sysctlbyname("hw.vmm.mem_free", &mem_free, &oldlen, NULL, 0);
- if (error)
- return -1;
- return mem_free;
-}
-
int
vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len)
{
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index f066c501e068..441e75f9d8d1 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -45,8 +45,6 @@ enum vm_mmap_style {
int vm_create(const char *name);
struct vmctx *vm_open(const char *name);
void vm_destroy(struct vmctx *ctx);
-size_t vmm_get_mem_total(void);
-size_t vmm_get_mem_free(void);
int vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len);
int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s);
void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len);
diff --git a/lib/libz/ChangeLog b/lib/libz/ChangeLog
index c2c643a1a9bc..f22aabaef534 100644
--- a/lib/libz/ChangeLog
+++ b/lib/libz/ChangeLog
@@ -1,6 +1,69 @@
ChangeLog file for zlib
+Changes in 1.2.8 (28 Apr 2013)
+- Update contrib/minizip/iowin32.c for Windows RT [Vollant]
+- Do not force Z_CONST for C++
+- Clean up contrib/vstudio [Ro§]
+- Correct spelling error in zlib.h
+- Fix mixed line endings in contrib/vstudio
+
+Changes in 1.2.7.3 (13 Apr 2013)
+- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc
+
+Changes in 1.2.7.2 (13 Apr 2013)
+- Change check for a four-byte type back to hexadecimal
+- Fix typo in win32/Makefile.msc
+- Add casts in gzwrite.c for pointer differences
+
+Changes in 1.2.7.1 (24 Mar 2013)
+- Replace use of unsafe string functions with snprintf if available
+- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink]
+- Fix gzgetc undefine when Z_PREFIX set [Turk]
+- Eliminate use of mktemp in Makefile (not always available)
+- Fix bug in 'F' mode for gzopen()
+- Add inflateGetDictionary() function
+- Correct comment in deflate.h
+- Use _snprintf for snprintf in Microsoft C
+- On Darwin, only use /usr/bin/libtool if libtool is not Apple
+- Delete "--version" file if created by "ar --version" [Richard G.]
+- Fix configure check for veracity of compiler error return codes
+- Fix CMake compilation of static lib for MSVC2010 x64
+- Remove unused variable in infback9.c
+- Fix argument checks in gzlog_compress() and gzlog_write()
+- Clean up the usage of z_const and respect const usage within zlib
+- Clean up examples/gzlog.[ch] comparisons of different types
+- Avoid shift equal to bits in type (caused endless loop)
+- Fix unintialized value bug in gzputc() introduced by const patches
+- Fix memory allocation error in examples/zran.c [Nor]
+- Fix bug where gzopen(), gzclose() would write an empty file
+- Fix bug in gzclose() when gzwrite() runs out of memory
+- Check for input buffer malloc failure in examples/gzappend.c
+- Add note to contrib/blast to use binary mode in stdio
+- Fix comparisons of differently signed integers in contrib/blast
+- Check for invalid code length codes in contrib/puff
+- Fix serious but very rare decompression bug in inftrees.c
+- Update inflateBack() comments, since inflate() can be faster
+- Use underscored I/O function names for WINAPI_FAMILY
+- Add _tr_flush_bits to the external symbols prefixed by --zprefix
+- Add contrib/vstudio/vc10 pre-build step for static only
+- Quote --version-script argument in CMakeLists.txt
+- Don't specify --version-script on Apple platforms in CMakeLists.txt
+- Fix casting error in contrib/testzlib/testzlib.c
+- Fix types in contrib/minizip to match result of get_crc_table()
+- Simplify contrib/vstudio/vc10 with 'd' suffix
+- Add TOP support to win32/Makefile.msc
+- Suport i686 and amd64 assembler builds in CMakeLists.txt
+- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h
+- Add vc11 and vc12 build files to contrib/vstudio
+- Add gzvprintf() as an undocumented function in zlib
+- Fix configure for Sun shell
+- Remove runtime check in configure for four-byte integer type
+- Add casts and consts to ease user conversion to C++
+- Add man pages for minizip and miniunzip
+- In Makefile uninstall, don't rm if preceding cd fails
+- Do not return Z_BUF_ERROR if deflateParam() has nothing to write
+
Changes in 1.2.7 (2 May 2012)
- Replace use of memmove() with a simple copy for portability
- Test for existence of strerror
diff --git a/lib/libz/README b/lib/libz/README
index 6f1255ffe48e..5ca9d127edaf 100644
--- a/lib/libz/README
+++ b/lib/libz/README
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.2.7 is a general purpose data compression library. All the code is
+zlib 1.2.8 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
@@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
http://marknelson.us/1997/01/01/zlib-engine/ .
-The changes made in version 1.2.7 are documented in the file ChangeLog.
+The changes made in version 1.2.8 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
@@ -84,7 +84,7 @@ Acknowledgments:
Copyright notice:
- (C) 1995-2012 Jean-loup Gailly and Mark Adler
+ (C) 1995-2013 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
diff --git a/lib/libz/Symbol.map b/lib/libz/Symbol.map
index c9eef6f979d1..b117cdd14778 100644
--- a/lib/libz/Symbol.map
+++ b/lib/libz/Symbol.map
@@ -2,6 +2,11 @@
* $FreeBSD: head/lib/libz/Symbol.map 206709 2010-04-16 20:07:24Z delphij $
*/
+ZLIB_1.2.7.1 {
+ inflateGetDictionary;
+ gzvprintf;
+};
+
ZLIB_1.2.7.0 {
deflatePending;
deflateResetKeep;
diff --git a/lib/libz/Versions.def b/lib/libz/Versions.def
index a5aeb28e19d0..f8e642574d9e 100644
--- a/lib/libz/Versions.def
+++ b/lib/libz/Versions.def
@@ -6,6 +6,9 @@ ZLIB_1.2.4.0 {
ZLIB_1.2.7.0 {
} ZLIB_1.2.4.0;
+ZLIB_1.2.7.1 {
+} ZLIB_1.2.7.0;
+
FBSD_1.2 {
} ZLIB_1.2.4.0;
diff --git a/lib/libz/compress.c b/lib/libz/compress.c
index ea4dfbe9d7b3..6e9762676a0d 100644
--- a/lib/libz/compress.c
+++ b/lib/libz/compress.c
@@ -29,7 +29,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
z_stream stream;
int err;
- stream.next_in = (Bytef*)source;
+ stream.next_in = (z_const Bytef *)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
diff --git a/lib/libz/contrib/README.contrib b/lib/libz/contrib/README.contrib
index dd2285d960a8..c66349b7c676 100644
--- a/lib/libz/contrib/README.contrib
+++ b/lib/libz/contrib/README.contrib
@@ -75,3 +75,4 @@ untgz/ by Pedro A. Aranda Gutierrez <paag@tid.es>
vstudio/ by Gilles Vollant <info@winimage.com>
Building a minizip-enhanced zlib with Microsoft Visual Studio
+ Includes vc11 from kreuzerkrieg and vc12 from davispuh
diff --git a/lib/libz/deflate.c b/lib/libz/deflate.c
index 9e4c2cbc8af8..696957705b75 100644
--- a/lib/libz/deflate.c
+++ b/lib/libz/deflate.c
@@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
+ * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler ";
+ " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -305,7 +305,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
s->pending_buf == Z_NULL) {
s->status = FINISH_STATE;
- strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
+ strm->msg = ERR_MSG(Z_MEM_ERROR);
deflateEnd (strm);
return Z_MEM_ERROR;
}
@@ -329,7 +329,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
uInt str, n;
int wrap;
unsigned avail;
- unsigned char *next;
+ z_const unsigned char *next;
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
return Z_STREAM_ERROR;
@@ -359,7 +359,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
avail = strm->avail_in;
next = strm->next_in;
strm->avail_in = dictLength;
- strm->next_in = (Bytef *)dictionary;
+ strm->next_in = (z_const Bytef *)dictionary;
fill_window(s);
while (s->lookahead >= MIN_MATCH) {
str = s->strstart;
@@ -513,6 +513,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
strm->total_in != 0) {
/* Flush the last buffer: */
err = deflate(strm, Z_BLOCK);
+ if (err == Z_BUF_ERROR && s->pending == 0)
+ err = Z_OK;
}
if (s->level != level) {
s->level = level;
diff --git a/lib/libz/deflate.h b/lib/libz/deflate.h
index fbac44d908ec..ce0299edd191 100644
--- a/lib/libz/deflate.h
+++ b/lib/libz/deflate.h
@@ -104,7 +104,7 @@ typedef struct internal_state {
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp gzhead; /* gzip header information to write */
uInt gzindex; /* where in extra, name, or comment */
- Byte method; /* STORED (for zip only) or DEFLATED */
+ Byte method; /* can only be DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
/* used by deflate.c: */
diff --git a/lib/libz/gzguts.h b/lib/libz/gzguts.h
index ee3f281aa571..d87659d0319f 100644
--- a/lib/libz/gzguts.h
+++ b/lib/libz/gzguts.h
@@ -1,5 +1,5 @@
/* gzguts.h -- zlib internal header definitions for gz* operations
- * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -35,6 +35,13 @@
# include <io.h>
#endif
+#ifdef WINAPI_FAMILY
+# define open _open
+# define read _read
+# define write _write
+# define close _close
+#endif
+
#ifdef NO_DEFLATE /* for compatibility with old definition */
# define NO_GZCOMPRESS
#endif
@@ -60,7 +67,7 @@
#ifndef HAVE_VSNPRINTF
# ifdef MSDOS
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
- but for now we just assume it doesn't. */
+ but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef __TURBOC__
@@ -88,6 +95,14 @@
# endif
#endif
+/* unlike snprintf (which is required in C99, yet still not supported by
+ Microsoft more than a decade later!), _snprintf does not guarantee null
+ termination of the result -- however this is only used in gzlib.c where
+ the result is assured to fit in the space provided */
+#ifdef _MSC_VER
+# define snprintf _snprintf
+#endif
+
#ifndef local
# define local static
#endif
@@ -127,7 +142,8 @@
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
#endif
-/* default i/o buffer size -- double this for output when reading */
+/* default i/o buffer size -- double this for output when reading (this and
+ twice this must be able to fit in an unsigned type) */
#define GZBUFSIZE 8192
/* gzip modes, also provide a little integrity check on the passed structure */
diff --git a/lib/libz/gzlib.c b/lib/libz/gzlib.c
index 33a8a5c72c6e..d8dbb7eefe3d 100644
--- a/lib/libz/gzlib.c
+++ b/lib/libz/gzlib.c
@@ -1,5 +1,5 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004, 2010, 2011, 2012 Mark Adler
+ * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -111,7 +111,7 @@ local gzFile gz_open(path, fd, mode)
return NULL;
/* allocate gzFile structure to return */
- state = malloc(sizeof(gz_state));
+ state = (gz_statep)malloc(sizeof(gz_state));
if (state == NULL)
return NULL;
state->size = 0; /* no buffers allocated yet */
@@ -165,8 +165,10 @@ local gzFile gz_open(path, fd, mode)
break;
case 'F':
state->strategy = Z_FIXED;
+ break;
case 'T':
state->direct = 1;
+ break;
default: /* could consider as an error, but just ignore */
;
}
@@ -197,8 +199,8 @@ local gzFile gz_open(path, fd, mode)
}
else
#endif
- len = strlen(path);
- state->path = malloc(len + 1);
+ len = strlen((const char *)path);
+ state->path = (char *)malloc(len + 1);
if (state->path == NULL) {
free(state);
return NULL;
@@ -211,7 +213,11 @@ local gzFile gz_open(path, fd, mode)
*(state->path) = 0;
else
#endif
+#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
+ snprintf(state->path, len + 1, "%s", (const char *)path);
+#else
strcpy(state->path, path);
+#endif
/* compute the flags for open() */
oflag =
@@ -239,7 +245,7 @@ local gzFile gz_open(path, fd, mode)
#ifdef _WIN32
fd == -2 ? _wopen(path, oflag, 0666) :
#endif
- open(path, oflag, 0666));
+ open((const char *)path, oflag, 0666));
if (state->fd == -1) {
free(state->path);
free(state);
@@ -285,9 +291,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
char *path; /* identifier for error messages */
gzFile gz;
- if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
+ if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
return NULL;
+#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
+ snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
+#else
sprintf(path, "<fd:%d>", fd); /* for debugging */
+#endif
gz = gz_open(path, fd, mode);
free(path);
return gz;
@@ -534,7 +544,8 @@ const char * ZEXPORT gzerror(file, errnum)
/* return error information */
if (errnum != NULL)
*errnum = state->err;
- return state->msg == NULL ? "" : state->msg;
+ return state->err == Z_MEM_ERROR ? "out of memory" :
+ (state->msg == NULL ? "" : state->msg);
}
/* -- see zlib.h -- */
@@ -585,21 +596,24 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
if (msg == NULL)
return;
- /* for an out of memory error, save as static string */
- if (err == Z_MEM_ERROR) {
- state->msg = (char *)msg;
+ /* for an out of memory error, return literal string when requested */
+ if (err == Z_MEM_ERROR)
return;
- }
/* construct error message with path */
- if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
+ if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) ==
+ NULL) {
state->err = Z_MEM_ERROR;
- state->msg = (char *)"out of memory";
return;
}
+#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
+ snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
+ "%s%s%s", state->path, ": ", msg);
+#else
strcpy(state->msg, state->path);
strcat(state->msg, ": ");
strcat(state->msg, msg);
+#endif
return;
}
diff --git a/lib/libz/gzread.c b/lib/libz/gzread.c
index bd2120524e67..a8292ea26361 100644
--- a/lib/libz/gzread.c
+++ b/lib/libz/gzread.c
@@ -1,5 +1,5 @@
/* gzread.c -- zlib functions for reading gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -61,7 +61,8 @@ local int gz_avail(state)
return -1;
if (state->eof == 0) {
if (strm->avail_in) { /* copy what's there to the start */
- unsigned char *p = state->in, *q = strm->next_in;
+ unsigned char *p = state->in;
+ unsigned const char *q = strm->next_in;
unsigned n = strm->avail_in;
do {
*p++ = *q++;
@@ -93,8 +94,8 @@ local int gz_look(state)
/* allocate read buffers and inflate memory */
if (state->size == 0) {
/* allocate buffers */
- state->in = malloc(state->want);
- state->out = malloc(state->want << 1);
+ state->in = (unsigned char *)malloc(state->want);
+ state->out = (unsigned char *)malloc(state->want << 1);
if (state->in == NULL || state->out == NULL) {
if (state->out != NULL)
free(state->out);
@@ -355,14 +356,14 @@ int ZEXPORT gzread(file, buf, len)
/* large len -- read directly into user buffer */
else if (state->how == COPY) { /* read directly */
- if (gz_load(state, buf, len, &n) == -1)
+ if (gz_load(state, (unsigned char *)buf, len, &n) == -1)
return -1;
}
/* large len -- decompress directly into user buffer */
else { /* state->how == GZIP */
strm->avail_out = len;
- strm->next_out = buf;
+ strm->next_out = (unsigned char *)buf;
if (gz_decomp(state) == -1)
return -1;
n = state->x.have;
@@ -381,7 +382,11 @@ int ZEXPORT gzread(file, buf, len)
}
/* -- see zlib.h -- */
-#undef gzgetc
+#ifdef Z_PREFIX_SET
+# undef z_gzgetc
+#else
+# undef gzgetc
+#endif
int ZEXPORT gzgetc(file)
gzFile file;
{
@@ -521,7 +526,7 @@ char * ZEXPORT gzgets(file, buf, len)
/* look for end-of-line in current output buffer */
n = state->x.have > left ? left : state->x.have;
- eol = memchr(state->x.next, '\n', n);
+ eol = (unsigned char *)memchr(state->x.next, '\n', n);
if (eol != NULL)
n = (unsigned)(eol - state->x.next) + 1;
diff --git a/lib/libz/gzwrite.c b/lib/libz/gzwrite.c
index 20344a2d3e02..99cb3c213c49 100644
--- a/lib/libz/gzwrite.c
+++ b/lib/libz/gzwrite.c
@@ -1,5 +1,5 @@
/* gzwrite.c -- zlib functions for writing gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -22,7 +22,7 @@ local int gz_init(state)
z_streamp strm = &(state->strm);
/* allocate input buffer */
- state->in = malloc(state->want);
+ state->in = (unsigned char *)malloc(state->want);
if (state->in == NULL) {
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
@@ -31,7 +31,7 @@ local int gz_init(state)
/* only need output buffer and deflate state if compressing */
if (!state->direct) {
/* allocate output buffer */
- state->out = malloc(state->want);
+ state->out = (unsigned char *)malloc(state->want);
if (state->out == NULL) {
free(state->in);
gz_error(state, Z_MEM_ERROR, "out of memory");
@@ -171,7 +171,6 @@ int ZEXPORT gzwrite(file, buf, len)
unsigned len;
{
unsigned put = len;
- unsigned n;
gz_statep state;
z_streamp strm;
@@ -211,16 +210,19 @@ int ZEXPORT gzwrite(file, buf, len)
if (len < state->size) {
/* copy to input buffer, compress when full */
do {
+ unsigned have, copy;
+
if (strm->avail_in == 0)
strm->next_in = state->in;
- n = state->size - strm->avail_in;
- if (n > len)
- n = len;
- memcpy(strm->next_in + strm->avail_in, buf, n);
- strm->avail_in += n;
- state->x.pos += n;
- buf = (char *)buf + n;
- len -= n;
+ have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
+ copy = state->size - have;
+ if (copy > len)
+ copy = len;
+ memcpy(state->in + have, buf, copy);
+ strm->avail_in += copy;
+ state->x.pos += copy;
+ buf = (const char *)buf + copy;
+ len -= copy;
if (len && gz_comp(state, Z_NO_FLUSH) == -1)
return 0;
} while (len);
@@ -232,7 +234,7 @@ int ZEXPORT gzwrite(file, buf, len)
/* directly compress user buffer to file */
strm->avail_in = len;
- strm->next_in = (voidp)buf;
+ strm->next_in = (z_const Bytef *)buf;
state->x.pos += len;
if (gz_comp(state, Z_NO_FLUSH) == -1)
return 0;
@@ -247,6 +249,7 @@ int ZEXPORT gzputc(file, c)
gzFile file;
int c;
{
+ unsigned have;
unsigned char buf[1];
gz_statep state;
z_streamp strm;
@@ -270,12 +273,16 @@ int ZEXPORT gzputc(file, c)
/* try writing to input buffer for speed (state->size == 0 if buffer not
initialized) */
- if (strm->avail_in < state->size) {
+ if (state->size) {
if (strm->avail_in == 0)
strm->next_in = state->in;
- strm->next_in[strm->avail_in++] = c;
- state->x.pos++;
- return c & 0xff;
+ have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
+ if (have < state->size) {
+ state->in[have] = c;
+ strm->avail_in++;
+ state->x.pos++;
+ return c & 0xff;
+ }
}
/* no room in buffer or not initialized, use gz_write() */
@@ -303,12 +310,11 @@ int ZEXPORT gzputs(file, str)
#include <stdarg.h>
/* -- see zlib.h -- */
-int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
+int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
{
int size, len;
gz_statep state;
z_streamp strm;
- va_list va;
/* get internal structure */
if (file == NULL)
@@ -338,25 +344,20 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
/* do the printf() into the input buffer, put length in len */
size = (int)(state->size);
state->in[size - 1] = 0;
- va_start(va, format);
#ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void
(void)vsprintf((char *)(state->in), format, va);
- va_end(va);
for (len = 0; len < size; len++)
if (state->in[len] == 0) break;
# else
len = vsprintf((char *)(state->in), format, va);
- va_end(va);
# endif
#else
# ifdef HAS_vsnprintf_void
(void)vsnprintf((char *)(state->in), size, format, va);
- va_end(va);
len = strlen((char *)(state->in));
# else
len = vsnprintf((char *)(state->in), size, format, va);
- va_end(va);
# endif
#endif
@@ -371,6 +372,17 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
return len;
}
+int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
+{
+ va_list va;
+ int ret;
+
+ va_start(va, format);
+ ret = gzvprintf(file, format, va);
+ va_end(va);
+ return ret;
+}
+
#else /* !STDC && !Z_HAVE_STDARG_H */
/* -- see zlib.h -- */
@@ -550,9 +562,9 @@ int ZEXPORT gzclose_w(file)
}
/* flush, free memory, and close file */
+ if (gz_comp(state, Z_FINISH) == -1)
+ ret = state->err;
if (state->size) {
- if (gz_comp(state, Z_FINISH) == -1)
- ret = state->err;
if (!state->direct) {
(void)deflateEnd(&(state->strm));
free(state->out);
diff --git a/lib/libz/infback.c b/lib/libz/infback.c
index 981aff17c2d4..f3833c2e434a 100644
--- a/lib/libz/infback.c
+++ b/lib/libz/infback.c
@@ -255,7 +255,7 @@ out_func out;
void FAR *out_desc;
{
struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
+ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */
unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */
diff --git a/lib/libz/inffast.c b/lib/libz/inffast.c
index 2f1d60b43b8a..bda59ceb6a12 100644
--- a/lib/libz/inffast.c
+++ b/lib/libz/inffast.c
@@ -1,5 +1,5 @@
/* inffast.c -- fast decoding
- * Copyright (C) 1995-2008, 2010 Mark Adler
+ * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -69,8 +69,8 @@ z_streamp strm;
unsigned start; /* inflate()'s starting value for strm->avail_out */
{
struct inflate_state FAR *state;
- unsigned char FAR *in; /* local strm->next_in */
- unsigned char FAR *last; /* while in < last, enough input available */
+ z_const unsigned char FAR *in; /* local strm->next_in */
+ z_const unsigned char FAR *last; /* have enough input while in < last */
unsigned char FAR *out; /* local strm->next_out */
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
unsigned char FAR *end; /* while out < end, enough space available */
diff --git a/lib/libz/inflate.c b/lib/libz/inflate.c
index 47418a1e1e1e..870f89bb4d36 100644
--- a/lib/libz/inflate.c
+++ b/lib/libz/inflate.c
@@ -93,11 +93,12 @@
/* function prototypes */
local void fixedtables OF((struct inflate_state FAR *state));
-local int updatewindow OF((z_streamp strm, unsigned out));
+local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
+ unsigned copy));
#ifdef BUILDFIXED
void makefixed OF((void));
#endif
-local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
+local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
unsigned len));
int ZEXPORT inflateResetKeep(strm)
@@ -375,12 +376,13 @@ void makefixed()
output will fall in the output data, making match copies simpler and faster.
The advantage may be dependent on the size of the processor's data caches.
*/
-local int updatewindow(strm, out)
+local int updatewindow(strm, end, copy)
z_streamp strm;
-unsigned out;
+const Bytef *end;
+unsigned copy;
{
struct inflate_state FAR *state;
- unsigned copy, dist;
+ unsigned dist;
state = (struct inflate_state FAR *)strm->state;
@@ -400,19 +402,18 @@ unsigned out;
}
/* copy state->wsize or less output bytes into the circular window */
- copy = out - strm->avail_out;
if (copy >= state->wsize) {
- zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
+ zmemcpy(state->window, end - state->wsize, state->wsize);
state->wnext = 0;
state->whave = state->wsize;
}
else {
dist = state->wsize - state->wnext;
if (dist > copy) dist = copy;
- zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
+ zmemcpy(state->window + state->wnext, end - copy, dist);
copy -= dist;
if (copy) {
- zmemcpy(state->window, strm->next_out - copy, copy);
+ zmemcpy(state->window, end - copy, copy);
state->wnext = copy;
state->whave = state->wsize;
}
@@ -606,7 +607,7 @@ z_streamp strm;
int flush;
{
struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
+ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */
unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */
@@ -920,7 +921,7 @@ int flush;
while (state->have < 19)
state->lens[order[state->have++]] = 0;
state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
+ state->lencode = (const code FAR *)(state->next);
state->lenbits = 7;
ret = inflate_table(CODES, state->lens, 19, &(state->next),
&(state->lenbits), state->work);
@@ -994,7 +995,7 @@ int flush;
values here (9 and 6) without reading the comments in inftrees.h
concerning the ENOUGH constants, which depend on those values */
state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
+ state->lencode = (const code FAR *)(state->next);
state->lenbits = 9;
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
&(state->lenbits), state->work);
@@ -1003,7 +1004,7 @@ int flush;
state->mode = BAD;
break;
}
- state->distcode = (code const FAR *)(state->next);
+ state->distcode = (const code FAR *)(state->next);
state->distbits = 6;
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
&(state->next), &(state->distbits), state->work);
@@ -1230,7 +1231,7 @@ int flush;
RESTORE();
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
(state->mode < CHECK || flush != Z_FINISH)))
- if (updatewindow(strm, out)) {
+ if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
state->mode = MEM;
return Z_MEM_ERROR;
}
@@ -1264,6 +1265,29 @@ z_streamp strm;
return Z_OK;
}
+int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
+z_streamp strm;
+Bytef *dictionary;
+uInt *dictLength;
+{
+ struct inflate_state FAR *state;
+
+ /* check state */
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+
+ /* copy dictionary */
+ if (state->whave && dictionary != Z_NULL) {
+ zmemcpy(dictionary, state->window + state->wnext,
+ state->whave - state->wnext);
+ zmemcpy(dictionary + state->whave - state->wnext,
+ state->window, state->wnext);
+ }
+ if (dictLength != Z_NULL)
+ *dictLength = state->whave;
+ return Z_OK;
+}
+
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
z_streamp strm;
const Bytef *dictionary;
@@ -1271,8 +1295,6 @@ uInt dictLength;
{
struct inflate_state FAR *state;
unsigned long dictid;
- unsigned char *next;
- unsigned avail;
int ret;
/* check state */
@@ -1291,13 +1313,7 @@ uInt dictLength;
/* copy dictionary to window using updatewindow(), which will amend the
existing dictionary if appropriate */
- next = strm->next_out;
- avail = strm->avail_out;
- strm->next_out = (Bytef *)dictionary + dictLength;
- strm->avail_out = 0;
- ret = updatewindow(strm, dictLength);
- strm->avail_out = avail;
- strm->next_out = next;
+ ret = updatewindow(strm, dictionary + dictLength, dictLength);
if (ret) {
state->mode = MEM;
return Z_MEM_ERROR;
@@ -1337,7 +1353,7 @@ gz_headerp head;
*/
local unsigned syncsearch(have, buf, len)
unsigned FAR *have;
-unsigned char FAR *buf;
+const unsigned char FAR *buf;
unsigned len;
{
unsigned got;
diff --git a/lib/libz/inftrees.c b/lib/libz/inftrees.c
index abcd7c45ed35..44d89cf24e1c 100644
--- a/lib/libz/inftrees.c
+++ b/lib/libz/inftrees.c
@@ -1,5 +1,5 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2012 Mark Adler
+ * Copyright (C) 1995-2013 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.2.7 Copyright 1995-2012 Mark Adler ";
+ " inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 78, 68};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -208,8 +208,8 @@ unsigned short FAR *work;
mask = used - 1; /* mask for comparing low */
/* check available table space */
- if ((type == LENS && used >= ENOUGH_LENS) ||
- (type == DISTS && used >= ENOUGH_DISTS))
+ if ((type == LENS && used > ENOUGH_LENS) ||
+ (type == DISTS && used > ENOUGH_DISTS))
return 1;
/* process all codes and make table entries */
@@ -277,8 +277,8 @@ unsigned short FAR *work;
/* check for enough space */
used += 1U << curr;
- if ((type == LENS && used >= ENOUGH_LENS) ||
- (type == DISTS && used >= ENOUGH_DISTS))
+ if ((type == LENS && used > ENOUGH_LENS) ||
+ (type == DISTS && used > ENOUGH_DISTS))
return 1;
/* point entry in root table to sub-table */
diff --git a/lib/libz/test/example.c b/lib/libz/test/example.c
index f515a4853d6f..138a699bd53e 100644
--- a/lib/libz/test/example.c
+++ b/lib/libz/test/example.c
@@ -26,7 +26,7 @@
} \
}
-const char hello[] = "hello, hello!";
+z_const char hello[] = "hello, hello!";
/* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry...
*/
@@ -212,7 +212,7 @@ void test_deflate(compr, comprLen)
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
- c_stream.next_in = (Bytef*)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.next_out = compr;
while (c_stream.total_in != len && c_stream.total_out < comprLen) {
@@ -387,7 +387,7 @@ void test_flush(compr, comprLen)
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
- c_stream.next_in = (Bytef*)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.next_out = compr;
c_stream.avail_in = 3;
c_stream.avail_out = (uInt)*comprLen;
@@ -476,7 +476,7 @@ void test_dict_deflate(compr, comprLen)
c_stream.next_out = compr;
c_stream.avail_out = (uInt)comprLen;
- c_stream.next_in = (Bytef*)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.avail_in = (uInt)strlen(hello)+1;
err = deflate(&c_stream, Z_FINISH);
diff --git a/lib/libz/test/minigzip.c b/lib/libz/test/minigzip.c
index aa7ac7a0494b..b3025a489a91 100644
--- a/lib/libz/test/minigzip.c
+++ b/lib/libz/test/minigzip.c
@@ -40,6 +40,10 @@
# define SET_BINARY_MODE(file)
#endif
+#ifdef _MSC_VER
+# define snprintf _snprintf
+#endif
+
#ifdef VMS
# define unlink delete
# define GZ_SUFFIX "-gz"
@@ -463,8 +467,12 @@ void file_compress(file, mode)
exit(1);
}
+#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
+ snprintf(outfile, sizeof(outfile), "%s%s", file, GZ_SUFFIX);
+#else
strcpy(outfile, file);
strcat(outfile, GZ_SUFFIX);
+#endif
in = fopen(file, "rb");
if (in == NULL) {
@@ -499,7 +507,11 @@ void file_uncompress(file)
exit(1);
}
+#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
+ snprintf(buf, sizeof(buf), "%s", file);
+#else
strcpy(buf, file);
+#endif
if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {
infile = file;
@@ -508,7 +520,11 @@ void file_uncompress(file)
} else {
outfile = file;
infile = buf;
+#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
+ snprintf(buf + len, sizeof(buf) - len, "%s", GZ_SUFFIX);
+#else
strcat(infile, GZ_SUFFIX);
+#endif
}
in = gzopen(infile, "rb");
if (in == NULL) {
@@ -546,7 +562,11 @@ int main(argc, argv)
gzFile file;
char *bname, outmode[20];
+#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
+ snprintf(outmode, sizeof(outmode), "%s", "wb6 ");
+#else
strcpy(outmode, "wb6 ");
+#endif
prog = argv[0];
bname = strrchr(argv[0], '/');
diff --git a/lib/libz/trees.c b/lib/libz/trees.c
index 8c32b214b1d4..1fd7759ef004 100644
--- a/lib/libz/trees.c
+++ b/lib/libz/trees.c
@@ -146,8 +146,8 @@ local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
local int build_bl_tree OF((deflate_state *s));
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
int blcodes));
-local void compress_block OF((deflate_state *s, ct_data *ltree,
- ct_data *dtree));
+local void compress_block OF((deflate_state *s, const ct_data *ltree,
+ const ct_data *dtree));
local int detect_data_type OF((deflate_state *s));
local unsigned bi_reverse OF((unsigned value, int length));
local void bi_windup OF((deflate_state *s));
@@ -972,7 +972,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
#endif
send_bits(s, (STATIC_TREES<<1)+last, 3);
- compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
+ compress_block(s, (const ct_data *)static_ltree,
+ (const ct_data *)static_dtree);
#ifdef DEBUG
s->compressed_len += 3 + s->static_len;
#endif
@@ -980,7 +981,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
send_bits(s, (DYN_TREES<<1)+last, 3);
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
max_blindex+1);
- compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
+ compress_block(s, (const ct_data *)s->dyn_ltree,
+ (const ct_data *)s->dyn_dtree);
#ifdef DEBUG
s->compressed_len += 3 + s->opt_len;
#endif
@@ -1057,8 +1059,8 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
*/
local void compress_block(s, ltree, dtree)
deflate_state *s;
- ct_data *ltree; /* literal tree */
- ct_data *dtree; /* distance tree */
+ const ct_data *ltree; /* literal tree */
+ const ct_data *dtree; /* distance tree */
{
unsigned dist; /* distance of matched string */
int lc; /* match length or unmatched char (if dist == 0) */
diff --git a/lib/libz/uncompr.c b/lib/libz/uncompr.c
index ad98be3a5d88..242e9493dff5 100644
--- a/lib/libz/uncompr.c
+++ b/lib/libz/uncompr.c
@@ -30,7 +30,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
z_stream stream;
int err;
- stream.next_in = (Bytef*)source;
+ stream.next_in = (z_const Bytef *)source;
stream.avail_in = (uInt)sourceLen;
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
diff --git a/lib/libz/zconf.h b/lib/libz/zconf.h
index a6f6b7e502d0..13a2e1c71a6b 100644
--- a/lib/libz/zconf.h
+++ b/lib/libz/zconf.h
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2012 Jean-loup Gailly.
+ * Copyright (C) 1995-2013 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -21,6 +21,7 @@
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
+# define _tr_flush_bits z__tr_flush_bits
# define _tr_flush_block z__tr_flush_block
# define _tr_init z__tr_init
# define _tr_stored_block z__tr_stored_block
@@ -77,6 +78,7 @@
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
+# define gzvprintf z_gzvprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
@@ -103,6 +105,7 @@
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
# define inflateSetDictionary z_inflateSetDictionary
+# define inflateGetDictionary z_inflateGetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
@@ -388,20 +391,14 @@ typedef uLong FAR uLongf;
typedef Byte *voidp;
#endif
-/* ./configure may #define Z_U4 here */
-
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
# include <limits.h>
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
-# else
-# if (ULONG_MAX == 0xffffffffUL)
-# define Z_U4 unsigned long
-# else
-# if (USHRT_MAX == 0xffffffffUL)
-# define Z_U4 unsigned short
-# endif
-# endif
+# elif (ULONG_MAX == 0xffffffffUL)
+# define Z_U4 unsigned long
+# elif (USHRT_MAX == 0xffffffffUL)
+# define Z_U4 unsigned short
# endif
#endif
@@ -425,8 +422,16 @@ typedef uLong FAR uLongf;
# endif
#endif
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+# ifndef Z_SOLO
+# include <stdarg.h> /* for va_list */
+# endif
+#endif
+
#ifdef _WIN32
-# include <stddef.h> /* for wchar_t */
+# ifndef Z_SOLO
+# include <stddef.h> /* for wchar_t */
+# endif
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
@@ -435,7 +440,7 @@ typedef uLong FAR uLongf;
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
* equivalently requesting no 64-bit operations
*/
-#if defined(LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
+#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE
#endif
@@ -443,7 +448,7 @@ typedef uLong FAR uLongf;
# define Z_HAVE_UNISTD_H
#endif
#ifndef Z_SOLO
-# if defined(Z_HAVE_UNISTD_H) || defined(LARGEFILE64_SOURCE)
+# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# ifdef VMS
# include <unixio.h> /* for off_t */
diff --git a/lib/libz/zlib.3 b/lib/libz/zlib.3
index 79d3402b39c4..0160e62b69f4 100644
--- a/lib/libz/zlib.3
+++ b/lib/libz/zlib.3
@@ -1,4 +1,4 @@
-.TH ZLIB 3 "2 May 2012"
+.TH ZLIB 3 "28 Apr 2013"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
@@ -125,8 +125,8 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS
-Version 1.2.7
-Copyright (C) 1995-2012 Jean-loup Gailly (jloup@gzip.org)
+Version 1.2.8
+Copyright (C) 1995-2013 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu).
.LP
This software is provided "as-is,"
diff --git a/lib/libz/zlib.h b/lib/libz/zlib.h
index 3edf3acdb570..3e0c7672ac51 100644
--- a/lib/libz/zlib.h
+++ b/lib/libz/zlib.h
@@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.7, May 2nd, 2012
+ version 1.2.8, April 28th, 2013
- Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
+ Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -37,11 +37,11 @@
extern "C" {
#endif
-#define ZLIB_VERSION "1.2.7"
-#define ZLIB_VERNUM 0x1270
+#define ZLIB_VERSION "1.2.8"
+#define ZLIB_VERNUM 0x1280
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
-#define ZLIB_VER_REVISION 7
+#define ZLIB_VER_REVISION 8
#define ZLIB_VER_SUBREVISION 0
/*
@@ -839,6 +839,21 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
inflate().
*/
+ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
+ Bytef *dictionary,
+ uInt *dictLength));
+/*
+ Returns the sliding dictionary being maintained by inflate. dictLength is
+ set to the number of bytes in the dictionary, and that many bytes are copied
+ to dictionary. dictionary must have enough space, where 32768 bytes is
+ always enough. If inflateGetDictionary() is called with dictionary equal to
+ Z_NULL, then only the dictionary length is returned, and nothing is copied.
+ Similary, if dictLength is Z_NULL, then it is not set.
+
+ inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
+ stream state is inconsistent.
+*/
+
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
/*
Skips invalid compressed data until a possible full flush point (see above
@@ -846,7 +861,7 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
available input is skipped. No output is provided.
inflateSync searches for a 00 00 FF FF pattern in the compressed data.
- All full flush points have this pattern, but not all occurences of this
+ All full flush points have this pattern, but not all occurrences of this
pattern are full flush points.
inflateSync returns Z_OK if a possible full flush point has been found,
@@ -1007,7 +1022,8 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
the version of the header file.
*/
-typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
+typedef unsigned (*in_func) OF((void FAR *,
+ z_const unsigned char FAR * FAR *));
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
@@ -1015,11 +1031,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
out_func out, void FAR *out_desc));
/*
inflateBack() does a raw inflate with a single call using a call-back
- interface for input and output. This is more efficient than inflate() for
- file i/o applications in that it avoids copying between the output and the
- sliding window by simply making the window itself the output buffer. This
- function trusts the application to not change the output buffer passed by
- the output function, at least until inflateBack() returns.
+ interface for input and output. This is potentially more efficient than
+ inflate() for file i/o applications, in that it avoids copying between the
+ output and the sliding window by simply making the window itself the output
+ buffer. inflate() can be faster on modern CPUs when used with large
+ buffers. inflateBack() trusts the application to not change the output
+ buffer passed by the output function, at least until inflateBack() returns.
inflateBackInit() must be called first to allocate the internal state
and to initialize the state with the user-provided window buffer.
@@ -1736,6 +1753,13 @@ ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode));
#endif
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+# ifndef Z_SOLO
+ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
+ const char *format,
+ va_list va));
+# endif
+#endif
#ifdef __cplusplus
}
diff --git a/lib/libz/zutil.c b/lib/libz/zutil.c
index 65e0d3b72b05..23d2ebef008f 100644
--- a/lib/libz/zutil.c
+++ b/lib/libz/zutil.c
@@ -14,7 +14,7 @@
struct internal_state {int dummy;}; /* for buggy compilers */
#endif
-const char * const z_errmsg[10] = {
+z_const char * const z_errmsg[10] = {
"need dictionary", /* Z_NEED_DICT 2 */
"stream end", /* Z_STREAM_END 1 */
"", /* Z_OK 0 */
diff --git a/lib/libz/zutil.h b/lib/libz/zutil.h
index 4e3dcc6ae9f7..24ab06b1cf60 100644
--- a/lib/libz/zutil.h
+++ b/lib/libz/zutil.h
@@ -1,5 +1,5 @@
/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2012 Jean-loup Gailly.
+ * Copyright (C) 1995-2013 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -44,13 +44,13 @@ typedef unsigned short ush;
typedef ush FAR ushf;
typedef unsigned long ulg;
-extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
+extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
- return (strm->msg = (char*)ERR_MSG(err), (err))
+ return (strm->msg = ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
@@ -168,7 +168,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
/* provide prototypes for these when building zlib without LFS */
-#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
+#if !defined(_WIN32) && \
+ (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
#endif
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index a50dded0e693..8b643211bee4 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -21,6 +21,10 @@ ARCH_SUBDIR= ${MACHINE_CPUARCH}
.include "${ARCH_SUBDIR}/Makefile.inc"
.PATH: ${.CURDIR}/${ARCH_SUBDIR}
+.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+.PATH: ${.CURDIR}/x86
+CFLAGS+= -I${.CURDIR}/x86
+.endif
# long double format
.if ${LDBL_PREC} == 64
@@ -92,18 +96,19 @@ SYMBOL_MAPS= ${SYM_MAPS}
COMMON_SRCS+= s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c
.if ${LDBL_PREC} != 53
# If long double != double use these; otherwise, we alias the double versions.
-COMMON_SRCS+= e_acosl.c e_asinl.c e_atan2l.c e_fmodl.c \
- e_hypotl.c e_remainderl.c e_sqrtl.c \
+COMMON_SRCS+= e_acoshl.c e_acosl.c e_asinl.c e_atan2l.c e_atanhl.c \
+ e_fmodl.c e_hypotl.c e_remainderl.c e_sqrtl.c \
invtrig.c k_cosl.c k_sinl.c k_tanl.c \
- s_atanl.c s_cbrtl.c s_ceill.c s_cosl.c s_cprojl.c \
+ s_asinhl.c s_atanl.c s_cbrtl.c s_ceill.c s_cosl.c s_cprojl.c \
s_csqrtl.c s_exp2l.c s_expl.c s_floorl.c s_fmal.c \
- s_frexpl.c s_logbl.c s_nanl.c s_nextafterl.c s_nexttoward.c \
- s_remquol.c s_rintl.c s_scalbnl.c \
+ s_frexpl.c s_logbl.c s_logl.c s_nanl.c s_nextafterl.c \
+ s_nexttoward.c s_remquol.c s_rintl.c s_scalbnl.c \
s_sinl.c s_tanl.c s_truncl.c w_cabsl.c
.endif
# C99 complex functions
-COMMON_SRCS+= s_ccosh.c s_ccoshf.c s_cexp.c s_cexpf.c \
+COMMON_SRCS+= catrig.c catrigf.c \
+ s_ccosh.c s_ccoshf.c s_cexp.c s_cexpf.c \
s_cimag.c s_cimagf.c s_cimagl.c \
s_conj.c s_conjf.c s_conjl.c \
s_cproj.c s_cprojf.c s_creal.c s_crealf.c s_creall.c \
@@ -119,18 +124,12 @@ COMMON_SRCS:= ${COMMON_SRCS:N${i:R}.c}
.endfor
.endif
-# Some files need certain gcc built-in functions to be disabled, since gcc's
-# model of the functions bogusly assumes -fno-trapping-math.
-XRINT_CFLAGS= -fno-builtin-rint -fno-builtin-rintf -fno-builtin-rintl
-CFLAGS+= ${XRINT_CFLAGS}
-XRINT_CFLAGS:= ${.IMPSRC:M*/s_nearbyint.c:C/^.+$/${XRINT_CFLAGS}/:C/^$//}
-
SRCS= ${COMMON_SRCS} ${ARCH_SRCS}
INCS+= fenv.h math.h
MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \
- ceil.3 ccos.3 ccosh.3 cexp.3 \
+ ceil.3 cacos.3 ccos.3 ccosh.3 cexp.3 \
cimag.3 copysign.3 cos.3 cosh.3 csqrt.3 erf.3 exp.3 fabs.3 fdim.3 \
feclearexcept.3 feenableexcept.3 fegetenv.3 \
fegetround.3 fenv.3 floor.3 \
@@ -141,13 +140,16 @@ MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \
complex.3
MLINKS+=acos.3 acosf.3 acos.3 acosl.3
-MLINKS+=acosh.3 acoshf.3
+MLINKS+=acosh.3 acoshf.3 acosh.3 acoshl.3
MLINKS+=asin.3 asinf.3 asin.3 asinl.3
-MLINKS+=asinh.3 asinhf.3
+MLINKS+=asinh.3 asinhf.3 asinh.3 asinhl.3
MLINKS+=atan.3 atanf.3 atan.3 atanl.3
-MLINKS+=atanh.3 atanhf.3
+MLINKS+=atanh.3 atanhf.3 atanh.3 atanhl.3
MLINKS+=atan2.3 atan2f.3 atan2.3 atan2l.3 \
atan2.3 carg.3 atan2.3 cargf.3 atan2.3 cargl.3
+MLINKS+=cacos.3 cacosf.3 cacos.3 cacosh.3 cacos.3 cacoshf.3 \
+ cacos.3 casin.3 cacos.3 casinf.3 cacos.3 casinh.3 cacos.3 casinhf.3 \
+ cacos.3 catan.3 cacos.3 catanf.3 cacos.3 catanh.3 cacos.3 catanhf.3
MLINKS+=ccos.3 ccosf.3 ccos.3 csin.3 ccos.3 csinf.3 ccos.3 ctan.3 ccos.3 ctanf.3
MLINKS+=ccosh.3 ccoshf.3 ccosh.3 csinh.3 ccosh.3 csinhf.3 \
ccosh.3 ctanh.3 ccosh.3 ctanhf.3
@@ -162,8 +164,8 @@ MLINKS+=cos.3 cosf.3 cos.3 cosl.3
MLINKS+=cosh.3 coshf.3
MLINKS+=csqrt.3 csqrtf.3 csqrt.3 csqrtl.3
MLINKS+=erf.3 erfc.3 erf.3 erff.3 erf.3 erfcf.3
-MLINKS+=exp.3 expm1.3 exp.3 expm1f.3 exp.3 pow.3 exp.3 powf.3 \
- exp.3 exp2.3 exp.3 exp2f.3 exp.3 exp2l.3 exp.3 expf.3
+MLINKS+=exp.3 expm1.3 exp.3 expm1f.3 exp.3 expm1l.3 exp.3 pow.3 exp.3 powf.3 \
+ exp.3 exp2.3 exp.3 exp2f.3 exp.3 exp2l.3 exp.3 expf.3 exp.3 expl.3
MLINKS+=fabs.3 fabsf.3 fabs.3 fabsl.3
MLINKS+=fdim.3 fdimf.3 fdim.3 fdiml.3
MLINKS+=feclearexcept.3 fegetexceptflag.3 feclearexcept.3 feraiseexcept.3 \
@@ -187,7 +189,10 @@ MLINKS+=j0.3 j1.3 j0.3 jn.3 j0.3 y0.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3
MLINKS+=j0.3 j0f.3 j0.3 j1f.3 j0.3 jnf.3 j0.3 y0f.3 j0.3 ynf.3
MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 lgammaf.3 \
lgamma.3 tgamma.3 lgamma.3 tgammaf.3
-MLINKS+=log.3 log10.3 log.3 log10f.3 log.3 log1p.3 log.3 log1pf.3 log.3 logf.3 log.3 log2.3 log.3 log2f.3
+MLINKS+=log.3 log10.3 log.3 log10f.3 log.3 log10l.3 \
+ log.3 log1p.3 log.3 log1pf.3 log.3 log1pl.3 \
+ log.3 logf.3 log.3 logl.3 \
+ log.3 log2.3 log.3 log2f.3 log.3 log2l.3
MLINKS+=lrint.3 llrint.3 lrint.3 llrintf.3 lrint.3 llrintl.3 \
lrint.3 lrintf.3 lrint.3 lrintl.3
MLINKS+=lround.3 llround.3 lround.3 llroundf.3 lround.3 llroundl.3 \
diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map
index 76f1bfb62891..f244af4793b7 100644
--- a/lib/msun/Symbol.map
+++ b/lib/msun/Symbol.map
@@ -237,6 +237,21 @@ FBSD_1.3 {
fegetround;
fesetround;
fesetenv;
+ acoshl;
+ asinhl;
+ atanhl;
+ cacos;
+ cacosf;
+ cacosh;
+ cacoshf;
+ casin;
+ casinf;
+ casinh;
+ casinhf;
+ catan;
+ catanf;
+ catanh;
+ catanhf;
csin;
csinf;
csinh;
@@ -250,4 +265,9 @@ FBSD_1.3 {
ctanh;
ctanhf;
expl;
+ expm1l;
+ log10l;
+ log1pl;
+ log2l;
+ logl;
};
diff --git a/lib/msun/amd64/fenv.h b/lib/msun/amd64/fenv.h
deleted file mode 100644
index b7c9873dd760..000000000000
--- a/lib/msun/amd64/fenv.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _FENV_H_
-#define _FENV_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-#ifndef __fenv_static
-#define __fenv_static static
-#endif
-
-typedef struct {
- struct {
- __uint32_t __control;
- __uint32_t __status;
- __uint32_t __tag;
- char __other[16];
- } __x87;
- __uint32_t __mxcsr;
-} fenv_t;
-
-typedef __uint16_t fexcept_t;
-
-/* Exception flags */
-#define FE_INVALID 0x01
-#define FE_DENORMAL 0x02
-#define FE_DIVBYZERO 0x04
-#define FE_OVERFLOW 0x08
-#define FE_UNDERFLOW 0x10
-#define FE_INEXACT 0x20
-#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
- FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define FE_TONEAREST 0x0000
-#define FE_DOWNWARD 0x0400
-#define FE_UPWARD 0x0800
-#define FE_TOWARDZERO 0x0c00
-#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
- FE_UPWARD | FE_TOWARDZERO)
-
-/*
- * As compared to the x87 control word, the SSE unit's control word
- * has the rounding control bits offset by 3 and the exception mask
- * bits offset by 7.
- */
-#define _SSE_ROUND_SHIFT 3
-#define _SSE_EMASK_SHIFT 7
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t __fe_dfl_env;
-#define FE_DFL_ENV (&__fe_dfl_env)
-
-#define __fldcw(__cw) __asm __volatile("fldcw %0" : : "m" (__cw))
-#define __fldenv(__env) __asm __volatile("fldenv %0" : : "m" (__env))
-#define __fldenvx(__env) __asm __volatile("fldenv %0" : : "m" (__env) \
- : "st", "st(1)", "st(2)", "st(3)", "st(4)", \
- "st(5)", "st(6)", "st(7)")
-#define __fnclex() __asm __volatile("fnclex")
-#define __fnstenv(__env) __asm __volatile("fnstenv %0" : "=m" (*(__env)))
-#define __fnstcw(__cw) __asm __volatile("fnstcw %0" : "=m" (*(__cw)))
-#define __fnstsw(__sw) __asm __volatile("fnstsw %0" : "=am" (*(__sw)))
-#define __fwait() __asm __volatile("fwait")
-#define __ldmxcsr(__csr) __asm __volatile("ldmxcsr %0" : : "m" (__csr))
-#define __stmxcsr(__csr) __asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
-
-__fenv_static inline int
-feclearexcept(int __excepts)
-{
- fenv_t __env;
-
- if (__excepts == FE_ALL_EXCEPT) {
- __fnclex();
- } else {
- __fnstenv(&__env.__x87);
- __env.__x87.__status &= ~__excepts;
- __fldenv(__env.__x87);
- }
- __stmxcsr(&__env.__mxcsr);
- __env.__mxcsr &= ~__excepts;
- __ldmxcsr(__env.__mxcsr);
- return (0);
-}
-
-__fenv_static inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
- __uint32_t __mxcsr;
- __uint16_t __status;
-
- __stmxcsr(&__mxcsr);
- __fnstsw(&__status);
- *__flagp = (__mxcsr | __status) & __excepts;
- return (0);
-}
-
-int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
-int feraiseexcept(int __excepts);
-
-__fenv_static inline int
-fetestexcept(int __excepts)
-{
- __uint32_t __mxcsr;
- __uint16_t __status;
-
- __stmxcsr(&__mxcsr);
- __fnstsw(&__status);
- return ((__status | __mxcsr) & __excepts);
-}
-
-__fenv_static inline int
-fegetround(void)
-{
- __uint16_t __control;
-
- /*
- * We assume that the x87 and the SSE unit agree on the
- * rounding mode. Reading the control word on the x87 turns
- * out to be about 5 times faster than reading it on the SSE
- * unit on an Opteron 244.
- */
- __fnstcw(&__control);
- return (__control & _ROUND_MASK);
-}
-
-__fenv_static inline int
-fesetround(int __round)
-{
- __uint32_t __mxcsr;
- __uint16_t __control;
-
- if (__round & ~_ROUND_MASK)
- return (-1);
-
- __fnstcw(&__control);
- __control &= ~_ROUND_MASK;
- __control |= __round;
- __fldcw(__control);
-
- __stmxcsr(&__mxcsr);
- __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
- __mxcsr |= __round << _SSE_ROUND_SHIFT;
- __ldmxcsr(__mxcsr);
-
- return (0);
-}
-
-int fegetenv(fenv_t *__envp);
-int feholdexcept(fenv_t *__envp);
-
-__fenv_static inline int
-fesetenv(const fenv_t *__envp)
-{
-
- /*
- * XXX Using fldenvx() instead of fldenv() tells the compiler that this
- * instruction clobbers the i387 register stack. This happens because
- * we restore the tag word from the saved environment. Normally, this
- * would happen anyway and we wouldn't care, because the ABI allows
- * function calls to clobber the i387 regs. However, fesetenv() is
- * inlined, so we need to be more careful.
- */
- __fldenvx(__envp->__x87);
- __ldmxcsr(__envp->__mxcsr);
- return (0);
-}
-
-int feupdateenv(const fenv_t *__envp);
-
-#if __BSD_VISIBLE
-
-int feenableexcept(int __mask);
-int fedisableexcept(int __mask);
-
-/* We currently provide no external definition of fegetexcept(). */
-static inline int
-fegetexcept(void)
-{
- __uint16_t __control;
-
- /*
- * We assume that the masks for the x87 and the SSE unit are
- * the same.
- */
- __fnstcw(&__control);
- return (~__control & FE_ALL_EXCEPT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif /* !_FENV_H_ */
diff --git a/lib/msun/ld128/s_exp2l.c b/lib/msun/ld128/s_exp2l.c
index 31178e40624d..5afa37e58222 100644
--- a/lib/msun/ld128/s_exp2l.c
+++ b/lib/msun/ld128/s_exp2l.c
@@ -39,14 +39,11 @@ __FBSDID("$FreeBSD$");
#define BIAS (LDBL_MAX_EXP - 1)
#define EXPMASK (BIAS + LDBL_MAX_EXP)
-#if 0 /* XXX Prevent gcc from erroneously constant folding this. */
-static const long double twom10000 = 0x1p-10000L;
-#else
-static volatile long double twom10000 = 0x1p-10000L;
-#endif
+static volatile long double
+ huge = 0x1p10000L,
+ twom10000 = 0x1p-10000L;
static const long double
- huge = 0x1p10000L,
P1 = 0x1.62e42fefa39ef35793c7673007e6p-1L,
P2 = 0x1.ebfbdff82c58ea86f16b06ec9736p-3L,
P3 = 0x1.c6b08d704a0bf8b33a762bad3459p-5L,
diff --git a/lib/msun/ld128/s_expl.c b/lib/msun/ld128/s_expl.c
index 5052c3afca67..176c93255cb8 100644
--- a/lib/msun/ld128/s_expl.c
+++ b/lib/msun/ld128/s_expl.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2012 Steven G. Kargl
+ * Copyright (c) 2009-2013 Steven G. Kargl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,6 +22,8 @@
* 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.
+ *
+ * Optimized by Bruce D. Evans.
*/
#include <sys/cdefs.h>
@@ -38,35 +40,61 @@ __FBSDID("$FreeBSD$");
#include "math_private.h"
#define INTERVALS 128
+#define LOG2_INTERVALS 7
#define BIAS (LDBL_MAX_EXP - 1)
+static const long double
+huge = 0x1p10000L,
+twom10000 = 0x1p-10000L;
+/* XXX Prevent gcc from erroneously constant folding this: */
static volatile const long double tiny = 0x1p-10000L;
static const long double
-INV_L = 1.84664965233787316142070359168242182e+02L,
-L1 = 5.41521234812457272982212595914567508e-03L,
-L2 = -1.02536706388947310094527932552595546e-29L,
-huge = 0x1p10000L,
+/* log(2**16384 - 0.5) rounded towards zero: */
+/* log(2**16384 - 0.5 + 1) rounded towards zero for expm1l() is the same: */
o_threshold = 11356.523406294143949491931077970763428L,
-twom10000 = 0x1p-10000L,
+/* log(2**(-16381-64-1)) rounded towards zero: */
u_threshold = -11433.462743336297878837243843452621503L;
+static const double
+/*
+ * ln2/INTERVALS = L1+L2 (hi+lo decomposition for multiplication). L1 must
+ * have at least 22 (= log2(|LDBL_MIN_EXP-extras|) + log2(INTERVALS)) lowest
+ * bits zero so that multiplication of it by n is exact.
+ */
+INV_L = 1.8466496523378731e+2, /* 0x171547652b82fe.0p-45 */
+L2 = -1.0253670638894731e-29; /* -0x1.9ff0342542fc3p-97 */
static const long double
-P2 = 5.00000000000000000000000000000000000e-1L,
-P3 = 1.66666666666666666666666666666666972e-1L,
-P4 = 4.16666666666666666666666666653708268e-2L,
-P5 = 8.33333333333333333333333315069867254e-3L,
-P6 = 1.38888888888888888888996596213795377e-3L,
-P7 = 1.98412698412698412718821436278644414e-4L,
-P8 = 2.48015873015869681884882576649543128e-5L,
-P9 = 2.75573192240103867817876199544468806e-6L,
-P10 = 2.75573236172670046201884000197885520e-7L,
-P11 = 2.50517544183909126492878226167697856e-8L;
+/* 0x1.62e42fefa39ef35793c768000000p-8 */
+L1 = 5.41521234812457272982212595914567508e-3L;
+
+static const long double
+/*
+ * Domain [-0.002708, 0.002708], range ~[-2.4021e-38, 2.4234e-38]:
+ * |exp(x) - p(x)| < 2**-124.9
+ * (0.002708 is ln2/(2*INTERVALS) rounded up a little).
+ */
+A2 = 0.5,
+A3 = 1.66666666666666666666666666651085500e-1L,
+A4 = 4.16666666666666666666666666425885320e-2L,
+A5 = 8.33333333333333333334522877160175842e-3L,
+A6 = 1.38888888888888888889971139751596836e-3L;
+
+static const double
+A7 = 1.9841269841269471e-4,
+A8 = 2.4801587301585284e-5,
+A9 = 2.7557324277411234e-6,
+A10 = 2.7557333722375072e-7;
static const struct {
+ /*
+ * hi must be rounded to at most 106 bits so that multiplication
+ * by r1 in expm1l() is exact, but it is rounded to 88 bits due to
+ * historical accidents.
+ */
long double hi;
long double lo;
-} s[INTERVALS] = {
+} tbl[INTERVALS] = {
0x1p0L, 0x0p0L,
0x1.0163da9fb33356d84a66aep0L, 0x3.36dcdfa4003ec04c360be2404078p-92L,
0x1.02c9a3e778060ee6f7cacap0L, 0x4.f7a29bde93d70a2cabc5cb89ba10p-92L,
@@ -201,9 +229,10 @@ long double
expl(long double x)
{
union IEEEl2bits u, v;
- long double fn, r, r1, r2, q, t, twopk, twopkp10000;
+ long double q, r, r1, t, twopk, twopkp10000;
+ double dr, fn, r2;
int k, n, n2;
- uint32_t hx, ix;
+ uint16_t hx, ix;
/* Filter out exceptional cases. */
u.e = x;
@@ -211,31 +240,39 @@ expl(long double x)
ix = hx & 0x7fff;
if (ix >= BIAS + 13) { /* |x| >= 8192 or x is NaN */
if (ix == BIAS + LDBL_MAX_EXP) {
- if (hx & 0x8000 && u.xbits.manh == 0 &&
- u.xbits.manl == 0)
- return (0.0L); /* x is -Inf */
- return (x + x); /* x is +Inf or NaN */
+ if (hx & 0x8000) /* x is -Inf or -NaN */
+ return (-1 / x);
+ return (x + x); /* x is +Inf or +NaN */
}
if (x > o_threshold)
return (huge * huge);
if (x < u_threshold)
return (tiny * tiny);
- } else if (ix < BIAS - 115) { /* |x| < 0x1p-115 */
- if (huge + x > 1.0L) /* trigger inexact iff x != 0 */
- return (1.0L + x);
+ } else if (ix < BIAS - 114) { /* |x| < 0x1p-114 */
+ return (1 + x); /* 1 with inexact iff x != 0 */
}
- /* Reduce x to (k*ln2 + midpoint[n2] + r1 + r2). */
- fn = x * INV_L + 0x1.8p112 - 0x1.8p112;
- n = (int)fn;
+ ENTERI();
+
+ /* Reduce x to (k*ln2 + endpoint[n2] + r1 + r2). */
+ /* Use a specialized rint() to get fn. Assume round-to-nearest. */
+ /* XXX assume no extra precision for the additions, as for trig fns. */
+ /* XXX this set of comments is now quadruplicated. */
+ fn = (double)x * INV_L + 0x1.8p52 - 0x1.8p52;
+#if defined(HAVE_EFFICIENT_IRINT)
+ n = irint(fn);
+#else
+ n = (int)fn;
+#endif
n2 = (unsigned)n % INTERVALS;
- k = (n - n2) / INTERVALS;
+ k = n >> LOG2_INTERVALS;
r1 = x - fn * L1;
- r2 = -fn * L2;
+ r2 = fn * -L2;
+ r = r1 + r2;
/* Prepare scale factors. */
- v.xbits.manh = 0;
- v.xbits.manl = 0;
+ /* XXX sparc64 multiplication is so slow that scalbnl() is faster. */
+ v.e = 1;
if (k >= LDBL_MIN_EXP) {
v.xbits.expsign = BIAS + k;
twopk = v.e;
@@ -244,18 +281,214 @@ expl(long double x)
twopkp10000 = v.e;
}
- r = r1 + r2;
- q = r * r * (P2 + r * (P3 + r * (P4 + r * (P5 + r * (P6 + r * (P7 +
- r * (P8 + r * (P9 + r * (P10 + r * P11)))))))));
- t = s[n2].lo + s[n2].hi;
- t = s[n2].hi + (s[n2].lo + t * (r2 + q + r1));
+ /* Evaluate expl(endpoint[n2] + r1 + r2) = tbl[n2] * expl(r1 + r2). */
+ dr = r;
+ q = r2 + r * r * (A2 + r * (A3 + r * (A4 + r * (A5 + r * (A6 +
+ dr * (A7 + dr * (A8 + dr * (A9 + dr * A10))))))));
+ t = tbl[n2].lo + tbl[n2].hi;
+ t = tbl[n2].lo + t * (q + r1) + tbl[n2].hi;
/* Scale by 2**k. */
if (k >= LDBL_MIN_EXP) {
if (k == LDBL_MAX_EXP)
- return (t * 2.0L * 0x1p16383L);
- return (t * twopk);
+ RETURNI(t * 2 * 0x1p16383L);
+ RETURNI(t * twopk);
} else {
- return (t * twopkp10000 * twom10000);
+ RETURNI(t * twopkp10000 * twom10000);
}
}
+
+/*
+ * Our T1 and T2 are chosen to be approximately the points where method
+ * A and method B have the same accuracy. Tang's T1 and T2 are the
+ * points where method A's accuracy changes by a full bit. For Tang,
+ * this drop in accuracy makes method A immediately less accurate than
+ * method B, but our larger INTERVALS makes method A 2 bits more
+ * accurate so it remains the most accurate method significantly
+ * closer to the origin despite losing the full bit in our extended
+ * range for it.
+ *
+ * Split the interval [T1, T2] into two intervals [T1, T3] and [T3, T2].
+ * Setting T3 to 0 would require the |x| < 0x1p-113 condition to appear
+ * in both subintervals, so set T3 = 2**-5, which places the condition
+ * into the [T1, T3] interval.
+ */
+static const double
+T1 = -0.1659, /* ~-30.625/128 * log(2) */
+T2 = 0.1659, /* ~30.625/128 * log(2) */
+T3 = 0.03125;
+
+/*
+ * Domain [-0.1659, 0.03125], range ~[2.9134e-44, 1.8404e-37]:
+ * |(exp(x)-1-x-x**2/2)/x - p(x)| < 2**-122.03
+ */
+static const long double
+C3 = 1.66666666666666666666666666666666667e-1L,
+C4 = 4.16666666666666666666666666666666645e-2L,
+C5 = 8.33333333333333333333333333333371638e-3L,
+C6 = 1.38888888888888888888888888891188658e-3L,
+C7 = 1.98412698412698412698412697235950394e-4L,
+C8 = 2.48015873015873015873015112487849040e-5L,
+C9 = 2.75573192239858906525606685484412005e-6L,
+C10 = 2.75573192239858906612966093057020362e-7L,
+C11 = 2.50521083854417203619031960151253944e-8L,
+C12 = 2.08767569878679576457272282566520649e-9L,
+C13 = 1.60590438367252471783548748824255707e-10L;
+
+static const double
+C14 = 1.1470745580491932e-11, /* 0x1.93974a81dae30p-37 */
+C15 = 7.6471620181090468e-13, /* 0x1.ae7f3820adab1p-41 */
+C16 = 4.7793721460260450e-14, /* 0x1.ae7cd18a18eacp-45 */
+C17 = 2.8074757356658877e-15, /* 0x1.949992a1937d9p-49 */
+C18 = 1.4760610323699476e-16; /* 0x1.545b43aabfbcdp-53 */
+
+/*
+ * Domain [0.03125, 0.1659], range ~[-2.7676e-37, -1.0367e-38]:
+ * |(exp(x)-1-x-x**2/2)/x - p(x)| < 2**-121.44
+ */
+static const long double
+D3 = 1.66666666666666666666666666666682245e-1L,
+D4 = 4.16666666666666666666666666634228324e-2L,
+D5 = 8.33333333333333333333333364022244481e-3L,
+D6 = 1.38888888888888888888887138722762072e-3L,
+D7 = 1.98412698412698412699085805424661471e-4L,
+D8 = 2.48015873015873015687993712101479612e-5L,
+D9 = 2.75573192239858944101036288338208042e-6L,
+D10 = 2.75573192239853161148064676533754048e-7L,
+D11 = 2.50521083855084570046480450935267433e-8L,
+D12 = 2.08767569819738524488686318024854942e-9L,
+D13 = 1.60590442297008495301927448122499313e-10L;
+
+static const double
+D14 = 1.1470726176204336e-11, /* 0x1.93971dc395d9ep-37 */
+D15 = 7.6478532249581686e-13, /* 0x1.ae892e3D16fcep-41 */
+D16 = 4.7628892832607741e-14, /* 0x1.ad00Dfe41feccp-45 */
+D17 = 3.0524857220358650e-15; /* 0x1.D7e8d886Df921p-49 */
+
+long double
+expm1l(long double x)
+{
+ union IEEEl2bits u, v;
+ long double hx2_hi, hx2_lo, q, r, r1, t, twomk, twopk, x_hi;
+ long double x_lo, x2;
+ double dr, dx, fn, r2;
+ int k, n, n2;
+ uint16_t hx, ix;
+
+ /* Filter out exceptional cases. */
+ u.e = x;
+ hx = u.xbits.expsign;
+ ix = hx & 0x7fff;
+ if (ix >= BIAS + 7) { /* |x| >= 128 or x is NaN */
+ if (ix == BIAS + LDBL_MAX_EXP) {
+ if (hx & 0x8000) /* x is -Inf or -NaN */
+ return (-1 / x - 1);
+ return (x + x); /* x is +Inf or +NaN */
+ }
+ if (x > o_threshold)
+ return (huge * huge);
+ /*
+ * expm1l() never underflows, but it must avoid
+ * unrepresentable large negative exponents. We used a
+ * much smaller threshold for large |x| above than in
+ * expl() so as to handle not so large negative exponents
+ * in the same way as large ones here.
+ */
+ if (hx & 0x8000) /* x <= -128 */
+ return (tiny - 1); /* good for x < -114ln2 - eps */
+ }
+
+ ENTERI();
+
+ if (T1 < x && x < T2) {
+ x2 = x * x;
+ dx = x;
+
+ if (x < T3) {
+ if (ix < BIAS - 113) { /* |x| < 0x1p-113 */
+ /* x (rounded) with inexact if x != 0: */
+ RETURNI(x == 0 ? x :
+ (0x1p200 * x + fabsl(x)) * 0x1p-200);
+ }
+ q = x * x2 * C3 + x2 * x2 * (C4 + x * (C5 + x * (C6 +
+ x * (C7 + x * (C8 + x * (C9 + x * (C10 +
+ x * (C11 + x * (C12 + x * (C13 +
+ dx * (C14 + dx * (C15 + dx * (C16 +
+ dx * (C17 + dx * C18))))))))))))));
+ } else {
+ q = x * x2 * D3 + x2 * x2 * (D4 + x * (D5 + x * (D6 +
+ x * (D7 + x * (D8 + x * (D9 + x * (D10 +
+ x * (D11 + x * (D12 + x * (D13 +
+ dx * (D14 + dx * (D15 + dx * (D16 +
+ dx * D17)))))))))))));
+ }
+
+ x_hi = (float)x;
+ x_lo = x - x_hi;
+ hx2_hi = x_hi * x_hi / 2;
+ hx2_lo = x_lo * (x + x_hi) / 2;
+ if (ix >= BIAS - 7)
+ RETURNI(hx2_lo + x_lo + q + (hx2_hi + x_hi));
+ else
+ RETURNI(hx2_lo + q + hx2_hi + x);
+ }
+
+ /* Reduce x to (k*ln2 + endpoint[n2] + r1 + r2). */
+ /* Use a specialized rint() to get fn. Assume round-to-nearest. */
+ fn = (double)x * INV_L + 0x1.8p52 - 0x1.8p52;
+#if defined(HAVE_EFFICIENT_IRINT)
+ n = irint(fn);
+#else
+ n = (int)fn;
+#endif
+ n2 = (unsigned)n % INTERVALS;
+ k = n >> LOG2_INTERVALS;
+ r1 = x - fn * L1;
+ r2 = fn * -L2;
+ r = r1 + r2;
+
+ /* Prepare scale factor. */
+ v.e = 1;
+ v.xbits.expsign = BIAS + k;
+ twopk = v.e;
+
+ /*
+ * Evaluate lower terms of
+ * expl(endpoint[n2] + r1 + r2) = tbl[n2] * expl(r1 + r2).
+ */
+ dr = r;
+ q = r2 + r * r * (A2 + r * (A3 + r * (A4 + r * (A5 + r * (A6 +
+ dr * (A7 + dr * (A8 + dr * (A9 + dr * A10))))))));
+
+ t = tbl[n2].lo + tbl[n2].hi;
+
+ if (k == 0) {
+ t = tbl[n2].lo * (r1 + 1) + t * q + tbl[n2].hi * r1 +
+ (tbl[n2].hi - 1);
+ RETURNI(t);
+ }
+ if (k == -1) {
+ t = tbl[n2].lo * (r1 + 1) + t * q + tbl[n2].hi * r1 +
+ (tbl[n2].hi - 2);
+ RETURNI(t / 2);
+ }
+ if (k < -7) {
+ t = tbl[n2].lo + t * (q + r1) + tbl[n2].hi;
+ RETURNI(t * twopk - 1);
+ }
+ if (k > 2 * LDBL_MANT_DIG - 1) {
+ t = tbl[n2].lo + t * (q + r1) + tbl[n2].hi;
+ if (k == LDBL_MAX_EXP)
+ RETURNI(t * 2 * 0x1p16383L - 1);
+ RETURNI(t * twopk - 1);
+ }
+
+ v.xbits.expsign = BIAS - k;
+ twomk = v.e;
+
+ if (k > LDBL_MANT_DIG - 1)
+ t = tbl[n2].lo - twomk + t * (q + r1) + tbl[n2].hi;
+ else
+ t = tbl[n2].lo + t * (q + r1) + (tbl[n2].hi - twomk);
+ RETURNI(t * twopk);
+}
diff --git a/lib/msun/ld128/s_logl.c b/lib/msun/ld128/s_logl.c
new file mode 100644
index 000000000000..391d623fcd55
--- /dev/null
+++ b/lib/msun/ld128/s_logl.c
@@ -0,0 +1,737 @@
+/*-
+ * Copyright (c) 2007-2013 Bruce D. Evans
+ * 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 unmodified, 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 ``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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/**
+ * Implementation of the natural logarithm of x for 128-bit format.
+ *
+ * First decompose x into its base 2 representation:
+ *
+ * log(x) = log(X * 2**k), where X is in [1, 2)
+ * = log(X) + k * log(2).
+ *
+ * Let X = X_i + e, where X_i is the center of one of the intervals
+ * [-1.0/256, 1.0/256), [1.0/256, 3.0/256), .... [2.0-1.0/256, 2.0+1.0/256)
+ * and X is in this interval. Then
+ *
+ * log(X) = log(X_i + e)
+ * = log(X_i * (1 + e / X_i))
+ * = log(X_i) + log(1 + e / X_i).
+ *
+ * The values log(X_i) are tabulated below. Let d = e / X_i and use
+ *
+ * log(1 + d) = p(d)
+ *
+ * where p(d) = d - 0.5*d*d + ... is a special minimax polynomial of
+ * suitably high degree.
+ *
+ * To get sufficiently small roundoff errors, k * log(2), log(X_i), and
+ * sometimes (if |k| is not large) the first term in p(d) must be evaluated
+ * and added up in extra precision. Extra precision is not needed for the
+ * rest of p(d). In the worst case when k = 0 and log(X_i) is 0, the final
+ * error is controlled mainly by the error in the second term in p(d). The
+ * error in this term itself is at most 0.5 ulps from the d*d operation in
+ * it. The error in this term relative to the first term is thus at most
+ * 0.5 * |-0.5| * |d| < 1.0/1024 ulps. We aim for an accumulated error of
+ * at most twice this at the point of the final rounding step. Thus the
+ * final error should be at most 0.5 + 1.0/512 = 0.5020 ulps. Exhaustive
+ * testing of a float variant of this function showed a maximum final error
+ * of 0.5008 ulps. Non-exhaustive testing of a double variant of this
+ * function showed a maximum final error of 0.5078 ulps (near 1+1.0/256).
+ *
+ * We made the maximum of |d| (and thus the total relative error and the
+ * degree of p(d)) small by using a large number of intervals. Using
+ * centers of intervals instead of endpoints reduces this maximum by a
+ * factor of 2 for a given number of intervals. p(d) is special only
+ * in beginning with the Taylor coefficients 0 + 1*d, which tends to happen
+ * naturally. The most accurate minimax polynomial of a given degree might
+ * be different, but then we wouldn't want it since we would have to do
+ * extra work to avoid roundoff error (especially for P0*d instead of d).
+ */
+
+#ifdef DEBUG
+#include <assert.h>
+#include <fenv.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#ifndef NO_STRUCT_RETURN
+#define STRUCT_RETURN
+#endif
+#include "math_private.h"
+
+#if !defined(NO_UTAB) && !defined(NO_UTABL)
+#define USE_UTAB
+#endif
+
+/*
+ * Domain [-0.005280, 0.004838], range ~[-1.1577e-37, 1.1582e-37]:
+ * |log(1 + d)/d - p(d)| < 2**-122.7
+ */
+static const long double
+P2 = -0.5L,
+P3 = 3.33333333333333333333333333333233795e-1L, /* 0x15555555555555555555555554d42.0p-114L */
+P4 = -2.49999999999999999999999999941139296e-1L, /* -0x1ffffffffffffffffffffffdab14e.0p-115L */
+P5 = 2.00000000000000000000000085468039943e-1L, /* 0x19999999999999999999a6d3567f4.0p-115L */
+P6 = -1.66666666666666666666696142372698408e-1L, /* -0x15555555555555555567267a58e13.0p-115L */
+P7 = 1.42857142857142857119522943477166120e-1L, /* 0x1249249249249248ed79a0ae434de.0p-115L */
+P8 = -1.24999999999999994863289015033581301e-1L; /* -0x1fffffffffffffa13e91765e46140.0p-116L */
+/* Double precision gives ~ 53 + log2(P9 * max(|d|)**8) ~= 120 bits. */
+static const double
+P9 = 1.1111111111111401e-1, /* 0x1c71c71c71c7ed.0p-56 */
+P10 = -1.0000000000040135e-1, /* -0x199999999a0a92.0p-56 */
+P11 = 9.0909090728136258e-2, /* 0x1745d173962111.0p-56 */
+P12 = -8.3333318851855284e-2, /* -0x1555551722c7a3.0p-56 */
+P13 = 7.6928634666404178e-2, /* 0x13b1985204a4ae.0p-56 */
+P14 = -7.1626810078462499e-2; /* -0x12562276cdc5d0.0p-56 */
+
+static volatile const double zero = 0;
+
+#define INTERVALS 128
+#define LOG2_INTERVALS 7
+#define TSIZE (INTERVALS + 1)
+#define G(i) (T[(i)].G)
+#define F_hi(i) (T[(i)].F_hi)
+#define F_lo(i) (T[(i)].F_lo)
+#define ln2_hi F_hi(TSIZE - 1)
+#define ln2_lo F_lo(TSIZE - 1)
+#define E(i) (U[(i)].E)
+#define H(i) (U[(i)].H)
+
+static const struct {
+ float G; /* 1/(1 + i/128) rounded to 8/9 bits */
+ float F_hi; /* log(1 / G_i) rounded (see below) */
+ /* The compiler will insert 8 bytes of padding here. */
+ long double F_lo; /* next 113 bits for log(1 / G_i) */
+} T[TSIZE] = {
+ /*
+ * ln2_hi and each F_hi(i) are rounded to a number of bits that
+ * makes F_hi(i) + dk*ln2_hi exact for all i and all dk.
+ *
+ * The last entry (for X just below 2) is used to define ln2_hi
+ * and ln2_lo, to ensure that F_hi(i) and F_lo(i) cancel exactly
+ * with dk*ln2_hi and dk*ln2_lo, respectively, when dk = -1.
+ * This is needed for accuracy when x is just below 1. (To avoid
+ * special cases, such x are "reduced" strangely to X just below
+ * 2 and dk = -1, and then the exact cancellation is needed
+ * because any the error from any non-exactness would be too
+ * large).
+ *
+ * The relevant range of dk is [-16445, 16383]. The maximum number
+ * of bits in F_hi(i) that works is very dependent on i but has
+ * a minimum of 93. We only need about 12 bits in F_hi(i) for
+ * it to provide enough extra precision.
+ *
+ * We round F_hi(i) to 24 bits so that it can have type float,
+ * mainly to minimize the size of the table. Using all 24 bits
+ * in a float for it automatically satisfies the above constraints.
+ */
+ 0x800000.0p-23, 0, 0,
+ 0xfe0000.0p-24, 0x8080ac.0p-30, -0x14ee431dae6674afa0c4bfe16e8fd.0p-144L,
+ 0xfc0000.0p-24, 0x8102b3.0p-29, -0x1db29ee2d83717be918e1119642ab.0p-144L,
+ 0xfa0000.0p-24, 0xc24929.0p-29, 0x1191957d173697cf302cc9476f561.0p-143L,
+ 0xf80000.0p-24, 0x820aec.0p-28, 0x13ce8888e02e78eba9b1113bc1c18.0p-142L,
+ 0xf60000.0p-24, 0xa33577.0p-28, -0x17a4382ce6eb7bfa509bec8da5f22.0p-142L,
+ 0xf48000.0p-24, 0xbc42cb.0p-28, -0x172a21161a107674986dcdca6709c.0p-143L,
+ 0xf30000.0p-24, 0xd57797.0p-28, -0x1e09de07cb958897a3ea46e84abb3.0p-142L,
+ 0xf10000.0p-24, 0xf7518e.0p-28, 0x1ae1eec1b036c484993c549c4bf40.0p-151L,
+ 0xef0000.0p-24, 0x8cb9df.0p-27, -0x1d7355325d560d9e9ab3d6ebab580.0p-141L,
+ 0xed8000.0p-24, 0x999ec0.0p-27, -0x1f9f02d256d5037108f4ec21e48cd.0p-142L,
+ 0xec0000.0p-24, 0xa6988b.0p-27, -0x16fc0a9d12c17a70f7a684c596b12.0p-143L,
+ 0xea0000.0p-24, 0xb80698.0p-27, 0x15d581c1e8da99ded322fb08b8462.0p-141L,
+ 0xe80000.0p-24, 0xc99af3.0p-27, -0x1535b3ba8f150ae09996d7bb4653e.0p-143L,
+ 0xe70000.0p-24, 0xd273b2.0p-27, 0x163786f5251aefe0ded34c8318f52.0p-145L,
+ 0xe50000.0p-24, 0xe442c0.0p-27, 0x1bc4b2368e32d56699c1799a244d4.0p-144L,
+ 0xe38000.0p-24, 0xf1b83f.0p-27, 0x1c6090f684e6766abceccab1d7174.0p-141L,
+ 0xe20000.0p-24, 0xff448a.0p-27, -0x1890aa69ac9f4215f93936b709efb.0p-142L,
+ 0xe08000.0p-24, 0x8673f6.0p-26, 0x1b9985194b6affd511b534b72a28e.0p-140L,
+ 0xdf0000.0p-24, 0x8d515c.0p-26, -0x1dc08d61c6ef1d9b2ef7e68680598.0p-143L,
+ 0xdd8000.0p-24, 0x943a9e.0p-26, -0x1f72a2dac729b3f46662238a9425a.0p-142L,
+ 0xdc0000.0p-24, 0x9b2fe6.0p-26, -0x1fd4dfd3a0afb9691aed4d5e3df94.0p-140L,
+ 0xda8000.0p-24, 0xa2315d.0p-26, -0x11b26121629c46c186384993e1c93.0p-142L,
+ 0xd90000.0p-24, 0xa93f2f.0p-26, 0x1286d633e8e5697dc6a402a56fce1.0p-141L,
+ 0xd78000.0p-24, 0xb05988.0p-26, 0x16128eba9367707ebfa540e45350c.0p-144L,
+ 0xd60000.0p-24, 0xb78094.0p-26, 0x16ead577390d31ef0f4c9d43f79b2.0p-140L,
+ 0xd50000.0p-24, 0xbc4c6c.0p-26, 0x151131ccf7c7b75e7d900b521c48d.0p-141L,
+ 0xd38000.0p-24, 0xc3890a.0p-26, -0x115e2cd714bd06508aeb00d2ae3e9.0p-140L,
+ 0xd20000.0p-24, 0xcad2d7.0p-26, -0x1847f406ebd3af80485c2f409633c.0p-142L,
+ 0xd10000.0p-24, 0xcfb620.0p-26, 0x1c2259904d686581799fbce0b5f19.0p-141L,
+ 0xcf8000.0p-24, 0xd71653.0p-26, 0x1ece57a8d5ae54f550444ecf8b995.0p-140L,
+ 0xce0000.0p-24, 0xde843a.0p-26, -0x1f109d4bc4595412b5d2517aaac13.0p-141L,
+ 0xcd0000.0p-24, 0xe37fde.0p-26, 0x1bc03dc271a74d3a85b5b43c0e727.0p-141L,
+ 0xcb8000.0p-24, 0xeb050c.0p-26, -0x1bf2badc0df841a71b79dd5645b46.0p-145L,
+ 0xca0000.0p-24, 0xf29878.0p-26, -0x18efededd89fbe0bcfbe6d6db9f66.0p-147L,
+ 0xc90000.0p-24, 0xf7ad6f.0p-26, 0x1373ff977baa6911c7bafcb4d84fb.0p-141L,
+ 0xc80000.0p-24, 0xfcc8e3.0p-26, 0x196766f2fb328337cc050c6d83b22.0p-140L,
+ 0xc68000.0p-24, 0x823f30.0p-25, 0x19bd076f7c434e5fcf1a212e2a91e.0p-139L,
+ 0xc58000.0p-24, 0x84d52c.0p-25, -0x1a327257af0f465e5ecab5f2a6f81.0p-139L,
+ 0xc40000.0p-24, 0x88bc74.0p-25, 0x113f23def19c5a0fe396f40f1dda9.0p-141L,
+ 0xc30000.0p-24, 0x8b5ae6.0p-25, 0x1759f6e6b37de945a049a962e66c6.0p-139L,
+ 0xc20000.0p-24, 0x8dfccb.0p-25, 0x1ad35ca6ed5147bdb6ddcaf59c425.0p-141L,
+ 0xc10000.0p-24, 0x90a22b.0p-25, 0x1a1d71a87deba46bae9827221dc98.0p-139L,
+ 0xbf8000.0p-24, 0x94a0d8.0p-25, -0x139e5210c2b730e28aba001a9b5e0.0p-140L,
+ 0xbe8000.0p-24, 0x974f16.0p-25, -0x18f6ebcff3ed72e23e13431adc4a5.0p-141L,
+ 0xbd8000.0p-24, 0x9a00f1.0p-25, -0x1aa268be39aab7148e8d80caa10b7.0p-139L,
+ 0xbc8000.0p-24, 0x9cb672.0p-25, -0x14c8815839c5663663d15faed7771.0p-139L,
+ 0xbb0000.0p-24, 0xa0cda1.0p-25, 0x1eaf46390dbb2438273918db7df5c.0p-141L,
+ 0xba0000.0p-24, 0xa38c6e.0p-25, 0x138e20d831f698298adddd7f32686.0p-141L,
+ 0xb90000.0p-24, 0xa64f05.0p-25, -0x1e8d3c41123615b147a5d47bc208f.0p-142L,
+ 0xb80000.0p-24, 0xa91570.0p-25, 0x1ce28f5f3840b263acb4351104631.0p-140L,
+ 0xb70000.0p-24, 0xabdfbb.0p-25, -0x186e5c0a42423457e22d8c650b355.0p-139L,
+ 0xb60000.0p-24, 0xaeadef.0p-25, -0x14d41a0b2a08a465dc513b13f567d.0p-143L,
+ 0xb50000.0p-24, 0xb18018.0p-25, 0x16755892770633947ffe651e7352f.0p-139L,
+ 0xb40000.0p-24, 0xb45642.0p-25, -0x16395ebe59b15228bfe8798d10ff0.0p-142L,
+ 0xb30000.0p-24, 0xb73077.0p-25, 0x1abc65c8595f088b61a335f5b688c.0p-140L,
+ 0xb20000.0p-24, 0xba0ec4.0p-25, -0x1273089d3dad88e7d353e9967d548.0p-139L,
+ 0xb10000.0p-24, 0xbcf133.0p-25, 0x10f9f67b1f4bbf45de06ecebfaf6d.0p-139L,
+ 0xb00000.0p-24, 0xbfd7d2.0p-25, -0x109fab904864092b34edda19a831e.0p-140L,
+ 0xaf0000.0p-24, 0xc2c2ac.0p-25, -0x1124680aa43333221d8a9b475a6ba.0p-139L,
+ 0xae8000.0p-24, 0xc439b3.0p-25, -0x1f360cc4710fbfe24b633f4e8d84d.0p-140L,
+ 0xad8000.0p-24, 0xc72afd.0p-25, -0x132d91f21d89c89c45003fc5d7807.0p-140L,
+ 0xac8000.0p-24, 0xca20a2.0p-25, -0x16bf9b4d1f8da8002f2449e174504.0p-139L,
+ 0xab8000.0p-24, 0xcd1aae.0p-25, 0x19deb5ce6a6a8717d5626e16acc7d.0p-141L,
+ 0xaa8000.0p-24, 0xd0192f.0p-25, 0x1a29fb48f7d3ca87dabf351aa41f4.0p-139L,
+ 0xaa0000.0p-24, 0xd19a20.0p-25, 0x1127d3c6457f9d79f51dcc73014c9.0p-141L,
+ 0xa90000.0p-24, 0xd49f6a.0p-25, -0x1ba930e486a0ac42d1bf9199188e7.0p-141L,
+ 0xa80000.0p-24, 0xd7a94b.0p-25, -0x1b6e645f31549dd1160bcc45c7e2c.0p-139L,
+ 0xa70000.0p-24, 0xdab7d0.0p-25, 0x1118a425494b610665377f15625b6.0p-140L,
+ 0xa68000.0p-24, 0xdc40d5.0p-25, 0x1966f24d29d3a2d1b2176010478be.0p-140L,
+ 0xa58000.0p-24, 0xdf566d.0p-25, -0x1d8e52eb2248f0c95dd83626d7333.0p-142L,
+ 0xa48000.0p-24, 0xe270ce.0p-25, -0x1ee370f96e6b67ccb006a5b9890ea.0p-140L,
+ 0xa40000.0p-24, 0xe3ffce.0p-25, 0x1d155324911f56db28da4d629d00a.0p-140L,
+ 0xa30000.0p-24, 0xe72179.0p-25, -0x1fe6e2f2f867d8f4d60c713346641.0p-140L,
+ 0xa20000.0p-24, 0xea4812.0p-25, 0x1b7be9add7f4d3b3d406b6cbf3ce5.0p-140L,
+ 0xa18000.0p-24, 0xebdd3d.0p-25, 0x1b3cfb3f7511dd73692609040ccc2.0p-139L,
+ 0xa08000.0p-24, 0xef0b5b.0p-25, -0x1220de1f7301901b8ad85c25afd09.0p-139L,
+ 0xa00000.0p-24, 0xf0a451.0p-25, -0x176364c9ac81cc8a4dfb804de6867.0p-140L,
+ 0x9f0000.0p-24, 0xf3da16.0p-25, 0x1eed6b9aafac8d42f78d3e65d3727.0p-141L,
+ 0x9e8000.0p-24, 0xf576e9.0p-25, 0x1d593218675af269647b783d88999.0p-139L,
+ 0x9d8000.0p-24, 0xf8b47c.0p-25, -0x13e8eb7da053e063714615f7cc91d.0p-144L,
+ 0x9d0000.0p-24, 0xfa553f.0p-25, 0x1c063259bcade02951686d5373aec.0p-139L,
+ 0x9c0000.0p-24, 0xfd9ac5.0p-25, 0x1ef491085fa3c1649349630531502.0p-139L,
+ 0x9b8000.0p-24, 0xff3f8c.0p-25, 0x1d607a7c2b8c5320619fb9433d841.0p-139L,
+ 0x9a8000.0p-24, 0x814697.0p-24, -0x12ad3817004f3f0bdff99f932b273.0p-138L,
+ 0x9a0000.0p-24, 0x821b06.0p-24, -0x189fc53117f9e54e78103a2bc1767.0p-141L,
+ 0x990000.0p-24, 0x83c5f8.0p-24, 0x14cf15a048907b7d7f47ddb45c5a3.0p-139L,
+ 0x988000.0p-24, 0x849c7d.0p-24, 0x1cbb1d35fb82873b04a9af1dd692c.0p-138L,
+ 0x978000.0p-24, 0x864ba6.0p-24, 0x1128639b814f9b9770d8cb6573540.0p-138L,
+ 0x970000.0p-24, 0x87244c.0p-24, 0x184733853300f002e836dfd47bd41.0p-139L,
+ 0x968000.0p-24, 0x87fdaa.0p-24, 0x109d23aef77dd5cd7cc94306fb3ff.0p-140L,
+ 0x958000.0p-24, 0x89b293.0p-24, -0x1a81ef367a59de2b41eeebd550702.0p-138L,
+ 0x950000.0p-24, 0x8a8e20.0p-24, -0x121ad3dbb2f45275c917a30df4ac9.0p-138L,
+ 0x948000.0p-24, 0x8b6a6a.0p-24, -0x1cfb981628af71a89df4e6df2e93b.0p-139L,
+ 0x938000.0p-24, 0x8d253a.0p-24, -0x1d21730ea76cfdec367828734cae5.0p-139L,
+ 0x930000.0p-24, 0x8e03c2.0p-24, 0x135cc00e566f76b87333891e0dec4.0p-138L,
+ 0x928000.0p-24, 0x8ee30d.0p-24, -0x10fcb5df257a263e3bf446c6e3f69.0p-140L,
+ 0x918000.0p-24, 0x90a3ee.0p-24, -0x16e171b15433d723a4c7380a448d8.0p-139L,
+ 0x910000.0p-24, 0x918587.0p-24, -0x1d050da07f3236f330972da2a7a87.0p-139L,
+ 0x908000.0p-24, 0x9267e7.0p-24, 0x1be03669a5268d21148c6002becd3.0p-139L,
+ 0x8f8000.0p-24, 0x942f04.0p-24, 0x10b28e0e26c336af90e00533323ba.0p-139L,
+ 0x8f0000.0p-24, 0x9513c3.0p-24, 0x1a1d820da57cf2f105a89060046aa.0p-138L,
+ 0x8e8000.0p-24, 0x95f950.0p-24, -0x19ef8f13ae3cf162409d8ea99d4c0.0p-139L,
+ 0x8e0000.0p-24, 0x96dfab.0p-24, -0x109e417a6e507b9dc10dac743ad7a.0p-138L,
+ 0x8d0000.0p-24, 0x98aed2.0p-24, 0x10d01a2c5b0e97c4990b23d9ac1f5.0p-139L,
+ 0x8c8000.0p-24, 0x9997a2.0p-24, -0x1d6a50d4b61ea74540bdd2aa99a42.0p-138L,
+ 0x8c0000.0p-24, 0x9a8145.0p-24, 0x1b3b190b83f9527e6aba8f2d783c1.0p-138L,
+ 0x8b8000.0p-24, 0x9b6bbf.0p-24, 0x13a69fad7e7abe7ba81c664c107e0.0p-138L,
+ 0x8b0000.0p-24, 0x9c5711.0p-24, -0x11cd12316f576aad348ae79867223.0p-138L,
+ 0x8a8000.0p-24, 0x9d433b.0p-24, 0x1c95c444b807a246726b304ccae56.0p-139L,
+ 0x898000.0p-24, 0x9f1e22.0p-24, -0x1b9c224ea698c2f9b47466d6123fe.0p-139L,
+ 0x890000.0p-24, 0xa00ce1.0p-24, 0x125ca93186cf0f38b4619a2483399.0p-141L,
+ 0x888000.0p-24, 0xa0fc80.0p-24, -0x1ee38a7bc228b3597043be78eaf49.0p-139L,
+ 0x880000.0p-24, 0xa1ed00.0p-24, -0x1a0db876613d204147dc69a07a649.0p-138L,
+ 0x878000.0p-24, 0xa2de62.0p-24, 0x193224e8516c008d3602a7b41c6e8.0p-139L,
+ 0x870000.0p-24, 0xa3d0a9.0p-24, 0x1fa28b4d2541aca7d5844606b2421.0p-139L,
+ 0x868000.0p-24, 0xa4c3d6.0p-24, 0x1c1b5760fb4571acbcfb03f16daf4.0p-138L,
+ 0x858000.0p-24, 0xa6acea.0p-24, 0x1fed5d0f65949c0a345ad743ae1ae.0p-140L,
+ 0x850000.0p-24, 0xa7a2d4.0p-24, 0x1ad270c9d749362382a7688479e24.0p-140L,
+ 0x848000.0p-24, 0xa899ab.0p-24, 0x199ff15ce532661ea9643a3a2d378.0p-139L,
+ 0x840000.0p-24, 0xa99171.0p-24, 0x1a19e15ccc45d257530a682b80490.0p-139L,
+ 0x838000.0p-24, 0xaa8a28.0p-24, -0x121a14ec532b35ba3e1f868fd0b5e.0p-140L,
+ 0x830000.0p-24, 0xab83d1.0p-24, 0x1aee319980bff3303dd481779df69.0p-139L,
+ 0x828000.0p-24, 0xac7e6f.0p-24, -0x18ffd9e3900345a85d2d86161742e.0p-140L,
+ 0x820000.0p-24, 0xad7a03.0p-24, -0x1e4db102ce29f79b026b64b42caa1.0p-140L,
+ 0x818000.0p-24, 0xae768f.0p-24, 0x17c35c55a04a82ab19f77652d977a.0p-141L,
+ 0x810000.0p-24, 0xaf7415.0p-24, 0x1448324047019b48d7b98c1cf7234.0p-138L,
+ 0x808000.0p-24, 0xb07298.0p-24, -0x1750ee3915a197e9c7359dd94152f.0p-138L,
+ 0x800000.0p-24, 0xb17218.0p-24, -0x105c610ca86c3898cff81a12a17e2.0p-141L,
+};
+
+#ifdef USE_UTAB
+static const struct {
+ float H; /* 1 + i/INTERVALS (exact) */
+ float E; /* H(i) * G(i) - 1 (exact) */
+} U[TSIZE] = {
+ 0x800000.0p-23, 0,
+ 0x810000.0p-23, -0x800000.0p-37,
+ 0x820000.0p-23, -0x800000.0p-35,
+ 0x830000.0p-23, -0x900000.0p-34,
+ 0x840000.0p-23, -0x800000.0p-33,
+ 0x850000.0p-23, -0xc80000.0p-33,
+ 0x860000.0p-23, -0xa00000.0p-36,
+ 0x870000.0p-23, 0x940000.0p-33,
+ 0x880000.0p-23, 0x800000.0p-35,
+ 0x890000.0p-23, -0xc80000.0p-34,
+ 0x8a0000.0p-23, 0xe00000.0p-36,
+ 0x8b0000.0p-23, 0x900000.0p-33,
+ 0x8c0000.0p-23, -0x800000.0p-35,
+ 0x8d0000.0p-23, -0xe00000.0p-33,
+ 0x8e0000.0p-23, 0x880000.0p-33,
+ 0x8f0000.0p-23, -0xa80000.0p-34,
+ 0x900000.0p-23, -0x800000.0p-35,
+ 0x910000.0p-23, 0x800000.0p-37,
+ 0x920000.0p-23, 0x900000.0p-35,
+ 0x930000.0p-23, 0xd00000.0p-35,
+ 0x940000.0p-23, 0xe00000.0p-35,
+ 0x950000.0p-23, 0xc00000.0p-35,
+ 0x960000.0p-23, 0xe00000.0p-36,
+ 0x970000.0p-23, -0x800000.0p-38,
+ 0x980000.0p-23, -0xc00000.0p-35,
+ 0x990000.0p-23, -0xd00000.0p-34,
+ 0x9a0000.0p-23, 0x880000.0p-33,
+ 0x9b0000.0p-23, 0xe80000.0p-35,
+ 0x9c0000.0p-23, -0x800000.0p-35,
+ 0x9d0000.0p-23, 0xb40000.0p-33,
+ 0x9e0000.0p-23, 0x880000.0p-34,
+ 0x9f0000.0p-23, -0xe00000.0p-35,
+ 0xa00000.0p-23, 0x800000.0p-33,
+ 0xa10000.0p-23, -0x900000.0p-36,
+ 0xa20000.0p-23, -0xb00000.0p-33,
+ 0xa30000.0p-23, -0xa00000.0p-36,
+ 0xa40000.0p-23, 0x800000.0p-33,
+ 0xa50000.0p-23, -0xf80000.0p-35,
+ 0xa60000.0p-23, 0x880000.0p-34,
+ 0xa70000.0p-23, -0x900000.0p-33,
+ 0xa80000.0p-23, -0x800000.0p-35,
+ 0xa90000.0p-23, 0x900000.0p-34,
+ 0xaa0000.0p-23, 0xa80000.0p-33,
+ 0xab0000.0p-23, -0xac0000.0p-34,
+ 0xac0000.0p-23, -0x800000.0p-37,
+ 0xad0000.0p-23, 0xf80000.0p-35,
+ 0xae0000.0p-23, 0xf80000.0p-34,
+ 0xaf0000.0p-23, -0xac0000.0p-33,
+ 0xb00000.0p-23, -0x800000.0p-33,
+ 0xb10000.0p-23, -0xb80000.0p-34,
+ 0xb20000.0p-23, -0x800000.0p-34,
+ 0xb30000.0p-23, -0xb00000.0p-35,
+ 0xb40000.0p-23, -0x800000.0p-35,
+ 0xb50000.0p-23, -0xe00000.0p-36,
+ 0xb60000.0p-23, -0x800000.0p-35,
+ 0xb70000.0p-23, -0xb00000.0p-35,
+ 0xb80000.0p-23, -0x800000.0p-34,
+ 0xb90000.0p-23, -0xb80000.0p-34,
+ 0xba0000.0p-23, -0x800000.0p-33,
+ 0xbb0000.0p-23, -0xac0000.0p-33,
+ 0xbc0000.0p-23, 0x980000.0p-33,
+ 0xbd0000.0p-23, 0xbc0000.0p-34,
+ 0xbe0000.0p-23, 0xe00000.0p-36,
+ 0xbf0000.0p-23, -0xb80000.0p-35,
+ 0xc00000.0p-23, -0x800000.0p-33,
+ 0xc10000.0p-23, 0xa80000.0p-33,
+ 0xc20000.0p-23, 0x900000.0p-34,
+ 0xc30000.0p-23, -0x800000.0p-35,
+ 0xc40000.0p-23, -0x900000.0p-33,
+ 0xc50000.0p-23, 0x820000.0p-33,
+ 0xc60000.0p-23, 0x800000.0p-38,
+ 0xc70000.0p-23, -0x820000.0p-33,
+ 0xc80000.0p-23, 0x800000.0p-33,
+ 0xc90000.0p-23, -0xa00000.0p-36,
+ 0xca0000.0p-23, -0xb00000.0p-33,
+ 0xcb0000.0p-23, 0x840000.0p-34,
+ 0xcc0000.0p-23, -0xd00000.0p-34,
+ 0xcd0000.0p-23, 0x800000.0p-33,
+ 0xce0000.0p-23, -0xe00000.0p-35,
+ 0xcf0000.0p-23, 0xa60000.0p-33,
+ 0xd00000.0p-23, -0x800000.0p-35,
+ 0xd10000.0p-23, 0xb40000.0p-33,
+ 0xd20000.0p-23, -0x800000.0p-35,
+ 0xd30000.0p-23, 0xaa0000.0p-33,
+ 0xd40000.0p-23, -0xe00000.0p-35,
+ 0xd50000.0p-23, 0x880000.0p-33,
+ 0xd60000.0p-23, -0xd00000.0p-34,
+ 0xd70000.0p-23, 0x9c0000.0p-34,
+ 0xd80000.0p-23, -0xb00000.0p-33,
+ 0xd90000.0p-23, -0x800000.0p-38,
+ 0xda0000.0p-23, 0xa40000.0p-33,
+ 0xdb0000.0p-23, -0xdc0000.0p-34,
+ 0xdc0000.0p-23, 0xc00000.0p-35,
+ 0xdd0000.0p-23, 0xca0000.0p-33,
+ 0xde0000.0p-23, -0xb80000.0p-34,
+ 0xdf0000.0p-23, 0xd00000.0p-35,
+ 0xe00000.0p-23, 0xc00000.0p-33,
+ 0xe10000.0p-23, -0xf40000.0p-34,
+ 0xe20000.0p-23, 0x800000.0p-37,
+ 0xe30000.0p-23, 0x860000.0p-33,
+ 0xe40000.0p-23, -0xc80000.0p-33,
+ 0xe50000.0p-23, -0xa80000.0p-34,
+ 0xe60000.0p-23, 0xe00000.0p-36,
+ 0xe70000.0p-23, 0x880000.0p-33,
+ 0xe80000.0p-23, -0xe00000.0p-33,
+ 0xe90000.0p-23, -0xfc0000.0p-34,
+ 0xea0000.0p-23, -0x800000.0p-35,
+ 0xeb0000.0p-23, 0xe80000.0p-35,
+ 0xec0000.0p-23, 0x900000.0p-33,
+ 0xed0000.0p-23, 0xe20000.0p-33,
+ 0xee0000.0p-23, -0xac0000.0p-33,
+ 0xef0000.0p-23, -0xc80000.0p-34,
+ 0xf00000.0p-23, -0x800000.0p-35,
+ 0xf10000.0p-23, 0x800000.0p-35,
+ 0xf20000.0p-23, 0xb80000.0p-34,
+ 0xf30000.0p-23, 0x940000.0p-33,
+ 0xf40000.0p-23, 0xc80000.0p-33,
+ 0xf50000.0p-23, -0xf20000.0p-33,
+ 0xf60000.0p-23, -0xc80000.0p-33,
+ 0xf70000.0p-23, -0xa20000.0p-33,
+ 0xf80000.0p-23, -0x800000.0p-33,
+ 0xf90000.0p-23, -0xc40000.0p-34,
+ 0xfa0000.0p-23, -0x900000.0p-34,
+ 0xfb0000.0p-23, -0xc80000.0p-35,
+ 0xfc0000.0p-23, -0x800000.0p-35,
+ 0xfd0000.0p-23, -0x900000.0p-36,
+ 0xfe0000.0p-23, -0x800000.0p-37,
+ 0xff0000.0p-23, -0x800000.0p-39,
+ 0x800000.0p-22, 0,
+};
+#endif /* USE_UTAB */
+
+#ifdef STRUCT_RETURN
+#define RETURN1(rp, v) do { \
+ (rp)->hi = (v); \
+ (rp)->lo_set = 0; \
+ return; \
+} while (0)
+
+#define RETURN2(rp, h, l) do { \
+ (rp)->hi = (h); \
+ (rp)->lo = (l); \
+ (rp)->lo_set = 1; \
+ return; \
+} while (0)
+
+struct ld {
+ long double hi;
+ long double lo;
+ int lo_set;
+};
+#else
+#define RETURN1(rp, v) RETURNF(v)
+#define RETURN2(rp, h, l) RETURNI((h) + (l))
+#endif
+
+#ifdef STRUCT_RETURN
+static inline __always_inline void
+k_logl(long double x, struct ld *rp)
+#else
+long double
+logl(long double x)
+#endif
+{
+ long double d, val_hi, val_lo;
+ double dd, dk;
+ uint64_t lx, llx;
+ int i, k;
+ uint16_t hx;
+
+ EXTRACT_LDBL128_WORDS(hx, lx, llx, x);
+ k = -16383;
+#if 0 /* Hard to do efficiently. Don't do it until we support all modes. */
+ if (x == 1)
+ RETURN1(rp, 0); /* log(1) = +0 in all rounding modes */
+#endif
+ if (hx == 0 || hx >= 0x8000) { /* zero, negative or subnormal? */
+ if (((hx & 0x7fff) | lx | llx) == 0)
+ RETURN1(rp, -1 / zero); /* log(+-0) = -Inf */
+ if (hx != 0)
+ /* log(neg or NaN) = qNaN: */
+ RETURN1(rp, (x - x) / zero);
+ x *= 0x1.0p113; /* subnormal; scale up x */
+ EXTRACT_LDBL128_WORDS(hx, lx, llx, x);
+ k = -16383 - 113;
+ } else if (hx >= 0x7fff)
+ RETURN1(rp, x + x); /* log(Inf or NaN) = Inf or qNaN */
+#ifndef STRUCT_RETURN
+ ENTERI();
+#endif
+ k += hx;
+ dk = k;
+
+ /* Scale x to be in [1, 2). */
+ SET_LDBL_EXPSIGN(x, 0x3fff);
+
+ /* 0 <= i <= INTERVALS: */
+#define L2I (49 - LOG2_INTERVALS)
+ i = (lx + (1LL << (L2I - 2))) >> (L2I - 1);
+
+ /*
+ * -0.005280 < d < 0.004838. In particular, the infinite-
+ * precision |d| is <= 2**-7. Rounding of G(i) to 8 bits
+ * ensures that d is representable without extra precision for
+ * this bound on |d| (since when this calculation is expressed
+ * as x*G(i)-1, the multiplication needs as many extra bits as
+ * G(i) has and the subtraction cancels 8 bits). But for
+ * most i (107 cases out of 129), the infinite-precision |d|
+ * is <= 2**-8. G(i) is rounded to 9 bits for such i to give
+ * better accuracy (this works by improving the bound on |d|,
+ * which in turn allows rounding to 9 bits in more cases).
+ * This is only important when the original x is near 1 -- it
+ * lets us avoid using a special method to give the desired
+ * accuracy for such x.
+ */
+ if (0)
+ d = x * G(i) - 1;
+ else {
+#ifdef USE_UTAB
+ d = (x - H(i)) * G(i) + E(i);
+#else
+ long double x_hi;
+ double x_lo;
+
+ /*
+ * Split x into x_hi + x_lo to calculate x*G(i)-1 exactly.
+ * G(i) has at most 9 bits, so the splitting point is not
+ * critical.
+ */
+ INSERT_LDBL128_WORDS(x_hi, 0x3fff, lx,
+ llx & 0xffffffffff000000ULL);
+ x_lo = x - x_hi;
+ d = x_hi * G(i) - 1 + x_lo * G(i);
+#endif
+ }
+
+ /*
+ * Our algorithm depends on exact cancellation of F_lo(i) and
+ * F_hi(i) with dk*ln_2_lo and dk*ln2_hi when k is -1 and i is
+ * at the end of the table. This and other technical complications
+ * make it difficult to avoid the double scaling in (dk*ln2) *
+ * log(base) for base != e without losing more accuracy and/or
+ * efficiency than is gained.
+ */
+ /*
+ * Use double precision operations wherever possible, since long
+ * double operations are emulated and are very slow on the only
+ * known machines that support ld128 (sparc64). Also, don't try
+ * to improve parallelism by increasing the number of operations,
+ * since any parallelism on such machines is needed for the
+ * emulation. Horner's method is good for this, and is also good
+ * for accuracy. Horner's method doesn't handle the `lo' term
+ * well, either for efficiency or accuracy. However, for accuracy
+ * we evaluate d * d * P2 separately to take advantage of
+ * by P2 being exact, and this gives a good place to sum the 'lo'
+ * term too.
+ */
+ dd = (double)d;
+ val_lo = d * d * d * (P3 +
+ d * (P4 + d * (P5 + d * (P6 + d * (P7 + d * (P8 +
+ dd * (P9 + dd * (P10 + dd * (P11 + dd * (P12 + dd * (P13 +
+ dd * P14))))))))))) + (F_lo(i) + dk * ln2_lo) + d * d * P2;
+ val_hi = d;
+#ifdef DEBUG
+ if (fetestexcept(FE_UNDERFLOW))
+ breakpoint();
+#endif
+
+ _3sumF(val_hi, val_lo, F_hi(i) + dk * ln2_hi);
+ RETURN2(rp, val_hi, val_lo);
+}
+
+long double
+log1pl(long double x)
+{
+ long double d, d_hi, f_lo, val_hi, val_lo;
+ long double f_hi, twopminusk;
+ double d_lo, dd, dk;
+ uint64_t lx, llx;
+ int i, k;
+ int16_t ax, hx;
+
+ DOPRINT_START(&x);
+ EXTRACT_LDBL128_WORDS(hx, lx, llx, x);
+ if (hx < 0x3fff) { /* x < 1, or x neg NaN */
+ ax = hx & 0x7fff;
+ if (ax >= 0x3fff) { /* x <= -1, or x neg NaN */
+ if (ax == 0x3fff && (lx | llx) == 0)
+ RETURNP(-1 / zero); /* log1p(-1) = -Inf */
+ /* log1p(x < 1, or x NaN) = qNaN: */
+ RETURNP((x - x) / (x - x));
+ }
+ if (ax <= 0x3f8d) { /* |x| < 2**-113 */
+ if ((int)x == 0)
+ RETURNP(x); /* x with inexact if x != 0 */
+ }
+ f_hi = 1;
+ f_lo = x;
+ } else if (hx >= 0x7fff) { /* x +Inf or non-neg NaN */
+ RETURNP(x + x); /* log1p(Inf or NaN) = Inf or qNaN */
+ } else if (hx < 0x40e1) { /* 1 <= x < 2**226 */
+ f_hi = x;
+ f_lo = 1;
+ } else { /* 2**226 <= x < +Inf */
+ f_hi = x;
+ f_lo = 0; /* avoid underflow of the P3 term */
+ }
+ ENTERI();
+ x = f_hi + f_lo;
+ f_lo = (f_hi - x) + f_lo;
+
+ EXTRACT_LDBL128_WORDS(hx, lx, llx, x);
+ k = -16383;
+
+ k += hx;
+ dk = k;
+
+ SET_LDBL_EXPSIGN(x, 0x3fff);
+ twopminusk = 1;
+ SET_LDBL_EXPSIGN(twopminusk, 0x7ffe - (hx & 0x7fff));
+ f_lo *= twopminusk;
+
+ i = (lx + (1LL << (L2I - 2))) >> (L2I - 1);
+
+ /*
+ * x*G(i)-1 (with a reduced x) can be represented exactly, as
+ * above, but now we need to evaluate the polynomial on d =
+ * (x+f_lo)*G(i)-1 and extra precision is needed for that.
+ * Since x+x_lo is a hi+lo decomposition and subtracting 1
+ * doesn't lose too many bits, an inexact calculation for
+ * f_lo*G(i) is good enough.
+ */
+ if (0)
+ d_hi = x * G(i) - 1;
+ else {
+#ifdef USE_UTAB
+ d_hi = (x - H(i)) * G(i) + E(i);
+#else
+ long double x_hi;
+ double x_lo;
+
+ INSERT_LDBL128_WORDS(x_hi, 0x3fff, lx,
+ llx & 0xffffffffff000000ULL);
+ x_lo = x - x_hi;
+ d_hi = x_hi * G(i) - 1 + x_lo * G(i);
+#endif
+ }
+ d_lo = f_lo * G(i);
+
+ /*
+ * This is _2sumF(d_hi, d_lo) inlined. The condition
+ * (d_hi == 0 || |d_hi| >= |d_lo|) for using _2sumF() is not
+ * always satisifed, so it is not clear that this works, but
+ * it works in practice. It works even if it gives a wrong
+ * normalized d_lo, since |d_lo| > |d_hi| implies that i is
+ * nonzero and d is tiny, so the F(i) term dominates d_lo.
+ * In float precision:
+ * (By exhaustive testing, the worst case is d_hi = 0x1.bp-25.
+ * And if d is only a little tinier than that, we would have
+ * another underflow problem for the P3 term; this is also ruled
+ * out by exhaustive testing.)
+ */
+ d = d_hi + d_lo;
+ d_lo = d_hi - d + d_lo;
+ d_hi = d;
+
+ dd = (double)d;
+ val_lo = d * d * d * (P3 +
+ d * (P4 + d * (P5 + d * (P6 + d * (P7 + d * (P8 +
+ dd * (P9 + dd * (P10 + dd * (P11 + dd * (P12 + dd * (P13 +
+ dd * P14))))))))))) + (F_lo(i) + dk * ln2_lo + d_lo) + d * d * P2;
+ val_hi = d_hi;
+#ifdef DEBUG
+ if (fetestexcept(FE_UNDERFLOW))
+ breakpoint();
+#endif
+
+ _3sumF(val_hi, val_lo, F_hi(i) + dk * ln2_hi);
+ RETURN2PI(val_hi, val_lo);
+}
+
+#ifdef STRUCT_RETURN
+
+long double
+logl(long double x)
+{
+ struct ld r;
+
+ ENTERI();
+ DOPRINT_START(&x);
+ k_logl(x, &r);
+ RETURNSPI(&r);
+}
+
+/*
+ * 29+113 bit decompositions. The bits are distributed so that the products
+ * of the hi terms are exact in double precision. The types are chosen so
+ * that the products of the hi terms are done in at least double precision,
+ * without any explicit conversions. More natural choices would require a
+ * slow long double precision multiplication.
+ */
+static const double
+invln10_hi = 4.3429448176175356e-1, /* 0x1bcb7b15000000.0p-54 */
+invln2_hi = 1.4426950402557850e0; /* 0x17154765000000.0p-52 */
+static const long double
+invln10_lo = 1.41498268538580090791605082294397000e-10L, /* 0x137287195355baaafad33dc323ee3.0p-145L */
+invln2_lo = 6.33178418956604368501892137426645911e-10L; /* 0x15c17f0bbbe87fed0691d3e88eb57.0p-143L */
+
+long double
+log10l(long double x)
+{
+ struct ld r;
+ long double lo;
+ float hi;
+
+ ENTERI();
+ DOPRINT_START(&x);
+ k_logl(x, &r);
+ if (!r.lo_set)
+ RETURNPI(r.hi);
+ _2sumF(r.hi, r.lo);
+ hi = r.hi;
+ lo = r.lo + (r.hi - hi);
+ RETURN2PI(invln10_hi * hi,
+ (invln10_lo + invln10_hi) * lo + invln10_lo * hi);
+}
+
+long double
+log2l(long double x)
+{
+ struct ld r;
+ long double lo;
+ float hi;
+
+ ENTERI();
+ DOPRINT_START(&x);
+ k_logl(x, &r);
+ if (!r.lo_set)
+ RETURNPI(r.hi);
+ _2sumF(r.hi, r.lo);
+ hi = r.hi;
+ lo = r.lo + (r.hi - hi);
+ RETURN2PI(invln2_hi * hi,
+ (invln2_lo + invln2_hi) * lo + invln2_lo * hi);
+}
+
+#endif /* STRUCT_RETURN */
diff --git a/lib/msun/ld80/s_exp2l.c b/lib/msun/ld80/s_exp2l.c
index 14dfc1d87f21..8730f1397186 100644
--- a/lib/msun/ld80/s_exp2l.c
+++ b/lib/msun/ld80/s_exp2l.c
@@ -36,28 +36,31 @@ __FBSDID("$FreeBSD$");
#include "fpmath.h"
#include "math.h"
+#include "math_private.h"
#define TBLBITS 7
#define TBLSIZE (1 << TBLBITS)
#define BIAS (LDBL_MAX_EXP - 1)
-#define EXPMASK (BIAS + LDBL_MAX_EXP)
-static const long double huge = 0x1p10000L;
-#if 0 /* XXX Prevent gcc from erroneously constant folding this. */
-static const long double twom10000 = 0x1p-10000L;
-#else
-static volatile long double twom10000 = 0x1p-10000L;
-#endif
+static volatile long double
+ huge = 0x1p10000L,
+ twom10000 = 0x1p-10000L;
+
+static const union IEEEl2bits
+P1 = LD80C(0xb17217f7d1cf79ac, -1, 6.93147180559945309429e-1L);
static const double
- redux = 0x1.8p63 / TBLSIZE,
- P1 = 0x1.62e42fefa39efp-1,
- P2 = 0x1.ebfbdff82c58fp-3,
- P3 = 0x1.c6b08d7049fap-5,
- P4 = 0x1.3b2ab6fba4da5p-7,
- P5 = 0x1.5d8804780a736p-10,
- P6 = 0x1.430918835e33dp-13;
+redux = 0x1.8p63 / TBLSIZE,
+/*
+ * Domain [-0.00390625, 0.00390625], range ~[-1.7079e-23, 1.7079e-23]
+ * |exp(x) - p(x)| < 2**-75.6
+ */
+P2 = 2.4022650695910072e-1, /* 0x1ebfbdff82c58f.0p-55 */
+P3 = 5.5504108664816879e-2, /* 0x1c6b08d7049e1a.0p-57 */
+P4 = 9.6181291055695180e-3, /* 0x13b2ab6fa8321a.0p-59 */
+P5 = 1.3333563089183052e-3, /* 0x15d8806f67f251.0p-62 */
+P6 = 1.5413361552277414e-4; /* 0x1433ddacff3441.0p-65 */
static const double tbl[TBLSIZE * 2] = {
0x1.6a09e667f3bcdp-1, -0x1.bdd3413b2648p-55,
@@ -190,8 +193,8 @@ static const double tbl[TBLSIZE * 2] = {
0x1.68155d44ca973p+0, 0x1.038ae44f74p-57,
};
-/*
- * exp2l(x): compute the base 2 exponential of x
+/**
+ * Compute the base 2 exponential of x for Intel 80-bit format.
*
* Accuracy: Peak error < 0.511 ulp.
*
@@ -207,7 +210,7 @@ static const double tbl[TBLSIZE * 2] = {
* with |z| <= 2**-(TBLBITS+1).
*
* We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
- * degree-6 minimax polynomial with maximum error under 2**-69.
+ * degree-6 minimax polynomial with maximum error under 2**-75.6.
* The table entries each have 104 bits of accuracy, encoded as
* a pair of double precision values.
*/
@@ -222,30 +225,22 @@ exp2l(long double x)
/* Filter out exceptional cases. */
u.e = x;
hx = u.xbits.expsign;
- ix = hx & EXPMASK;
+ ix = hx & 0x7fff;
if (ix >= BIAS + 14) { /* |x| >= 16384 or x is NaN */
if (ix == BIAS + LDBL_MAX_EXP) {
- if (u.xbits.man != 1ULL << 63 || (hx & 0x8000) == 0)
- return (x + x); /* x is +Inf or NaN */
- else
- return (0.0); /* x is -Inf */
+ if (hx & 0x8000 && u.xbits.man == 1ULL << 63)
+ return (0.0L); /* x is -Inf */
+ return (x + x); /* x is +Inf, NaN or unsupported */
}
if (x >= 16384)
return (huge * huge); /* overflow */
if (x <= -16446)
return (twom10000 * twom10000); /* underflow */
- } else if (ix <= BIAS - 66) { /* |x| < 0x1p-66 */
- return (1.0 + x);
+ } else if (ix <= BIAS - 66) { /* |x| < 0x1p-65 (includes pseudos) */
+ return (1.0L + x); /* 1 with inexact */
}
-#ifdef __i386__
- /*
- * The default precision on i386 is 53 bits, so long doubles are
- * broken. Call exp2() to get an accurate (double precision) result.
- */
- if (fpgetprec() != FP_PE)
- return (exp2(x));
-#endif
+ ENTERI();
/*
* Reduce x, computing z, i0, and k. The low bits of x + redux
@@ -269,26 +264,25 @@ exp2l(long double x)
z = x - u.e;
v.xbits.man = 1ULL << 63;
if (k >= LDBL_MIN_EXP) {
- v.xbits.expsign = LDBL_MAX_EXP - 1 + k;
+ v.xbits.expsign = BIAS + k;
twopk = v.e;
} else {
- v.xbits.expsign = LDBL_MAX_EXP - 1 + k + 10000;
+ v.xbits.expsign = BIAS + k + 10000;
twopkp10000 = v.e;
}
/* Compute r = exp2l(y) = exp2lt[i0] * p(z). */
long double t_hi = tbl[i0];
long double t_lo = tbl[i0 + 1];
- /* XXX This gives > 1 ulp errors outside of FE_TONEAREST mode */
- r = t_lo + (t_hi + t_lo) * z * (P1 + z * (P2 + z * (P3 + z * (P4
+ r = t_lo + (t_hi + t_lo) * z * (P1.e + z * (P2 + z * (P3 + z * (P4
+ z * (P5 + z * P6))))) + t_hi;
/* Scale by 2**k. */
if (k >= LDBL_MIN_EXP) {
if (k == LDBL_MAX_EXP)
- return (r * 2.0 * 0x1p16383L);
- return (r * twopk);
+ RETURNI(r * 2.0 * 0x1p16383L);
+ RETURNI(r * twopk);
} else {
- return (r * twopkp10000 * twom10000);
+ RETURNI(r * twopkp10000 * twom10000);
}
}
diff --git a/lib/msun/ld80/s_expl.c b/lib/msun/ld80/s_expl.c
index af6366802ef6..ec748d371b65 100644
--- a/lib/msun/ld80/s_expl.c
+++ b/lib/msun/ld80/s_expl.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2009-2012 Steven G. Kargl
+ * Copyright (c) 2009-2013 Steven G. Kargl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-/*-
+/**
* Compute the exponential of x for Intel 80-bit format. This is based on:
*
* PTP Tang, "Table-driven implementation of the exponential function
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include "math_private.h"
#define INTERVALS 128
+#define LOG2_INTERVALS 7
#define BIAS (LDBL_MAX_EXP - 1)
static const long double
@@ -60,9 +61,12 @@ static volatile const long double tiny = 0x1p-10000L;
static const union IEEEl2bits
/* log(2**16384 - 0.5) rounded towards zero: */
-o_threshold = LD80C(0xb17217f7d1cf79ab, 13, 11356.5234062941439488L),
+/* log(2**16384 - 0.5 + 1) rounded towards zero for expm1l() is the same: */
+o_thresholdu = LD80C(0xb17217f7d1cf79ab, 13, 11356.5234062941439488L),
+#define o_threshold (o_thresholdu.e)
/* log(2**(-16381-64-1)) rounded towards zero: */
-u_threshold = LD80C(0xb21dfe7f09e2baa9, 13, -11399.4985314888605581L);
+u_thresholdu = LD80C(0xb21dfe7f09e2baa9, 13, -11399.4985314888605581L);
+#define u_threshold (u_thresholdu.e)
static const double
/*
@@ -78,11 +82,11 @@ L2 = -3.2819649005320973e-13, /* -0x1718432a1b0e26.0p-94 */
* |exp(x) - p(x)| < 2**-77.2
* (0.002708 is ln2/(2*INTERVALS) rounded up a little).
*/
-P2 = 0.5,
-P3 = 1.6666666666666119e-1, /* 0x15555555555490.0p-55 */
-P4 = 4.1666666666665887e-2, /* 0x155555555554e5.0p-57 */
-P5 = 8.3333354987869413e-3, /* 0x1111115b789919.0p-59 */
-P6 = 1.3888891738560272e-3; /* 0x16c16c651633ae.0p-62 */
+A2 = 0.5,
+A3 = 1.6666666666666119e-1, /* 0x15555555555490.0p-55 */
+A4 = 4.1666666666665887e-2, /* 0x155555555554e5.0p-57 */
+A5 = 8.3333354987869413e-3, /* 0x1111115b789919.0p-59 */
+A6 = 1.3888891738560272e-3; /* 0x16c16c651633ae.0p-62 */
/*
* 2^(i/INTERVALS) for i in [0,INTERVALS] is represented by two values where
@@ -96,8 +100,7 @@ P6 = 1.3888891738560272e-3; /* 0x16c16c651633ae.0p-62 */
static const struct {
double hi;
double lo;
-/* XXX should rename 's'. */
-} s[INTERVALS] = {
+} tbl[INTERVALS] = {
0x1p+0, 0x0p+0,
0x1.0163da9fb3335p+0, 0x1.b61299ab8cdb7p-54,
0x1.02c9a3e778060p+0, 0x1.dcdef95949ef4p-53,
@@ -232,7 +235,8 @@ long double
expl(long double x)
{
union IEEEl2bits u, v;
- long double fn, q, r, r1, r2, t, t23, t45, twopk, twopkp10000, z;
+ long double fn, q, r, r1, r2, t, twopk, twopkp10000;
+ long double z;
int k, n, n2;
uint16_t hx, ix;
@@ -242,40 +246,39 @@ expl(long double x)
ix = hx & 0x7fff;
if (ix >= BIAS + 13) { /* |x| >= 8192 or x is NaN */
if (ix == BIAS + LDBL_MAX_EXP) {
- if (hx & 0x8000 && u.xbits.man == 1ULL << 63)
- return (0.0L); /* x is -Inf */
- return (x + x); /* x is +Inf, NaN or unsupported */
+ if (hx & 0x8000) /* x is -Inf, -NaN or unsupported */
+ return (-1 / x);
+ return (x + x); /* x is +Inf, +NaN or unsupported */
}
- if (x > o_threshold.e)
+ if (x > o_threshold)
return (huge * huge);
- if (x < u_threshold.e)
+ if (x < u_threshold)
return (tiny * tiny);
- } else if (ix < BIAS - 66) { /* |x| < 0x1p-66 */
- /* includes pseudo-denormals */
- if (huge + x > 1.0L) /* trigger inexact iff x != 0 */
- return (1.0L + x);
+ } else if (ix < BIAS - 65) { /* |x| < 0x1p-65 (includes pseudos) */
+ return (1 + x); /* 1 with inexact iff x != 0 */
}
ENTERI();
- /* Reduce x to (k*ln2 + midpoint[n2] + r1 + r2). */
+ /* Reduce x to (k*ln2 + endpoint[n2] + r1 + r2). */
/* Use a specialized rint() to get fn. Assume round-to-nearest. */
fn = x * INV_L + 0x1.8p63 - 0x1.8p63;
r = x - fn * L1 - fn * L2; /* r = r1 + r2 done independently. */
#if defined(HAVE_EFFICIENT_IRINTL)
- n = irintl(fn);
+ n = irintl(fn);
#elif defined(HAVE_EFFICIENT_IRINT)
- n = irint(fn);
+ n = irint(fn);
#else
- n = (int)fn;
+ n = (int)fn;
#endif
n2 = (unsigned)n % INTERVALS;
- k = (n - n2) / INTERVALS;
+ /* Depend on the sign bit being propagated: */
+ k = n >> LOG2_INTERVALS;
r1 = x - fn * L1;
- r2 = -fn * L2;
+ r2 = fn * -L2;
/* Prepare scale factors. */
- v.xbits.man = 1ULL << 63;
+ v.e = 1;
if (k >= LDBL_MIN_EXP) {
v.xbits.expsign = BIAS + k;
twopk = v.e;
@@ -284,21 +287,183 @@ expl(long double x)
twopkp10000 = v.e;
}
- /* Evaluate expl(midpoint[n2] + r1 + r2) = s[n2] * expl(r1 + r2). */
- /* Here q = q(r), not q(r1), since r1 is lopped like L1. */
- t45 = r * P5 + P4;
+ /* Evaluate expl(endpoint[n2] + r1 + r2) = tbl[n2] * expl(r1 + r2). */
z = r * r;
- t23 = r * P3 + P2;
- q = r2 + z * t23 + z * z * t45 + z * z * z * P6;
- t = (long double)s[n2].lo + s[n2].hi;
- t = s[n2].lo + t * (q + r1) + s[n2].hi;
+ q = r2 + z * (A2 + r * A3) + z * z * (A4 + r * A5) + z * z * z * A6;
+ t = (long double)tbl[n2].lo + tbl[n2].hi;
+ t = tbl[n2].lo + t * (q + r1) + tbl[n2].hi;
/* Scale by 2**k. */
if (k >= LDBL_MIN_EXP) {
if (k == LDBL_MAX_EXP)
- RETURNI(t * 2.0L * 0x1p16383L);
+ RETURNI(t * 2 * 0x1p16383L);
RETURNI(t * twopk);
} else {
RETURNI(t * twopkp10000 * twom10000);
}
}
+
+/**
+ * Compute expm1l(x) for Intel 80-bit format. This is based on:
+ *
+ * PTP Tang, "Table-driven implementation of the Expm1 function
+ * in IEEE floating-point arithmetic," ACM Trans. Math. Soft., 18,
+ * 211-222 (1992).
+ */
+
+/*
+ * Our T1 and T2 are chosen to be approximately the points where method
+ * A and method B have the same accuracy. Tang's T1 and T2 are the
+ * points where method A's accuracy changes by a full bit. For Tang,
+ * this drop in accuracy makes method A immediately less accurate than
+ * method B, but our larger INTERVALS makes method A 2 bits more
+ * accurate so it remains the most accurate method significantly
+ * closer to the origin despite losing the full bit in our extended
+ * range for it.
+ */
+static const double
+T1 = -0.1659, /* ~-30.625/128 * log(2) */
+T2 = 0.1659; /* ~30.625/128 * log(2) */
+
+/*
+ * Domain [-0.1659, 0.1659], range ~[-1.2027e-22, 3.4417e-22]:
+ * |(exp(x)-1-x-x**2/2)/x - p(x)| < 2**-71.2
+ */
+static const union IEEEl2bits
+B3 = LD80C(0xaaaaaaaaaaaaaaab, -3, 1.66666666666666666671e-1L),
+B4 = LD80C(0xaaaaaaaaaaaaaaac, -5, 4.16666666666666666712e-2L);
+
+static const double
+B5 = 8.3333333333333245e-3, /* 0x1.111111111110cp-7 */
+B6 = 1.3888888888888861e-3, /* 0x1.6c16c16c16c0ap-10 */
+B7 = 1.9841269841532042e-4, /* 0x1.a01a01a0319f9p-13 */
+B8 = 2.4801587302069236e-5, /* 0x1.a01a01a03cbbcp-16 */
+B9 = 2.7557316558468562e-6, /* 0x1.71de37fd33d67p-19 */
+B10 = 2.7557315829785151e-7, /* 0x1.27e4f91418144p-22 */
+B11 = 2.5063168199779829e-8, /* 0x1.ae94fabdc6b27p-26 */
+B12 = 2.0887164654459567e-9; /* 0x1.1f122d6413fe1p-29 */
+
+long double
+expm1l(long double x)
+{
+ union IEEEl2bits u, v;
+ long double fn, hx2_hi, hx2_lo, q, r, r1, r2, t, twomk, twopk, x_hi;
+ long double x_lo, x2, z;
+ long double x4;
+ int k, n, n2;
+ uint16_t hx, ix;
+
+ /* Filter out exceptional cases. */
+ u.e = x;
+ hx = u.xbits.expsign;
+ ix = hx & 0x7fff;
+ if (ix >= BIAS + 6) { /* |x| >= 64 or x is NaN */
+ if (ix == BIAS + LDBL_MAX_EXP) {
+ if (hx & 0x8000) /* x is -Inf, -NaN or unsupported */
+ return (-1 / x - 1);
+ return (x + x); /* x is +Inf, +NaN or unsupported */
+ }
+ if (x > o_threshold)
+ return (huge * huge);
+ /*
+ * expm1l() never underflows, but it must avoid
+ * unrepresentable large negative exponents. We used a
+ * much smaller threshold for large |x| above than in
+ * expl() so as to handle not so large negative exponents
+ * in the same way as large ones here.
+ */
+ if (hx & 0x8000) /* x <= -64 */
+ return (tiny - 1); /* good for x < -65ln2 - eps */
+ }
+
+ ENTERI();
+
+ if (T1 < x && x < T2) {
+ if (ix < BIAS - 64) { /* |x| < 0x1p-64 (includes pseudos) */
+ /* x (rounded) with inexact if x != 0: */
+ RETURNI(x == 0 ? x :
+ (0x1p100 * x + fabsl(x)) * 0x1p-100);
+ }
+
+ x2 = x * x;
+ x4 = x2 * x2;
+ q = x4 * (x2 * (x4 *
+ /*
+ * XXX the number of terms is no longer good for
+ * pairwise grouping of all except B3, and the
+ * grouping is no longer from highest down.
+ */
+ (x2 * B12 + (x * B11 + B10)) +
+ (x2 * (x * B9 + B8) + (x * B7 + B6))) +
+ (x * B5 + B4.e)) + x2 * x * B3.e;
+
+ x_hi = (float)x;
+ x_lo = x - x_hi;
+ hx2_hi = x_hi * x_hi / 2;
+ hx2_lo = x_lo * (x + x_hi) / 2;
+ if (ix >= BIAS - 7)
+ RETURNI(hx2_lo + x_lo + q + (hx2_hi + x_hi));
+ else
+ RETURNI(hx2_lo + q + hx2_hi + x);
+ }
+
+ /* Reduce x to (k*ln2 + endpoint[n2] + r1 + r2). */
+ /* Use a specialized rint() to get fn. Assume round-to-nearest. */
+ fn = x * INV_L + 0x1.8p63 - 0x1.8p63;
+#if defined(HAVE_EFFICIENT_IRINTL)
+ n = irintl(fn);
+#elif defined(HAVE_EFFICIENT_IRINT)
+ n = irint(fn);
+#else
+ n = (int)fn;
+#endif
+ n2 = (unsigned)n % INTERVALS;
+ k = n >> LOG2_INTERVALS;
+ r1 = x - fn * L1;
+ r2 = fn * -L2;
+ r = r1 + r2;
+
+ /* Prepare scale factor. */
+ v.e = 1;
+ v.xbits.expsign = BIAS + k;
+ twopk = v.e;
+
+ /*
+ * Evaluate lower terms of
+ * expl(endpoint[n2] + r1 + r2) = tbl[n2] * expl(r1 + r2).
+ */
+ z = r * r;
+ q = r2 + z * (A2 + r * A3) + z * z * (A4 + r * A5) + z * z * z * A6;
+
+ t = (long double)tbl[n2].lo + tbl[n2].hi;
+
+ if (k == 0) {
+ t = tbl[n2].lo * (r1 + 1) + t * q + tbl[n2].hi * r1 +
+ (tbl[n2].hi - 1);
+ RETURNI(t);
+ }
+ if (k == -1) {
+ t = tbl[n2].lo * (r1 + 1) + t * q + tbl[n2].hi * r1 +
+ (tbl[n2].hi - 2);
+ RETURNI(t / 2);
+ }
+ if (k < -7) {
+ t = tbl[n2].lo + t * (q + r1) + tbl[n2].hi;
+ RETURNI(t * twopk - 1);
+ }
+ if (k > 2 * LDBL_MANT_DIG - 1) {
+ t = tbl[n2].lo + t * (q + r1) + tbl[n2].hi;
+ if (k == LDBL_MAX_EXP)
+ RETURNI(t * 2 * 0x1p16383L - 1);
+ RETURNI(t * twopk - 1);
+ }
+
+ v.xbits.expsign = BIAS - k;
+ twomk = v.e;
+
+ if (k > LDBL_MANT_DIG - 1)
+ t = tbl[n2].lo - twomk + t * (q + r1) + tbl[n2].hi;
+ else
+ t = tbl[n2].lo + t * (q + r1) + (tbl[n2].hi - twomk);
+ RETURNI(t * twopk);
+}
diff --git a/lib/msun/ld80/s_logl.c b/lib/msun/ld80/s_logl.c
new file mode 100644
index 000000000000..3a35753299b1
--- /dev/null
+++ b/lib/msun/ld80/s_logl.c
@@ -0,0 +1,717 @@
+/*-
+ * Copyright (c) 2007-2013 Bruce D. Evans
+ * 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 unmodified, 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 ``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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/**
+ * Implementation of the natural logarithm of x for Intel 80-bit format.
+ *
+ * First decompose x into its base 2 representation:
+ *
+ * log(x) = log(X * 2**k), where X is in [1, 2)
+ * = log(X) + k * log(2).
+ *
+ * Let X = X_i + e, where X_i is the center of one of the intervals
+ * [-1.0/256, 1.0/256), [1.0/256, 3.0/256), .... [2.0-1.0/256, 2.0+1.0/256)
+ * and X is in this interval. Then
+ *
+ * log(X) = log(X_i + e)
+ * = log(X_i * (1 + e / X_i))
+ * = log(X_i) + log(1 + e / X_i).
+ *
+ * The values log(X_i) are tabulated below. Let d = e / X_i and use
+ *
+ * log(1 + d) = p(d)
+ *
+ * where p(d) = d - 0.5*d*d + ... is a special minimax polynomial of
+ * suitably high degree.
+ *
+ * To get sufficiently small roundoff errors, k * log(2), log(X_i), and
+ * sometimes (if |k| is not large) the first term in p(d) must be evaluated
+ * and added up in extra precision. Extra precision is not needed for the
+ * rest of p(d). In the worst case when k = 0 and log(X_i) is 0, the final
+ * error is controlled mainly by the error in the second term in p(d). The
+ * error in this term itself is at most 0.5 ulps from the d*d operation in
+ * it. The error in this term relative to the first term is thus at most
+ * 0.5 * |-0.5| * |d| < 1.0/1024 ulps. We aim for an accumulated error of
+ * at most twice this at the point of the final rounding step. Thus the
+ * final error should be at most 0.5 + 1.0/512 = 0.5020 ulps. Exhaustive
+ * testing of a float variant of this function showed a maximum final error
+ * of 0.5008 ulps. Non-exhaustive testing of a double variant of this
+ * function showed a maximum final error of 0.5078 ulps (near 1+1.0/256).
+ *
+ * We made the maximum of |d| (and thus the total relative error and the
+ * degree of p(d)) small by using a large number of intervals. Using
+ * centers of intervals instead of endpoints reduces this maximum by a
+ * factor of 2 for a given number of intervals. p(d) is special only
+ * in beginning with the Taylor coefficients 0 + 1*d, which tends to happen
+ * naturally. The most accurate minimax polynomial of a given degree might
+ * be different, but then we wouldn't want it since we would have to do
+ * extra work to avoid roundoff error (especially for P0*d instead of d).
+ */
+
+#ifdef DEBUG
+#include <assert.h>
+#include <fenv.h>
+#endif
+
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#define i386_SSE_GOOD
+#ifndef NO_STRUCT_RETURN
+#define STRUCT_RETURN
+#endif
+#include "math_private.h"
+
+#if !defined(NO_UTAB) && !defined(NO_UTABL)
+#define USE_UTAB
+#endif
+
+/*
+ * Domain [-0.005280, 0.004838], range ~[-5.1736e-22, 5.1738e-22]:
+ * |log(1 + d)/d - p(d)| < 2**-70.7
+ */
+static const double
+P2 = -0.5,
+P3 = 3.3333333333333359e-1, /* 0x1555555555555a.0p-54 */
+P4 = -2.5000000000004424e-1, /* -0x1000000000031d.0p-54 */
+P5 = 1.9999999992970016e-1, /* 0x1999999972f3c7.0p-55 */
+P6 = -1.6666666072191585e-1, /* -0x15555548912c09.0p-55 */
+P7 = 1.4286227413310518e-1, /* 0x12494f9d9def91.0p-55 */
+P8 = -1.2518388626763144e-1; /* -0x1006068cc0b97c.0p-55 */
+
+static volatile const double zero = 0;
+
+#define INTERVALS 128
+#define LOG2_INTERVALS 7
+#define TSIZE (INTERVALS + 1)
+#define G(i) (T[(i)].G)
+#define F_hi(i) (T[(i)].F_hi)
+#define F_lo(i) (T[(i)].F_lo)
+#define ln2_hi F_hi(TSIZE - 1)
+#define ln2_lo F_lo(TSIZE - 1)
+#define E(i) (U[(i)].E)
+#define H(i) (U[(i)].H)
+
+static const struct {
+ float G; /* 1/(1 + i/128) rounded to 8/9 bits */
+ float F_hi; /* log(1 / G_i) rounded (see below) */
+ double F_lo; /* next 53 bits for log(1 / G_i) */
+} T[TSIZE] = {
+ /*
+ * ln2_hi and each F_hi(i) are rounded to a number of bits that
+ * makes F_hi(i) + dk*ln2_hi exact for all i and all dk.
+ *
+ * The last entry (for X just below 2) is used to define ln2_hi
+ * and ln2_lo, to ensure that F_hi(i) and F_lo(i) cancel exactly
+ * with dk*ln2_hi and dk*ln2_lo, respectively, when dk = -1.
+ * This is needed for accuracy when x is just below 1. (To avoid
+ * special cases, such x are "reduced" strangely to X just below
+ * 2 and dk = -1, and then the exact cancellation is needed
+ * because any the error from any non-exactness would be too
+ * large).
+ *
+ * We want to share this table between double precision and ld80,
+ * so the relevant range of dk is the larger one of ld80
+ * ([-16445, 16383]) and the relevant exactness requirement is
+ * the stricter one of double precision. The maximum number of
+ * bits in F_hi(i) that works is very dependent on i but has
+ * a minimum of 33. We only need about 12 bits in F_hi(i) for
+ * it to provide enough extra precision in double precision (11
+ * more than that are required for ld80).
+ *
+ * We round F_hi(i) to 24 bits so that it can have type float,
+ * mainly to minimize the size of the table. Using all 24 bits
+ * in a float for it automatically satisfies the above constraints.
+ */
+ 0x800000.0p-23, 0, 0,
+ 0xfe0000.0p-24, 0x8080ac.0p-30, -0x14ee431dae6675.0p-84,
+ 0xfc0000.0p-24, 0x8102b3.0p-29, -0x1db29ee2d83718.0p-84,
+ 0xfa0000.0p-24, 0xc24929.0p-29, 0x1191957d173698.0p-83,
+ 0xf80000.0p-24, 0x820aec.0p-28, 0x13ce8888e02e79.0p-82,
+ 0xf60000.0p-24, 0xa33577.0p-28, -0x17a4382ce6eb7c.0p-82,
+ 0xf48000.0p-24, 0xbc42cb.0p-28, -0x172a21161a1076.0p-83,
+ 0xf30000.0p-24, 0xd57797.0p-28, -0x1e09de07cb9589.0p-82,
+ 0xf10000.0p-24, 0xf7518e.0p-28, 0x1ae1eec1b036c5.0p-91,
+ 0xef0000.0p-24, 0x8cb9df.0p-27, -0x1d7355325d560e.0p-81,
+ 0xed8000.0p-24, 0x999ec0.0p-27, -0x1f9f02d256d503.0p-82,
+ 0xec0000.0p-24, 0xa6988b.0p-27, -0x16fc0a9d12c17a.0p-83,
+ 0xea0000.0p-24, 0xb80698.0p-27, 0x15d581c1e8da9a.0p-81,
+ 0xe80000.0p-24, 0xc99af3.0p-27, -0x1535b3ba8f150b.0p-83,
+ 0xe70000.0p-24, 0xd273b2.0p-27, 0x163786f5251af0.0p-85,
+ 0xe50000.0p-24, 0xe442c0.0p-27, 0x1bc4b2368e32d5.0p-84,
+ 0xe38000.0p-24, 0xf1b83f.0p-27, 0x1c6090f684e676.0p-81,
+ 0xe20000.0p-24, 0xff448a.0p-27, -0x1890aa69ac9f42.0p-82,
+ 0xe08000.0p-24, 0x8673f6.0p-26, 0x1b9985194b6b00.0p-80,
+ 0xdf0000.0p-24, 0x8d515c.0p-26, -0x1dc08d61c6ef1e.0p-83,
+ 0xdd8000.0p-24, 0x943a9e.0p-26, -0x1f72a2dac729b4.0p-82,
+ 0xdc0000.0p-24, 0x9b2fe6.0p-26, -0x1fd4dfd3a0afb9.0p-80,
+ 0xda8000.0p-24, 0xa2315d.0p-26, -0x11b26121629c47.0p-82,
+ 0xd90000.0p-24, 0xa93f2f.0p-26, 0x1286d633e8e569.0p-81,
+ 0xd78000.0p-24, 0xb05988.0p-26, 0x16128eba936770.0p-84,
+ 0xd60000.0p-24, 0xb78094.0p-26, 0x16ead577390d32.0p-80,
+ 0xd50000.0p-24, 0xbc4c6c.0p-26, 0x151131ccf7c7b7.0p-81,
+ 0xd38000.0p-24, 0xc3890a.0p-26, -0x115e2cd714bd06.0p-80,
+ 0xd20000.0p-24, 0xcad2d7.0p-26, -0x1847f406ebd3b0.0p-82,
+ 0xd10000.0p-24, 0xcfb620.0p-26, 0x1c2259904d6866.0p-81,
+ 0xcf8000.0p-24, 0xd71653.0p-26, 0x1ece57a8d5ae55.0p-80,
+ 0xce0000.0p-24, 0xde843a.0p-26, -0x1f109d4bc45954.0p-81,
+ 0xcd0000.0p-24, 0xe37fde.0p-26, 0x1bc03dc271a74d.0p-81,
+ 0xcb8000.0p-24, 0xeb050c.0p-26, -0x1bf2badc0df842.0p-85,
+ 0xca0000.0p-24, 0xf29878.0p-26, -0x18efededd89fbe.0p-87,
+ 0xc90000.0p-24, 0xf7ad6f.0p-26, 0x1373ff977baa69.0p-81,
+ 0xc80000.0p-24, 0xfcc8e3.0p-26, 0x196766f2fb3283.0p-80,
+ 0xc68000.0p-24, 0x823f30.0p-25, 0x19bd076f7c434e.0p-79,
+ 0xc58000.0p-24, 0x84d52c.0p-25, -0x1a327257af0f46.0p-79,
+ 0xc40000.0p-24, 0x88bc74.0p-25, 0x113f23def19c5a.0p-81,
+ 0xc30000.0p-24, 0x8b5ae6.0p-25, 0x1759f6e6b37de9.0p-79,
+ 0xc20000.0p-24, 0x8dfccb.0p-25, 0x1ad35ca6ed5148.0p-81,
+ 0xc10000.0p-24, 0x90a22b.0p-25, 0x1a1d71a87deba4.0p-79,
+ 0xbf8000.0p-24, 0x94a0d8.0p-25, -0x139e5210c2b731.0p-80,
+ 0xbe8000.0p-24, 0x974f16.0p-25, -0x18f6ebcff3ed73.0p-81,
+ 0xbd8000.0p-24, 0x9a00f1.0p-25, -0x1aa268be39aab7.0p-79,
+ 0xbc8000.0p-24, 0x9cb672.0p-25, -0x14c8815839c566.0p-79,
+ 0xbb0000.0p-24, 0xa0cda1.0p-25, 0x1eaf46390dbb24.0p-81,
+ 0xba0000.0p-24, 0xa38c6e.0p-25, 0x138e20d831f698.0p-81,
+ 0xb90000.0p-24, 0xa64f05.0p-25, -0x1e8d3c41123616.0p-82,
+ 0xb80000.0p-24, 0xa91570.0p-25, 0x1ce28f5f3840b2.0p-80,
+ 0xb70000.0p-24, 0xabdfbb.0p-25, -0x186e5c0a424234.0p-79,
+ 0xb60000.0p-24, 0xaeadef.0p-25, -0x14d41a0b2a08a4.0p-83,
+ 0xb50000.0p-24, 0xb18018.0p-25, 0x16755892770634.0p-79,
+ 0xb40000.0p-24, 0xb45642.0p-25, -0x16395ebe59b152.0p-82,
+ 0xb30000.0p-24, 0xb73077.0p-25, 0x1abc65c8595f09.0p-80,
+ 0xb20000.0p-24, 0xba0ec4.0p-25, -0x1273089d3dad89.0p-79,
+ 0xb10000.0p-24, 0xbcf133.0p-25, 0x10f9f67b1f4bbf.0p-79,
+ 0xb00000.0p-24, 0xbfd7d2.0p-25, -0x109fab90486409.0p-80,
+ 0xaf0000.0p-24, 0xc2c2ac.0p-25, -0x1124680aa43333.0p-79,
+ 0xae8000.0p-24, 0xc439b3.0p-25, -0x1f360cc4710fc0.0p-80,
+ 0xad8000.0p-24, 0xc72afd.0p-25, -0x132d91f21d89c9.0p-80,
+ 0xac8000.0p-24, 0xca20a2.0p-25, -0x16bf9b4d1f8da8.0p-79,
+ 0xab8000.0p-24, 0xcd1aae.0p-25, 0x19deb5ce6a6a87.0p-81,
+ 0xaa8000.0p-24, 0xd0192f.0p-25, 0x1a29fb48f7d3cb.0p-79,
+ 0xaa0000.0p-24, 0xd19a20.0p-25, 0x1127d3c6457f9d.0p-81,
+ 0xa90000.0p-24, 0xd49f6a.0p-25, -0x1ba930e486a0ac.0p-81,
+ 0xa80000.0p-24, 0xd7a94b.0p-25, -0x1b6e645f31549e.0p-79,
+ 0xa70000.0p-24, 0xdab7d0.0p-25, 0x1118a425494b61.0p-80,
+ 0xa68000.0p-24, 0xdc40d5.0p-25, 0x1966f24d29d3a3.0p-80,
+ 0xa58000.0p-24, 0xdf566d.0p-25, -0x1d8e52eb2248f1.0p-82,
+ 0xa48000.0p-24, 0xe270ce.0p-25, -0x1ee370f96e6b68.0p-80,
+ 0xa40000.0p-24, 0xe3ffce.0p-25, 0x1d155324911f57.0p-80,
+ 0xa30000.0p-24, 0xe72179.0p-25, -0x1fe6e2f2f867d9.0p-80,
+ 0xa20000.0p-24, 0xea4812.0p-25, 0x1b7be9add7f4d4.0p-80,
+ 0xa18000.0p-24, 0xebdd3d.0p-25, 0x1b3cfb3f7511dd.0p-79,
+ 0xa08000.0p-24, 0xef0b5b.0p-25, -0x1220de1f730190.0p-79,
+ 0xa00000.0p-24, 0xf0a451.0p-25, -0x176364c9ac81cd.0p-80,
+ 0x9f0000.0p-24, 0xf3da16.0p-25, 0x1eed6b9aafac8d.0p-81,
+ 0x9e8000.0p-24, 0xf576e9.0p-25, 0x1d593218675af2.0p-79,
+ 0x9d8000.0p-24, 0xf8b47c.0p-25, -0x13e8eb7da053e0.0p-84,
+ 0x9d0000.0p-24, 0xfa553f.0p-25, 0x1c063259bcade0.0p-79,
+ 0x9c0000.0p-24, 0xfd9ac5.0p-25, 0x1ef491085fa3c1.0p-79,
+ 0x9b8000.0p-24, 0xff3f8c.0p-25, 0x1d607a7c2b8c53.0p-79,
+ 0x9a8000.0p-24, 0x814697.0p-24, -0x12ad3817004f3f.0p-78,
+ 0x9a0000.0p-24, 0x821b06.0p-24, -0x189fc53117f9e5.0p-81,
+ 0x990000.0p-24, 0x83c5f8.0p-24, 0x14cf15a048907b.0p-79,
+ 0x988000.0p-24, 0x849c7d.0p-24, 0x1cbb1d35fb8287.0p-78,
+ 0x978000.0p-24, 0x864ba6.0p-24, 0x1128639b814f9c.0p-78,
+ 0x970000.0p-24, 0x87244c.0p-24, 0x184733853300f0.0p-79,
+ 0x968000.0p-24, 0x87fdaa.0p-24, 0x109d23aef77dd6.0p-80,
+ 0x958000.0p-24, 0x89b293.0p-24, -0x1a81ef367a59de.0p-78,
+ 0x950000.0p-24, 0x8a8e20.0p-24, -0x121ad3dbb2f452.0p-78,
+ 0x948000.0p-24, 0x8b6a6a.0p-24, -0x1cfb981628af72.0p-79,
+ 0x938000.0p-24, 0x8d253a.0p-24, -0x1d21730ea76cfe.0p-79,
+ 0x930000.0p-24, 0x8e03c2.0p-24, 0x135cc00e566f77.0p-78,
+ 0x928000.0p-24, 0x8ee30d.0p-24, -0x10fcb5df257a26.0p-80,
+ 0x918000.0p-24, 0x90a3ee.0p-24, -0x16e171b15433d7.0p-79,
+ 0x910000.0p-24, 0x918587.0p-24, -0x1d050da07f3237.0p-79,
+ 0x908000.0p-24, 0x9267e7.0p-24, 0x1be03669a5268d.0p-79,
+ 0x8f8000.0p-24, 0x942f04.0p-24, 0x10b28e0e26c337.0p-79,
+ 0x8f0000.0p-24, 0x9513c3.0p-24, 0x1a1d820da57cf3.0p-78,
+ 0x8e8000.0p-24, 0x95f950.0p-24, -0x19ef8f13ae3cf1.0p-79,
+ 0x8e0000.0p-24, 0x96dfab.0p-24, -0x109e417a6e507c.0p-78,
+ 0x8d0000.0p-24, 0x98aed2.0p-24, 0x10d01a2c5b0e98.0p-79,
+ 0x8c8000.0p-24, 0x9997a2.0p-24, -0x1d6a50d4b61ea7.0p-78,
+ 0x8c0000.0p-24, 0x9a8145.0p-24, 0x1b3b190b83f952.0p-78,
+ 0x8b8000.0p-24, 0x9b6bbf.0p-24, 0x13a69fad7e7abe.0p-78,
+ 0x8b0000.0p-24, 0x9c5711.0p-24, -0x11cd12316f576b.0p-78,
+ 0x8a8000.0p-24, 0x9d433b.0p-24, 0x1c95c444b807a2.0p-79,
+ 0x898000.0p-24, 0x9f1e22.0p-24, -0x1b9c224ea698c3.0p-79,
+ 0x890000.0p-24, 0xa00ce1.0p-24, 0x125ca93186cf0f.0p-81,
+ 0x888000.0p-24, 0xa0fc80.0p-24, -0x1ee38a7bc228b3.0p-79,
+ 0x880000.0p-24, 0xa1ed00.0p-24, -0x1a0db876613d20.0p-78,
+ 0x878000.0p-24, 0xa2de62.0p-24, 0x193224e8516c01.0p-79,
+ 0x870000.0p-24, 0xa3d0a9.0p-24, 0x1fa28b4d2541ad.0p-79,
+ 0x868000.0p-24, 0xa4c3d6.0p-24, 0x1c1b5760fb4572.0p-78,
+ 0x858000.0p-24, 0xa6acea.0p-24, 0x1fed5d0f65949c.0p-80,
+ 0x850000.0p-24, 0xa7a2d4.0p-24, 0x1ad270c9d74936.0p-80,
+ 0x848000.0p-24, 0xa899ab.0p-24, 0x199ff15ce53266.0p-79,
+ 0x840000.0p-24, 0xa99171.0p-24, 0x1a19e15ccc45d2.0p-79,
+ 0x838000.0p-24, 0xaa8a28.0p-24, -0x121a14ec532b36.0p-80,
+ 0x830000.0p-24, 0xab83d1.0p-24, 0x1aee319980bff3.0p-79,
+ 0x828000.0p-24, 0xac7e6f.0p-24, -0x18ffd9e3900346.0p-80,
+ 0x820000.0p-24, 0xad7a03.0p-24, -0x1e4db102ce29f8.0p-80,
+ 0x818000.0p-24, 0xae768f.0p-24, 0x17c35c55a04a83.0p-81,
+ 0x810000.0p-24, 0xaf7415.0p-24, 0x1448324047019b.0p-78,
+ 0x808000.0p-24, 0xb07298.0p-24, -0x1750ee3915a198.0p-78,
+ 0x800000.0p-24, 0xb17218.0p-24, -0x105c610ca86c39.0p-81,
+};
+
+#ifdef USE_UTAB
+static const struct {
+ float H; /* 1 + i/INTERVALS (exact) */
+ float E; /* H(i) * G(i) - 1 (exact) */
+} U[TSIZE] = {
+ 0x800000.0p-23, 0,
+ 0x810000.0p-23, -0x800000.0p-37,
+ 0x820000.0p-23, -0x800000.0p-35,
+ 0x830000.0p-23, -0x900000.0p-34,
+ 0x840000.0p-23, -0x800000.0p-33,
+ 0x850000.0p-23, -0xc80000.0p-33,
+ 0x860000.0p-23, -0xa00000.0p-36,
+ 0x870000.0p-23, 0x940000.0p-33,
+ 0x880000.0p-23, 0x800000.0p-35,
+ 0x890000.0p-23, -0xc80000.0p-34,
+ 0x8a0000.0p-23, 0xe00000.0p-36,
+ 0x8b0000.0p-23, 0x900000.0p-33,
+ 0x8c0000.0p-23, -0x800000.0p-35,
+ 0x8d0000.0p-23, -0xe00000.0p-33,
+ 0x8e0000.0p-23, 0x880000.0p-33,
+ 0x8f0000.0p-23, -0xa80000.0p-34,
+ 0x900000.0p-23, -0x800000.0p-35,
+ 0x910000.0p-23, 0x800000.0p-37,
+ 0x920000.0p-23, 0x900000.0p-35,
+ 0x930000.0p-23, 0xd00000.0p-35,
+ 0x940000.0p-23, 0xe00000.0p-35,
+ 0x950000.0p-23, 0xc00000.0p-35,
+ 0x960000.0p-23, 0xe00000.0p-36,
+ 0x970000.0p-23, -0x800000.0p-38,
+ 0x980000.0p-23, -0xc00000.0p-35,
+ 0x990000.0p-23, -0xd00000.0p-34,
+ 0x9a0000.0p-23, 0x880000.0p-33,
+ 0x9b0000.0p-23, 0xe80000.0p-35,
+ 0x9c0000.0p-23, -0x800000.0p-35,
+ 0x9d0000.0p-23, 0xb40000.0p-33,
+ 0x9e0000.0p-23, 0x880000.0p-34,
+ 0x9f0000.0p-23, -0xe00000.0p-35,
+ 0xa00000.0p-23, 0x800000.0p-33,
+ 0xa10000.0p-23, -0x900000.0p-36,
+ 0xa20000.0p-23, -0xb00000.0p-33,
+ 0xa30000.0p-23, -0xa00000.0p-36,
+ 0xa40000.0p-23, 0x800000.0p-33,
+ 0xa50000.0p-23, -0xf80000.0p-35,
+ 0xa60000.0p-23, 0x880000.0p-34,
+ 0xa70000.0p-23, -0x900000.0p-33,
+ 0xa80000.0p-23, -0x800000.0p-35,
+ 0xa90000.0p-23, 0x900000.0p-34,
+ 0xaa0000.0p-23, 0xa80000.0p-33,
+ 0xab0000.0p-23, -0xac0000.0p-34,
+ 0xac0000.0p-23, -0x800000.0p-37,
+ 0xad0000.0p-23, 0xf80000.0p-35,
+ 0xae0000.0p-23, 0xf80000.0p-34,
+ 0xaf0000.0p-23, -0xac0000.0p-33,
+ 0xb00000.0p-23, -0x800000.0p-33,
+ 0xb10000.0p-23, -0xb80000.0p-34,
+ 0xb20000.0p-23, -0x800000.0p-34,
+ 0xb30000.0p-23, -0xb00000.0p-35,
+ 0xb40000.0p-23, -0x800000.0p-35,
+ 0xb50000.0p-23, -0xe00000.0p-36,
+ 0xb60000.0p-23, -0x800000.0p-35,
+ 0xb70000.0p-23, -0xb00000.0p-35,
+ 0xb80000.0p-23, -0x800000.0p-34,
+ 0xb90000.0p-23, -0xb80000.0p-34,
+ 0xba0000.0p-23, -0x800000.0p-33,
+ 0xbb0000.0p-23, -0xac0000.0p-33,
+ 0xbc0000.0p-23, 0x980000.0p-33,
+ 0xbd0000.0p-23, 0xbc0000.0p-34,
+ 0xbe0000.0p-23, 0xe00000.0p-36,
+ 0xbf0000.0p-23, -0xb80000.0p-35,
+ 0xc00000.0p-23, -0x800000.0p-33,
+ 0xc10000.0p-23, 0xa80000.0p-33,
+ 0xc20000.0p-23, 0x900000.0p-34,
+ 0xc30000.0p-23, -0x800000.0p-35,
+ 0xc40000.0p-23, -0x900000.0p-33,
+ 0xc50000.0p-23, 0x820000.0p-33,
+ 0xc60000.0p-23, 0x800000.0p-38,
+ 0xc70000.0p-23, -0x820000.0p-33,
+ 0xc80000.0p-23, 0x800000.0p-33,
+ 0xc90000.0p-23, -0xa00000.0p-36,
+ 0xca0000.0p-23, -0xb00000.0p-33,
+ 0xcb0000.0p-23, 0x840000.0p-34,
+ 0xcc0000.0p-23, -0xd00000.0p-34,
+ 0xcd0000.0p-23, 0x800000.0p-33,
+ 0xce0000.0p-23, -0xe00000.0p-35,
+ 0xcf0000.0p-23, 0xa60000.0p-33,
+ 0xd00000.0p-23, -0x800000.0p-35,
+ 0xd10000.0p-23, 0xb40000.0p-33,
+ 0xd20000.0p-23, -0x800000.0p-35,
+ 0xd30000.0p-23, 0xaa0000.0p-33,
+ 0xd40000.0p-23, -0xe00000.0p-35,
+ 0xd50000.0p-23, 0x880000.0p-33,
+ 0xd60000.0p-23, -0xd00000.0p-34,
+ 0xd70000.0p-23, 0x9c0000.0p-34,
+ 0xd80000.0p-23, -0xb00000.0p-33,
+ 0xd90000.0p-23, -0x800000.0p-38,
+ 0xda0000.0p-23, 0xa40000.0p-33,
+ 0xdb0000.0p-23, -0xdc0000.0p-34,
+ 0xdc0000.0p-23, 0xc00000.0p-35,
+ 0xdd0000.0p-23, 0xca0000.0p-33,
+ 0xde0000.0p-23, -0xb80000.0p-34,
+ 0xdf0000.0p-23, 0xd00000.0p-35,
+ 0xe00000.0p-23, 0xc00000.0p-33,
+ 0xe10000.0p-23, -0xf40000.0p-34,
+ 0xe20000.0p-23, 0x800000.0p-37,
+ 0xe30000.0p-23, 0x860000.0p-33,
+ 0xe40000.0p-23, -0xc80000.0p-33,
+ 0xe50000.0p-23, -0xa80000.0p-34,
+ 0xe60000.0p-23, 0xe00000.0p-36,
+ 0xe70000.0p-23, 0x880000.0p-33,
+ 0xe80000.0p-23, -0xe00000.0p-33,
+ 0xe90000.0p-23, -0xfc0000.0p-34,
+ 0xea0000.0p-23, -0x800000.0p-35,
+ 0xeb0000.0p-23, 0xe80000.0p-35,
+ 0xec0000.0p-23, 0x900000.0p-33,
+ 0xed0000.0p-23, 0xe20000.0p-33,
+ 0xee0000.0p-23, -0xac0000.0p-33,
+ 0xef0000.0p-23, -0xc80000.0p-34,
+ 0xf00000.0p-23, -0x800000.0p-35,
+ 0xf10000.0p-23, 0x800000.0p-35,
+ 0xf20000.0p-23, 0xb80000.0p-34,
+ 0xf30000.0p-23, 0x940000.0p-33,
+ 0xf40000.0p-23, 0xc80000.0p-33,
+ 0xf50000.0p-23, -0xf20000.0p-33,
+ 0xf60000.0p-23, -0xc80000.0p-33,
+ 0xf70000.0p-23, -0xa20000.0p-33,
+ 0xf80000.0p-23, -0x800000.0p-33,
+ 0xf90000.0p-23, -0xc40000.0p-34,
+ 0xfa0000.0p-23, -0x900000.0p-34,
+ 0xfb0000.0p-23, -0xc80000.0p-35,
+ 0xfc0000.0p-23, -0x800000.0p-35,
+ 0xfd0000.0p-23, -0x900000.0p-36,
+ 0xfe0000.0p-23, -0x800000.0p-37,
+ 0xff0000.0p-23, -0x800000.0p-39,
+ 0x800000.0p-22, 0,
+};
+#endif /* USE_UTAB */
+
+#ifdef STRUCT_RETURN
+#define RETURN1(rp, v) do { \
+ (rp)->hi = (v); \
+ (rp)->lo_set = 0; \
+ return; \
+} while (0)
+
+#define RETURN2(rp, h, l) do { \
+ (rp)->hi = (h); \
+ (rp)->lo = (l); \
+ (rp)->lo_set = 1; \
+ return; \
+} while (0)
+
+struct ld {
+ long double hi;
+ long double lo;
+ int lo_set;
+};
+#else
+#define RETURN1(rp, v) RETURNF(v)
+#define RETURN2(rp, h, l) RETURNI((h) + (l))
+#endif
+
+#ifdef STRUCT_RETURN
+static inline __always_inline void
+k_logl(long double x, struct ld *rp)
+#else
+long double
+logl(long double x)
+#endif
+{
+ long double d, dk, val_hi, val_lo, z;
+ uint64_t ix, lx;
+ int i, k;
+ uint16_t hx;
+
+ EXTRACT_LDBL80_WORDS(hx, lx, x);
+ k = -16383;
+#if 0 /* Hard to do efficiently. Don't do it until we support all modes. */
+ if (x == 1)
+ RETURN1(rp, 0); /* log(1) = +0 in all rounding modes */
+#endif
+ if (hx == 0 || hx >= 0x8000) { /* zero, negative or subnormal? */
+ if (((hx & 0x7fff) | lx) == 0)
+ RETURN1(rp, -1 / zero); /* log(+-0) = -Inf */
+ if (hx != 0)
+ /* log(neg or [pseudo-]NaN) = qNaN: */
+ RETURN1(rp, (x - x) / zero);
+ x *= 0x1.0p65; /* subnormal; scale up x */
+ /* including pseudo-subnormals */
+ EXTRACT_LDBL80_WORDS(hx, lx, x);
+ k = -16383 - 65;
+ } else if (hx >= 0x7fff || (lx & 0x8000000000000000ULL) == 0)
+ RETURN1(rp, x + x); /* log(Inf or NaN) = Inf or qNaN */
+ /* log(pseudo-Inf) = qNaN */
+ /* log(pseudo-NaN) = qNaN */
+ /* log(unnormal) = qNaN */
+#ifndef STRUCT_RETURN
+ ENTERI();
+#endif
+ k += hx;
+ ix = lx & 0x7fffffffffffffffULL;
+ dk = k;
+
+ /* Scale x to be in [1, 2). */
+ SET_LDBL_EXPSIGN(x, 0x3fff);
+
+ /* 0 <= i <= INTERVALS: */
+#define L2I (64 - LOG2_INTERVALS)
+ i = (ix + (1LL << (L2I - 2))) >> (L2I - 1);
+
+ /*
+ * -0.005280 < d < 0.004838. In particular, the infinite-
+ * precision |d| is <= 2**-7. Rounding of G(i) to 8 bits
+ * ensures that d is representable without extra precision for
+ * this bound on |d| (since when this calculation is expressed
+ * as x*G(i)-1, the multiplication needs as many extra bits as
+ * G(i) has and the subtraction cancels 8 bits). But for
+ * most i (107 cases out of 129), the infinite-precision |d|
+ * is <= 2**-8. G(i) is rounded to 9 bits for such i to give
+ * better accuracy (this works by improving the bound on |d|,
+ * which in turn allows rounding to 9 bits in more cases).
+ * This is only important when the original x is near 1 -- it
+ * lets us avoid using a special method to give the desired
+ * accuracy for such x.
+ */
+ if (0)
+ d = x * G(i) - 1;
+ else {
+#ifdef USE_UTAB
+ d = (x - H(i)) * G(i) + E(i);
+#else
+ long double x_hi, x_lo;
+ float fx_hi;
+
+ /*
+ * Split x into x_hi + x_lo to calculate x*G(i)-1 exactly.
+ * G(i) has at most 9 bits, so the splitting point is not
+ * critical.
+ */
+ SET_FLOAT_WORD(fx_hi, (lx >> 40) | 0x3f800000);
+ x_hi = fx_hi;
+ x_lo = x - x_hi;
+ d = x_hi * G(i) - 1 + x_lo * G(i);
+#endif
+ }
+
+ /*
+ * Our algorithm depends on exact cancellation of F_lo(i) and
+ * F_hi(i) with dk*ln_2_lo and dk*ln2_hi when k is -1 and i is
+ * at the end of the table. This and other technical complications
+ * make it difficult to avoid the double scaling in (dk*ln2) *
+ * log(base) for base != e without losing more accuracy and/or
+ * efficiency than is gained.
+ */
+ z = d * d;
+ val_lo = z * d * z * (z * (d * P8 + P7) + (d * P6 + P5)) +
+ (F_lo(i) + dk * ln2_lo + z * d * (d * P4 + P3)) + z * P2;
+ val_hi = d;
+#ifdef DEBUG
+ if (fetestexcept(FE_UNDERFLOW))
+ breakpoint();
+#endif
+
+ _3sumF(val_hi, val_lo, F_hi(i) + dk * ln2_hi);
+ RETURN2(rp, val_hi, val_lo);
+}
+
+long double
+log1pl(long double x)
+{
+ long double d, d_hi, d_lo, dk, f_lo, val_hi, val_lo, z;
+ long double f_hi, twopminusk;
+ uint64_t ix, lx;
+ int i, k;
+ int16_t ax, hx;
+
+ DOPRINT_START(&x);
+ EXTRACT_LDBL80_WORDS(hx, lx, x);
+ if (hx < 0x3fff) { /* x < 1, or x neg NaN */
+ ax = hx & 0x7fff;
+ if (ax >= 0x3fff) { /* x <= -1, or x neg NaN */
+ if (ax == 0x3fff && lx == 0x8000000000000000ULL)
+ RETURNP(-1 / zero); /* log1p(-1) = -Inf */
+ /* log1p(x < 1, or x [pseudo-]NaN) = qNaN: */
+ RETURNP((x - x) / (x - x));
+ }
+ if (ax <= 0x3fbe) { /* |x| < 2**-64 */
+ if ((int)x == 0)
+ RETURNP(x); /* x with inexact if x != 0 */
+ }
+ f_hi = 1;
+ f_lo = x;
+ } else if (hx >= 0x7fff) { /* x +Inf or non-neg NaN */
+ RETURNP(x + x); /* log1p(Inf or NaN) = Inf or qNaN */
+ /* log1p(pseudo-Inf) = qNaN */
+ /* log1p(pseudo-NaN) = qNaN */
+ /* log1p(unnormal) = qNaN */
+ } else if (hx < 0x407f) { /* 1 <= x < 2**128 */
+ f_hi = x;
+ f_lo = 1;
+ } else { /* 2**128 <= x < +Inf */
+ f_hi = x;
+ f_lo = 0; /* avoid underflow of the P5 term */
+ }
+ ENTERI();
+ x = f_hi + f_lo;
+ f_lo = (f_hi - x) + f_lo;
+
+ EXTRACT_LDBL80_WORDS(hx, lx, x);
+ k = -16383;
+
+ k += hx;
+ ix = lx & 0x7fffffffffffffffULL;
+ dk = k;
+
+ SET_LDBL_EXPSIGN(x, 0x3fff);
+ twopminusk = 1;
+ SET_LDBL_EXPSIGN(twopminusk, 0x7ffe - (hx & 0x7fff));
+ f_lo *= twopminusk;
+
+ i = (ix + (1LL << (L2I - 2))) >> (L2I - 1);
+
+ /*
+ * x*G(i)-1 (with a reduced x) can be represented exactly, as
+ * above, but now we need to evaluate the polynomial on d =
+ * (x+f_lo)*G(i)-1 and extra precision is needed for that.
+ * Since x+x_lo is a hi+lo decomposition and subtracting 1
+ * doesn't lose too many bits, an inexact calculation for
+ * f_lo*G(i) is good enough.
+ */
+ if (0)
+ d_hi = x * G(i) - 1;
+ else {
+#ifdef USE_UTAB
+ d_hi = (x - H(i)) * G(i) + E(i);
+#else
+ long double x_hi, x_lo;
+ float fx_hi;
+
+ SET_FLOAT_WORD(fx_hi, (lx >> 40) | 0x3f800000);
+ x_hi = fx_hi;
+ x_lo = x - x_hi;
+ d_hi = x_hi * G(i) - 1 + x_lo * G(i);
+#endif
+ }
+ d_lo = f_lo * G(i);
+
+ /*
+ * This is _2sumF(d_hi, d_lo) inlined. The condition
+ * (d_hi == 0 || |d_hi| >= |d_lo|) for using _2sumF() is not
+ * always satisifed, so it is not clear that this works, but
+ * it works in practice. It works even if it gives a wrong
+ * normalized d_lo, since |d_lo| > |d_hi| implies that i is
+ * nonzero and d is tiny, so the F(i) term dominates d_lo.
+ * In float precision:
+ * (By exhaustive testing, the worst case is d_hi = 0x1.bp-25.
+ * And if d is only a little tinier than that, we would have
+ * another underflow problem for the P3 term; this is also ruled
+ * out by exhaustive testing.)
+ */
+ d = d_hi + d_lo;
+ d_lo = d_hi - d + d_lo;
+ d_hi = d;
+
+ z = d * d;
+ val_lo = z * d * z * (z * (d * P8 + P7) + (d * P6 + P5)) +
+ (F_lo(i) + dk * ln2_lo + d_lo + z * d * (d * P4 + P3)) + z * P2;
+ val_hi = d_hi;
+#ifdef DEBUG
+ if (fetestexcept(FE_UNDERFLOW))
+ breakpoint();
+#endif
+
+ _3sumF(val_hi, val_lo, F_hi(i) + dk * ln2_hi);
+ RETURN2PI(val_hi, val_lo);
+}
+
+#ifdef STRUCT_RETURN
+
+long double
+logl(long double x)
+{
+ struct ld r;
+
+ ENTERI();
+ DOPRINT_START(&x);
+ k_logl(x, &r);
+ RETURNSPI(&r);
+}
+
+static const double
+invln10_hi = 4.3429448190317999e-1, /* 0x1bcb7b1526e000.0p-54 */
+invln10_lo = 7.1842412889749798e-14, /* 0x1438ca9aadd558.0p-96 */
+invln2_hi = 1.4426950408887933e0, /* 0x171547652b8000.0p-52 */
+invln2_lo = 1.7010652264631490e-13; /* 0x17f0bbbe87fed0.0p-95 */
+
+long double
+log10l(long double x)
+{
+ struct ld r;
+ long double hi, lo;
+
+ ENTERI();
+ DOPRINT_START(&x);
+ k_logl(x, &r);
+ if (!r.lo_set)
+ RETURNPI(r.hi);
+ _2sumF(r.hi, r.lo);
+ hi = (float)r.hi;
+ lo = r.lo + (r.hi - hi);
+ RETURN2PI(invln10_hi * hi,
+ (invln10_lo + invln10_hi) * lo + invln10_lo * hi);
+}
+
+long double
+log2l(long double x)
+{
+ struct ld r;
+ long double hi, lo;
+
+ ENTERI();
+ DOPRINT_START(&x);
+ k_logl(x, &r);
+ if (!r.lo_set)
+ RETURNPI(r.hi);
+ _2sumF(r.hi, r.lo);
+ hi = (float)r.hi;
+ lo = r.lo + (r.hi - hi);
+ RETURN2PI(invln2_hi * hi,
+ (invln2_lo + invln2_hi) * lo + invln2_lo * hi);
+}
+
+#endif /* STRUCT_RETURN */
diff --git a/lib/msun/man/acosh.3 b/lib/msun/man/acosh.3
index cd04bb78cfce..b32c2ea259a1 100644
--- a/lib/msun/man/acosh.3
+++ b/lib/msun/man/acosh.3
@@ -28,12 +28,13 @@
.\" from: @(#)acosh.3 5.2 (Berkeley) 5/6/91
.\" $FreeBSD$
.\"
-.Dd January 14, 2005
+.Dd June 9, 2013
.Dt ACOSH 3
.Os
.Sh NAME
.Nm acosh ,
-.Nm acoshf
+.Nm acoshf ,
+.Nm acoshl
.Nd inverse hyperbolic cosine functions
.Sh LIBRARY
.Lb libm
@@ -43,11 +44,14 @@
.Fn acosh "double x"
.Ft float
.Fn acoshf "float x"
+.Ft long double
+.Fn acoshl "long double x"
.Sh DESCRIPTION
The
-.Fn acosh
-and the
-.Fn acoshf
+.Fn acosh ,
+.Fn acoshf ,
+and
+.Fn acoshl
functions compute the inverse hyperbolic cosine
of the real
argument
@@ -55,11 +59,7 @@ argument
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
-The
-.Fn acosh
-and the
-.Fn acoshf
-functions
+These functions
return the inverse hyperbolic cosine of
.Ar x .
If the argument is less than 1,
@@ -73,6 +73,13 @@ raises an invalid exception and returns an \*(Na.
.Xr math 3
.Sh HISTORY
The
-.Fn acosh
-function appeared in
-.Bx 4.3 .
+.Fn acosh ,
+.Fn acoshf ,
+and
+.Fn acoshl
+functions appeared in
+.Bx 4.3 ,
+.Fx 2.0 ,
+and
+.Fx 10.0 ,
+respectively.
diff --git a/lib/msun/man/asinh.3 b/lib/msun/man/asinh.3
index 6dba2176bf82..bab8da6932b8 100644
--- a/lib/msun/man/asinh.3
+++ b/lib/msun/man/asinh.3
@@ -28,12 +28,13 @@
.\" from: @(#)asinh.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD$
.\"
-.Dd May 6, 1991
+.Dd June 9, 2013
.Dt ASINH 3
.Os
.Sh NAME
.Nm asinh ,
-.Nm asinhf
+.Nm asinhf ,
+.Nm asinhl
.Nd inverse hyperbolic sine functions
.Sh LIBRARY
.Lb libm
@@ -43,11 +44,14 @@
.Fn asinh "double x"
.Ft float
.Fn asinhf "float x"
+.Ft long double
+.Fn asinhl "long double x"
.Sh DESCRIPTION
The
-.Fn asinh
-and the
-.Fn asinhf
+.Fn asinh ,
+.Fn asinhf ,
+and
+.Fn asinhl
functions compute the inverse hyperbolic sine
of the real
argument
@@ -55,11 +59,7 @@ argument
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
-The
-.Fn asinh
-and the
-.Fn asinhf
-functions
+These functions
return the inverse hyperbolic sine of
.Ar x .
.Sh SEE ALSO
@@ -69,6 +69,13 @@ return the inverse hyperbolic sine of
.Xr math 3
.Sh HISTORY
The
-.Fn asinh
-function appeared in
-.Bx 4.3 .
+.Fn asinh ,
+.Fn asinhf ,
+and
+.Fn asinhl
+functions appeared in
+.Bx 4.3 ,
+.Fx 2.0 ,
+and
+.Fx 10.0 ,
+respectively.
diff --git a/lib/msun/man/atanh.3 b/lib/msun/man/atanh.3
index 0638a1fb0591..7763c46a68c9 100644
--- a/lib/msun/man/atanh.3
+++ b/lib/msun/man/atanh.3
@@ -28,12 +28,13 @@
.\" from: @(#)atanh.3 5.2 (Berkeley) 5/6/91
.\" $FreeBSD$
.\"
-.Dd January 14, 2005
+.Dd June 9, 2013
.Dt ATANH 3
.Os
.Sh NAME
.Nm atanh ,
-.Nm atanhf
+.Nm atanhf ,
+.Nm atanhl
.Nd inverse hyperbolic tangent functions
.Sh LIBRARY
.Lb libm
@@ -43,11 +44,14 @@
.Fn atanh "double x"
.Ft float
.Fn atanhf "float x"
+.Ft long double
+.Fn atanhl "long double x"
.Sh DESCRIPTION
The
-.Fn atanh
-and the
-.Fn atanhf
+.Fn atanh ,
+.Fn atanhf ,
+and
+.Fn atanhl
functions compute the inverse hyperbolic tangent
of the real
argument
@@ -55,11 +59,7 @@ argument
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
-The
-.Fn atanh
-and the
-.Fn atanhf
-functions
+These functions
return the inverse hyperbolic tangent of
.Ar x
if successful.
@@ -76,6 +76,13 @@ If
.Xr math 3
.Sh HISTORY
The
-.Fn atanh
-function appeared in
-.Bx 4.3 .
+.Fn atanh ,
+.Fn atanhf ,
+and
+.Fn atanhl
+functions appeared in
+.Bx 4.3 ,
+.Fx 2.0 ,
+and
+.Fx 10.0 ,
+respectively.
diff --git a/lib/msun/man/cacos.3 b/lib/msun/man/cacos.3
new file mode 100644
index 000000000000..0bf3f0fd4263
--- /dev/null
+++ b/lib/msun/man/cacos.3
@@ -0,0 +1,128 @@
+.\" Copyright (c) 2013 David Schultz <das@FreeBSD.org>
+.\" 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 27, 2013
+.Dt CACOS 3
+.Os
+.Sh NAME
+.Nm cacos ,
+.Nm cacosf ,
+.Nm cacosh ,
+.Nm cacoshf ,
+.Nm casin ,
+.Nm casinf
+.Nm casinh ,
+.Nm casinhf
+.Nm catan ,
+.Nm catanf
+.Nm catanh ,
+.Nm catanhf
+.Nd complex arc trigonometric and hyperbolic functions
+.Sh LIBRARY
+.Lb libm
+.Sh SYNOPSIS
+.In complex.h
+.Ft double complex
+.Fn cacos "double complex z"
+.Ft float complex
+.Fn cacosf "float complex z"
+.Ft double complex
+.Fn cacosh "double complex z"
+.Ft float complex
+.Fn cacoshf "float complex z"
+.Ft double complex
+.Fn casin "double complex z"
+.Ft float complex
+.Fn casinf "float complex z"
+.Ft double complex
+.Fn casinh "double complex z"
+.Ft float complex
+.Fn casinhf "float complex z"
+.Ft double complex
+.Fn catan "double complex z"
+.Ft float complex
+.Fn catanf "float complex z"
+.Ft double complex
+.Fn catanh "double complex z"
+.Ft float complex
+.Fn catanhf "float complex z"
+.Sh DESCRIPTION
+The
+.Fn cacos ,
+.Fn casin ,
+and
+.Fn catan
+functions compute the principal value of the inverse cosine, sine,
+and tangent of the complex number
+.Fa z ,
+respectively.
+The
+.Fn cacosh ,
+.Fn casinh ,
+and
+.Fn catanh
+functions compute the principal value of the inverse hyperbolic
+cosine, sine, and tangent.
+The
+.Fn cacosf ,
+.Fn casinf ,
+.Fn catanf
+.Fn cacoshf ,
+.Fn casinhf ,
+and
+.Fn catanhf
+functions perform the same operations in
+.Fa float
+precision.
+.Pp
+.ie '\*[.T]'utf8'
+. ds Un \[cu]
+.el
+. ds Un U
+.
+There is no universal convention for defining the principal values of
+these functions. The following table gives the branch cuts, and the
+corresponding ranges for the return values, adopted by the C language.
+.Bl -column ".Sy Function" ".Sy (-\*(If*I, -I) \*(Un (I, \*(If*I)" ".Sy [-\*(Pi/2*I, \*(Pi/2*I]"
+.It Sy Function Ta Sy Branch Cut(s) Ta Sy Range
+.It cacos Ta (-\*(If, -1) \*(Un (1, \*(If) Ta [0, \*(Pi]
+.It casin Ta (-\*(If, -1) \*(Un (1, \*(If) Ta [-\*(Pi/2, \*(Pi/2]
+.It catan Ta (-\*(If*I, -i) \*(Un (I, \*(If*I) Ta [-\*(Pi/2, \*(Pi/2]
+.It cacosh Ta (-\*(If, 1) Ta [-\*(Pi*I, \*(Pi*I]
+.It casinh Ta (-\*(If*I, -i) \*(Un (I, \*(If*I) Ta [-\*(Pi/2*I, \*(Pi/2*I]
+.It catanh Ta (-\*(If, -1) \*(Un (1, \*(If) Ta [-\*(Pi/2*I, \*(Pi/2*I]
+.El
+.Sh SEE ALSO
+.Xr ccos 3 ,
+.Xr ccosh 3 ,
+.Xr complex 3 ,
+.Xr cos 3 ,
+.Xr math 3 ,
+.Xr sin 3 ,
+.Xr tan 3
+.Sh STANDARDS
+These functions conform to
+.St -isoC-99 .
diff --git a/lib/msun/man/ccos.3 b/lib/msun/man/ccos.3
index cf708c15f20f..c07205e6d91d 100644
--- a/lib/msun/man/ccos.3
+++ b/lib/msun/man/ccos.3
@@ -69,6 +69,7 @@ functions perform the same operations in
.Fa float
precision.
.Sh SEE ALSO
+.Xr cacos 3 ,
.Xr ccosh 3 ,
.Xr complex 3 ,
.Xr cos 3 ,
diff --git a/lib/msun/man/ccosh.3 b/lib/msun/man/ccosh.3
index 01688b5bdb8c..f006442cdc1d 100644
--- a/lib/msun/man/ccosh.3
+++ b/lib/msun/man/ccosh.3
@@ -69,6 +69,7 @@ functions perform the same operations in
.Fa float
precision.
.Sh SEE ALSO
+.Xr cacosh 3 ,
.Xr ccos 3 ,
.Xr complex 3 ,
.Xr cosh 3 ,
diff --git a/lib/msun/man/complex.3 b/lib/msun/man/complex.3
index 4c4dd68054e9..34eb03e5fc18 100644
--- a/lib/msun/man/complex.3
+++ b/lib/msun/man/complex.3
@@ -89,6 +89,12 @@ creal compute the real part
.\" Section 7.3.5-6 of ISO C99 standard
.Ss Trigonometric and Hyperbolic Functions
.Cl
+cacos arc cosine
+cacosh arc hyperbolic cosine
+casin arc sine
+casinh arc hyperbolic sine
+catan arc tangent
+catanh arc hyperbolic tangent
ccos cosine
ccosh hyperbolic cosine
csin sine
@@ -111,20 +117,8 @@ The
functions described here conform to
.St -isoC-99 .
.Sh BUGS
-The inverse trigonometric and hyperbolic functions
-.Fn cacos ,
-.Fn cacosh ,
-.Fn casin ,
-.Fn casinh ,
-.Fn catan ,
-and
-.Fn catanh
-are not implemented.
-.Pp
The logarithmic functions
.Fn clog
-are not implemented.
-.Pp
-The power functions
+and the power functions
.Fn cpow
are not implemented.
diff --git a/lib/msun/man/exp.3 b/lib/msun/man/exp.3
index 590733761e34..89a2dc5f484f 100644
--- a/lib/msun/man/exp.3
+++ b/lib/msun/man/exp.3
@@ -28,7 +28,7 @@
.\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91
.\" $FreeBSD$
.\"
-.Dd July 10, 2012
+.Dd June 3, 2013
.Dt EXP 3
.Os
.Sh NAME
@@ -41,6 +41,7 @@
.Nm exp2l ,
.Nm expm1 ,
.Nm expm1f ,
+.Nm expm1l ,
.Nm pow ,
.Nm powf
.Nd exponential and power functions
@@ -64,6 +65,8 @@
.Fn expm1 "double x"
.Ft float
.Fn expm1f "float x"
+.Ft long double
+.Fn expm1l "long double x"
.Ft double
.Fn pow "double x" "double y"
.Ft float
@@ -88,9 +91,10 @@ functions compute the base 2 exponential of the given argument
.Fa x .
.Pp
The
-.Fn expm1
+.Fn expm1 ,
+.Fn expm1f ,
and the
-.Fn expm1f
+.Fn expm1l
functions compute the value exp(x)\-1 accurately even for tiny argument
.Fa x .
.Pp
diff --git a/lib/msun/man/log.3 b/lib/msun/man/log.3
index b9fd83c35938..b08e6922e88e 100644
--- a/lib/msun/man/log.3
+++ b/lib/msun/man/log.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 5, 2010
+.Dd June 3, 2013
.Dt LOG 3
.Os
.Sh NAME
@@ -33,10 +33,13 @@
.Nm logl ,
.Nm log10 ,
.Nm log10f ,
+.Nm log10l ,
.Nm log2 ,
.Nm log2f ,
+.Nm log2l ,
.Nm log1p ,
-.Nm log1pf
+.Nm log1pf ,
+.Nm log1pl
.Nd logarithm functions
.Sh LIBRARY
.Lb libm
@@ -46,43 +49,55 @@
.Fn log "double x"
.Ft float
.Fn logf "float x"
+.Ft long double
+.Fn logl "long double x"
.Ft double
.Fn log10 "double x"
.Ft float
.Fn log10f "float x"
+.Ft long double
+.Fn log10l "long double x"
.Ft double
.Fn log2 "double x"
.Ft float
.Fn log2f "float x"
+.Ft long double
+.Fn log2l "long double x"
.Ft double
.Fn log1p "double x"
.Ft float
.Fn log1pf "float x"
+.Ft long double
+.Fn log1pl "long double x"
.Sh DESCRIPTION
The
-.Fn log
+.Fn log ,
+.Fn logf ,
and
-.Fn logf
+.Fn logl
functions compute the natural logarithm of
.Fa x .
.Pp
The
-.Fn log10
+.Fn log10 ,
+.Fn log10f ,
and
-.Fn log10f
+.Fn log10l
functions compute the logarithm base 10 of
.Fa x ,
while
-.Fn log2
+.Fn log2 ,
+.Fn log2f ,
and
-.Fn log2f
+.Fn log2l
compute the logarithm base 2 of
.Fa x .
.Pp
The
-.Fn log1p
+.Fn log1p ,
+.Fn log1pf ,
and
-.Fn log1pf
+.Fn log1pl
functions compute the natural logarithm of
.No "1 + x" .
Computing the natural logarithm as
@@ -107,12 +122,16 @@ results in an invalid exception and a return value of \*(Na.
The
.Fn log ,
.Fn logf ,
+.Fn logl ,
.Fn log10 ,
.Fn log10f ,
+.Fn log10l ,
.Fn log2 ,
.Fn log2f ,
+.Fn log2l ,
.Fn log1p ,
+.Fn log1pf ,
and
-.Fn log1pf
+.Fn log1pl
functions conform to
.St -isoC-99 .
diff --git a/lib/msun/src/catrig.c b/lib/msun/src/catrig.c
new file mode 100644
index 000000000000..200977c0af48
--- /dev/null
+++ b/lib/msun/src/catrig.c
@@ -0,0 +1,639 @@
+/*-
+ * Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+#undef isinf
+#define isinf(x) (fabs(x) == INFINITY)
+#undef isnan
+#define isnan(x) ((x) != (x))
+#define raise_inexact() do { volatile float junk = 1 + tiny; } while(0)
+#undef signbit
+#define signbit(x) (__builtin_signbit(x))
+
+/* We need that DBL_EPSILON^2/128 is larger than FOUR_SQRT_MIN. */
+static const double
+A_crossover = 10, /* Hull et al suggest 1.5, but 10 works better */
+B_crossover = 0.6417, /* suggested by Hull et al */
+FOUR_SQRT_MIN = 0x1p-509, /* >= 4 * sqrt(DBL_MIN) */
+QUARTER_SQRT_MAX = 0x1p509, /* <= sqrt(DBL_MAX) / 4 */
+m_e = 2.7182818284590452e0, /* 0x15bf0a8b145769.0p-51 */
+m_ln2 = 6.9314718055994531e-1, /* 0x162e42fefa39ef.0p-53 */
+pio2_hi = 1.5707963267948966e0, /* 0x1921fb54442d18.0p-52 */
+RECIP_EPSILON = 1 / DBL_EPSILON,
+SQRT_3_EPSILON = 2.5809568279517849e-8, /* 0x1bb67ae8584caa.0p-78 */
+SQRT_6_EPSILON = 3.6500241499888571e-8, /* 0x13988e1409212e.0p-77 */
+SQRT_MIN = 0x1p-511; /* >= sqrt(DBL_MIN) */
+
+static const volatile double
+pio2_lo = 6.1232339957367659e-17; /* 0x11a62633145c07.0p-106 */
+static const volatile float
+tiny = 0x1p-100;
+
+static double complex clog_for_large_values(double complex z);
+
+/*
+ * Testing indicates that all these functions are accurate up to 4 ULP.
+ * The functions casin(h) and cacos(h) are about 2.5 times slower than asinh.
+ * The functions catan(h) are a little under 2 times slower than atanh.
+ *
+ * The code for casinh, casin, cacos, and cacosh comes first. The code is
+ * rather complicated, and the four functions are highly interdependent.
+ *
+ * The code for catanh and catan comes at the end. It is much simpler than
+ * the other functions, and the code for these can be disconnected from the
+ * rest of the code.
+ */
+
+/*
+ * ================================
+ * | casinh, casin, cacos, cacosh |
+ * ================================
+ */
+
+/*
+ * The algorithm is very close to that in "Implementing the complex arcsine
+ * and arccosine functions using exception handling" by T. E. Hull, Thomas F.
+ * Fairgrieve, and Ping Tak Peter Tang, published in ACM Transactions on
+ * Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335,
+ * http://dl.acm.org/citation.cfm?id=275324.
+ *
+ * Throughout we use the convention z = x + I*y.
+ *
+ * casinh(z) = sign(x)*log(A+sqrt(A*A-1)) + I*asin(B)
+ * where
+ * A = (|z+I| + |z-I|) / 2
+ * B = (|z+I| - |z-I|) / 2 = y/A
+ *
+ * These formulas become numerically unstable:
+ * (a) for Re(casinh(z)) when z is close to the line segment [-I, I] (that
+ * is, Re(casinh(z)) is close to 0);
+ * (b) for Im(casinh(z)) when z is close to either of the intervals
+ * [I, I*infinity) or (-I*infinity, -I] (that is, |Im(casinh(z))| is
+ * close to PI/2).
+ *
+ * These numerical problems are overcome by defining
+ * f(a, b) = (hypot(a, b) - b) / 2 = a*a / (hypot(a, b) + b) / 2
+ * Then if A < A_crossover, we use
+ * log(A + sqrt(A*A-1)) = log1p((A-1) + sqrt((A-1)*(A+1)))
+ * A-1 = f(x, 1+y) + f(x, 1-y)
+ * and if B > B_crossover, we use
+ * asin(B) = atan2(y, sqrt(A*A - y*y)) = atan2(y, sqrt((A+y)*(A-y)))
+ * A-y = f(x, y+1) + f(x, y-1)
+ * where without loss of generality we have assumed that x and y are
+ * non-negative.
+ *
+ * Much of the difficulty comes because the intermediate computations may
+ * produce overflows or underflows. This is dealt with in the paper by Hull
+ * et al by using exception handling. We do this by detecting when
+ * computations risk underflow or overflow. The hardest part is handling the
+ * underflows when computing f(a, b).
+ *
+ * Note that the function f(a, b) does not appear explicitly in the paper by
+ * Hull et al, but the idea may be found on pages 308 and 309. Introducing the
+ * function f(a, b) allows us to concentrate many of the clever tricks in this
+ * paper into one function.
+ */
+
+/*
+ * Function f(a, b, hypot_a_b) = (hypot(a, b) - b) / 2.
+ * Pass hypot(a, b) as the third argument.
+ */
+static inline double
+f(double a, double b, double hypot_a_b)
+{
+ if (b < 0)
+ return ((hypot_a_b - b) / 2);
+ if (b == 0)
+ return (a / 2);
+ return (a * a / (hypot_a_b + b) / 2);
+}
+
+/*
+ * All the hard work is contained in this function.
+ * x and y are assumed positive or zero, and less than RECIP_EPSILON.
+ * Upon return:
+ * rx = Re(casinh(z)) = -Im(cacos(y + I*x)).
+ * B_is_usable is set to 1 if the value of B is usable.
+ * If B_is_usable is set to 0, sqrt_A2my2 = sqrt(A*A - y*y), and new_y = y.
+ * If returning sqrt_A2my2 has potential to result in an underflow, it is
+ * rescaled, and new_y is similarly rescaled.
+ */
+static inline void
+do_hard_work(double x, double y, double *rx, int *B_is_usable, double *B,
+ double *sqrt_A2my2, double *new_y)
+{
+ double R, S, A; /* A, B, R, and S are as in Hull et al. */
+ double Am1, Amy; /* A-1, A-y. */
+
+ R = hypot(x, y + 1); /* |z+I| */
+ S = hypot(x, y - 1); /* |z-I| */
+
+ /* A = (|z+I| + |z-I|) / 2 */
+ A = (R + S) / 2;
+ /*
+ * Mathematically A >= 1. There is a small chance that this will not
+ * be so because of rounding errors. So we will make certain it is
+ * so.
+ */
+ if (A < 1)
+ A = 1;
+
+ if (A < A_crossover) {
+ /*
+ * Am1 = fp + fm, where fp = f(x, 1+y), and fm = f(x, 1-y).
+ * rx = log1p(Am1 + sqrt(Am1*(A+1)))
+ */
+ if (y == 1 && x < DBL_EPSILON * DBL_EPSILON / 128) {
+ /*
+ * fp is of order x^2, and fm = x/2.
+ * A = 1 (inexactly).
+ */
+ *rx = sqrt(x);
+ } else if (x >= DBL_EPSILON * fabs(y - 1)) {
+ /*
+ * Underflow will not occur because
+ * x >= DBL_EPSILON^2/128 >= FOUR_SQRT_MIN
+ */
+ Am1 = f(x, 1 + y, R) + f(x, 1 - y, S);
+ *rx = log1p(Am1 + sqrt(Am1 * (A + 1)));
+ } else if (y < 1) {
+ /*
+ * fp = x*x/(1+y)/4, fm = x*x/(1-y)/4, and
+ * A = 1 (inexactly).
+ */
+ *rx = x / sqrt((1 - y) * (1 + y));
+ } else { /* if (y > 1) */
+ /*
+ * A-1 = y-1 (inexactly).
+ */
+ *rx = log1p((y - 1) + sqrt((y - 1) * (y + 1)));
+ }
+ } else {
+ *rx = log(A + sqrt(A * A - 1));
+ }
+
+ *new_y = y;
+
+ if (y < FOUR_SQRT_MIN) {
+ /*
+ * Avoid a possible underflow caused by y/A. For casinh this
+ * would be legitimate, but will be picked up by invoking atan2
+ * later on. For cacos this would not be legitimate.
+ */
+ *B_is_usable = 0;
+ *sqrt_A2my2 = A * (2 / DBL_EPSILON);
+ *new_y = y * (2 / DBL_EPSILON);
+ return;
+ }
+
+ /* B = (|z+I| - |z-I|) / 2 = y/A */
+ *B = y / A;
+ *B_is_usable = 1;
+
+ if (*B > B_crossover) {
+ *B_is_usable = 0;
+ /*
+ * Amy = fp + fm, where fp = f(x, y+1), and fm = f(x, y-1).
+ * sqrt_A2my2 = sqrt(Amy*(A+y))
+ */
+ if (y == 1 && x < DBL_EPSILON / 128) {
+ /*
+ * fp is of order x^2, and fm = x/2.
+ * A = 1 (inexactly).
+ */
+ *sqrt_A2my2 = sqrt(x) * sqrt((A + y) / 2);
+ } else if (x >= DBL_EPSILON * fabs(y - 1)) {
+ /*
+ * Underflow will not occur because
+ * x >= DBL_EPSILON/128 >= FOUR_SQRT_MIN
+ * and
+ * x >= DBL_EPSILON^2 >= FOUR_SQRT_MIN
+ */
+ Amy = f(x, y + 1, R) + f(x, y - 1, S);
+ *sqrt_A2my2 = sqrt(Amy * (A + y));
+ } else if (y > 1) {
+ /*
+ * fp = x*x/(y+1)/4, fm = x*x/(y-1)/4, and
+ * A = y (inexactly).
+ *
+ * y < RECIP_EPSILON. So the following
+ * scaling should avoid any underflow problems.
+ */
+ *sqrt_A2my2 = x * (4 / DBL_EPSILON / DBL_EPSILON) * y /
+ sqrt((y + 1) * (y - 1));
+ *new_y = y * (4 / DBL_EPSILON / DBL_EPSILON);
+ } else { /* if (y < 1) */
+ /*
+ * fm = 1-y >= DBL_EPSILON, fp is of order x^2, and
+ * A = 1 (inexactly).
+ */
+ *sqrt_A2my2 = sqrt((1 - y) * (1 + y));
+ }
+ }
+}
+
+/*
+ * casinh(z) = z + O(z^3) as z -> 0
+ *
+ * casinh(z) = sign(x)*clog(sign(x)*z) + O(1/z^2) as z -> infinity
+ * The above formula works for the imaginary part as well, because
+ * Im(casinh(z)) = sign(x)*atan2(sign(x)*y, fabs(x)) + O(y/z^3)
+ * as z -> infinity, uniformly in y
+ */
+double complex
+casinh(double complex z)
+{
+ double x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y;
+ int B_is_usable;
+ double complex w;
+
+ x = creal(z);
+ y = cimag(z);
+ ax = fabs(x);
+ ay = fabs(y);
+
+ if (isnan(x) || isnan(y)) {
+ /* casinh(+-Inf + I*NaN) = +-Inf + I*NaN */
+ if (isinf(x))
+ return (cpack(x, y + y));
+ /* casinh(NaN + I*+-Inf) = opt(+-)Inf + I*NaN */
+ if (isinf(y))
+ return (cpack(y, x + x));
+ /* casinh(NaN + I*0) = NaN + I*0 */
+ if (y == 0)
+ return (cpack(x + x, y));
+ /*
+ * All other cases involving NaN return NaN + I*NaN.
+ * C99 leaves it optional whether to raise invalid if one of
+ * the arguments is not NaN, so we opt not to raise it.
+ */
+ return (cpack(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ /* clog...() will raise inexact unless x or y is infinite. */
+ if (signbit(x) == 0)
+ w = clog_for_large_values(z) + m_ln2;
+ else
+ w = clog_for_large_values(-z) + m_ln2;
+ return (cpack(copysign(creal(w), x), copysign(cimag(w), y)));
+ }
+
+ /* Avoid spuriously raising inexact for z = 0. */
+ if (x == 0 && y == 0)
+ return (z);
+
+ /* All remaining cases are inexact. */
+ raise_inexact();
+
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
+ return (z);
+
+ do_hard_work(ax, ay, &rx, &B_is_usable, &B, &sqrt_A2my2, &new_y);
+ if (B_is_usable)
+ ry = asin(B);
+ else
+ ry = atan2(new_y, sqrt_A2my2);
+ return (cpack(copysign(rx, x), copysign(ry, y)));
+}
+
+/*
+ * casin(z) = reverse(casinh(reverse(z)))
+ * where reverse(x + I*y) = y + I*x = I*conj(z).
+ */
+double complex
+casin(double complex z)
+{
+ double complex w = casinh(cpack(cimag(z), creal(z)));
+
+ return (cpack(cimag(w), creal(w)));
+}
+
+/*
+ * cacos(z) = PI/2 - casin(z)
+ * but do the computation carefully so cacos(z) is accurate when z is
+ * close to 1.
+ *
+ * cacos(z) = PI/2 - z + O(z^3) as z -> 0
+ *
+ * cacos(z) = -sign(y)*I*clog(z) + O(1/z^2) as z -> infinity
+ * The above formula works for the real part as well, because
+ * Re(cacos(z)) = atan2(fabs(y), x) + O(y/z^3)
+ * as z -> infinity, uniformly in y
+ */
+double complex
+cacos(double complex z)
+{
+ double x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x;
+ int sx, sy;
+ int B_is_usable;
+ double complex w;
+
+ x = creal(z);
+ y = cimag(z);
+ sx = signbit(x);
+ sy = signbit(y);
+ ax = fabs(x);
+ ay = fabs(y);
+
+ if (isnan(x) || isnan(y)) {
+ /* cacos(+-Inf + I*NaN) = NaN + I*opt(-)Inf */
+ if (isinf(x))
+ return (cpack(y + y, -INFINITY));
+ /* cacos(NaN + I*+-Inf) = NaN + I*-+Inf */
+ if (isinf(y))
+ return (cpack(x + x, -y));
+ /* cacos(0 + I*NaN) = PI/2 + I*NaN with inexact */
+ if (x == 0)
+ return (cpack(pio2_hi + pio2_lo, y + y));
+ /*
+ * All other cases involving NaN return NaN + I*NaN.
+ * C99 leaves it optional whether to raise invalid if one of
+ * the arguments is not NaN, so we opt not to raise it.
+ */
+ return (cpack(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ /* clog...() will raise inexact unless x or y is infinite. */
+ w = clog_for_large_values(z);
+ rx = fabs(cimag(w));
+ ry = creal(w) + m_ln2;
+ if (sy == 0)
+ ry = -ry;
+ return (cpack(rx, ry));
+ }
+
+ /* Avoid spuriously raising inexact for z = 1. */
+ if (x == 1 && y == 0)
+ return (cpack(0, -y));
+
+ /* All remaining cases are inexact. */
+ raise_inexact();
+
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
+ return (cpack(pio2_hi - (x - pio2_lo), -y));
+
+ do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x);
+ if (B_is_usable) {
+ if (sx == 0)
+ rx = acos(B);
+ else
+ rx = acos(-B);
+ } else {
+ if (sx == 0)
+ rx = atan2(sqrt_A2mx2, new_x);
+ else
+ rx = atan2(sqrt_A2mx2, -new_x);
+ }
+ if (sy == 0)
+ ry = -ry;
+ return (cpack(rx, ry));
+}
+
+/*
+ * cacosh(z) = I*cacos(z) or -I*cacos(z)
+ * where the sign is chosen so Re(cacosh(z)) >= 0.
+ */
+double complex
+cacosh(double complex z)
+{
+ double complex w;
+ double rx, ry;
+
+ w = cacos(z);
+ rx = creal(w);
+ ry = cimag(w);
+ /* cacosh(NaN + I*NaN) = NaN + I*NaN */
+ if (isnan(rx) && isnan(ry))
+ return (cpack(ry, rx));
+ /* cacosh(NaN + I*+-Inf) = +Inf + I*NaN */
+ /* cacosh(+-Inf + I*NaN) = +Inf + I*NaN */
+ if (isnan(rx))
+ return (cpack(fabs(ry), rx));
+ /* cacosh(0 + I*NaN) = NaN + I*NaN */
+ if (isnan(ry))
+ return (cpack(ry, ry));
+ return (cpack(fabs(ry), copysign(rx, cimag(z))));
+}
+
+/*
+ * Optimized version of clog() for |z| finite and larger than ~RECIP_EPSILON.
+ */
+static double complex
+clog_for_large_values(double complex z)
+{
+ double x, y;
+ double ax, ay, t;
+
+ x = creal(z);
+ y = cimag(z);
+ ax = fabs(x);
+ ay = fabs(y);
+ if (ax < ay) {
+ t = ax;
+ ax = ay;
+ ay = t;
+ }
+
+ /*
+ * Avoid overflow in hypot() when x and y are both very large.
+ * Divide x and y by E, and then add 1 to the logarithm. This depends
+ * on E being larger than sqrt(2).
+ * Dividing by E causes an insignificant loss of accuracy; however
+ * this method is still poor since it is uneccessarily slow.
+ */
+ if (ax > DBL_MAX / 2)
+ return (cpack(log(hypot(x / m_e, y / m_e)) + 1, atan2(y, x)));
+
+ /*
+ * Avoid overflow when x or y is large. Avoid underflow when x or
+ * y is small.
+ */
+ if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN)
+ return (cpack(log(hypot(x, y)), atan2(y, x)));
+
+ return (cpack(log(ax * ax + ay * ay) / 2, atan2(y, x)));
+}
+
+/*
+ * =================
+ * | catanh, catan |
+ * =================
+ */
+
+/*
+ * sum_squares(x,y) = x*x + y*y (or just x*x if y*y would underflow).
+ * Assumes x*x and y*y will not overflow.
+ * Assumes x and y are finite.
+ * Assumes y is non-negative.
+ * Assumes fabs(x) >= DBL_EPSILON.
+ */
+static inline double
+sum_squares(double x, double y)
+{
+
+ /* Avoid underflow when y is small. */
+ if (y < SQRT_MIN)
+ return (x * x);
+
+ return (x * x + y * y);
+}
+
+/*
+ * real_part_reciprocal(x, y) = Re(1/(x+I*y)) = x/(x*x + y*y).
+ * Assumes x and y are not NaN, and one of x and y is larger than
+ * RECIP_EPSILON. We avoid unwarranted underflow. It is important to not use
+ * the code creal(1/z), because the imaginary part may produce an unwanted
+ * underflow.
+ * This is only called in a context where inexact is always raised before
+ * the call, so no effort is made to avoid or force inexact.
+ */
+static inline double
+real_part_reciprocal(double x, double y)
+{
+ double scale;
+ uint32_t hx, hy;
+ int32_t ix, iy;
+
+ /*
+ * This code is inspired by the C99 document n1124.pdf, Section G.5.1,
+ * example 2.
+ */
+ GET_HIGH_WORD(hx, x);
+ ix = hx & 0x7ff00000;
+ GET_HIGH_WORD(hy, y);
+ iy = hy & 0x7ff00000;
+#define BIAS (DBL_MAX_EXP - 1)
+/* XXX more guard digits are useful iff there is extra precision. */
+#define CUTOFF (DBL_MANT_DIG / 2 + 1) /* just half or 1 guard digit */
+ if (ix - iy >= CUTOFF << 20 || isinf(x))
+ return (1 / x); /* +-Inf -> +-0 is special */
+ if (iy - ix >= CUTOFF << 20)
+ return (x / y / y); /* should avoid double div, but hard */
+ if (ix <= (BIAS + DBL_MAX_EXP / 2 - CUTOFF) << 20)
+ return (x / (x * x + y * y));
+ scale = 1;
+ SET_HIGH_WORD(scale, 0x7ff00000 - ix); /* 2**(1-ilogb(x)) */
+ x *= scale;
+ y *= scale;
+ return (x / (x * x + y * y) * scale);
+}
+
+/*
+ * catanh(z) = log((1+z)/(1-z)) / 2
+ * = log1p(4*x / |z-1|^2) / 4
+ * + I * atan2(2*y, (1-x)*(1+x)-y*y) / 2
+ *
+ * catanh(z) = z + O(z^3) as z -> 0
+ *
+ * catanh(z) = 1/z + sign(y)*I*PI/2 + O(1/z^3) as z -> infinity
+ * The above formula works for the real part as well, because
+ * Re(catanh(z)) = x/|z|^2 + O(x/z^4)
+ * as z -> infinity, uniformly in x
+ */
+double complex
+catanh(double complex z)
+{
+ double x, y, ax, ay, rx, ry;
+
+ x = creal(z);
+ y = cimag(z);
+ ax = fabs(x);
+ ay = fabs(y);
+
+ /* This helps handle many cases. */
+ if (y == 0 && ax <= 1)
+ return (cpack(atanh(x), y));
+
+ /* To ensure the same accuracy as atan(), and to filter out z = 0. */
+ if (x == 0)
+ return (cpack(x, atan(y)));
+
+ if (isnan(x) || isnan(y)) {
+ /* catanh(+-Inf + I*NaN) = +-0 + I*NaN */
+ if (isinf(x))
+ return (cpack(copysign(0, x), y + y));
+ /* catanh(NaN + I*+-Inf) = sign(NaN)0 + I*+-PI/2 */
+ if (isinf(y))
+ return (cpack(copysign(0, x),
+ copysign(pio2_hi + pio2_lo, y)));
+ /*
+ * All other cases involving NaN return NaN + I*NaN.
+ * C99 leaves it optional whether to raise invalid if one of
+ * the arguments is not NaN, so we opt not to raise it.
+ */
+ return (cpack(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
+ return (cpack(real_part_reciprocal(x, y),
+ copysign(pio2_hi + pio2_lo, y)));
+
+ if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) {
+ /*
+ * z = 0 was filtered out above. All other cases must raise
+ * inexact, but this is the only only that needs to do it
+ * explicitly.
+ */
+ raise_inexact();
+ return (z);
+ }
+
+ if (ax == 1 && ay < DBL_EPSILON)
+ rx = (m_ln2 - log(ay)) / 2;
+ else
+ rx = log1p(4 * ax / sum_squares(ax - 1, ay)) / 4;
+
+ if (ax == 1)
+ ry = atan2(2, -ay) / 2;
+ else if (ay < DBL_EPSILON)
+ ry = atan2(2 * ay, (1 - ax) * (1 + ax)) / 2;
+ else
+ ry = atan2(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2;
+
+ return (cpack(copysign(rx, x), copysign(ry, y)));
+}
+
+/*
+ * catan(z) = reverse(catanh(reverse(z)))
+ * where reverse(x + I*y) = y + I*x = I*conj(z).
+ */
+double complex
+catan(double complex z)
+{
+ double complex w = catanh(cpack(cimag(z), creal(z)));
+
+ return (cpack(cimag(w), creal(w)));
+}
diff --git a/lib/msun/src/catrigf.c b/lib/msun/src/catrigf.c
new file mode 100644
index 000000000000..08ebef783666
--- /dev/null
+++ b/lib/msun/src/catrigf.c
@@ -0,0 +1,393 @@
+/*-
+ * Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG>
+ * 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.
+ */
+
+/*
+ * The algorithm is very close to that in "Implementing the complex arcsine
+ * and arccosine functions using exception handling" by T. E. Hull, Thomas F.
+ * Fairgrieve, and Ping Tak Peter Tang, published in ACM Transactions on
+ * Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335,
+ * http://dl.acm.org/citation.cfm?id=275324.
+ *
+ * See catrig.c for complete comments.
+ *
+ * XXX comments were removed automatically, and even short ones on the right
+ * of statements were removed (all of them), contrary to normal style. Only
+ * a few comments on the right of declarations remain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+#undef isinf
+#define isinf(x) (fabsf(x) == INFINITY)
+#undef isnan
+#define isnan(x) ((x) != (x))
+#define raise_inexact() do { volatile float junk = 1 + tiny; } while(0)
+#undef signbit
+#define signbit(x) (__builtin_signbitf(x))
+
+static const float
+A_crossover = 10,
+B_crossover = 0.6417,
+FOUR_SQRT_MIN = 0x1p-61,
+QUARTER_SQRT_MAX = 0x1p61,
+m_e = 2.7182818285e0, /* 0xadf854.0p-22 */
+m_ln2 = 6.9314718056e-1, /* 0xb17218.0p-24 */
+pio2_hi = 1.5707962513e0, /* 0xc90fda.0p-23 */
+RECIP_EPSILON = 1 / FLT_EPSILON,
+SQRT_3_EPSILON = 5.9801995673e-4, /* 0x9cc471.0p-34 */
+SQRT_6_EPSILON = 8.4572793338e-4, /* 0xddb3d7.0p-34 */
+SQRT_MIN = 0x1p-63;
+
+static const volatile float
+pio2_lo = 7.5497899549e-8, /* 0xa22169.0p-47 */
+tiny = 0x1p-100;
+
+static float complex clog_for_large_values(float complex z);
+
+static inline float
+f(float a, float b, float hypot_a_b)
+{
+ if (b < 0)
+ return ((hypot_a_b - b) / 2);
+ if (b == 0)
+ return (a / 2);
+ return (a * a / (hypot_a_b + b) / 2);
+}
+
+static inline void
+do_hard_work(float x, float y, float *rx, int *B_is_usable, float *B,
+ float *sqrt_A2my2, float *new_y)
+{
+ float R, S, A;
+ float Am1, Amy;
+
+ R = hypotf(x, y + 1);
+ S = hypotf(x, y - 1);
+
+ A = (R + S) / 2;
+ if (A < 1)
+ A = 1;
+
+ if (A < A_crossover) {
+ if (y == 1 && x < FLT_EPSILON * FLT_EPSILON / 128) {
+ *rx = sqrtf(x);
+ } else if (x >= FLT_EPSILON * fabsf(y - 1)) {
+ Am1 = f(x, 1 + y, R) + f(x, 1 - y, S);
+ *rx = log1pf(Am1 + sqrtf(Am1 * (A + 1)));
+ } else if (y < 1) {
+ *rx = x / sqrtf((1 - y) * (1 + y));
+ } else {
+ *rx = log1pf((y - 1) + sqrtf((y - 1) * (y + 1)));
+ }
+ } else {
+ *rx = logf(A + sqrtf(A * A - 1));
+ }
+
+ *new_y = y;
+
+ if (y < FOUR_SQRT_MIN) {
+ *B_is_usable = 0;
+ *sqrt_A2my2 = A * (2 / FLT_EPSILON);
+ *new_y = y * (2 / FLT_EPSILON);
+ return;
+ }
+
+ *B = y / A;
+ *B_is_usable = 1;
+
+ if (*B > B_crossover) {
+ *B_is_usable = 0;
+ if (y == 1 && x < FLT_EPSILON / 128) {
+ *sqrt_A2my2 = sqrtf(x) * sqrtf((A + y) / 2);
+ } else if (x >= FLT_EPSILON * fabsf(y - 1)) {
+ Amy = f(x, y + 1, R) + f(x, y - 1, S);
+ *sqrt_A2my2 = sqrtf(Amy * (A + y));
+ } else if (y > 1) {
+ *sqrt_A2my2 = x * (4 / FLT_EPSILON / FLT_EPSILON) * y /
+ sqrtf((y + 1) * (y - 1));
+ *new_y = y * (4 / FLT_EPSILON / FLT_EPSILON);
+ } else {
+ *sqrt_A2my2 = sqrtf((1 - y) * (1 + y));
+ }
+ }
+}
+
+float complex
+casinhf(float complex z)
+{
+ float x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y;
+ int B_is_usable;
+ float complex w;
+
+ x = crealf(z);
+ y = cimagf(z);
+ ax = fabsf(x);
+ ay = fabsf(y);
+
+ if (isnan(x) || isnan(y)) {
+ if (isinf(x))
+ return (cpackf(x, y + y));
+ if (isinf(y))
+ return (cpackf(y, x + x));
+ if (y == 0)
+ return (cpackf(x + x, y));
+ return (cpackf(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ if (signbit(x) == 0)
+ w = clog_for_large_values(z) + m_ln2;
+ else
+ w = clog_for_large_values(-z) + m_ln2;
+ return (cpackf(copysignf(crealf(w), x),
+ copysignf(cimagf(w), y)));
+ }
+
+ if (x == 0 && y == 0)
+ return (z);
+
+ raise_inexact();
+
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
+ return (z);
+
+ do_hard_work(ax, ay, &rx, &B_is_usable, &B, &sqrt_A2my2, &new_y);
+ if (B_is_usable)
+ ry = asinf(B);
+ else
+ ry = atan2f(new_y, sqrt_A2my2);
+ return (cpackf(copysignf(rx, x), copysignf(ry, y)));
+}
+
+float complex
+casinf(float complex z)
+{
+ float complex w = casinhf(cpackf(cimagf(z), crealf(z)));
+
+ return (cpackf(cimagf(w), crealf(w)));
+}
+
+float complex
+cacosf(float complex z)
+{
+ float x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x;
+ int sx, sy;
+ int B_is_usable;
+ float complex w;
+
+ x = crealf(z);
+ y = cimagf(z);
+ sx = signbit(x);
+ sy = signbit(y);
+ ax = fabsf(x);
+ ay = fabsf(y);
+
+ if (isnan(x) || isnan(y)) {
+ if (isinf(x))
+ return (cpackf(y + y, -INFINITY));
+ if (isinf(y))
+ return (cpackf(x + x, -y));
+ if (x == 0)
+ return (cpackf(pio2_hi + pio2_lo, y + y));
+ return (cpackf(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) {
+ w = clog_for_large_values(z);
+ rx = fabsf(cimagf(w));
+ ry = crealf(w) + m_ln2;
+ if (sy == 0)
+ ry = -ry;
+ return (cpackf(rx, ry));
+ }
+
+ if (x == 1 && y == 0)
+ return (cpackf(0, -y));
+
+ raise_inexact();
+
+ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4)
+ return (cpackf(pio2_hi - (x - pio2_lo), -y));
+
+ do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x);
+ if (B_is_usable) {
+ if (sx == 0)
+ rx = acosf(B);
+ else
+ rx = acosf(-B);
+ } else {
+ if (sx == 0)
+ rx = atan2f(sqrt_A2mx2, new_x);
+ else
+ rx = atan2f(sqrt_A2mx2, -new_x);
+ }
+ if (sy == 0)
+ ry = -ry;
+ return (cpackf(rx, ry));
+}
+
+float complex
+cacoshf(float complex z)
+{
+ float complex w;
+ float rx, ry;
+
+ w = cacosf(z);
+ rx = crealf(w);
+ ry = cimagf(w);
+ if (isnan(rx) && isnan(ry))
+ return (cpackf(ry, rx));
+ if (isnan(rx))
+ return (cpackf(fabsf(ry), rx));
+ if (isnan(ry))
+ return (cpackf(ry, ry));
+ return (cpackf(fabsf(ry), copysignf(rx, cimagf(z))));
+}
+
+static float complex
+clog_for_large_values(float complex z)
+{
+ float x, y;
+ float ax, ay, t;
+
+ x = crealf(z);
+ y = cimagf(z);
+ ax = fabsf(x);
+ ay = fabsf(y);
+ if (ax < ay) {
+ t = ax;
+ ax = ay;
+ ay = t;
+ }
+
+ if (ax > FLT_MAX / 2)
+ return (cpackf(logf(hypotf(x / m_e, y / m_e)) + 1,
+ atan2f(y, x)));
+
+ if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN)
+ return (cpackf(logf(hypotf(x, y)), atan2f(y, x)));
+
+ return (cpackf(logf(ax * ax + ay * ay) / 2, atan2f(y, x)));
+}
+
+static inline float
+sum_squares(float x, float y)
+{
+
+ if (y < SQRT_MIN)
+ return (x * x);
+
+ return (x * x + y * y);
+}
+
+static inline float
+real_part_reciprocal(float x, float y)
+{
+ float scale;
+ uint32_t hx, hy;
+ int32_t ix, iy;
+
+ GET_FLOAT_WORD(hx, x);
+ ix = hx & 0x7f800000;
+ GET_FLOAT_WORD(hy, y);
+ iy = hy & 0x7f800000;
+#define BIAS (FLT_MAX_EXP - 1)
+#define CUTOFF (FLT_MANT_DIG / 2 + 1)
+ if (ix - iy >= CUTOFF << 23 || isinf(x))
+ return (1 / x);
+ if (iy - ix >= CUTOFF << 23)
+ return (x / y / y);
+ if (ix <= (BIAS + FLT_MAX_EXP / 2 - CUTOFF) << 23)
+ return (x / (x * x + y * y));
+ SET_FLOAT_WORD(scale, 0x7f800000 - ix);
+ x *= scale;
+ y *= scale;
+ return (x / (x * x + y * y) * scale);
+}
+
+float complex
+catanhf(float complex z)
+{
+ float x, y, ax, ay, rx, ry;
+
+ x = crealf(z);
+ y = cimagf(z);
+ ax = fabsf(x);
+ ay = fabsf(y);
+
+ if (y == 0 && ax <= 1)
+ return (cpackf(atanhf(x), y));
+
+ if (x == 0)
+ return (cpackf(x, atanf(y)));
+
+ if (isnan(x) || isnan(y)) {
+ if (isinf(x))
+ return (cpackf(copysignf(0, x), y + y));
+ if (isinf(y))
+ return (cpackf(copysignf(0, x),
+ copysignf(pio2_hi + pio2_lo, y)));
+ return (cpackf(x + 0.0L + (y + 0), x + 0.0L + (y + 0)));
+ }
+
+ if (ax > RECIP_EPSILON || ay > RECIP_EPSILON)
+ return (cpackf(real_part_reciprocal(x, y),
+ copysignf(pio2_hi + pio2_lo, y)));
+
+ if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) {
+ raise_inexact();
+ return (z);
+ }
+
+ if (ax == 1 && ay < FLT_EPSILON)
+ rx = (m_ln2 - logf(ay)) / 2;
+ else
+ rx = log1pf(4 * ax / sum_squares(ax - 1, ay)) / 4;
+
+ if (ax == 1)
+ ry = atan2f(2, -ay) / 2;
+ else if (ay < FLT_EPSILON)
+ ry = atan2f(2 * ay, (1 - ax) * (1 + ax)) / 2;
+ else
+ ry = atan2f(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2;
+
+ return (cpackf(copysignf(rx, x), copysignf(ry, y)));
+}
+
+float complex
+catanf(float complex z)
+{
+ float complex w = catanhf(cpackf(cimagf(z), crealf(z)));
+
+ return (cpackf(cimagf(w), crealf(w)));
+}
diff --git a/lib/msun/src/e_acosh.c b/lib/msun/src/e_acosh.c
index a0cc6cb55f01..358c8bd6a636 100644
--- a/lib/msun/src/e_acosh.c
+++ b/lib/msun/src/e_acosh.c
@@ -29,6 +29,8 @@ __FBSDID("$FreeBSD$");
* acosh(NaN) is NaN without signal.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -60,3 +62,7 @@ __ieee754_acosh(double x)
return log1p(t+sqrt(2.0*t+t*t));
}
}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(acosh, acoshl);
+#endif
diff --git a/lib/msun/src/e_acoshl.c b/lib/msun/src/e_acoshl.c
new file mode 100644
index 000000000000..b9f3aed67e63
--- /dev/null
+++ b/lib/msun/src/e_acoshl.c
@@ -0,0 +1,89 @@
+/* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
+
+/* @(#)e_acosh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * See e_acosh.c for complete comments.
+ *
+ * Converted to long double by David Schultz <das@FreeBSD.ORG> and
+ * Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+/* EXP_LARGE is the threshold above which we use acosh(x) ~= log(2x). */
+#if LDBL_MANT_DIG == 64
+#define EXP_LARGE 34
+#elif LDBL_MANT_DIG == 113
+#define EXP_LARGE 58
+#else
+#error "Unsupported long double format"
+#endif
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const double
+one = 1.0;
+
+#if LDBL_MANT_DIG == 64
+static const union IEEEl2bits
+u_ln2 = LD80C(0xb17217f7d1cf79ac, -1, 6.93147180559945309417e-1L);
+#define ln2 u_ln2.e
+#elif LDBL_MANT_DIG == 113
+static const long double
+ln2 = 6.93147180559945309417232121458176568e-1L; /* 0x162e42fefa39ef35793c7673007e6.0p-113 */
+#else
+#error "Unsupported long double format"
+#endif
+
+long double
+acoshl(long double x)
+{
+ long double t;
+ int16_t hx;
+
+ ENTERI();
+ GET_LDBL_EXPSIGN(hx, x);
+ if (hx < 0x3fff) { /* x < 1, or misnormal */
+ RETURNI((x-x)/(x-x));
+ } else if (hx >= BIAS + EXP_LARGE) { /* x >= LARGE */
+ if (hx >= 0x7fff) { /* x is inf, NaN or misnormal */
+ RETURNI(x+x);
+ } else
+ RETURNI(logl(x)+ln2); /* acosh(huge)=log(2x), or misnormal */
+ } else if (hx == 0x3fff && x == 1) {
+ RETURNI(0.0); /* acosh(1) = 0 */
+ } else if (hx >= 0x4000) { /* LARGE > x >= 2, or misnormal */
+ t=x*x;
+ RETURNI(logl(2.0*x-one/(x+sqrtl(t-one))));
+ } else { /* 1<x<2 */
+ t = x-one;
+ RETURNI(log1pl(t+sqrtl(2.0*t+t*t)));
+ }
+}
diff --git a/lib/msun/src/e_atanh.c b/lib/msun/src/e_atanh.c
index ab8a2e181fb6..422ff2698067 100644
--- a/lib/msun/src/e_atanh.c
+++ b/lib/msun/src/e_atanh.c
@@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$");
*
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -60,3 +62,7 @@ __ieee754_atanh(double x)
t = 0.5*log1p((x+x)/(one-x));
if(hx>=0) return t; else return -t;
}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(atanh, atanhl);
+#endif
diff --git a/lib/msun/src/e_atanhl.c b/lib/msun/src/e_atanhl.c
new file mode 100644
index 000000000000..11d56ea52e7f
--- /dev/null
+++ b/lib/msun/src/e_atanhl.c
@@ -0,0 +1,74 @@
+/* from: FreeBSD: head/lib/msun/src/e_atanh.c 176451 2008-02-22 02:30:36Z das */
+
+/* @(#)e_atanh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * See e_atanh.c for complete comments.
+ *
+ * Converted to long double by David Schultz <das@FreeBSD.ORG> and
+ * Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+/* EXP_TINY is the threshold below which we use atanh(x) ~= x. */
+#if LDBL_MANT_DIG == 64
+#define EXP_TINY -34
+#elif LDBL_MANT_DIG == 113
+#define EXP_TINY -58
+#else
+#error "Unsupported long double format"
+#endif
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const double one = 1.0, huge = 1e300;
+static const double zero = 0.0;
+
+long double
+atanhl(long double x)
+{
+ long double t;
+ uint16_t hx, ix;
+
+ ENTERI();
+ GET_LDBL_EXPSIGN(hx, x);
+ ix = hx & 0x7fff;
+ if (ix >= 0x3fff) /* |x| >= 1, or NaN or misnormal */
+ RETURNI(fabsl(x) == 1 ? x / zero : (x - x) / (x - x));
+ if (ix < BIAS + EXP_TINY && (huge + x) > zero)
+ RETURNI(x); /* x is tiny */
+ SET_LDBL_EXPSIGN(x, ix);
+ if (ix < 0x3ffe) { /* |x| < 0.5, or misnormal */
+ t = x+x;
+ t = 0.5*log1pl(t+t*x/(one-x));
+ } else
+ t = 0.5*log1pl((x+x)/(one-x));
+ RETURNI((hx & 0x8000) == 0 ? t : -t);
+}
diff --git a/lib/msun/src/e_exp.c b/lib/msun/src/e_exp.c
index e432bc83c1be..94c9769da38d 100644
--- a/lib/msun/src/e_exp.c
+++ b/lib/msun/src/e_exp.c
@@ -84,7 +84,6 @@ __FBSDID("$FreeBSD$");
static const double
one = 1.0,
halF[2] = {0.5,-0.5,},
-huge = 1.0e+300,
o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */
ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
@@ -99,6 +98,7 @@ P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
static volatile double
+huge = 1.0e+300,
twom1000= 9.33263618503218878990e-302; /* 2**-1000=0x01700000,0*/
double
diff --git a/lib/msun/src/e_expf.c b/lib/msun/src/e_expf.c
index a4790765bcb5..b1fe2c5371ac 100644
--- a/lib/msun/src/e_expf.c
+++ b/lib/msun/src/e_expf.c
@@ -24,7 +24,6 @@ __FBSDID("$FreeBSD$");
static const float
one = 1.0,
halF[2] = {0.5,-0.5,},
-huge = 1.0e+30,
o_threshold= 8.8721679688e+01, /* 0x42b17180 */
u_threshold= -1.0397208405e+02, /* 0xc2cff1b5 */
ln2HI[2] ={ 6.9314575195e-01, /* 0x3f317200 */
@@ -39,7 +38,9 @@ invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */
P1 = 1.6666625440e-1, /* 0xaaaa8f.0p-26 */
P2 = -2.7667332906e-3; /* -0xb55215.0p-32 */
-static volatile float twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
+static volatile float
+huge = 1.0e+30,
+twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
float
__ieee754_expf(float x)
diff --git a/lib/msun/src/e_log.c b/lib/msun/src/e_log.c
index 204fb48e4605..68bc1070ba37 100644
--- a/lib/msun/src/e_log.c
+++ b/lib/msun/src/e_log.c
@@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$");
* to produce the hexadecimal values shown.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -81,6 +83,7 @@ Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
static const double zero = 0.0;
+static volatile double vzero = 0.0;
double
__ieee754_log(double x)
@@ -94,7 +97,7 @@ __ieee754_log(double x)
k=0;
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
+ return -two54/vzero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
@@ -138,3 +141,7 @@ __ieee754_log(double x)
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
}
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(log, logl);
+#endif
diff --git a/lib/msun/src/e_log10.c b/lib/msun/src/e_log10.c
index 104d2574c659..3c89ed2d86cb 100644
--- a/lib/msun/src/e_log10.c
+++ b/lib/msun/src/e_log10.c
@@ -22,6 +22,8 @@ __FBSDID("$FreeBSD$");
* in not-quite-routine extra precision.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
#include "k_log.h"
@@ -34,6 +36,7 @@ log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
static const double zero = 0.0;
+static volatile double vzero = 0.0;
double
__ieee754_log10(double x)
@@ -47,7 +50,7 @@ __ieee754_log10(double x)
k=0;
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
+ return -two54/vzero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
@@ -85,3 +88,7 @@ __ieee754_log10(double x)
return val_lo + val_hi;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(log10, log10l);
+#endif
diff --git a/lib/msun/src/e_log10f.c b/lib/msun/src/e_log10f.c
index c8765941c6d0..9856df2e7b6a 100644
--- a/lib/msun/src/e_log10f.c
+++ b/lib/msun/src/e_log10f.c
@@ -28,6 +28,7 @@ log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */
log10_2lo = 7.9034151668e-07; /* 0x355427db */
static const float zero = 0.0;
+static volatile float vzero = 0.0;
float
__ieee754_log10f(float x)
@@ -40,7 +41,7 @@ __ieee754_log10f(float x)
k=0;
if (hx < 0x00800000) { /* x < 2**-126 */
if ((hx&0x7fffffff)==0)
- return -two25/zero; /* log(+-0)=-inf */
+ return -two25/vzero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 25; x *= two25; /* subnormal number, scale up x */
GET_FLOAT_WORD(hx,x);
diff --git a/lib/msun/src/e_log2.c b/lib/msun/src/e_log2.c
index 1fc44a5fedec..4766cdb49583 100644
--- a/lib/msun/src/e_log2.c
+++ b/lib/msun/src/e_log2.c
@@ -24,6 +24,8 @@ __FBSDID("$FreeBSD$");
* in not-quite-routine extra precision.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
#include "k_log.h"
@@ -34,6 +36,7 @@ ivln2hi = 1.44269504072144627571e+00, /* 0x3ff71547, 0x65200000 */
ivln2lo = 1.67517131648865118353e-10; /* 0x3de705fc, 0x2eefa200 */
static const double zero = 0.0;
+static volatile double vzero = 0.0;
double
__ieee754_log2(double x)
@@ -47,7 +50,7 @@ __ieee754_log2(double x)
k=0;
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
+ return -two54/vzero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
@@ -108,3 +111,7 @@ __ieee754_log2(double x)
return val_lo + val_hi;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(log2, log2l);
+#endif
diff --git a/lib/msun/src/e_log2f.c b/lib/msun/src/e_log2f.c
index 716634664a42..1794484e64ec 100644
--- a/lib/msun/src/e_log2f.c
+++ b/lib/msun/src/e_log2f.c
@@ -26,6 +26,7 @@ ivln2hi = 1.4428710938e+00, /* 0x3fb8b000 */
ivln2lo = -1.7605285393e-04; /* 0xb9389ad4 */
static const float zero = 0.0;
+static volatile float vzero = 0.0;
float
__ieee754_log2f(float x)
@@ -38,7 +39,7 @@ __ieee754_log2f(float x)
k=0;
if (hx < 0x00800000) { /* x < 2**-126 */
if ((hx&0x7fffffff)==0)
- return -two25/zero; /* log(+-0)=-inf */
+ return -two25/vzero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 25; x *= two25; /* subnormal number, scale up x */
GET_FLOAT_WORD(hx,x);
diff --git a/lib/msun/src/e_logf.c b/lib/msun/src/e_logf.c
index c3be6eda5694..ec3985fcbeda 100644
--- a/lib/msun/src/e_logf.c
+++ b/lib/msun/src/e_logf.c
@@ -30,6 +30,7 @@ Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
static const float zero = 0.0;
+static volatile float vzero = 0.0;
float
__ieee754_logf(float x)
@@ -42,7 +43,7 @@ __ieee754_logf(float x)
k=0;
if (ix < 0x00800000) { /* x < 2**-126 */
if ((ix&0x7fffffff)==0)
- return -two25/zero; /* log(+-0)=-inf */
+ return -two25/vzero; /* log(+-0)=-inf */
if (ix<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 25; x *= two25; /* subnormal number, scale up x */
GET_FLOAT_WORD(ix,x);
diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h
index c6cee1318d7b..1bd931c318f3 100644
--- a/lib/msun/src/math.h
+++ b/lib/msun/src/math.h
@@ -80,27 +80,43 @@ extern const union __nan_un {
#define FP_NORMAL 0x04
#define FP_SUBNORMAL 0x08
#define FP_ZERO 0x10
+
+#if (__STDC_VERSION__ >= 201112L && defined(__clang__)) || \
+ __has_extension(c_generic_selections)
+#define __fp_type_select(x, f, d, ld) _Generic((x), \
+ float: f(x), \
+ double: d(x), \
+ long double: ld(x), \
+ volatile float: f(x), \
+ volatile double: d(x), \
+ volatile long double: ld(x), \
+ volatile const float: f(x), \
+ volatile const double: d(x), \
+ volatile const long double: ld(x), \
+ const float: f(x), \
+ const double: d(x), \
+ const long double: ld(x))
+#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
+#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), long double), ld(x), \
+ __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), double), d(x), \
+ __builtin_choose_expr( \
+ __builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
+#else
+#define __fp_type_select(x, f, d, ld) \
+ ((sizeof(x) == sizeof(float)) ? f(x) \
+ : (sizeof(x) == sizeof(double)) ? d(x) \
+ : ld(x))
+#endif
+
#define fpclassify(x) \
- ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
- : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
- : __fpclassifyl(x))
-
-#define isfinite(x) \
- ((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
- : (sizeof (x) == sizeof (double)) ? __isfinite(x) \
- : __isfinitel(x))
-#define isinf(x) \
- ((sizeof (x) == sizeof (float)) ? __isinff(x) \
- : (sizeof (x) == sizeof (double)) ? isinf(x) \
- : __isinfl(x))
-#define isnan(x) \
- ((sizeof (x) == sizeof (float)) ? __isnanf(x) \
- : (sizeof (x) == sizeof (double)) ? isnan(x) \
- : __isnanl(x))
-#define isnormal(x) \
- ((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
- : (sizeof (x) == sizeof (double)) ? __isnormal(x) \
- : __isnormall(x))
+ __fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyl)
+#define isfinite(x) __fp_type_select(x, __isfinitef, __isfinite, __isfinitel)
+#define isinf(x) __fp_type_select(x, __isinff, __isinf, __isinfl)
+#define isnan(x) \
+ __fp_type_select(x, __inline_isnanf, __inline_isnan, __inline_isnanl)
+#define isnormal(x) __fp_type_select(x, __isnormalf, __isnormal, __isnormall)
#ifdef __MATH_BUILTIN_RELOPS
#define isgreater(x, y) __builtin_isgreater((x), (y))
@@ -119,10 +135,7 @@ extern const union __nan_un {
#define isunordered(x, y) (isnan(x) || isnan(y))
#endif /* __MATH_BUILTIN_RELOPS */
-#define signbit(x) \
- ((sizeof (x) == sizeof (float)) ? __signbitf(x) \
- : (sizeof (x) == sizeof (double)) ? __signbit(x) \
- : __signbitl(x))
+#define signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl)
typedef __double_t double_t;
typedef __float_t float_t;
@@ -175,9 +188,8 @@ int __isfinitef(float) __pure2;
int __isfinite(double) __pure2;
int __isfinitel(long double) __pure2;
int __isinff(float) __pure2;
+int __isinf(double) __pure2;
int __isinfl(long double) __pure2;
-int __isnanf(float) __pure2;
-int __isnanl(long double) __pure2;
int __isnormalf(float) __pure2;
int __isnormal(double) __pure2;
int __isnormall(long double) __pure2;
@@ -185,6 +197,42 @@ int __signbit(double) __pure2;
int __signbitf(float) __pure2;
int __signbitl(long double) __pure2;
+static __inline int
+__inline_isnan(__const double __x)
+{
+
+ return (__x != __x);
+}
+
+static __inline int
+__inline_isnanf(__const float __x)
+{
+
+ return (__x != __x);
+}
+
+static __inline int
+__inline_isnanl(__const long double __x)
+{
+
+ return (__x != __x);
+}
+
+/*
+ * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and
+ * isinf() as functions taking double. C99, and the subsequent POSIX revisions
+ * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating
+ * point type. If we are targeting SUSv2 and C99 or C11 (or C++11) then we
+ * expose the newer definition, assuming that the language spec takes
+ * precedence over the operating system interface spec.
+ */
+#if __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 && __ISO_C_VISIBLE < 1999
+#undef isinf
+#undef isnan
+int isinf(double);
+int isnan(double);
+#endif
+
double acos(double);
double asin(double);
double atan(double);
@@ -227,8 +275,6 @@ double expm1(double);
double fma(double, double, double);
double hypot(double, double);
int ilogb(double) __pure2;
-int (isinf)(double) __pure2;
-int (isnan)(double) __pure2;
double lgamma(double);
long long llrint(double);
long long llround(double);
@@ -395,9 +441,12 @@ float significandf(float);
* long double versions of ISO/POSIX math functions
*/
#if __ISO_C_VISIBLE >= 1999
+long double acoshl(long double);
long double acosl(long double);
+long double asinhl(long double);
long double asinl(long double);
long double atan2l(long double, long double);
+long double atanhl(long double);
long double atanl(long double);
long double cbrtl(long double);
long double ceill(long double);
@@ -405,6 +454,7 @@ long double copysignl(long double, long double) __pure2;
long double cosl(long double);
long double exp2l(long double);
long double expl(long double);
+long double expm1l(long double);
long double fabsl(long double) __pure2;
long double fdiml(long double, long double);
long double floorl(long double);
@@ -418,7 +468,11 @@ int ilogbl(long double) __pure2;
long double ldexpl(long double, int);
long long llrintl(long double);
long long llroundl(long double);
+long double log10l(long double);
+long double log1pl(long double);
+long double log2l(long double);
long double logbl(long double);
+long double logl(long double);
long lrintl(long double);
long lroundl(long double);
long double modfl(long double, long double *); /* fundamentally !__pure2 */
@@ -456,18 +510,10 @@ __END_DECLS
*/
__BEGIN_DECLS
-long double acoshl(long double);
-long double asinhl(long double);
-long double atanhl(long double);
long double coshl(long double);
long double erfcl(long double);
long double erfl(long double);
-long double expm1l(long double);
long double lgammal(long double);
-long double log10l(long double);
-long double log1pl(long double);
-long double log2l(long double);
-long double logl(long double);
long double powl(long double, long double);
long double sinhl(long double);
long double tanhl(long double);
diff --git a/lib/msun/src/math_private.h b/lib/msun/src/math_private.h
index 5662df01aaae..8ebc7fbf30c8 100644
--- a/lib/msun/src/math_private.h
+++ b/lib/msun/src/math_private.h
@@ -188,6 +188,33 @@ do { \
(d) = sf_u.value; \
} while (0)
+/*
+ * Get expsign and mantissa as 16 bit and 64 bit ints from an 80 bit long
+ * double.
+ */
+
+#define EXTRACT_LDBL80_WORDS(ix0,ix1,d) \
+do { \
+ union IEEEl2bits ew_u; \
+ ew_u.e = (d); \
+ (ix0) = ew_u.xbits.expsign; \
+ (ix1) = ew_u.xbits.man; \
+} while (0)
+
+/*
+ * Get expsign and mantissa as one 16 bit and two 64 bit ints from a 128 bit
+ * long double.
+ */
+
+#define EXTRACT_LDBL128_WORDS(ix0,ix1,ix2,d) \
+do { \
+ union IEEEl2bits ew_u; \
+ ew_u.e = (d); \
+ (ix0) = ew_u.xbits.expsign; \
+ (ix1) = ew_u.xbits.manh; \
+ (ix2) = ew_u.xbits.manl; \
+} while (0)
+
/* Get expsign as a 16 bit int from a long double. */
#define GET_LDBL_EXPSIGN(i,d) \
@@ -197,6 +224,33 @@ do { \
(i) = ge_u.xbits.expsign; \
} while (0)
+/*
+ * Set an 80 bit long double from a 16 bit int expsign and a 64 bit int
+ * mantissa.
+ */
+
+#define INSERT_LDBL80_WORDS(d,ix0,ix1) \
+do { \
+ union IEEEl2bits iw_u; \
+ iw_u.xbits.expsign = (ix0); \
+ iw_u.xbits.man = (ix1); \
+ (d) = iw_u.e; \
+} while (0)
+
+/*
+ * Set a 128 bit long double from a 16 bit int expsign and two 64 bit ints
+ * comprising the mantissa.
+ */
+
+#define INSERT_LDBL128_WORDS(d,ix0,ix1,ix2) \
+do { \
+ union IEEEl2bits iw_u; \
+ iw_u.xbits.expsign = (ix0); \
+ iw_u.xbits.manh = (ix1); \
+ iw_u.xbits.manl = (ix2); \
+ (d) = iw_u.e; \
+} while (0)
+
/* Set expsign of a long double from a 16 bit int. */
#define SET_LDBL_EXPSIGN(d,v) \
@@ -261,6 +315,110 @@ do { \
#define RETURNF(v) return (v)
/*
+ * 2sum gives the same result as 2sumF without requiring |a| >= |b| or
+ * a == 0, but is slower.
+ */
+#define _2sum(a, b) do { \
+ __typeof(a) __s, __w; \
+ \
+ __w = (a) + (b); \
+ __s = __w - (a); \
+ (b) = ((a) - (__w - __s)) + ((b) - __s); \
+ (a) = __w; \
+} while (0)
+
+/*
+ * 2sumF algorithm.
+ *
+ * "Normalize" the terms in the infinite-precision expression a + b for
+ * the sum of 2 floating point values so that b is as small as possible
+ * relative to 'a'. (The resulting 'a' is the value of the expression in
+ * the same precision as 'a' and the resulting b is the rounding error.)
+ * |a| must be >= |b| or 0, b's type must be no larger than 'a's type, and
+ * exponent overflow or underflow must not occur. This uses a Theorem of
+ * Dekker (1971). See Knuth (1981) 4.2.2 Theorem C. The name "TwoSum"
+ * is apparently due to Skewchuk (1997).
+ *
+ * For this to always work, assignment of a + b to 'a' must not retain any
+ * extra precision in a + b. This is required by C standards but broken
+ * in many compilers. The brokenness cannot be worked around using
+ * STRICT_ASSIGN() like we do elsewhere, since the efficiency of this
+ * algorithm would be destroyed by non-null strict assignments. (The
+ * compilers are correct to be broken -- the efficiency of all floating
+ * point code calculations would be destroyed similarly if they forced the
+ * conversions.)
+ *
+ * Fortunately, a case that works well can usually be arranged by building
+ * any extra precision into the type of 'a' -- 'a' should have type float_t,
+ * double_t or long double. b's type should be no larger than 'a's type.
+ * Callers should use these types with scopes as large as possible, to
+ * reduce their own extra-precision and efficiciency problems. In
+ * particular, they shouldn't convert back and forth just to call here.
+ */
+#ifdef DEBUG
+#define _2sumF(a, b) do { \
+ __typeof(a) __w; \
+ volatile __typeof(a) __ia, __ib, __r, __vw; \
+ \
+ __ia = (a); \
+ __ib = (b); \
+ assert(__ia == 0 || fabsl(__ia) >= fabsl(__ib)); \
+ \
+ __w = (a) + (b); \
+ (b) = ((a) - __w) + (b); \
+ (a) = __w; \
+ \
+ /* The next 2 assertions are weak if (a) is already long double. */ \
+ assert((long double)__ia + __ib == (long double)(a) + (b)); \
+ __vw = __ia + __ib; \
+ __r = __ia - __vw; \
+ __r += __ib; \
+ assert(__vw == (a) && __r == (b)); \
+} while (0)
+#else /* !DEBUG */
+#define _2sumF(a, b) do { \
+ __typeof(a) __w; \
+ \
+ __w = (a) + (b); \
+ (b) = ((a) - __w) + (b); \
+ (a) = __w; \
+} while (0)
+#endif /* DEBUG */
+
+/*
+ * Set x += c, where x is represented in extra precision as a + b.
+ * x must be sufficiently normalized and sufficiently larger than c,
+ * and the result is then sufficiently normalized.
+ *
+ * The details of ordering are that |a| must be >= |c| (so that (a, c)
+ * can be normalized without extra work to swap 'a' with c). The details of
+ * the normalization are that b must be small relative to the normalized 'a'.
+ * Normalization of (a, c) makes the normalized c tiny relative to the
+ * normalized a, so b remains small relative to 'a' in the result. However,
+ * b need not ever be tiny relative to 'a'. For example, b might be about
+ * 2**20 times smaller than 'a' to give about 20 extra bits of precision.
+ * That is usually enough, and adding c (which by normalization is about
+ * 2**53 times smaller than a) cannot change b significantly. However,
+ * cancellation of 'a' with c in normalization of (a, c) may reduce 'a'
+ * significantly relative to b. The caller must ensure that significant
+ * cancellation doesn't occur, either by having c of the same sign as 'a',
+ * or by having |c| a few percent smaller than |a|. Pre-normalization of
+ * (a, b) may help.
+ *
+ * This is is a variant of an algorithm of Kahan (see Knuth (1981) 4.2.2
+ * exercise 19). We gain considerable efficiency by requiring the terms to
+ * be sufficiently normalized and sufficiently increasing.
+ */
+#define _3sumF(a, b, c) do { \
+ __typeof(a) __tmp; \
+ \
+ __tmp = (c); \
+ _2sumF(__tmp, (a)); \
+ (b) += (a); \
+ (a) = __tmp; \
+} while (0)
+
+/*
* Common routine to process the arguments to nan(), nanf(), and nanl().
*/
void _scan_nan(uint32_t *__words, int __num_words, const char *__s);
@@ -370,6 +528,140 @@ irintl(long double x)
#endif /* __GNUCLIKE_ASM */
+#ifdef DEBUG
+#if defined(__amd64__) || defined(__i386__)
+#define breakpoint() asm("int $3")
+#else
+#include <signal.h>
+
+#define breakpoint() raise(SIGTRAP)
+#endif
+#endif
+
+/* Write a pari script to test things externally. */
+#ifdef DOPRINT
+#include <stdio.h>
+
+#ifndef DOPRINT_SWIZZLE
+#define DOPRINT_SWIZZLE 0
+#endif
+
+#ifdef DOPRINT_LD80
+
+#define DOPRINT_START(xp) do { \
+ uint64_t __lx; \
+ uint16_t __hx; \
+ \
+ /* Hack to give more-problematic args. */ \
+ EXTRACT_LDBL80_WORDS(__hx, __lx, *xp); \
+ __lx ^= DOPRINT_SWIZZLE; \
+ INSERT_LDBL80_WORDS(*xp, __hx, __lx); \
+ printf("x = %.21Lg; ", (long double)*xp); \
+} while (0)
+#define DOPRINT_END1(v) \
+ printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
+#define DOPRINT_END2(hi, lo) \
+ printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n", \
+ (long double)(hi), (long double)(lo))
+
+#elif defined(DOPRINT_D64)
+
+#define DOPRINT_START(xp) do { \
+ uint32_t __hx, __lx; \
+ \
+ EXTRACT_WORDS(__hx, __lx, *xp); \
+ __lx ^= DOPRINT_SWIZZLE; \
+ INSERT_WORDS(*xp, __hx, __lx); \
+ printf("x = %.21Lg; ", (long double)*xp); \
+} while (0)
+#define DOPRINT_END1(v) \
+ printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
+#define DOPRINT_END2(hi, lo) \
+ printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n", \
+ (long double)(hi), (long double)(lo))
+
+#elif defined(DOPRINT_F32)
+
+#define DOPRINT_START(xp) do { \
+ uint32_t __hx; \
+ \
+ GET_FLOAT_WORD(__hx, *xp); \
+ __hx ^= DOPRINT_SWIZZLE; \
+ SET_FLOAT_WORD(*xp, __hx); \
+ printf("x = %.21Lg; ", (long double)*xp); \
+} while (0)
+#define DOPRINT_END1(v) \
+ printf("y = %.21Lg; z = 0; show(x, y, z);\n", (long double)(v))
+#define DOPRINT_END2(hi, lo) \
+ printf("y = %.21Lg; z = %.21Lg; show(x, y, z);\n", \
+ (long double)(hi), (long double)(lo))
+
+#else /* !DOPRINT_LD80 && !DOPRINT_D64 (LD128 only) */
+
+#ifndef DOPRINT_SWIZZLE_HIGH
+#define DOPRINT_SWIZZLE_HIGH 0
+#endif
+
+#define DOPRINT_START(xp) do { \
+ uint64_t __lx, __llx; \
+ uint16_t __hx; \
+ \
+ EXTRACT_LDBL128_WORDS(__hx, __lx, __llx, *xp); \
+ __llx ^= DOPRINT_SWIZZLE; \
+ __lx ^= DOPRINT_SWIZZLE_HIGH; \
+ INSERT_LDBL128_WORDS(*xp, __hx, __lx, __llx); \
+ printf("x = %.36Lg; ", (long double)*xp); \
+} while (0)
+#define DOPRINT_END1(v) \
+ printf("y = %.36Lg; z = 0; show(x, y, z);\n", (long double)(v))
+#define DOPRINT_END2(hi, lo) \
+ printf("y = %.36Lg; z = %.36Lg; show(x, y, z);\n", \
+ (long double)(hi), (long double)(lo))
+
+#endif /* DOPRINT_LD80 */
+
+#else /* !DOPRINT */
+#define DOPRINT_START(xp)
+#define DOPRINT_END1(v)
+#define DOPRINT_END2(hi, lo)
+#endif /* DOPRINT */
+
+#define RETURNP(x) do { \
+ DOPRINT_END1(x); \
+ RETURNF(x); \
+} while (0)
+#define RETURNPI(x) do { \
+ DOPRINT_END1(x); \
+ RETURNI(x); \
+} while (0)
+#define RETURN2P(x, y) do { \
+ DOPRINT_END2((x), (y)); \
+ RETURNF((x) + (y)); \
+} while (0)
+#define RETURN2PI(x, y) do { \
+ DOPRINT_END2((x), (y)); \
+ RETURNI((x) + (y)); \
+} while (0)
+#ifdef STRUCT_RETURN
+#define RETURNSP(rp) do { \
+ if (!(rp)->lo_set) \
+ RETURNP((rp)->hi); \
+ RETURN2P((rp)->hi, (rp)->lo); \
+} while (0)
+#define RETURNSPI(rp) do { \
+ if (!(rp)->lo_set) \
+ RETURNPI((rp)->hi); \
+ RETURN2PI((rp)->hi, (rp)->lo); \
+} while (0)
+#endif
+#define SUM2P(x, y) ({ \
+ const __typeof (x) __x = (x); \
+ const __typeof (y) __y = (y); \
+ \
+ DOPRINT_END2(__x, __y); \
+ __x + __y; \
+})
+
/*
* ieee style elementary functions
*
diff --git a/lib/msun/src/s_asinh.c b/lib/msun/src/s_asinh.c
index f3fdf741a9f1..cbb3d463a30f 100644
--- a/lib/msun/src/s_asinh.c
+++ b/lib/msun/src/s_asinh.c
@@ -24,6 +24,8 @@ __FBSDID("$FreeBSD$");
* := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -54,3 +56,7 @@ asinh(double x)
}
if(hx>0) return w; else return -w;
}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(asinh, asinhl);
+#endif
diff --git a/lib/msun/src/s_asinhl.c b/lib/msun/src/s_asinhl.c
new file mode 100644
index 000000000000..ba28f599c3ca
--- /dev/null
+++ b/lib/msun/src/s_asinhl.c
@@ -0,0 +1,91 @@
+/* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
+
+/* @(#)s_asinh.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * See s_asinh.c for complete comments.
+ *
+ * Converted to long double by David Schultz <das@FreeBSD.ORG> and
+ * Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+/* EXP_LARGE is the threshold above which we use asinh(x) ~= log(2x). */
+/* EXP_TINY is the threshold below which we use asinh(x) ~= x. */
+#if LDBL_MANT_DIG == 64
+#define EXP_LARGE 34
+#define EXP_TINY -34
+#elif LDBL_MANT_DIG == 113
+#define EXP_LARGE 58
+#define EXP_TINY -58
+#else
+#error "Unsupported long double format"
+#endif
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const double
+one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+huge= 1.00000000000000000000e+300;
+
+#if LDBL_MANT_DIG == 64
+static const union IEEEl2bits
+u_ln2 = LD80C(0xb17217f7d1cf79ac, -1, 6.93147180559945309417e-1L);
+#define ln2 u_ln2.e
+#elif LDBL_MANT_DIG == 113
+static const long double
+ln2 = 6.93147180559945309417232121458176568e-1L; /* 0x162e42fefa39ef35793c7673007e6.0p-113 */
+#else
+#error "Unsupported long double format"
+#endif
+
+long double
+asinhl(long double x)
+{
+ long double t, w;
+ uint16_t hx, ix;
+
+ ENTERI();
+ GET_LDBL_EXPSIGN(hx, x);
+ ix = hx & 0x7fff;
+ if (ix >= 0x7fff) RETURNI(x+x); /* x is inf, NaN or misnormal */
+ if (ix < BIAS + EXP_TINY) { /* |x| < TINY, or misnormal */
+ if (huge + x > one) RETURNI(x); /* return x inexact except 0 */
+ }
+ if (ix >= BIAS + EXP_LARGE) { /* |x| >= LARGE, or misnormal */
+ w = logl(fabsl(x))+ln2;
+ } else if (ix >= 0x4000) { /* LARGE > |x| >= 2.0, or misnormal */
+ t = fabsl(x);
+ w = logl(2.0*t+one/(sqrtl(x*x+one)+t));
+ } else { /* 2.0 > |x| >= TINY, or misnormal */
+ t = x*x;
+ w =log1pl(fabsl(x)+t/(one+sqrtl(one+t)));
+ }
+ RETURNI((hx & 0x8000) == 0 ? w : -w);
+}
diff --git a/lib/msun/src/s_erf.c b/lib/msun/src/s_erf.c
index 0886e5e7df91..854767bc913f 100644
--- a/lib/msun/src/s_erf.c
+++ b/lib/msun/src/s_erf.c
@@ -201,7 +201,7 @@ erf(double x)
if(ix < 0x3feb0000) { /* |x|<0.84375 */
if(ix < 0x3e300000) { /* |x|<2**-28 */
if (ix < 0x00800000)
- return 0.125*(8.0*x+efx8*x); /*avoid underflow */
+ return (8*x+efx8*x)/8; /* avoid spurious underflow */
return x + efx*x;
}
z = x*x;
diff --git a/lib/msun/src/s_erff.c b/lib/msun/src/s_erff.c
index a44e13565065..b97ca1d12356 100644
--- a/lib/msun/src/s_erff.c
+++ b/lib/msun/src/s_erff.c
@@ -24,75 +24,59 @@ tiny = 1e-30,
half= 5.0000000000e-01, /* 0x3F000000 */
one = 1.0000000000e+00, /* 0x3F800000 */
two = 2.0000000000e+00, /* 0x40000000 */
- /* c = (subfloat)0.84506291151 */
-erx = 8.4506291151e-01, /* 0x3f58560b */
/*
- * Coefficients for approximation to erf on [0,0.84375]
+ * Coefficients for approximation to erf on [0,0.84375]
*/
efx = 1.2837916613e-01, /* 0x3e0375d4 */
efx8= 1.0270333290e+00, /* 0x3f8375d4 */
-pp0 = 1.2837916613e-01, /* 0x3e0375d4 */
-pp1 = -3.2504209876e-01, /* 0xbea66beb */
-pp2 = -2.8481749818e-02, /* 0xbce9528f */
-pp3 = -5.7702702470e-03, /* 0xbbbd1489 */
-pp4 = -2.3763017452e-05, /* 0xb7c756b1 */
-qq1 = 3.9791721106e-01, /* 0x3ecbbbce */
-qq2 = 6.5022252500e-02, /* 0x3d852a63 */
-qq3 = 5.0813062117e-03, /* 0x3ba68116 */
-qq4 = 1.3249473704e-04, /* 0x390aee49 */
-qq5 = -3.9602282413e-06, /* 0xb684e21a */
/*
- * Coefficients for approximation to erf in [0.84375,1.25]
+ * Domain [0, 0.84375], range ~[-5.4446e-10,5.5197e-10]:
+ * |(erf(x) - x)/x - p(x)/q(x)| < 2**-31.
*/
-pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */
-pa1 = 4.1485610604e-01, /* 0x3ed46805 */
-pa2 = -3.7220788002e-01, /* 0xbebe9208 */
-pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */
-pa4 = -1.1089469492e-01, /* 0xbde31cc2 */
-pa5 = 3.5478305072e-02, /* 0x3d1151b3 */
-pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */
-qa1 = 1.0642088205e-01, /* 0x3dd9f331 */
-qa2 = 5.4039794207e-01, /* 0x3f0a5785 */
-qa3 = 7.1828655899e-02, /* 0x3d931ae7 */
-qa4 = 1.2617121637e-01, /* 0x3e013307 */
-qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */
-qa6 = 1.1984500103e-02, /* 0x3c445aa3 */
+pp0 = 1.28379166e-01F, /* 0x1.06eba8p-3 */
+pp1 = -3.36030394e-01F, /* -0x1.58185ap-2 */
+pp2 = -1.86260219e-03F, /* -0x1.e8451ep-10 */
+qq1 = 3.12324286e-01F, /* 0x1.3fd1f0p-2 */
+qq2 = 2.16070302e-02F, /* 0x1.620274p-6 */
+qq3 = -1.98859419e-03F, /* -0x1.04a626p-9 */
/*
- * Coefficients for approximation to erfc in [1.25,1/0.35]
+ * Domain [0.84375, 1.25], range ~[-1.953e-11,1.940e-11]:
+ * |(erf(x) - erx) - p(x)/q(x)| < 2**-36.
*/
-ra0 = -9.8649440333e-03, /* 0xbc21a093 */
-ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */
-ra2 = -1.0558626175e+01, /* 0xc128f022 */
-ra3 = -6.2375331879e+01, /* 0xc2798057 */
-ra4 = -1.6239666748e+02, /* 0xc322658c */
-ra5 = -1.8460508728e+02, /* 0xc3389ae7 */
-ra6 = -8.1287437439e+01, /* 0xc2a2932b */
-ra7 = -9.8143291473e+00, /* 0xc11d077e */
-sa1 = 1.9651271820e+01, /* 0x419d35ce */
-sa2 = 1.3765776062e+02, /* 0x4309a863 */
-sa3 = 4.3456588745e+02, /* 0x43d9486f */
-sa4 = 6.4538726807e+02, /* 0x442158c9 */
-sa5 = 4.2900814819e+02, /* 0x43d6810b */
-sa6 = 1.0863500214e+02, /* 0x42d9451f */
-sa7 = 6.5702495575e+00, /* 0x40d23f7c */
-sa8 = -6.0424413532e-02, /* 0xbd777f97 */
+erx = 8.42697144e-01F, /* 0x1.af7600p-1. erf(1) rounded to 16 bits. */
+pa0 = 3.64939137e-06F, /* 0x1.e9d022p-19 */
+pa1 = 4.15109694e-01F, /* 0x1.a91284p-2 */
+pa2 = -1.65179938e-01F, /* -0x1.5249dcp-3 */
+pa3 = 1.10914491e-01F, /* 0x1.c64e46p-4 */
+qa1 = 6.02074385e-01F, /* 0x1.344318p-1 */
+qa2 = 5.35934687e-01F, /* 0x1.126608p-1 */
+qa3 = 1.68576106e-01F, /* 0x1.593e6ep-3 */
+qa4 = 5.62181212e-02F, /* 0x1.cc89f2p-5 */
/*
- * Coefficients for approximation to erfc in [1/.35,28]
+ * Domain [1.25,1/0.35], range ~[-7.043e-10,7.457e-10]:
+ * |log(x*erfc(x)) + x**2 + 0.5625 - r(x)/s(x)| < 2**-30
*/
-rb0 = -9.8649431020e-03, /* 0xbc21a092 */
-rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */
-rb2 = -1.7757955551e+01, /* 0xc18e104b */
-rb3 = -1.6063638306e+02, /* 0xc320a2ea */
-rb4 = -6.3756646729e+02, /* 0xc41f6441 */
-rb5 = -1.0250950928e+03, /* 0xc480230b */
-rb6 = -4.8351919556e+02, /* 0xc3f1c275 */
-sb1 = 3.0338060379e+01, /* 0x41f2b459 */
-sb2 = 3.2579251099e+02, /* 0x43a2e571 */
-sb3 = 1.5367296143e+03, /* 0x44c01759 */
-sb4 = 3.1998581543e+03, /* 0x4547fdbb */
-sb5 = 2.5530502930e+03, /* 0x451f90ce */
-sb6 = 4.7452853394e+02, /* 0x43ed43a7 */
-sb7 = -2.2440952301e+01; /* 0xc1b38712 */
+ra0 = -9.87132732e-03F, /* -0x1.4376b2p-7 */
+ra1 = -5.53605914e-01F, /* -0x1.1b723cp-1 */
+ra2 = -2.17589188e+00F, /* -0x1.1683a0p+1 */
+ra3 = -1.43268085e+00F, /* -0x1.6ec42cp+0 */
+sa1 = 5.45995426e+00F, /* 0x1.5d6fe4p+2 */
+sa2 = 6.69798088e+00F, /* 0x1.acabb8p+2 */
+sa3 = 1.43113089e+00F, /* 0x1.6e5e98p+0 */
+sa4 = -5.77397496e-02F, /* -0x1.d90108p-5 */
+/*
+ * Domain [1/0.35, 11], range ~[-2.264e-13,2.336e-13]:
+ * |log(x*erfc(x)) + x**2 + 0.5625 - r(x)/s(x)| < 2**-42
+ */
+rb0 = -9.86494310e-03F, /* -0x1.434124p-7 */
+rb1 = -6.25171244e-01F, /* -0x1.401672p-1 */
+rb2 = -6.16498327e+00F, /* -0x1.8a8f16p+2 */
+rb3 = -1.66696873e+01F, /* -0x1.0ab70ap+4 */
+rb4 = -9.53764343e+00F, /* -0x1.313460p+3 */
+sb1 = 1.26884899e+01F, /* 0x1.96081cp+3 */
+sb2 = 4.51839523e+01F, /* 0x1.6978bcp+5 */
+sb3 = 4.72810211e+01F, /* 0x1.7a3f88p+5 */
+sb4 = 8.93033314e+00F; /* 0x1.1dc54ap+3 */
float
erff(float x)
@@ -107,43 +91,37 @@ erff(float x)
}
if(ix < 0x3f580000) { /* |x|<0.84375 */
- if(ix < 0x31800000) { /* |x|<2**-28 */
- if (ix < 0x04000000)
- /*avoid underflow */
- return (float)0.125*((float)8.0*x+efx8*x);
+ if(ix < 0x38800000) { /* |x|<2**-14 */
+ if (ix < 0x04000000) /* |x|<0x1p-119 */
+ return (8*x+efx8*x)/8; /* avoid spurious underflow */
return x + efx*x;
}
z = x*x;
- r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
- s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+ r = pp0+z*(pp1+z*pp2);
+ s = one+z*(qq1+z*(qq2+z*qq3));
y = r/s;
return x + x*y;
}
if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */
s = fabsf(x)-one;
- P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
- Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ P = pa0+s*(pa1+s*(pa2+s*pa3));
+ Q = one+s*(qa1+s*(qa2+s*(qa3+s*qa4)));
if(hx>=0) return erx + P/Q; else return -erx - P/Q;
}
- if (ix >= 0x40c00000) { /* inf>|x|>=6 */
+ if (ix >= 0x40800000) { /* inf>|x|>=4 */
if(hx>=0) return one-tiny; else return tiny-one;
}
x = fabsf(x);
s = one/(x*x);
if(ix< 0x4036DB6E) { /* |x| < 1/0.35 */
- R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
- ra5+s*(ra6+s*ra7))))));
- S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
- sa5+s*(sa6+s*(sa7+s*sa8)))))));
+ R=ra0+s*(ra1+s*(ra2+s*ra3));
+ S=one+s*(sa1+s*(sa2+s*(sa3+s*sa4)));
} else { /* |x| >= 1/0.35 */
- R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
- rb5+s*rb6)))));
- S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
- sb5+s*(sb6+s*sb7))))));
+ R=rb0+s*(rb1+s*(rb2+s*(rb3+s*rb4)));
+ S=one+s*(sb1+s*(sb2+s*(sb3+s*sb4)));
}
- GET_FLOAT_WORD(ix,x);
- SET_FLOAT_WORD(z,ix&0xfffff000);
- r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S);
+ SET_FLOAT_WORD(z,hx&0xffffe000);
+ r = expf(-z*z-0.5625F)*expf((z-x)*(z+x)+R/S);
if(hx>=0) return one-r/x; else return r/x-one;
}
@@ -160,11 +138,11 @@ erfcf(float x)
}
if(ix < 0x3f580000) { /* |x|<0.84375 */
- if(ix < 0x23800000) /* |x|<2**-56 */
+ if(ix < 0x33800000) /* |x|<2**-24 */
return one-x;
z = x*x;
- r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
- s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+ r = pp0+z*(pp1+z*pp2);
+ s = one+z*(qq1+z*(qq2+z*qq3));
y = r/s;
if(hx < 0x3e800000) { /* x<1/4 */
return one-(x+x*y);
@@ -176,33 +154,27 @@ erfcf(float x)
}
if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */
s = fabsf(x)-one;
- P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
- Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ P = pa0+s*(pa1+s*(pa2+s*pa3));
+ Q = one+s*(qa1+s*(qa2+s*(qa3+s*qa4)));
if(hx>=0) {
z = one-erx; return z - P/Q;
} else {
z = erx+P/Q; return one+z;
}
}
- if (ix < 0x41e00000) { /* |x|<28 */
+ if (ix < 0x41300000) { /* |x|<11 */
x = fabsf(x);
s = one/(x*x);
if(ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/
- R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
- ra5+s*(ra6+s*ra7))))));
- S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
- sa5+s*(sa6+s*(sa7+s*sa8)))))));
+ R=ra0+s*(ra1+s*(ra2+s*ra3));
+ S=one+s*(sa1+s*(sa2+s*(sa3+s*sa4)));
} else { /* |x| >= 1/.35 ~ 2.857143 */
- if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */
- R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
- rb5+s*rb6)))));
- S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
- sb5+s*(sb6+s*sb7))))));
+ if(hx<0&&ix>=0x40a00000) return two-tiny;/* x < -5 */
+ R=rb0+s*(rb1+s*(rb2+s*(rb3+s*rb4)));
+ S=one+s*(sb1+s*(sb2+s*(sb3+s*sb4)));
}
- GET_FLOAT_WORD(ix,x);
- SET_FLOAT_WORD(z,ix&0xfffff000);
- r = __ieee754_expf(-z*z-(float)0.5625)*
- __ieee754_expf((z-x)*(z+x)+R/S);
+ SET_FLOAT_WORD(z,hx&0xffffe000);
+ r = expf(-z*z-0.5625F)*expf((z-x)*(z+x)+R/S);
if(hx>0) return r/x; else return two-r/x;
} else {
if(hx>0) return tiny*tiny; else return two-tiny;
diff --git a/lib/msun/src/s_exp2.c b/lib/msun/src/s_exp2.c
index 485b4e3c3e7f..fde11c27d63e 100644
--- a/lib/msun/src/s_exp2.c
+++ b/lib/msun/src/s_exp2.c
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#define TBLSIZE (1 << TBLBITS)
static const double
- huge = 0x1p1000,
redux = 0x1.8p52 / TBLSIZE,
P1 = 0x1.62e42fefa39efp-1,
P2 = 0x1.ebfbdff82c575p-3,
@@ -44,7 +43,9 @@ static const double
P4 = 0x1.3b2ab88f70400p-7,
P5 = 0x1.5d88003875c74p-10;
-static volatile double twom1000 = 0x1p-1000;
+static volatile double
+ huge = 0x1p1000,
+ twom1000 = 0x1p-1000;
static const double tbl[TBLSIZE * 2] = {
/* exp2(z + eps) eps */
diff --git a/lib/msun/src/s_exp2f.c b/lib/msun/src/s_exp2f.c
index 0a97bf64d7a8..9ac7c1f6cac2 100644
--- a/lib/msun/src/s_exp2f.c
+++ b/lib/msun/src/s_exp2f.c
@@ -36,14 +36,15 @@ __FBSDID("$FreeBSD$");
#define TBLSIZE (1 << TBLBITS)
static const float
- huge = 0x1p100f,
redux = 0x1.8p23f / TBLSIZE,
P1 = 0x1.62e430p-1f,
P2 = 0x1.ebfbe0p-3f,
P3 = 0x1.c6b348p-5f,
P4 = 0x1.3b2c9cp-7f;
-static volatile float twom100 = 0x1p-100f;
+static volatile float
+ huge = 0x1p100f,
+ twom100 = 0x1p-100f;
static const double exp2ft[TBLSIZE] = {
0x1.6a09e667f3bcdp-1,
diff --git a/lib/msun/src/s_expm1.c b/lib/msun/src/s_expm1.c
index 5aa1917b5a4c..37998a3871aa 100644
--- a/lib/msun/src/s_expm1.c
+++ b/lib/msun/src/s_expm1.c
@@ -115,7 +115,6 @@ __FBSDID("$FreeBSD$");
static const double
one = 1.0,
-huge = 1.0e+300,
tiny = 1.0e-300,
o_threshold = 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */
ln2_hi = 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */
@@ -128,6 +127,8 @@ Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */
Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
+static volatile double huge = 1.0e+300;
+
double
expm1(double x)
{
@@ -215,3 +216,7 @@ expm1(double x)
}
return y;
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(expm1, expm1l);
+#endif
diff --git a/lib/msun/src/s_expm1f.c b/lib/msun/src/s_expm1f.c
index fb374943000e..c0a39340fc04 100644
--- a/lib/msun/src/s_expm1f.c
+++ b/lib/msun/src/s_expm1f.c
@@ -23,7 +23,6 @@ __FBSDID("$FreeBSD$");
static const float
one = 1.0,
-huge = 1.0e+30,
tiny = 1.0e-30,
o_threshold = 8.8721679688e+01,/* 0x42b17180 */
ln2_hi = 6.9313812256e-01,/* 0x3f317180 */
@@ -37,6 +36,8 @@ invln2 = 1.4426950216e+00,/* 0x3fb8aa3b */
Q1 = -3.3333212137e-2, /* -0x888868.0p-28 */
Q2 = 1.5807170421e-3; /* 0xcf3010.0p-33 */
+static volatile float huge = 1.0e+30;
+
float
expm1f(float x)
{
diff --git a/lib/msun/src/s_fma.c b/lib/msun/src/s_fma.c
index dfbd13c46815..b1066c20a15f 100644
--- a/lib/msun/src/s_fma.c
+++ b/lib/msun/src/s_fma.c
@@ -117,7 +117,7 @@ add_and_denormalize(double a, double b, int scale)
if (sum.lo != 0) {
EXTRACT_WORD64(hibits, sum.hi);
bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 1;
- if (bits_lost != 1 ^ (int)(hibits & 1)) {
+ if ((bits_lost != 1) ^ (int)(hibits & 1)) {
/* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
EXTRACT_WORD64(lobits, sum.lo);
hibits += 1 - (((hibits ^ lobits) >> 62) & 2);
@@ -238,6 +238,8 @@ fma(double x, double y, double z)
zs = copysign(DBL_MIN, zs);
fesetround(FE_TONEAREST);
+ /* work around clang bug 8100 */
+ volatile double vxs = xs;
/*
* Basic approach for round-to-nearest:
@@ -247,7 +249,7 @@ fma(double x, double y, double z)
* adj = xy.lo + r.lo (inexact; low bit is sticky)
* result = r.hi + adj (correctly rounded)
*/
- xy = dd_mul(xs, ys);
+ xy = dd_mul(vxs, ys);
r = dd_add(xy.hi, zs);
spread = ex + ey;
@@ -268,7 +270,9 @@ fma(double x, double y, double z)
* rounding modes.
*/
fesetround(oround);
- adj = r.lo + xy.lo;
+ /* work around clang bug 8100 */
+ volatile double vrlo = r.lo;
+ adj = vrlo + xy.lo;
return (ldexp(r.hi + adj, spread));
}
diff --git a/lib/msun/src/s_fmal.c b/lib/msun/src/s_fmal.c
index c2a691350999..d435f4f451fd 100644
--- a/lib/msun/src/s_fmal.c
+++ b/lib/msun/src/s_fmal.c
@@ -113,7 +113,7 @@ add_and_denormalize(long double a, long double b, int scale)
if (sum.lo != 0) {
u.e = sum.hi;
bits_lost = -u.bits.exp - scale + 1;
- if (bits_lost != 1 ^ (int)(u.bits.manl & 1))
+ if ((bits_lost != 1) ^ (int)(u.bits.manl & 1))
sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
}
return (ldexp(sum.hi, scale));
@@ -226,6 +226,8 @@ fmal(long double x, long double y, long double z)
zs = copysignl(LDBL_MIN, zs);
fesetround(FE_TONEAREST);
+ /* work around clang bug 8100 */
+ volatile long double vxs = xs;
/*
* Basic approach for round-to-nearest:
@@ -235,7 +237,7 @@ fmal(long double x, long double y, long double z)
* adj = xy.lo + r.lo (inexact; low bit is sticky)
* result = r.hi + adj (correctly rounded)
*/
- xy = dd_mul(xs, ys);
+ xy = dd_mul(vxs, ys);
r = dd_add(xy.hi, zs);
spread = ex + ey;
@@ -256,7 +258,9 @@ fmal(long double x, long double y, long double z)
* rounding modes.
*/
fesetround(oround);
- adj = r.lo + xy.lo;
+ /* work around clang bug 8100 */
+ volatile long double vrlo = r.lo;
+ adj = vrlo + xy.lo;
return (ldexpl(r.hi + adj, spread));
}
diff --git a/lib/msun/src/s_log1p.c b/lib/msun/src/s_log1p.c
index b062a8ad9290..3cc77bda2ec8 100644
--- a/lib/msun/src/s_log1p.c
+++ b/lib/msun/src/s_log1p.c
@@ -96,6 +96,7 @@ Lp6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
Lp7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
static const double zero = 0.0;
+static volatile double vzero = 0.0;
double
log1p(double x)
@@ -109,7 +110,7 @@ log1p(double x)
k = 1;
if (hx < 0x3FDA827A) { /* 1+x < sqrt(2)+ */
if(ax>=0x3ff00000) { /* x <= -1.0 */
- if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */
+ if(x==-1.0) return -two54/vzero; /* log1p(-1)=+inf */
else return (x-x)/(x-x); /* log1p(x<-1)=NaN */
}
if(ax<0x3e200000) { /* |x| < 2**-29 */
@@ -173,3 +174,7 @@ log1p(double x)
if(k==0) return f-(hfsq-s*(hfsq+R)); else
return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
}
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(log1p, log1pl);
+#endif
diff --git a/lib/msun/src/s_log1pf.c b/lib/msun/src/s_log1pf.c
index 01d3457d306f..df04c6756e8d 100644
--- a/lib/msun/src/s_log1pf.c
+++ b/lib/msun/src/s_log1pf.c
@@ -34,6 +34,7 @@ Lp6 = 1.5313838422e-01, /* 3E1CD04F */
Lp7 = 1.4798198640e-01; /* 3E178897 */
static const float zero = 0.0;
+static volatile float vzero = 0.0;
float
log1pf(float x)
@@ -47,7 +48,7 @@ log1pf(float x)
k = 1;
if (hx < 0x3ed413d0) { /* 1+x < sqrt(2)+ */
if(ax>=0x3f800000) { /* x <= -1.0 */
- if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=+inf */
+ if(x==(float)-1.0) return -two25/vzero; /* log1p(-1)=+inf */
else return (x-x)/(x-x); /* log1p(x<-1)=NaN */
}
if(ax<0x38000000) { /* |x| < 2**-15 */
diff --git a/lib/msun/src/s_nearbyint.c b/lib/msun/src/s_nearbyint.c
index 12493d292809..063f8d7365f9 100644
--- a/lib/msun/src/s_nearbyint.c
+++ b/lib/msun/src/s_nearbyint.c
@@ -36,12 +36,16 @@ __FBSDID("$FreeBSD$");
* instead of feclearexcept()/feupdateenv() to restore the environment
* because the only exception defined for rint() is overflow, and
* rounding can't overflow as long as emax >= p.
+ *
+ * The volatile keyword is needed below because clang incorrectly assumes
+ * that rint won't raise any floating-point exceptions. Declaring ret volatile
+ * is sufficient to trick the compiler into doing the right thing.
*/
#define DECL(type, fn, rint) \
type \
fn(type x) \
{ \
- type ret; \
+ volatile type ret; \
fenv_t env; \
\
fegetenv(&env); \
diff --git a/lib/msun/i387/fenv.h b/lib/msun/x86/fenv.h
index 329dfe1021cb..a4e452d5e465 100644
--- a/lib/msun/i387/fenv.h
+++ b/lib/msun/x86/fenv.h
@@ -36,26 +36,6 @@
#define __fenv_static static
#endif
-/*
- * To preserve binary compatibility with FreeBSD 5.3, we pack the
- * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
- */
-typedef struct {
- __uint16_t __control;
- __uint16_t __mxcsr_hi;
- __uint16_t __status;
- __uint16_t __mxcsr_lo;
- __uint32_t __tag;
- char __other[16];
-} fenv_t;
-
-#define __get_mxcsr(env) (((env).__mxcsr_hi << 16) | \
- ((env).__mxcsr_lo))
-#define __set_mxcsr(env, x) do { \
- (env).__mxcsr_hi = (__uint32_t)(x) >> 16; \
- (env).__mxcsr_lo = (__uint16_t)(x); \
-} while (0)
-
typedef __uint16_t fexcept_t;
/* Exception flags */
@@ -84,18 +64,32 @@ typedef __uint16_t fexcept_t;
#define _SSE_ROUND_SHIFT 3
#define _SSE_EMASK_SHIFT 7
-__BEGIN_DECLS
+#ifdef __i386__
+/*
+ * To preserve binary compatibility with FreeBSD 5.3, we pack the
+ * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
+ */
+typedef struct {
+ __uint16_t __control;
+ __uint16_t __mxcsr_hi;
+ __uint16_t __status;
+ __uint16_t __mxcsr_lo;
+ __uint32_t __tag;
+ char __other[16];
+} fenv_t;
+#else /* __amd64__ */
+typedef struct {
+ struct {
+ __uint32_t __control;
+ __uint32_t __status;
+ __uint32_t __tag;
+ char __other[16];
+ } __x87;
+ __uint32_t __mxcsr;
+} fenv_t;
+#endif /* __i386__ */
-/* After testing for SSE support once, we cache the result in __has_sse. */
-enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
-extern enum __sse_support __has_sse;
-int __test_sse(void);
-#ifdef __SSE__
-#define __HAS_SSE() 1
-#else
-#define __HAS_SSE() (__has_sse == __SSE_YES || \
- (__has_sse == __SSE_UNK && __test_sse()))
-#endif
+__BEGIN_DECLS
/* Default floating-point environment */
extern const fenv_t __fe_dfl_env;
@@ -114,6 +108,68 @@ extern const fenv_t __fe_dfl_env;
#define __ldmxcsr(__csr) __asm __volatile("ldmxcsr %0" : : "m" (__csr))
#define __stmxcsr(__csr) __asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
+int fegetenv(fenv_t *__envp);
+int feholdexcept(fenv_t *__envp);
+int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+int feraiseexcept(int __excepts);
+int feupdateenv(const fenv_t *__envp);
+
+__fenv_static inline int
+fegetround(void)
+{
+ __uint16_t __control;
+
+ /*
+ * We assume that the x87 and the SSE unit agree on the
+ * rounding mode. Reading the control word on the x87 turns
+ * out to be about 5 times faster than reading it on the SSE
+ * unit on an Opteron 244.
+ */
+ __fnstcw(&__control);
+ return (__control & _ROUND_MASK);
+}
+
+#if __BSD_VISIBLE
+
+int feenableexcept(int __mask);
+int fedisableexcept(int __mask);
+
+/* We currently provide no external definition of fegetexcept(). */
+static inline int
+fegetexcept(void)
+{
+ __uint16_t __control;
+
+ /*
+ * We assume that the masks for the x87 and the SSE unit are
+ * the same.
+ */
+ __fnstcw(&__control);
+ return (~__control & FE_ALL_EXCEPT);
+}
+
+#endif /* __BSD_VISIBLE */
+
+#ifdef __i386__
+
+/* After testing for SSE support once, we cache the result in __has_sse. */
+enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
+extern enum __sse_support __has_sse;
+int __test_sse(void);
+#ifdef __SSE__
+#define __HAS_SSE() 1
+#else
+#define __HAS_SSE() (__has_sse == __SSE_YES || \
+ (__has_sse == __SSE_UNK && __test_sse()))
+#endif
+
+#define __get_mxcsr(env) (((env).__mxcsr_hi << 16) | \
+ ((env).__mxcsr_lo))
+#define __set_mxcsr(env, x) do { \
+ (env).__mxcsr_hi = (__uint32_t)(x) >> 16; \
+ (env).__mxcsr_lo = (__uint16_t)(x); \
+} while (0)
+
__fenv_static inline int
feclearexcept(int __excepts)
{
@@ -150,9 +206,6 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
return (0);
}
-int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
-int feraiseexcept(int __excepts);
-
__fenv_static inline int
fetestexcept(int __excepts)
{
@@ -168,21 +221,6 @@ fetestexcept(int __excepts)
}
__fenv_static inline int
-fegetround(void)
-{
- __uint16_t __control;
-
- /*
- * We assume that the x87 and the SSE unit agree on the
- * rounding mode. Reading the control word on the x87 turns
- * out to be about 5 times faster than reading it on the SSE
- * unit on an Opteron 244.
- */
- __fnstcw(&__control);
- return (__control & _ROUND_MASK);
-}
-
-__fenv_static inline int
fesetround(int __round)
{
__uint32_t __mxcsr;
@@ -206,9 +244,6 @@ fesetround(int __round)
return (0);
}
-int fegetenv(fenv_t *__envp);
-int feholdexcept(fenv_t *__envp);
-
__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
@@ -231,28 +266,89 @@ fesetenv(const fenv_t *__envp)
return (0);
}
-int feupdateenv(const fenv_t *__envp);
+#else /* __amd64__ */
-#if __BSD_VISIBLE
+__fenv_static inline int
+feclearexcept(int __excepts)
+{
+ fenv_t __env;
-int feenableexcept(int __mask);
-int fedisableexcept(int __mask);
+ if (__excepts == FE_ALL_EXCEPT) {
+ __fnclex();
+ } else {
+ __fnstenv(&__env.__x87);
+ __env.__x87.__status &= ~__excepts;
+ __fldenv(__env.__x87);
+ }
+ __stmxcsr(&__env.__mxcsr);
+ __env.__mxcsr &= ~__excepts;
+ __ldmxcsr(__env.__mxcsr);
+ return (0);
+}
-/* We currently provide no external definition of fegetexcept(). */
-static inline int
-fegetexcept(void)
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+ __uint32_t __mxcsr;
+ __uint16_t __status;
+
+ __stmxcsr(&__mxcsr);
+ __fnstsw(&__status);
+ *__flagp = (__mxcsr | __status) & __excepts;
+ return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
{
+ __uint32_t __mxcsr;
+ __uint16_t __status;
+
+ __stmxcsr(&__mxcsr);
+ __fnstsw(&__status);
+ return ((__status | __mxcsr) & __excepts);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+ __uint32_t __mxcsr;
__uint16_t __control;
+ if (__round & ~_ROUND_MASK)
+ return (-1);
+
+ __fnstcw(&__control);
+ __control &= ~_ROUND_MASK;
+ __control |= __round;
+ __fldcw(__control);
+
+ __stmxcsr(&__mxcsr);
+ __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
+ __mxcsr |= __round << _SSE_ROUND_SHIFT;
+ __ldmxcsr(__mxcsr);
+
+ return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
+{
+
/*
- * We assume that the masks for the x87 and the SSE unit are
- * the same.
+ * XXX Using fldenvx() instead of fldenv() tells the compiler that this
+ * instruction clobbers the i387 register stack. This happens because
+ * we restore the tag word from the saved environment. Normally, this
+ * would happen anyway and we wouldn't care, because the ABI allows
+ * function calls to clobber the i387 regs. However, fesetenv() is
+ * inlined, so we need to be more careful.
*/
- __fnstcw(&__control);
- return (~__control & FE_ALL_EXCEPT);
+ __fldenvx(__envp->__x87);
+ __ldmxcsr(__envp->__mxcsr);
+ return (0);
}
-#endif /* __BSD_VISIBLE */
+#endif /* __i386__ */
__END_DECLS
diff --git a/lib/ncurses/form/Makefile b/lib/ncurses/form/Makefile
index d05cbfec0fb9..aa1224220737 100644
--- a/lib/ncurses/form/Makefile
+++ b/lib/ncurses/form/Makefile
@@ -54,7 +54,7 @@ CLEANFILES= ncurses_def.h
CFLAGS+= -I${SRCDIR}
CFLAGS+= -I${NCURSES_DIR}/menu
-DPADD= ${LIBNCURSES${LIB_SUFFIX:U}}
+DPADD= ${LIBNCURSES${LIB_SUFFIX:tu}}
LDADD= -lncurses${LIB_SUFFIX}
.if defined(ENABLE_WIDEC)
diff --git a/lib/ncurses/menu/Makefile b/lib/ncurses/menu/Makefile
index 19a1ff3ce9cf..46bc023e4d83 100644
--- a/lib/ncurses/menu/Makefile
+++ b/lib/ncurses/menu/Makefile
@@ -40,7 +40,7 @@ CLEANFILES= ncurses_def.h
CFLAGS+= -I${SRCDIR}
-DPADD= ${LIBNCURSES${LIB_SUFFIX:U}}
+DPADD= ${LIBNCURSES${LIB_SUFFIX:tu}}
LDADD= -lncurses${LIB_SUFFIX}
.if defined(ENABLE_WIDEC)
diff --git a/lib/ncurses/panel/Makefile b/lib/ncurses/panel/Makefile
index 689586de2d39..8e997675dd6c 100644
--- a/lib/ncurses/panel/Makefile
+++ b/lib/ncurses/panel/Makefile
@@ -29,7 +29,7 @@ CLEANFILES= ncurses_def.h
CFLAGS+= -I${SRCDIR}
-DPADD= ${LIBNCURSES${LIB_SUFFIX:U}}
+DPADD= ${LIBNCURSES${LIB_SUFFIX:tu}}
LDADD= -lncurses${LIB_SUFFIX}
.if defined(ENABLE_WIDEC)