summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2011-10-27 04:56:53 +0000
committergrehan <grehan@FreeBSD.org>2011-10-27 04:56:53 +0000
commit6608b60465ff680d8774363c5efb950503d6cde5 (patch)
treec8ad385de528afbbabd70f4b27b4b7f80796d429 /lib
parent9de15373c371786da8c7814387bad682698eb9bd (diff)
parent0a7d6450d66712b7cb6e6e8396620f2e38a7d018 (diff)
downloadFreeBSD-src-6608b60465ff680d8774363c5efb950503d6cde5.zip
FreeBSD-src-6608b60465ff680d8774363c5efb950503d6cde5.tar.gz
IFC @ r226824
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile12
-rw-r--r--lib/clang/Makefile1
-rw-r--r--lib/clang/clang.build.mk45
-rw-r--r--lib/clang/include/ARMGenDecoderTables.inc2
-rw-r--r--lib/clang/include/ARMGenDisassemblerTables.inc2
-rw-r--r--lib/clang/include/clang/Basic/Version.inc4
-rw-r--r--lib/clang/include/clang/Parse/AttrLateParsed.inc2
-rw-r--r--lib/clang/include/llvm/Config/config.h27
-rw-r--r--lib/clang/include/llvm/Config/llvm-config.h25
-rw-r--r--lib/clang/libclanganalysis/Makefile2
-rw-r--r--lib/clang/libclangarcmigrate/Makefile2
-rw-r--r--lib/clang/libclangast/Makefile5
-rw-r--r--lib/clang/libclangbasic/Makefile1
-rw-r--r--lib/clang/libclangcodegen/Makefile3
-rw-r--r--lib/clang/libclangfrontend/Makefile2
-rw-r--r--lib/clang/libclangparse/Makefile3
-rw-r--r--lib/clang/libclangsema/Makefile4
-rw-r--r--lib/clang/libclangserialization/Makefile4
-rw-r--r--lib/clang/libclangstaticanalyzercheckers/Makefile5
-rw-r--r--lib/clang/libclangstaticanalyzercore/Makefile12
-rw-r--r--lib/clang/libllvmarmcodegen/Makefile7
-rw-r--r--lib/clang/libllvmarmdesc/Makefile8
-rw-r--r--lib/clang/libllvmarmdisassembler/Makefile4
-rw-r--r--lib/clang/libllvmcodegen/Makefile6
-rw-r--r--lib/clang/libllvmipo/Makefile2
-rw-r--r--lib/clang/libllvmmc/Makefile6
-rw-r--r--lib/clang/libllvmmcparser/Makefile2
-rw-r--r--lib/clang/libllvmmipscodegen/Makefile2
-rw-r--r--lib/clang/libllvmmipsdesc/Makefile5
-rw-r--r--lib/clang/libllvmpowerpccodegen/Makefile5
-rw-r--r--lib/clang/libllvmpowerpcdesc/Makefile9
-rw-r--r--lib/clang/libllvmscalaropts/Makefile1
-rw-r--r--lib/clang/libllvmtablegen/Makefile14
-rw-r--r--lib/clang/libllvmtarget/Makefile2
-rw-r--r--lib/clang/libllvmtransformutils/Makefile1
-rw-r--r--lib/clang/libllvmx86codegen/Makefile9
-rw-r--r--lib/clang/libllvmx86desc/Makefile6
-rw-r--r--lib/clang/libllvmx86disassembler/Makefile1
-rw-r--r--lib/libarchive/archive_hash.h28
-rw-r--r--lib/libarchive/archive_read_disk.312
-rw-r--r--lib/libarchive/config_freebsd.h8
-rw-r--r--lib/libc/Versions.def6
-rw-r--r--lib/libc/amd64/Symbol.map1
-rw-r--r--lib/libc/amd64/gen/Makefile.inc2
-rw-r--r--lib/libc/amd64/gen/modf.S91
-rw-r--r--lib/libc/arm/Symbol.map1
-rw-r--r--lib/libc/arm/gen/Makefile.inc2
-rw-r--r--lib/libc/arm/gen/modf.c107
-rw-r--r--lib/libc/gen/Makefile.inc2
-rw-r--r--lib/libc/gen/Symbol.map1
-rw-r--r--lib/libc/gen/ctermid.35
-rw-r--r--lib/libc/gen/ctermid.c51
-rw-r--r--lib/libc/gen/devname.c5
-rw-r--r--lib/libc/gen/getutxent.32
-rw-r--r--lib/libc/gen/modf.c138
-rw-r--r--lib/libc/i386/Symbol.map1
-rw-r--r--lib/libc/i386/gen/Makefile.inc2
-rw-r--r--lib/libc/i386/gen/modf.S87
-rw-r--r--lib/libc/ia64/Symbol.map1
-rw-r--r--lib/libc/ia64/gen/Makefile.inc2
-rw-r--r--lib/libc/ia64/gen/modf.c106
-rw-r--r--lib/libc/iconv/citrus_none.c3
-rw-r--r--lib/libc/locale/isspace.36
-rw-r--r--lib/libc/mips/Symbol.map5
-rw-r--r--lib/libc/mips/gen/Makefile.inc2
-rw-r--r--lib/libc/mips/gen/modf.S82
-rw-r--r--lib/libc/mips/gen/modf.c107
-rw-r--r--lib/libc/net/Symbol.map20
-rw-r--r--lib/libc/powerpc/Symbol.map1
-rw-r--r--lib/libc/powerpc/gen/Makefile.inc2
-rw-r--r--lib/libc/powerpc/gen/modf.c107
-rw-r--r--lib/libc/powerpc64/Symbol.map1
-rw-r--r--lib/libc/powerpc64/gen/Makefile.inc2
-rw-r--r--lib/libc/powerpc64/gen/modf.c107
-rw-r--r--lib/libc/sparc64/Symbol.map3
-rw-r--r--lib/libc/sparc64/gen/Makefile.inc2
-rw-r--r--lib/libc/sparc64/gen/modf.S177
-rw-r--r--lib/libc/stdio/flags.c23
-rw-r--r--lib/libc/stdio/fopen.386
-rw-r--r--lib/libc/sys/ktrace.226
-rw-r--r--lib/libc/sys/ptrace.210
-rw-r--r--lib/libc/sys/timer_create.22
-rw-r--r--lib/libelf/elf_update.32
-rw-r--r--lib/libfetch/common.c2
-rw-r--r--lib/libfetch/common.h2
-rw-r--r--lib/libfetch/fetch.324
-rw-r--r--lib/libfetch/fetch.c2
-rw-r--r--lib/libfetch/fetch.h2
-rw-r--r--lib/libfetch/file.c2
-rw-r--r--lib/libfetch/ftp.c11
-rw-r--r--lib/libfetch/http.c2
-rw-r--r--lib/libftpio/Makefile34
-rw-r--r--lib/libftpio/ftp.errors45
-rw-r--r--lib/libftpio/ftpio.3260
-rw-r--r--lib/libftpio/ftpio.c1069
-rw-r--r--lib/libftpio/ftpio.h71
-rw-r--r--lib/libgssapi/Symbol.map2
-rw-r--r--lib/libipsec/ipsec_strerror.32
-rw-r--r--lib/libmp/Symbol.map2
-rw-r--r--lib/libncp/ncpl_bind.c2
-rw-r--r--lib/libpam/libpam/Makefile11
-rw-r--r--lib/libpam/modules/pam_ssh/pam_ssh.86
-rw-r--r--lib/libpam/modules/pam_ssh/pam_ssh.c3
-rw-r--r--lib/libpmc/libpmc.c6
-rw-r--r--lib/libpmc/pmc.34
-rw-r--r--lib/libpmc/pmc.core.32
-rw-r--r--lib/libpmc/pmc.h1
-rw-r--r--lib/libpmc/pmc_configure_logfile.311
-rw-r--r--lib/libsdp/sdp.h6
-rw-r--r--lib/libulog/Symbol.map2
-rw-r--r--lib/libusb/Makefile3
-rw-r--r--lib/libusb/libusb.315
-rw-r--r--lib/libusb/libusb.h1
-rw-r--r--lib/libusb/libusb10.c78
-rw-r--r--lib/libusb/libusb20.328
-rw-r--r--lib/libusb/libusb20.c74
-rw-r--r--lib/libusb/libusb20.h5
-rw-r--r--lib/libusbhid/data.c27
-rw-r--r--lib/libusbhid/parse.c26
-rw-r--r--lib/libusbhid/usbhid.316
-rw-r--r--lib/libusbhid/usbhid.h5
-rw-r--r--lib/libutil/pidfile.325
-rw-r--r--lib/libutil/pidfile.c24
-rw-r--r--lib/msun/Makefile14
-rw-r--r--lib/msun/Symbol.map22
-rw-r--r--lib/msun/amd64/Symbol.map2
-rw-r--r--lib/msun/amd64/fenv.c25
-rw-r--r--lib/msun/amd64/fenv.h19
-rw-r--r--lib/msun/arm/Symbol.map8
-rw-r--r--lib/msun/arm/fenv.c19
-rw-r--r--lib/msun/arm/fenv.h34
-rw-r--r--lib/msun/bsdsrc/b_exp.c20
-rw-r--r--lib/msun/i387/Symbol.map2
-rw-r--r--lib/msun/i387/fenv.c23
-rw-r--r--lib/msun/i387/fenv.h19
-rw-r--r--lib/msun/ia64/Symbol.map7
-rw-r--r--lib/msun/ia64/fenv.c19
-rw-r--r--lib/msun/ia64/fenv.h32
-rw-r--r--lib/msun/man/ccos.380
-rw-r--r--lib/msun/man/ccosh.380
-rw-r--r--lib/msun/man/complex.322
-rw-r--r--lib/msun/man/cos.31
-rw-r--r--lib/msun/man/cosh.31
-rw-r--r--lib/msun/man/fenv.335
-rw-r--r--lib/msun/man/ieee.32
-rw-r--r--lib/msun/man/math.317
-rw-r--r--lib/msun/man/sin.31
-rw-r--r--lib/msun/man/sinh.31
-rw-r--r--lib/msun/man/tan.31
-rw-r--r--lib/msun/man/tanh.31
-rw-r--r--lib/msun/mips/Symbol.map8
-rw-r--r--lib/msun/mips/fenv.c19
-rw-r--r--lib/msun/mips/fenv.h34
-rw-r--r--lib/msun/powerpc/Symbol.map8
-rw-r--r--lib/msun/powerpc/fenv.c19
-rw-r--r--lib/msun/powerpc/fenv.h34
-rw-r--r--lib/msun/sparc64/Symbol.map8
-rw-r--r--lib/msun/sparc64/fenv.c19
-rw-r--r--lib/msun/sparc64/fenv.h34
-rw-r--r--lib/msun/src/e_cosh.c10
-rw-r--r--lib/msun/src/e_coshf.c7
-rw-r--r--lib/msun/src/e_exp.c4
-rw-r--r--lib/msun/src/e_expf.c6
-rw-r--r--lib/msun/src/e_hypot.c2
-rw-r--r--lib/msun/src/e_hypotf.c2
-rw-r--r--lib/msun/src/e_hypotl.c15
-rw-r--r--lib/msun/src/e_lgamma_r.c1
-rw-r--r--lib/msun/src/e_lgammaf_r.c1
-rw-r--r--lib/msun/src/e_log10.c51
-rw-r--r--lib/msun/src/e_log10f.c39
-rw-r--r--lib/msun/src/e_log2.c76
-rw-r--r--lib/msun/src/e_log2f.c51
-rw-r--r--lib/msun/src/e_pow.c5
-rw-r--r--lib/msun/src/e_powf.c5
-rw-r--r--lib/msun/src/e_sinh.c11
-rw-r--r--lib/msun/src/e_sinhf.c9
-rw-r--r--lib/msun/src/k_exp.c108
-rw-r--r--lib/msun/src/k_expf.c87
-rw-r--r--lib/msun/src/k_log.h38
-rw-r--r--lib/msun/src/k_logf.h26
-rw-r--r--lib/msun/src/math.h7
-rw-r--r--lib/msun/src/math_private.h51
-rw-r--r--lib/msun/src/s_ccosh.c155
-rw-r--r--lib/msun/src/s_ccoshf.c104
-rw-r--r--lib/msun/src/s_cexp.c26
-rw-r--r--lib/msun/src/s_cexpf.c23
-rw-r--r--lib/msun/src/s_csinh.c157
-rw-r--r--lib/msun/src/s_csinhf.c105
-rw-r--r--lib/msun/src/s_ctanh.c144
-rw-r--r--lib/msun/src/s_ctanhf.c84
-rw-r--r--lib/msun/src/s_expm1.c5
-rw-r--r--lib/msun/src/s_expm1f.c5
-rw-r--r--lib/msun/src/s_fma.c251
-rw-r--r--lib/msun/src/s_fmaf.c38
-rw-r--r--lib/msun/src/s_fmal.c239
195 files changed, 2965 insertions, 3276 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 9a89886..6537b5a 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -70,7 +70,6 @@ SUBDIR= ${SUBDIR_ORDERED} \
${_libefi} \
libexpat \
libfetch \
- libftpio \
libgeom \
${_libgpib} \
${_libgssapi} \
@@ -188,18 +187,15 @@ _libproc= libproc
_librtld_db= librtld_db
.endif
+.if ${MACHINE_CPUARCH} == "amd64"
+_libvmmapi= libvmmapi
+.endif
+
.if ${MACHINE_CPUARCH} == "ia64"
_libefi= libefi
_libsmb= libsmb
.endif
-.if ${MACHINE_CPUARCH} == "amd64"
-.if ${MK_NCP} != "no"
-_libncp= libncp
-.endif
-_libvmmapi= libvmmapi
-.endif
-
.if ${MACHINE_CPUARCH} == "powerpc"
_libsmb= libsmb
.endif
diff --git a/lib/clang/Makefile b/lib/clang/Makefile
index abcc113..8f7d18a 100644
--- a/lib/clang/Makefile
+++ b/lib/clang/Makefile
@@ -35,6 +35,7 @@ SUBDIR= libclanganalysis \
libllvmscalaropts \
libllvmselectiondag \
libllvmsupport \
+ libllvmtablegen \
libllvmtarget \
libllvmtransformutils \
\
diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk
index 17b47c3..ceaeb05 100644
--- a/lib/clang/clang.build.mk
+++ b/lib/clang/clang.build.mk
@@ -14,8 +14,7 @@ CFLAGS+= -O1
.endif
TARGET_ARCH?= ${MACHINE_ARCH}
-# XXX: 8.0, to keep __FreeBSD_cc_version happy
-CFLAGS+=-DLLVM_HOSTTRIPLE=\"${TARGET_ARCH:C/amd64/x86_64/}-unknown-freebsd9.0\"
+CFLAGS+=-DLLVM_HOSTTRIPLE=\"${TARGET_ARCH:C/amd64/x86_64/}-unknown-freebsd10.0\"
.ifndef LLVM_REQUIRES_EH
CXXFLAGS+=-fno-exceptions
@@ -35,6 +34,7 @@ CFLAGS+=-DCLANG_PREFIX=\"${TOOLS_PREFIX}\"
.PATH: ${LLVM_SRCS}/${SRCDIR}
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
@@ -64,82 +64,83 @@ ${arch:T}Gen${hdr:H:C/$/.inc.h/}: ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
. endfor
.endfor
-ARMGenDecoderTables.inc.h: ${LLVM_SRCS}/lib/Target/ARM/ARM.td
- ${TBLGEN} -I ${LLVM_SRCS}/lib/Target/ARM ${TBLINC} \
- -gen-arm-decoder -o ${.TARGET} ${.ALLSRC}
-
Attrs.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
-gen-clang-attr-classes -o ${.TARGET} \
-I ${CLANG_SRCS}/include ${.ALLSRC}
AttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
-gen-clang-attr-impl -o ${.TARGET} \
-I ${CLANG_SRCS}/include ${.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}
+
AttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
-gen-clang-attr-list -o ${.TARGET} \
-I ${CLANG_SRCS}/include ${.ALLSRC}
AttrPCHRead.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
${TBLINC} -gen-clang-attr-pch-read -o ${.TARGET} \
-I ${CLANG_SRCS}/include ${.ALLSRC}
AttrPCHWrite.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
${TBLINC} -gen-clang-attr-pch-write -o ${.TARGET} \
-I ${CLANG_SRCS}/include ${.ALLSRC}
AttrSpellings.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Lex ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Lex ${TBLINC} \
-gen-clang-attr-spelling-list -o ${.TARGET} \
-I ${CLANG_SRCS}/include ${.ALLSRC}
DeclNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
-gen-clang-decl-nodes -o ${.TARGET} ${.ALLSRC}
StmtNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
-gen-clang-stmt-nodes -o ${.TARGET} ${.ALLSRC}
arm_neon.inc.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
-gen-arm-neon-sema -o ${.TARGET} ${.ALLSRC}
DiagnosticGroups.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
-gen-clang-diag-groups -o ${.TARGET} ${.ALLSRC}
DiagnosticIndexName.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
-gen-clang-diags-index-name -o ${.TARGET} ${.ALLSRC}
.for hdr in AST Analysis Common Driver Frontend Lex Parse Sema
Diagnostic${hdr}Kinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
-gen-clang-diags-defs -clang-component=${hdr} \
-o ${.TARGET} ${.ALLSRC}
.endfor
Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/Options.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
-gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC}
CC1Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/CC1Options.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
-gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC}
CC1AsOptions.inc.h: ${CLANG_SRCS}/include/clang/Driver/CC1AsOptions.td
- ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
-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
- ${TBLGEN} -I ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers \
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers \
${TBLINC} -gen-clang-sa-checkers -o ${.TARGET} \
-I ${CLANG_SRCS}/include \
${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
diff --git a/lib/clang/include/ARMGenDecoderTables.inc b/lib/clang/include/ARMGenDecoderTables.inc
deleted file mode 100644
index b09685c..0000000
--- a/lib/clang/include/ARMGenDecoderTables.inc
+++ /dev/null
@@ -1,2 +0,0 @@
-/* $FreeBSD$ */
-#include "ARMGenDecoderTables.inc.h"
diff --git a/lib/clang/include/ARMGenDisassemblerTables.inc b/lib/clang/include/ARMGenDisassemblerTables.inc
new file mode 100644
index 0000000..7ea91ee
--- /dev/null
+++ b/lib/clang/include/ARMGenDisassemblerTables.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "ARMGenDisassemblerTables.inc.h"
diff --git a/lib/clang/include/clang/Basic/Version.inc b/lib/clang/include/clang/Basic/Version.inc
index 3e3b44c..1ab3e3e 100644
--- a/lib/clang/include/clang/Basic/Version.inc
+++ b/lib/clang/include/clang/Basic/Version.inc
@@ -5,6 +5,6 @@
#define CLANG_VERSION_MINOR 0
#define CLANG_VENDOR "FreeBSD "
-#define CLANG_VENDOR_SUFFIX " 20110717"
+#define CLANG_VENDOR_SUFFIX " 20111021"
-#define SVN_REVISION "135360"
+#define SVN_REVISION "142614"
diff --git a/lib/clang/include/clang/Parse/AttrLateParsed.inc b/lib/clang/include/clang/Parse/AttrLateParsed.inc
new file mode 100644
index 0000000..1282d9e
--- /dev/null
+++ b/lib/clang/include/clang/Parse/AttrLateParsed.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "AttrLateParsed.inc.h"
diff --git a/lib/clang/include/llvm/Config/config.h b/lib/clang/include/llvm/Config/config.h
index f264571..5b6761c 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
+/* Bug report URL. */
+#define BUG_REPORT_URL "http://llvm.org/bugs/"
+
/* Relative directory for resource files */
#define CLANG_RESOURCE_DIR ""
@@ -301,16 +304,16 @@
#define HAVE_PRINTF_A 1
/* Have pthread_getspecific */
-#define HAVE_PTHREAD_GETSPECIFIC 1
+/* #undef HAVE_PTHREAD_GETSPECIFIC */
/* Define to 1 if you have the <pthread.h> header file. */
-#define HAVE_PTHREAD_H 1
+/* #undef HAVE_PTHREAD_H */
/* Have pthread_mutex_lock */
-#define HAVE_PTHREAD_MUTEX_LOCK 1
+/* #undef HAVE_PTHREAD_MUTEX_LOCK */
/* Have pthread_rwlock_init */
-#define HAVE_PTHREAD_RWLOCK_INIT 1
+/* #undef HAVE_PTHREAD_RWLOCK_INIT */
/* Define to 1 if srand48/lrand48/drand48 exist in <stdlib.h> */
#define HAVE_RAND48 1
@@ -548,6 +551,9 @@
/* Installation directory for config files */
/* #undef LLVM_ETCDIR */
+/* Has gcc/MSVC atomic intrinsics */
+#define LLVM_HAS_ATOMICS 1
+
/* Host triple we were built on */
/* #undef LLVM_HOSTTRIPLE */
@@ -563,9 +569,6 @@
/* Installation directory for man pages */
/* #undef LLVM_MANDIR */
-/* Build multithreading support into LLVM */
-/* #undef LLVM_MULTITHREADED */
-
/* LLVM architecture name for the native architecture, if available */
#define LLVM_NATIVE_ARCH X86
@@ -575,15 +578,15 @@
/* LLVM name for the native AsmPrinter init function, if available */
#define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter
-/* LLVM name for the native MCAsmInfo init function, if available */
-#define LLVM_NATIVE_MCASMINFO LLVMInitializeX86MCAsmInfo
-
/* LLVM name for the native Target init function, if available */
#define LLVM_NATIVE_TARGET LLVMInitializeX86Target
/* LLVM name for the native TargetInfo init function, if available */
#define LLVM_NATIVE_TARGETINFO LLVMInitializeX86TargetInfo
+/* LLVM name for the native target MC init function, if available */
+#define LLVM_NATIVE_TARGETMC LLVMInitializeX86TargetMC
+
/* Define if this is Unixish platform */
#define LLVM_ON_UNIX 1
@@ -651,13 +654,13 @@
#define PACKAGE_NAME "llvm"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "llvm 3.0svn"
+#define PACKAGE_STRING "llvm 3.0"
/* 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.0svn"
+#define PACKAGE_VERSION "3.0"
/* 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 e76d10f..05e17ca 100644
--- a/lib/clang/include/llvm/Config/llvm-config.h
+++ b/lib/clang/include/llvm/Config/llvm-config.h
@@ -33,6 +33,9 @@
/* Installation directory for config files */
/* #undef LLVM_ETCDIR */
+/* Has gcc/MSVC atomic intrinsics */
+#define LLVM_HAS_ATOMICS 1
+
/* Host triple we were built on */
/* #undef LLVM_HOSTTRIPLE */
@@ -48,26 +51,23 @@
/* Installation directory for man pages */
/* #undef LLVM_MANDIR */
-/* Build multithreading support into LLVM */
-/* #undef LLVM_MULTITHREADED */
-
/* LLVM architecture name for the native architecture, if available */
#define LLVM_NATIVE_ARCH X86
+/* LLVM name for the native AsmParser init function, if available */
+#define LLVM_NATIVE_ASMPARSER LLVMInitializeX86AsmParser
+
+/* LLVM name for the native AsmPrinter init function, if available */
+#define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter
+
/* LLVM name for the native Target init function, if available */
#define LLVM_NATIVE_TARGET LLVMInitializeX86Target
/* LLVM name for the native TargetInfo init function, if available */
#define LLVM_NATIVE_TARGETINFO LLVMInitializeX86TargetInfo
-/* LLVM name for the native MCAsmInfo init function, if available */
-#define LLVM_NATIVE_MCASMINFO LLVMInitializeX86MCAsmInfo
-
-/* LLVM name for the native AsmPrinter init function, if available */
-#define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter
-
-/* LLVM name for the native AsmPrinter init function, if available */
-#define LLVM_NATIVE_ASMPARSER LLVMInitializeX86AsmParser
+/* LLVM name for the native target MC init function, if available */
+#define LLVM_NATIVE_TARGETMC LLVMInitializeX86TargetMC
/* Define if this is Unixish platform */
#define LLVM_ON_UNIX 1
@@ -99,6 +99,9 @@
/* Define to path to twopi program if found or 'echo twopi' otherwise */
/* #undef LLVM_PATH_TWOPI */
+/* Define to path to xdot.py program if found or 'echo xdot.py' otherwise */
+/* #undef LLVM_PATH_XDOT_PY */
+
/* Installation prefix directory */
/* #undef LLVM_PREFIX */
diff --git a/lib/clang/libclanganalysis/Makefile b/lib/clang/libclanganalysis/Makefile
index d0df779..f5fbc627 100644
--- a/lib/clang/libclanganalysis/Makefile
+++ b/lib/clang/libclanganalysis/Makefile
@@ -11,9 +11,11 @@ SRCS= AnalysisContext.cpp \
FormatString.cpp \
LiveVariables.cpp \
PrintfFormatString.cpp \
+ ProgramPoint.cpp \
PseudoConstantAnalysis.cpp \
ReachableCode.cpp \
ScanfFormatString.cpp \
+ ThreadSafety.cpp \
UninitializedValues.cpp
TGHDRS= AttrList \
diff --git a/lib/clang/libclangarcmigrate/Makefile b/lib/clang/libclangarcmigrate/Makefile
index c1e4511..957c3ba 100644
--- a/lib/clang/libclangarcmigrate/Makefile
+++ b/lib/clang/libclangarcmigrate/Makefile
@@ -6,6 +6,8 @@ SRCDIR= tools/clang/lib/ARCMigrate
SRCS= ARCMT.cpp \
ARCMTActions.cpp \
FileRemapper.cpp \
+ PlistReporter.cpp \
+ TransAPIUses.cpp \
TransARCAssign.cpp \
TransAutoreleasePool.cpp \
TransBlockObjCVariable.cpp \
diff --git a/lib/clang/libclangast/Makefile b/lib/clang/libclangast/Makefile
index 61b44fb..61f6881 100644
--- a/lib/clang/libclangast/Makefile
+++ b/lib/clang/libclangast/Makefile
@@ -35,6 +35,7 @@ SRCS= APValue.cpp \
ParentMap.cpp \
RecordLayout.cpp \
RecordLayoutBuilder.cpp \
+ SelectorLocationsKind.cpp \
Stmt.cpp \
StmtDumper.cpp \
StmtIterator.cpp \
@@ -45,7 +46,9 @@ SRCS= APValue.cpp \
TemplateName.cpp \
Type.cpp \
TypeLoc.cpp \
- TypePrinter.cpp
+ TypePrinter.cpp \
+ VTTBuilder.cpp \
+ VTableBuilder.cpp
TGHDRS= AttrImpl \
AttrList \
diff --git a/lib/clang/libclangbasic/Makefile b/lib/clang/libclangbasic/Makefile
index 49e3533..dec03c5 100644
--- a/lib/clang/libclangbasic/Makefile
+++ b/lib/clang/libclangbasic/Makefile
@@ -10,6 +10,7 @@ SRCS= Builtins.cpp \
FileManager.cpp \
FileSystemStatCache.cpp \
IdentifierTable.cpp \
+ LangOptions.cpp \
SourceLocation.cpp \
SourceManager.cpp \
TargetInfo.cpp \
diff --git a/lib/clang/libclangcodegen/Makefile b/lib/clang/libclangcodegen/Makefile
index d1798ca..467b2d2 100644
--- a/lib/clang/libclangcodegen/Makefile
+++ b/lib/clang/libclangcodegen/Makefile
@@ -6,6 +6,8 @@ SRCDIR= tools/clang/lib/CodeGen
SRCS= BackendUtil.cpp \
CGBlocks.cpp \
CGBuiltin.cpp \
+ CGCUDANV.cpp \
+ CGCUDARuntime.cpp \
CGCXX.cpp \
CGCXXABI.cpp \
CGCall.cpp \
@@ -25,6 +27,7 @@ SRCS= BackendUtil.cpp \
CGObjCGNU.cpp \
CGObjCMac.cpp \
CGObjCRuntime.cpp \
+ CGOpenCLRuntime.cpp \
CGRTTI.cpp \
CGRecordLayoutBuilder.cpp \
CGStmt.cpp \
diff --git a/lib/clang/libclangfrontend/Makefile b/lib/clang/libclangfrontend/Makefile
index 2087900..d8495a2 100644
--- a/lib/clang/libclangfrontend/Makefile
+++ b/lib/clang/libclangfrontend/Makefile
@@ -23,7 +23,7 @@ SRCS= ASTConsumers.cpp \
PrintPreprocessedOutput.cpp \
TextDiagnosticBuffer.cpp \
TextDiagnosticPrinter.cpp \
- VerifyDiagnosticsClient.cpp \
+ VerifyDiagnosticConsumer.cpp \
Warnings.cpp
TGHDRS= AttrList \
diff --git a/lib/clang/libclangparse/Makefile b/lib/clang/libclangparse/Makefile
index ee272fe..6bd0b5b 100644
--- a/lib/clang/libclangparse/Makefile
+++ b/lib/clang/libclangparse/Makefile
@@ -17,7 +17,8 @@ SRCS= ParseAST.cpp \
ParseTentative.cpp \
Parser.cpp
-TGHDRS= AttrList \
+TGHDRS= AttrLateParsed \
+ AttrList \
Attrs \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangsema/Makefile b/lib/clang/libclangsema/Makefile
index 3c03773..57f5ccb 100644
--- a/lib/clang/libclangsema/Makefile
+++ b/lib/clang/libclangsema/Makefile
@@ -10,12 +10,13 @@ SRCS= AnalysisBasedWarnings.cpp \
DelayedDiagnostic.cpp \
IdentifierResolver.cpp \
JumpDiagnostics.cpp \
+ MultiInitializer.cpp \
Scope.cpp \
Sema.cpp \
SemaAccess.cpp \
SemaAttr.cpp \
- SemaCXXCast.cpp \
SemaCXXScopeSpec.cpp \
+ SemaCast.cpp \
SemaChecking.cpp \
SemaCodeComplete.cpp \
SemaDecl.cpp \
@@ -27,6 +28,7 @@ SRCS= AnalysisBasedWarnings.cpp \
SemaExpr.cpp \
SemaExprCXX.cpp \
SemaExprObjC.cpp \
+ SemaFixItUtils.cpp \
SemaInit.cpp \
SemaLookup.cpp \
SemaObjCProperty.cpp \
diff --git a/lib/clang/libclangserialization/Makefile b/lib/clang/libclangserialization/Makefile
index 75a0031..a4e0f36 100644
--- a/lib/clang/libclangserialization/Makefile
+++ b/lib/clang/libclangserialization/Makefile
@@ -11,7 +11,9 @@ SRCS= ASTCommon.cpp \
ASTWriterDecl.cpp \
ASTWriterStmt.cpp \
ChainedIncludesSource.cpp \
- GeneratePCH.cpp
+ GeneratePCH.cpp \
+ Module.cpp \
+ ModuleManager.cpp
TGHDRS= AttrList \
AttrPCHRead \
diff --git a/lib/clang/libclangstaticanalyzercheckers/Makefile b/lib/clang/libclangstaticanalyzercheckers/Makefile
index adc7882..44f7d58 100644
--- a/lib/clang/libclangstaticanalyzercheckers/Makefile
+++ b/lib/clang/libclangstaticanalyzercheckers/Makefile
@@ -19,7 +19,7 @@ SRCS= AdjustedReturnValueChecker.cpp \
CheckSecuritySyntaxOnly.cpp \
CheckSizeofPointer.cpp \
ChrootChecker.cpp \
- ClangSACheckerProvider.cpp \
+ ClangCheckers.cpp \
DeadStoresChecker.cpp \
DebugCheckers.cpp \
DereferenceChecker.cpp \
@@ -28,8 +28,10 @@ SRCS= AdjustedReturnValueChecker.cpp \
IdempotentOperationChecker.cpp \
IteratorsChecker.cpp \
LLVMConventionsChecker.cpp \
+ MacOSKeychainAPIChecker.cpp \
MacOSXAPIChecker.cpp \
MallocChecker.cpp \
+ MallocOverflowSecurityChecker.cpp \
NSAutoreleasePoolChecker.cpp \
NSErrorChecker.cpp \
NoReturnFunctionChecker.cpp \
@@ -40,6 +42,7 @@ SRCS= AdjustedReturnValueChecker.cpp \
PointerArithChecker.cpp \
PointerSubChecker.cpp \
PthreadLockChecker.cpp \
+ RetainCountChecker.cpp \
ReturnPointerRangeChecker.cpp \
ReturnUndefChecker.cpp \
StackAddrEscapeChecker.cpp \
diff --git a/lib/clang/libclangstaticanalyzercore/Makefile b/lib/clang/libclangstaticanalyzercore/Makefile
index 76863dc..9a33751 100644
--- a/lib/clang/libclangstaticanalyzercore/Makefile
+++ b/lib/clang/libclangstaticanalyzercore/Makefile
@@ -6,27 +6,29 @@ SRCDIR= tools/clang/lib/StaticAnalyzer/Core
SRCS= AggExprVisitor.cpp \
AnalysisManager.cpp \
BasicConstraintManager.cpp \
- BasicStore.cpp \
BasicValueFactory.cpp \
BlockCounter.cpp \
BugReporter.cpp \
BugReporterVisitors.cpp \
- CFRefCount.cpp \
- CXXExprEngine.cpp \
+ Checker.cpp \
CheckerContext.cpp \
CheckerHelpers.cpp \
CheckerManager.cpp \
+ CheckerRegistry.cpp \
CoreEngine.cpp \
Environment.cpp \
ExplodedGraph.cpp \
ExprEngine.cpp \
- FlatStore.cpp \
- GRState.cpp \
+ ExprEngineC.cpp \
+ ExprEngineCXX.cpp \
+ ExprEngineCallAndReturn.cpp \
+ ExprEngineObjC.cpp \
HTMLDiagnostics.cpp \
MemRegion.cpp \
ObjCMessage.cpp \
PathDiagnostic.cpp \
PlistDiagnostics.cpp \
+ ProgramState.cpp \
RangeConstraintManager.cpp \
RegionStore.cpp \
SValBuilder.cpp \
diff --git a/lib/clang/libllvmarmcodegen/Makefile b/lib/clang/libllvmarmcodegen/Makefile
index 0110781..29579bc 100644
--- a/lib/clang/libllvmarmcodegen/Makefile
+++ b/lib/clang/libllvmarmcodegen/Makefile
@@ -3,8 +3,7 @@
LIB= llvmarmcodegen
SRCDIR= lib/Target/ARM
-SRCS= ARMAsmBackend.cpp \
- ARMAsmPrinter.cpp \
+SRCS= ARMAsmPrinter.cpp \
ARMBaseInstrInfo.cpp \
ARMBaseRegisterInfo.cpp \
ARMCodeEmitter.cpp \
@@ -21,17 +20,13 @@ SRCS= ARMAsmBackend.cpp \
ARMInstrInfo.cpp \
ARMJITInfo.cpp \
ARMLoadStoreOptimizer.cpp \
- ARMMCCodeEmitter.cpp \
- ARMMCExpr.cpp \
ARMMCInstLower.cpp \
- ARMMachObjectWriter.cpp \
ARMRegisterInfo.cpp \
ARMSelectionDAGInfo.cpp \
ARMSubtarget.cpp \
ARMTargetMachine.cpp \
ARMTargetObjectFile.cpp \
MLxExpansionPass.cpp \
- NEONMoveFix.cpp \
Thumb1FrameLowering.cpp \
Thumb1InstrInfo.cpp \
Thumb1RegisterInfo.cpp \
diff --git a/lib/clang/libllvmarmdesc/Makefile b/lib/clang/libllvmarmdesc/Makefile
index 0074ec2..e732074 100644
--- a/lib/clang/libllvmarmdesc/Makefile
+++ b/lib/clang/libllvmarmdesc/Makefile
@@ -3,10 +3,16 @@
LIB= llvmarmdesc
SRCDIR= lib/Target/ARM/MCTargetDesc
-SRCS= ARMMCAsmInfo.cpp \
+SRCS= ARMAsmBackend.cpp \
+ ARMMachObjectWriter.cpp \
+ ARMMCAsmInfo.cpp \
+ ARMMCCodeEmitter.cpp \
+ ARMMCExpr.cpp \
ARMMCTargetDesc.cpp
+CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= ARMGenInstrInfo \
+ ARMGenMCCodeEmitter \
ARMGenRegisterInfo \
ARMGenSubtargetInfo
diff --git a/lib/clang/libllvmarmdisassembler/Makefile b/lib/clang/libllvmarmdisassembler/Makefile
index c0648bb..a3d16f7 100644
--- a/lib/clang/libllvmarmdisassembler/Makefile
+++ b/lib/clang/libllvmarmdisassembler/Makefile
@@ -4,9 +4,9 @@ LIB= llvmarmdisassembler
SRCDIR= lib/Target/ARM/Disassembler
INCDIR= lib/Target/ARM
-SRCS= ARMDisassemblerCore.cpp
+SRCS= ARMDisassembler.cpp
-TGHDRS= ARMGenDecoderTables \
+TGHDRS= ARMGenDisassemblerTables \
ARMGenEDInfo \
ARMGenInstrInfo \
ARMGenRegisterInfo \
diff --git a/lib/clang/libllvmcodegen/Makefile b/lib/clang/libllvmcodegen/Makefile
index 702c476..0d593b6 100644
--- a/lib/clang/libllvmcodegen/Makefile
+++ b/lib/clang/libllvmcodegen/Makefile
@@ -17,7 +17,9 @@ SRCS= AggressiveAntiDepBreaker.cpp \
ELFCodeEmitter.cpp \
ELFWriter.cpp \
EdgeBundles.cpp \
+ ExecutionDepsFix.cpp \
ExpandISelPseudos.cpp \
+ ExpandPostRAPseudos.cpp \
GCMetadata.cpp \
GCMetadataPrinter.cpp \
GCStrategy.cpp \
@@ -27,16 +29,18 @@ SRCS= AggressiveAntiDepBreaker.cpp \
IntrinsicLowering.cpp \
LLVMTargetMachine.cpp \
LatencyPriorityQueue.cpp \
+ LexicalScopes.cpp \
LiveDebugVariables.cpp \
LiveInterval.cpp \
LiveIntervalAnalysis.cpp \
LiveIntervalUnion.cpp \
LiveStackAnalysis.cpp \
LiveVariables.cpp \
+ LiveRangeCalc.cpp \
LiveRangeEdit.cpp \
LocalStackSlotAllocation.cpp \
- LowerSubregs.cpp \
MachineBasicBlock.cpp \
+ MachineBranchProbabilityInfo.cpp \
MachineCSE.cpp \
MachineDominators.cpp \
MachineFunction.cpp \
diff --git a/lib/clang/libllvmipo/Makefile b/lib/clang/libllvmipo/Makefile
index 062ba5b..42cc2fa 100644
--- a/lib/clang/libllvmipo/Makefile
+++ b/lib/clang/libllvmipo/Makefile
@@ -16,9 +16,9 @@ SRCS= ArgumentPromotion.cpp \
Inliner.cpp \
Internalize.cpp \
LoopExtractor.cpp \
- LowerSetJmp.cpp \
MergeFunctions.cpp \
PartialInlining.cpp \
+ PassManagerBuilder.cpp \
PruneEH.cpp \
StripDeadPrototypes.cpp \
StripSymbols.cpp
diff --git a/lib/clang/libllvmmc/Makefile b/lib/clang/libllvmmc/Makefile
index 435cdf4..5fef440 100644
--- a/lib/clang/libllvmmc/Makefile
+++ b/lib/clang/libllvmmc/Makefile
@@ -4,11 +4,13 @@ LIB= llvmmc
SRCDIR= lib/MC
SRCS= ELFObjectWriter.cpp \
+ MCAsmBackend.cpp \
MCAsmInfo.cpp \
MCAsmInfoCOFF.cpp \
MCAsmInfoDarwin.cpp \
MCAsmStreamer.cpp \
MCAssembler.cpp \
+ MCCodeGenInfo.cpp \
MCCodeEmitter.cpp \
MCContext.cpp \
MCDwarf.cpp \
@@ -18,10 +20,12 @@ SRCS= ELFObjectWriter.cpp \
MCExpr.cpp \
MCInst.cpp \
MCInstPrinter.cpp \
+ MCInstrAnalysis.cpp \
MCLoggingStreamer.cpp \
MCMachOStreamer.cpp \
MCMachObjectTargetWriter.cpp \
MCNullStreamer.cpp \
+ MCObjectFileInfo.cpp \
MCObjectStreamer.cpp \
MCObjectWriter.cpp \
MCPureStreamer.cpp \
@@ -32,10 +36,10 @@ SRCS= ELFObjectWriter.cpp \
MCStreamer.cpp \
MCSubtargetInfo.cpp \
MCSymbol.cpp \
+ MCTargetAsmLexer.cpp \
MCWin64EH.cpp \
MachObjectWriter.cpp \
SubtargetFeature.cpp \
- TargetAsmBackend.cpp \
WinCOFFObjectWriter.cpp \
WinCOFFStreamer.cpp
diff --git a/lib/clang/libllvmmcparser/Makefile b/lib/clang/libllvmmcparser/Makefile
index 4f2f8bf..48deadf 100644
--- a/lib/clang/libllvmmcparser/Makefile
+++ b/lib/clang/libllvmmcparser/Makefile
@@ -11,6 +11,6 @@ SRCS= AsmLexer.cpp \
MCAsmLexer.cpp \
MCAsmParser.cpp \
MCAsmParserExtension.cpp \
- TargetAsmParser.cpp
+ MCTargetAsmParser.cpp
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmipscodegen/Makefile b/lib/clang/libllvmmipscodegen/Makefile
index 1651831..a70c072 100644
--- a/lib/clang/libllvmmipscodegen/Makefile
+++ b/lib/clang/libllvmmipscodegen/Makefile
@@ -4,6 +4,7 @@ LIB= llvmmipscodegen
SRCDIR= lib/Target/Mips
SRCS= MipsAsmPrinter.cpp \
+ MipsCodeEmitter.cpp \
MipsDelaySlotFiller.cpp \
MipsEmitGPRestore.cpp \
MipsExpandPseudo.cpp \
@@ -11,6 +12,7 @@ SRCS= MipsAsmPrinter.cpp \
MipsISelDAGToDAG.cpp \
MipsISelLowering.cpp \
MipsInstrInfo.cpp \
+ MipsJITInfo.cpp \
MipsMCInstLower.cpp \
MipsMCSymbolRefExpr.cpp \
MipsRegisterInfo.cpp \
diff --git a/lib/clang/libllvmmipsdesc/Makefile b/lib/clang/libllvmmipsdesc/Makefile
index 4147209..2313603 100644
--- a/lib/clang/libllvmmipsdesc/Makefile
+++ b/lib/clang/libllvmmipsdesc/Makefile
@@ -3,8 +3,11 @@
LIB= llvmmipsdesc
SRCDIR= lib/Target/Mips/MCTargetDesc
-SRCS= MipsMCAsmInfo.cpp \
+SRCS= MipsAsmBackend.cpp \
+ MipsMCAsmInfo.cpp \
+ MipsMCCodeEmitter.cpp \
MipsMCTargetDesc.cpp
+CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= MipsGenInstrInfo \
MipsGenRegisterInfo \
diff --git a/lib/clang/libllvmpowerpccodegen/Makefile b/lib/clang/libllvmpowerpccodegen/Makefile
index 08663e8..aec0e1e 100644
--- a/lib/clang/libllvmpowerpccodegen/Makefile
+++ b/lib/clang/libllvmpowerpccodegen/Makefile
@@ -3,8 +3,7 @@
LIB= llvmpowerpccodegen
SRCDIR= lib/Target/PowerPC
-SRCS= PPCAsmBackend.cpp \
- PPCAsmPrinter.cpp \
+SRCS= PPCAsmPrinter.cpp \
PPCBranchSelector.cpp \
PPCCodeEmitter.cpp \
PPCFrameLowering.cpp \
@@ -13,9 +12,7 @@ SRCS= PPCAsmBackend.cpp \
PPCISelLowering.cpp \
PPCInstrInfo.cpp \
PPCJITInfo.cpp \
- PPCMCCodeEmitter.cpp \
PPCMCInstLower.cpp \
- PPCPredicates.cpp \
PPCRegisterInfo.cpp \
PPCSelectionDAGInfo.cpp \
PPCSubtarget.cpp \
diff --git a/lib/clang/libllvmpowerpcdesc/Makefile b/lib/clang/libllvmpowerpcdesc/Makefile
index 9207da2..c45abec 100644
--- a/lib/clang/libllvmpowerpcdesc/Makefile
+++ b/lib/clang/libllvmpowerpcdesc/Makefile
@@ -3,10 +3,15 @@
LIB= llvmpowerpcdesc
SRCDIR= lib/Target/PowerPC/MCTargetDesc
-SRCS= PPCMCAsmInfo.cpp \
- PPCMCTargetDesc.cpp
+SRCS= PPCAsmBackend.cpp \
+ PPCMCAsmInfo.cpp \
+ PPCMCCodeEmitter.cpp \
+ PPCMCTargetDesc.cpp \
+ PPCPredicates.cpp
+CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= PPCGenInstrInfo \
+ PPCGenMCCodeEmitter \
PPCGenRegisterInfo \
PPCGenSubtargetInfo
diff --git a/lib/clang/libllvmscalaropts/Makefile b/lib/clang/libllvmscalaropts/Makefile
index 81998a4..c376b68 100644
--- a/lib/clang/libllvmscalaropts/Makefile
+++ b/lib/clang/libllvmscalaropts/Makefile
@@ -29,7 +29,6 @@ SRCS= ADCE.cpp \
SimplifyCFGPass.cpp \
SimplifyLibCalls.cpp \
Sink.cpp \
- TailDuplication.cpp \
TailRecursionElimination.cpp
TGHDRS= Intrinsics
diff --git a/lib/clang/libllvmtablegen/Makefile b/lib/clang/libllvmtablegen/Makefile
new file mode 100644
index 0000000..272aa88
--- /dev/null
+++ b/lib/clang/libllvmtablegen/Makefile
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+LIB= llvmtablegen
+
+SRCDIR= lib/TableGen
+SRCS= Error.cpp \
+ Main.cpp \
+ Record.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 493b7c1..8c16f84 100644
--- a/lib/clang/libllvmtarget/Makefile
+++ b/lib/clang/libllvmtarget/Makefile
@@ -5,8 +5,6 @@ LIB= llvmtarget
SRCDIR= lib/Target
SRCS= Mangler.cpp \
Target.cpp \
- TargetAsmInfo.cpp \
- TargetAsmLexer.cpp \
TargetData.cpp \
TargetELFWriterInfo.cpp \
TargetFrameLowering.cpp \
diff --git a/lib/clang/libllvmtransformutils/Makefile b/lib/clang/libllvmtransformutils/Makefile
index 50dae17..18eecda 100644
--- a/lib/clang/libllvmtransformutils/Makefile
+++ b/lib/clang/libllvmtransformutils/Makefile
@@ -25,6 +25,7 @@ SRCS= AddrModeMatcher.cpp \
PromoteMemoryToRegister.cpp \
SSAUpdater.cpp \
SimplifyCFG.cpp \
+ SimplifyIndVar.cpp \
UnifyFunctionExitNodes.cpp \
ValueMapper.cpp
diff --git a/lib/clang/libllvmx86codegen/Makefile b/lib/clang/libllvmx86codegen/Makefile
index 6964501..5dc45ef 100644
--- a/lib/clang/libllvmx86codegen/Makefile
+++ b/lib/clang/libllvmx86codegen/Makefile
@@ -3,9 +3,7 @@
LIB= llvmx86codegen
SRCDIR= lib/Target/X86
-SRCS= SSEDomainFix.cpp \
- X86AsmBackend.cpp \
- X86AsmPrinter.cpp \
+SRCS= X86AsmPrinter.cpp \
X86COFFMachineModuleInfo.cpp \
X86CodeEmitter.cpp \
X86ELFWriterInfo.cpp \
@@ -16,14 +14,13 @@ SRCS= SSEDomainFix.cpp \
X86ISelLowering.cpp \
X86InstrInfo.cpp \
X86JITInfo.cpp \
- X86MCCodeEmitter.cpp \
X86MCInstLower.cpp \
- X86MachObjectWriter.cpp \
X86RegisterInfo.cpp \
X86SelectionDAGInfo.cpp \
X86Subtarget.cpp \
X86TargetMachine.cpp \
- X86TargetObjectFile.cpp
+ X86TargetObjectFile.cpp \
+ X86VZeroUpper.cpp \
TGHDRS= Intrinsics \
X86GenCallingConv \
diff --git a/lib/clang/libllvmx86desc/Makefile b/lib/clang/libllvmx86desc/Makefile
index 44b20a5..badb0f2 100644
--- a/lib/clang/libllvmx86desc/Makefile
+++ b/lib/clang/libllvmx86desc/Makefile
@@ -3,8 +3,12 @@
LIB= llvmx86desc
SRCDIR= lib/Target/X86/MCTargetDesc
-SRCS= X86MCAsmInfo.cpp \
+SRCS= X86AsmBackend.cpp \
+ X86MachObjectWriter.cpp \
+ X86MCAsmInfo.cpp \
+ X86MCCodeEmitter.cpp \
X86MCTargetDesc.cpp
+CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= X86GenInstrInfo \
X86GenRegisterInfo \
diff --git a/lib/clang/libllvmx86disassembler/Makefile b/lib/clang/libllvmx86disassembler/Makefile
index b9055fc..1d1b3b6 100644
--- a/lib/clang/libllvmx86disassembler/Makefile
+++ b/lib/clang/libllvmx86disassembler/Makefile
@@ -8,6 +8,7 @@ SRCS= X86Disassembler.cpp
TGHDRS= X86GenDisassemblerTables \
X86GenEDInfo \
+ X86GenInstrInfo \
X86GenRegisterInfo
.include "../clang.lib.mk"
diff --git a/lib/libarchive/archive_hash.h b/lib/libarchive/archive_hash.h
index dc63d94..43f398c 100644
--- a/lib/libarchive/archive_hash.h
+++ b/lib/libarchive/archive_hash.h
@@ -79,6 +79,13 @@ typedef MD5_CTX archive_md5_ctx;
# define archive_md5_init(ctx) MD5Init(ctx)
# define archive_md5_final(ctx, buf) MD5Final(buf, ctx)
# define archive_md5_update(ctx, buf, n) MD5Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_MD5_LIBMD)
+# include <md5.h>
+# define ARCHIVE_HAS_MD5
+typedef MD5_CTX archive_md5_ctx;
+# define archive_md5_init(ctx) MD5Init(ctx)
+# define archive_md5_final(ctx, buf) MD5Final(buf, ctx)
+# define archive_md5_update(ctx, buf, n) MD5Update(ctx, buf, n)
#elif defined(ARCHIVE_HASH_MD5_LIBSYSTEM)
# include <CommonCrypto/CommonDigest.h>
# define ARCHIVE_HAS_MD5
@@ -125,6 +132,13 @@ typedef SHA1_CTX archive_sha1_ctx;
# define archive_sha1_init(ctx) SHA1Init(ctx)
# define archive_sha1_final(ctx, buf) SHA1Final(buf, ctx)
# define archive_sha1_update(ctx, buf, n) SHA1Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA1_LIBMD)
+# include <sha.h>
+# define ARCHIVE_HAS_SHA1
+typedef SHA1_CTX archive_sha1_ctx;
+# define archive_sha1_init(ctx) SHA1_Init(ctx)
+# define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx)
+# define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n)
#elif defined(ARCHIVE_HASH_SHA1_LIBSYSTEM)
# include <CommonCrypto/CommonDigest.h>
# define ARCHIVE_HAS_SHA1
@@ -169,6 +183,13 @@ typedef SHA2_CTX archive_sha256_ctx;
# define archive_sha256_init(ctx) SHA256Init(ctx)
# define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx)
# define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA256_LIBMD)
+# include <sha256.h>
+# define ARCHIVE_HAS_SHA256
+typedef SHA256_CTX archive_sha256_ctx;
+# define archive_sha256_init(ctx) SHA256_Init(ctx)
+# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx)
+# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n)
#elif defined(ARCHIVE_HASH_SHA256_LIBSYSTEM)
# include <CommonCrypto/CommonDigest.h>
# define ARCHIVE_HAS_SHA256
@@ -257,6 +278,13 @@ typedef SHA2_CTX archive_sha512_ctx;
# define archive_sha512_init(ctx) SHA512Init(ctx)
# define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx)
# define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA512_LIBMD)
+# include <sha512.h>
+# define ARCHIVE_HAS_SHA512
+typedef SHA512_CTX archive_sha512_ctx;
+# define archive_sha512_init(ctx) SHA512_Init(ctx)
+# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx)
+# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n)
#elif defined(ARCHIVE_HASH_SHA512_LIBSYSTEM)
# include <CommonCrypto/CommonDigest.h>
# define ARCHIVE_HAS_SHA512
diff --git a/lib/libarchive/archive_read_disk.3 b/lib/libarchive/archive_read_disk.3
index 290d3a1..638c158 100644
--- a/lib/libarchive/archive_read_disk.3
+++ b/lib/libarchive/archive_read_disk.3
@@ -133,16 +133,16 @@ object is destroyed or when new lookup functions are registered.
This convenience function installs a standard set of user
and group name lookup functions.
These functions use
-.Xr getpwid 3
+.Xr getpwuid 3
and
-.Xr getgrid 3
+.Xr getgrgid 3
to convert ids to names, defaulting to NULL if the names cannot
be looked up.
These functions also implement a simple memory cache to reduce
the number of calls to
-.Xr getpwid 3
+.Xr getpwuid 3
and
-.Xr getgrid 3 .
+.Xr getgrgid 3 .
.It Fn archive_read_disk_entry_from_file
Populates a
.Tn struct archive_entry
@@ -281,9 +281,9 @@ library was written by
The
.Dq standard
user name and group name lookup functions are not the defaults because
-.Xr getgrid 3
+.Xr getgrgid 3
and
-.Xr getpwid 3
+.Xr getpwuid 3
are sometimes too large for particular applications.
The current design allows the application author to use a more
compact implementation when appropriate.
diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h
index d1cb462..a39a1fb 100644
--- a/lib/libarchive/config_freebsd.h
+++ b/lib/libarchive/config_freebsd.h
@@ -176,8 +176,8 @@
#define ARCHIVE_HASH_SHA384_OPENSSL 1
#define ARCHIVE_HASH_SHA512_OPENSSL 1
#else
-#define ARCHIVE_HASH_MD5_LIBC 1
-#define ARCHIVE_HASH_SHA1_LIBC 1
-#define ARCHIVE_HASH_SHA256_LIBC 1
-#define ARCHIVE_HASH_SHA512_LIBC 1
+#define ARCHIVE_HASH_MD5_LIBMD 1
+#define ARCHIVE_HASH_SHA1_LIBMD 1
+#define ARCHIVE_HASH_SHA256_LIBMD 1
+#define ARCHIVE_HASH_SHA512_LIBMD 1
#endif
diff --git a/lib/libc/Versions.def b/lib/libc/Versions.def
index da0ca6f..bbd59a4 100644
--- a/lib/libc/Versions.def
+++ b/lib/libc/Versions.def
@@ -19,6 +19,10 @@ FBSD_1.1 {
FBSD_1.2 {
} FBSD_1.1;
+# This version was first added to 10.0-current.
+FBSD_1.3 {
+} FBSD_1.2;
+
# This is our private namespace. Any global interfaces that are
# strictly for use only by other FreeBSD applications and libraries
# are listed here. We use a separate namespace so we can write
@@ -26,4 +30,4 @@ FBSD_1.2 {
#
# Please do NOT increment the version of this namespace.
FBSDprivate_1.0 {
-} FBSD_1.2;
+} FBSD_1.3;
diff --git a/lib/libc/amd64/Symbol.map b/lib/libc/amd64/Symbol.map
index ab85781..9997cc2 100644
--- a/lib/libc/amd64/Symbol.map
+++ b/lib/libc/amd64/Symbol.map
@@ -26,7 +26,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
- modf;
rfork_thread;
setjmp;
longjmp;
diff --git a/lib/libc/amd64/gen/Makefile.inc b/lib/libc/amd64/gen/Makefile.inc
index 38fe7e1..30fb05f 100644
--- a/lib/libc/amd64/gen/Makefile.inc
+++ b/lib/libc/amd64/gen/Makefile.inc
@@ -2,7 +2,7 @@
# $FreeBSD$
SRCS+= _setjmp.S _set_tp.c rfork_thread.S setjmp.S sigsetjmp.S \
- fabs.S modf.S \
+ fabs.S \
infinity.c ldexp.c makecontext.c signalcontext.c \
flt_rounds.c fpgetmask.c fpsetmask.c fpgetprec.c fpsetprec.c \
fpgetround.c fpsetround.c fpgetsticky.c
diff --git a/lib/libc/amd64/gen/modf.S b/lib/libc/amd64/gen/modf.S
deleted file mode 100644
index 691aad8..0000000
--- a/lib/libc/amd64/gen/modf.S
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Sean Eric Fagan.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)modf.s 5.5 (Berkeley) 3/18/91
- */
-
-#include <machine/asm.h>
-#if defined(LIBC_SCCS)
- RCSID("$NetBSD: modf.S,v 1.5 1997/07/16 14:37:18 christos Exp $")
-#endif
-__FBSDID("$FreeBSD$");
-
-/*
- * modf(value, iptr): return fractional part of value, and stores the
- * integral part into iptr (a pointer to double).
- *
- * Written by Sean Eric Fagan (sef@kithrup.COM)
- * Sun Mar 11 20:27:30 PST 1990
- */
-
-/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */
-ENTRY(modf)
-
- /*
- * Set chop mode.
- */
- fnstcw -12(%rsp)
- movw -12(%rsp),%dx
- orw $3072,%dx
- movw %dx,-16(%rsp)
- fldcw -16(%rsp)
-
- /*
- * Get integral part.
- */
- movsd %xmm0,-24(%rsp)
- fldl -24(%rsp)
- frndint
- fstpl -8(%rsp)
-
- /*
- * Restore control word.
- */
- fldcw -12(%rsp)
-
- /*
- * Store integral part.
- */
- movsd -8(%rsp),%xmm0
- movsd %xmm0,(%rdi)
-
- /*
- * Get fractional part and return it.
- */
- fldl -24(%rsp)
- fsubl -8(%rsp)
- fstpl -8(%rsp)
- movsd -8(%rsp),%xmm0
-
- ret
-END(modf)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/arm/Symbol.map b/lib/libc/arm/Symbol.map
index 6b7e6e4..2cc5157 100644
--- a/lib/libc/arm/Symbol.map
+++ b/lib/libc/arm/Symbol.map
@@ -19,7 +19,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
- modf;
setjmp;
longjmp;
sigsetjmp;
diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc
index bbe2257..fb9d885 100644
--- a/lib/libc/arm/gen/Makefile.inc
+++ b/lib/libc/arm/gen/Makefile.inc
@@ -2,5 +2,5 @@
# $FreeBSD$
SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \
- infinity.c ldexp.c makecontext.c modf.c \
+ infinity.c ldexp.c makecontext.c \
setjmp.S signalcontext.c sigsetjmp.S divsi3.S
diff --git a/lib/libc/arm/gen/modf.c b/lib/libc/arm/gen/modf.c
deleted file mode 100644
index cb5aeac..0000000
--- a/lib/libc/arm/gen/modf.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1994, 1995 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- *
- * $NetBSD: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <errno.h>
-#include <math.h>
-#include <machine/ieee.h>
-
-/*
- * double modf(double val, double *iptr)
- * returns: f and i such that |f| < 1.0, (f + i) = val, and
- * sign(f) == sign(i) == sign(val).
- *
- * Beware signedness when doing subtraction, and also operand size!
- */
-double
-modf(val, iptr)
- double val, *iptr;
-{
- union doub {
- double v;
- struct ieee_double s;
- } u, v;
- u_int64_t frac;
-
- /*
- * If input is Inf or NaN, return it and leave i alone.
- */
- u.v = val;
- if (u.s.dbl_exp == DBL_EXP_INFNAN)
- return (u.v);
-
- /*
- * If input can't have a fractional part, return
- * (appropriately signed) zero, and make i be the input.
- */
- if ((int)u.s.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) {
- *iptr = u.v;
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- return (v.v);
- }
-
- /*
- * If |input| < 1.0, return it, and set i to the appropriately
- * signed zero.
- */
- if (u.s.dbl_exp < DBL_EXP_BIAS) {
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- *iptr = v.v;
- return (u.v);
- }
-
- /*
- * There can be a fractional part of the input.
- * If you look at the math involved for a few seconds, it's
- * plain to see that the integral part is the input, with the
- * low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed,
- * the fractional part is the part with the rest of the
- * bits zeroed. Just zeroing the high bits to get the
- * fractional part would yield a fraction in need of
- * normalization. Therefore, we take the easy way out, and
- * just use subtraction to get the fractional part.
- */
- v.v = u.v;
- /* Zero the low bits of the fraction, the sleazy way. */
- frac = ((u_int64_t)v.s.dbl_frach << 32) + v.s.dbl_fracl;
- frac >>= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- frac <<= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- v.s.dbl_fracl = frac & 0xffffffff;
- v.s.dbl_frach = frac >> 32;
- *iptr = v.v;
-
- u.v -= v.v;
- u.s.dbl_sign = v.s.dbl_sign;
- return (u.v);
-}
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index d55bc46..d3ccf0a 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -35,6 +35,8 @@ SRCS+= __getosreldate.c __xuname.c \
usleep.c utime.c utxdb.c valloc.c vis.c wait.c wait3.c waitpid.c \
wordexp.c
+MISRCS+=modf.c
+
CANCELPOINTS_SRCS=sem.c sem_new.c
.for src in ${CANCELPOINTS_SRCS}
SRCS+=cancelpoints_${src}
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index 32cf92c..c62e016 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -213,6 +213,7 @@ FBSD_1.0 {
ldexp;
lockf;
lrand48;
+ modf;
mrand48;
nftw;
nice;
diff --git a/lib/libc/gen/ctermid.3 b/lib/libc/gen/ctermid.3
index 3402d1d..d737e5e 100644
--- a/lib/libc/gen/ctermid.3
+++ b/lib/libc/gen/ctermid.3
@@ -28,7 +28,7 @@
.\" @(#)ctermid.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd October 1, 2011
.Dt CTERMID 3
.Os
.Sh NAME
@@ -77,7 +77,8 @@ pointer,
.Dv NULL
is returned.
.Pp
-The current implementation simply returns
+If no suitable lookup of the controlling terminal name can be performed,
+this implementation returns
.Ql /dev/tty .
.Sh RETURN VALUES
Upon successful completion, a
diff --git a/lib/libc/gen/ctermid.c b/lib/libc/gen/ctermid.c
index f88b1f5..8af1cb2 100644
--- a/lib/libc/gen/ctermid.c
+++ b/lib/libc/gen/ctermid.c
@@ -1,6 +1,6 @@
/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 2011 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
@@ -10,14 +10,11 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * 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 REGENTS OR CONTRIBUTORS BE LIABLE
+ * 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)
@@ -27,31 +24,47 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ctermid.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <stdio.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+
+#include <errno.h>
#include <paths.h>
+#include <stdio.h>
#include <string.h>
+#define LEN_PATH_DEV (sizeof(_PATH_DEV) - 1)
+
char *
ctermid(char *s)
{
- static char def[] = _PATH_TTY;
+ static char def[sizeof(_PATH_DEV) + SPECNAMELEN];
+ struct stat sb;
+ size_t dlen;
+ int sverrno;
- if (s) {
- bcopy(def, s, sizeof(_PATH_TTY));
- return(s);
- }
- return(def);
-}
+ if (s == NULL) {
+ s = def;
+ dlen = sizeof(def) - LEN_PATH_DEV;
+ } else
+ dlen = L_ctermid - LEN_PATH_DEV;
+ strcpy(s, _PATH_TTY);
+ /* Attempt to perform a lookup of the actual TTY pathname. */
+ sverrno = errno;
+ if (stat(_PATH_TTY, &sb) == 0 && S_ISCHR(sb.st_mode))
+ (void)sysctlbyname("kern.devname", s + LEN_PATH_DEV,
+ &dlen, &sb.st_rdev, sizeof(sb.st_rdev));
+ errno = sverrno;
+ return (s);
+}
char *
ctermid_r(char *s)
{
- return (s) ? ctermid(s) : NULL;
+
+ return (s != NULL ? ctermid(s) : NULL);
}
diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c
index 65a690f..da0b923 100644
--- a/lib/libc/gen/devname.c
+++ b/lib/libc/gen/devname.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
@@ -60,8 +61,8 @@ devname_r(dev_t dev, mode_t type, char *buf, int len)
}
/* Finally just format it */
- snprintf(buf, len, "#%c:%d:0x%x",
- S_ISCHR(type) ? 'C' : 'B', major(dev), minor(dev));
+ snprintf(buf, len, "#%c:%#jx",
+ S_ISCHR(type) ? 'C' : 'B', (uintmax_t)dev);
return (buf);
}
diff --git a/lib/libc/gen/getutxent.3 b/lib/libc/gen/getutxent.3
index 1920555..d25aacf 100644
--- a/lib/libc/gen/getutxent.3
+++ b/lib/libc/gen/getutxent.3
@@ -243,7 +243,7 @@ or
.Dv LOGIN_PROCESS
and whose
.Fa ut_line
-is equal to the the same field in
+is equal to the same field in
.Fa line .
.Pp
The
diff --git a/lib/libc/gen/modf.c b/lib/libc/gen/modf.c
new file mode 100644
index 0000000..d67b441
--- /dev/null
+++ b/lib/libc/gen/modf.c
@@ -0,0 +1,138 @@
+/* @(#)s_modf.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$");
+
+/*
+ * modf(double x, double *iptr)
+ * return fraction part of x, and return x's integral part in *iptr.
+ * Method:
+ * Bit twiddling.
+ *
+ * Exception:
+ * No exception.
+ */
+
+#include <sys/types.h>
+#include <machine/endian.h>
+#include <math.h>
+
+/* Bit fiddling routines copied from msun/src/math_private.h,v 1.15 */
+
+#if BYTE_ORDER == BIG_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+ u_int32_t msw;
+ u_int32_t lsw;
+ } parts;
+} ieee_double_shape_type;
+
+#endif
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+ u_int32_t lsw;
+ u_int32_t msw;
+ } parts;
+} ieee_double_shape_type;
+
+#endif
+
+/* Get two 32 bit ints from a double. */
+
+#define EXTRACT_WORDS(ix0,ix1,d) \
+do { \
+ ieee_double_shape_type ew_u; \
+ ew_u.value = (d); \
+ (ix0) = ew_u.parts.msw; \
+ (ix1) = ew_u.parts.lsw; \
+} while (0)
+
+/* Get the more significant 32 bit int from a double. */
+
+#define GET_HIGH_WORD(i,d) \
+do { \
+ ieee_double_shape_type gh_u; \
+ gh_u.value = (d); \
+ (i) = gh_u.parts.msw; \
+} while (0)
+
+/* Set a double from two 32 bit ints. */
+
+#define INSERT_WORDS(d,ix0,ix1) \
+do { \
+ ieee_double_shape_type iw_u; \
+ iw_u.parts.msw = (ix0); \
+ iw_u.parts.lsw = (ix1); \
+ (d) = iw_u.value; \
+} while (0)
+
+static const double one = 1.0;
+
+double
+modf(double x, double *iptr)
+{
+ int32_t i0,i1,j0;
+ u_int32_t i;
+ EXTRACT_WORDS(i0,i1,x);
+ j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */
+ if(j0<20) { /* integer part in high x */
+ if(j0<0) { /* |x|<1 */
+ INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */
+ return x;
+ } else {
+ i = (0x000fffff)>>j0;
+ if(((i0&i)|i1)==0) { /* x is integral */
+ u_int32_t high;
+ *iptr = x;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else {
+ INSERT_WORDS(*iptr,i0&(~i),0);
+ return x - *iptr;
+ }
+ }
+ } else if (j0>51) { /* no fraction part */
+ u_int32_t high;
+ if (j0 == 0x400) { /* inf/NaN */
+ *iptr = x;
+ return 0.0 / x;
+ }
+ *iptr = x*one;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else { /* fraction part in low x */
+ i = ((u_int32_t)(0xffffffff))>>(j0-20);
+ if((i1&i)==0) { /* x is integral */
+ u_int32_t high;
+ *iptr = x;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else {
+ INSERT_WORDS(*iptr,i0,i1&(~i));
+ return x - *iptr;
+ }
+ }
+}
diff --git a/lib/libc/i386/Symbol.map b/lib/libc/i386/Symbol.map
index 9fd9dc2..8a01802 100644
--- a/lib/libc/i386/Symbol.map
+++ b/lib/libc/i386/Symbol.map
@@ -20,7 +20,6 @@ FBSD_1.0 {
__nan;
__infinity;
makecontext;
- modf;
rfork_thread;
setjmp;
longjmp;
diff --git a/lib/libc/i386/gen/Makefile.inc b/lib/libc/i386/gen/Makefile.inc
index 89319c8..45e69ca 100644
--- a/lib/libc/i386/gen/Makefile.inc
+++ b/lib/libc/i386/gen/Makefile.inc
@@ -2,5 +2,5 @@
# $FreeBSD$
SRCS+= _ctx_start.S _setjmp.S _set_tp.c fabs.S \
- flt_rounds.c infinity.c ldexp.c makecontext.c modf.S \
+ flt_rounds.c infinity.c ldexp.c makecontext.c \
rfork_thread.S setjmp.S signalcontext.c sigsetjmp.S
diff --git a/lib/libc/i386/gen/modf.S b/lib/libc/i386/gen/modf.S
deleted file mode 100644
index 33c211f..0000000
--- a/lib/libc/i386/gen/modf.S
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Sean Eric Fagan.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)modf.s 5.5 (Berkeley) 3/18/91"
-#endif /* LIBC_SCCS and not lint */
-#include <machine/asm.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * modf(value, iptr): return fractional part of value, and stores the
- * integral part into iptr (a pointer to double).
- *
- * Written by Sean Eric Fagan (sef@kithrup.COM)
- * Sun Mar 11 20:27:30 PST 1990
- */
-
-/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */
-
-ENTRY(modf)
- pushl %ebp
- movl %esp,%ebp
- /* Check for Inf/NaN */
- movl 12(%ebp),%eax
- andl $0x7fffffff,%eax
- cmpl $0x7ff00000,%eax
- jae 1f
- /* Finite value */
- subl $16,%esp
- fnstcw -12(%ebp)
- movw -12(%ebp),%dx
- orw $3072,%dx
- movw %dx,-16(%ebp)
- fldcw -16(%ebp)
- fldl 8(%ebp)
- frndint
- fstpl -8(%ebp)
- fldcw -12(%ebp)
- movl 16(%ebp),%eax
- movl -8(%ebp),%edx
- movl -4(%ebp),%ecx
- movl %edx,(%eax)
- movl %ecx,4(%eax)
- fldl 8(%ebp)
- fsubl -8(%ebp)
- leave
- ret
- /* Inf/NaN handling */
-1: fldl 8(%ebp)
- movl 16(%ebp),%edx
- fstl (%edx)
- fldz
- fdivp /* return +/- 0 for +/- Inf, NaN for NaN */
- leave
- ret
-END(modf)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/ia64/Symbol.map b/lib/libc/ia64/Symbol.map
index a730922..7a31a51 100644
--- a/lib/libc/ia64/Symbol.map
+++ b/lib/libc/ia64/Symbol.map
@@ -23,7 +23,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
- modf;
setjmp;
longjmp;
sigsetjmp;
diff --git a/lib/libc/ia64/gen/Makefile.inc b/lib/libc/ia64/gen/Makefile.inc
index 5358ea8..685ab86 100644
--- a/lib/libc/ia64/gen/Makefile.inc
+++ b/lib/libc/ia64/gen/Makefile.inc
@@ -3,7 +3,7 @@
SRCS+= __divdf3.S __divdi3.S __divsf3.S __divsi3.S __moddi3.S __modsi3.S \
__udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S _mcount.S _set_tp.c \
_setjmp.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c fpsetmask.c \
- fpsetround.c infinity.c ldexp.c makecontext.c modf.c setjmp.S \
+ fpsetround.c infinity.c ldexp.c makecontext.c setjmp.S \
signalcontext.c sigsetjmp.S
# The following may go away if function _Unwind_FindTableEntry()
diff --git a/lib/libc/ia64/gen/modf.c b/lib/libc/ia64/gen/modf.c
deleted file mode 100644
index 13e6182..0000000
--- a/lib/libc/ia64/gen/modf.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* $NetBSD: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $ */
-
-/*
- * Copyright (c) 1994, 1995 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <machine/ieee.h>
-#include <math.h>
-
-/*
- * double modf(double val, double *iptr)
- * returns: f and i such that |f| < 1.0, (f + i) = val, and
- * sign(f) == sign(i) == sign(val).
- *
- * Beware signedness when doing subtraction, and also operand size!
- */
-double
-modf(val, iptr)
- double val, *iptr;
-{
- union doub {
- double v;
- struct ieee_double s;
- } u, v;
- u_int64_t frac;
-
- /*
- * If input is Inf or NaN, return it and leave i alone.
- */
- u.v = val;
- if (u.s.dbl_exp == DBL_EXP_INFNAN)
- return (u.v);
-
- /*
- * If input can't have a fractional part, return
- * (appropriately signed) zero, and make i be the input.
- */
- if ((int)u.s.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) {
- *iptr = u.v;
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- return (v.v);
- }
-
- /*
- * If |input| < 1.0, return it, and set i to the appropriately
- * signed zero.
- */
- if (u.s.dbl_exp < DBL_EXP_BIAS) {
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- *iptr = v.v;
- return (u.v);
- }
-
- /*
- * There can be a fractional part of the input.
- * If you look at the math involved for a few seconds, it's
- * plain to see that the integral part is the input, with the
- * low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed,
- * the fractional part is the part with the rest of the
- * bits zeroed. Just zeroing the high bits to get the
- * fractional part would yield a fraction in need of
- * normalization. Therefore, we take the easy way out, and
- * just use subtraction to get the fractional part.
- */
- v.v = u.v;
- /* Zero the low bits of the fraction, the sleazy way. */
- frac = ((u_int64_t)v.s.dbl_frach << 32) + v.s.dbl_fracl;
- frac >>= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- frac <<= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- v.s.dbl_fracl = frac & 0xffffffff;
- v.s.dbl_frach = frac >> 32;
- *iptr = v.v;
-
- u.v -= v.v;
- u.s.dbl_sign = v.s.dbl_sign;
- return (u.v);
-}
diff --git a/lib/libc/iconv/citrus_none.c b/lib/libc/iconv/citrus_none.c
index 1f77ad0..9ec4bd3 100644
--- a/lib/libc/iconv/citrus_none.c
+++ b/lib/libc/iconv/citrus_none.c
@@ -190,7 +190,6 @@ _citrus_NONE_stdenc_wctomb(struct _citrus_stdenc * __restrict ce __unused,
void * __restrict pspriv __unused, size_t * __restrict nresult,
struct iconv_hooks *hooks __unused)
{
- int ret;
if ((wc & ~0xFFU) != 0) {
*nresult = (size_t)-1;
@@ -198,7 +197,7 @@ _citrus_NONE_stdenc_wctomb(struct _citrus_stdenc * __restrict ce __unused,
}
if (n == 0) {
*nresult = (size_t)-1;
- ret = E2BIG;
+ return (E2BIG);
}
*nresult = 1;
diff --git a/lib/libc/locale/isspace.3 b/lib/libc/locale/isspace.3
index f1e08d6..eab6cfc 100644
--- a/lib/libc/locale/isspace.3
+++ b/lib/libc/locale/isspace.3
@@ -47,16 +47,16 @@
.Sh DESCRIPTION
The
.Fn isspace
-function tests for the white-space characters.
+function tests for white-space characters.
For any locale, this includes the following standard characters:
.Pp
.Bl -column \&`\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___
.It "\&``\et''\t``\en''\t``\ev''\t``\ef''\t``\er''\t`` ''"
.El
.Pp
-In the "C" locale
+In the "C" locale,
.Fn isspace
-successful test is limited to this characters only.
+returns non-zero for these characters only.
The value of the argument must be representable as an
.Vt "unsigned char"
or the value of
diff --git a/lib/libc/mips/Symbol.map b/lib/libc/mips/Symbol.map
index b478551..d7fbd0a 100644
--- a/lib/libc/mips/Symbol.map
+++ b/lib/libc/mips/Symbol.map
@@ -1,5 +1,5 @@
-/*
- * $FreeBSD$
+/*
+ * $FreeBSD$
*/
/*
@@ -18,7 +18,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
- modf;
setjmp;
longjmp;
sigsetjmp;
diff --git a/lib/libc/mips/gen/Makefile.inc b/lib/libc/mips/gen/Makefile.inc
index 1fafb01..8ee69d0 100644
--- a/lib/libc/mips/gen/Makefile.inc
+++ b/lib/libc/mips/gen/Makefile.inc
@@ -1,7 +1,7 @@
# $NetBSD: Makefile.inc,v 1.27 2005/10/07 17:16:40 tsutsui Exp $
# $FreeBSD$
-SRCS+= infinity.c fabs.c ldexp.c modf.c
+SRCS+= infinity.c fabs.c ldexp.c
# SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
# fpsetround.c fpsetsticky.c
diff --git a/lib/libc/mips/gen/modf.S b/lib/libc/mips/gen/modf.S
deleted file mode 100644
index 5eee3f1..0000000
--- a/lib/libc/mips/gen/modf.S
+++ /dev/null
@@ -1,82 +0,0 @@
-/* $NetBSD: modf.S,v 1.10 2003/08/07 16:42:15 agc Exp $ */
-
-/*-
- * Copyright (c) 1991, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD$");
-
-#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)modf.s 8.1 (Berkeley) 6/4/93")
- ASMSTR("$NetBSD: modf.S,v 1.10 2003/08/07 16:42:15 agc Exp $")
-#endif /* LIBC_SCCS and not lint */
-
-#ifdef __ABICALLS__
- .abicalls
-#endif
-
-/*
- * double modf(val, iptr)
- * double val, *iptr;
- * returns: xxx and n (in *iptr) where val == n.xxx
- */
-LEAF(modf)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
- cfc1 t0, $31 # get the control register
- li.d $f2, 4503599627370496e0 # f2 <- 2^52
-
- or t1, t0, 0x3 # set rounding mode to round to zero
- xor t1, t1, 0x2 # (i.e., 01)
- ctc1 t1, $31
-
- mov.d $f0, $f12 # f0 <- f12
- abs.d $f4, $f12 # f4 <- |f12|
- c.olt.d $f4, $f2 # f4 ? < f2
- bc1f 1f # leave f0 alone if Nan, infinity
- # or >=2^52
- c.eq.d $f12,$f4 # was f12 positive ?
- add.d $f4,$f2,$f4 # round off to integer
- bc1f 2f # No -> will have to negate result
- sub.d $f0,$f4,$f2 # Remove fudge factor
- j 1f # integer fraction got
-2:
- sub.d $f0,$f2,$f4 # Remove fudge factor and negate
-1:
- ctc1 t0, $31 # restore old rounding mode
- s.d $f0, 0(a2) # save the integer part
- sub.d $f0, $f12, $f0 # subtract val - integer part
- j ra
-END(modf)
diff --git a/lib/libc/mips/gen/modf.c b/lib/libc/mips/gen/modf.c
deleted file mode 100644
index cb5aeac..0000000
--- a/lib/libc/mips/gen/modf.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1994, 1995 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- *
- * $NetBSD: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <errno.h>
-#include <math.h>
-#include <machine/ieee.h>
-
-/*
- * double modf(double val, double *iptr)
- * returns: f and i such that |f| < 1.0, (f + i) = val, and
- * sign(f) == sign(i) == sign(val).
- *
- * Beware signedness when doing subtraction, and also operand size!
- */
-double
-modf(val, iptr)
- double val, *iptr;
-{
- union doub {
- double v;
- struct ieee_double s;
- } u, v;
- u_int64_t frac;
-
- /*
- * If input is Inf or NaN, return it and leave i alone.
- */
- u.v = val;
- if (u.s.dbl_exp == DBL_EXP_INFNAN)
- return (u.v);
-
- /*
- * If input can't have a fractional part, return
- * (appropriately signed) zero, and make i be the input.
- */
- if ((int)u.s.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) {
- *iptr = u.v;
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- return (v.v);
- }
-
- /*
- * If |input| < 1.0, return it, and set i to the appropriately
- * signed zero.
- */
- if (u.s.dbl_exp < DBL_EXP_BIAS) {
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- *iptr = v.v;
- return (u.v);
- }
-
- /*
- * There can be a fractional part of the input.
- * If you look at the math involved for a few seconds, it's
- * plain to see that the integral part is the input, with the
- * low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed,
- * the fractional part is the part with the rest of the
- * bits zeroed. Just zeroing the high bits to get the
- * fractional part would yield a fraction in need of
- * normalization. Therefore, we take the easy way out, and
- * just use subtraction to get the fractional part.
- */
- v.v = u.v;
- /* Zero the low bits of the fraction, the sleazy way. */
- frac = ((u_int64_t)v.s.dbl_frach << 32) + v.s.dbl_fracl;
- frac >>= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- frac <<= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- v.s.dbl_fracl = frac & 0xffffffff;
- v.s.dbl_frach = frac >> 32;
- *iptr = v.v;
-
- u.v -= v.v;
- u.s.dbl_sign = v.s.dbl_sign;
- return (u.v);
-}
diff --git a/lib/libc/net/Symbol.map b/lib/libc/net/Symbol.map
index de44cc5..39ab2c7 100644
--- a/lib/libc/net/Symbol.map
+++ b/lib/libc/net/Symbol.map
@@ -155,14 +155,14 @@ FBSDprivate_1.0 {
__ivaliduser_sa;
__check_rhosts_file;
__rcmd_errstr;
- __nss_compat_getgrnam_r;
- __nss_compat_getgrgid_r;
- __nss_compat_getgrent_r;
- __nss_compat_setgrent;
- __nss_compat_endgrent;
- __nss_compat_getpwnam_r;
- __nss_compat_getpwuid_r;
- __nss_compat_getpwent_r;
- __nss_compat_setpwent;
- __nss_compat_endpwent;
+ __nss_compat_getgrnam_r;
+ __nss_compat_getgrgid_r;
+ __nss_compat_getgrent_r;
+ __nss_compat_setgrent;
+ __nss_compat_endgrent;
+ __nss_compat_getpwnam_r;
+ __nss_compat_getpwuid_r;
+ __nss_compat_getpwent_r;
+ __nss_compat_setpwent;
+ __nss_compat_endpwent;
};
diff --git a/lib/libc/powerpc/Symbol.map b/lib/libc/powerpc/Symbol.map
index 5b24024..14b4811 100644
--- a/lib/libc/powerpc/Symbol.map
+++ b/lib/libc/powerpc/Symbol.map
@@ -24,7 +24,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
- modf;
setjmp;
longjmp;
sigsetjmp;
diff --git a/lib/libc/powerpc/gen/Makefile.inc b/lib/libc/powerpc/gen/Makefile.inc
index 4b381c3..3bfabda 100644
--- a/lib/libc/powerpc/gen/Makefile.inc
+++ b/lib/libc/powerpc/gen/Makefile.inc
@@ -2,7 +2,7 @@
SRCS += _ctx_start.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
fpgetsticky.c fpsetmask.c fpsetround.c \
- infinity.c ldexp.c makecontext.c modf.c _setjmp.S \
+ infinity.c ldexp.c makecontext.c _setjmp.S \
setjmp.S sigsetjmp.S signalcontext.c syncicache.c \
_set_tp.c
diff --git a/lib/libc/powerpc/gen/modf.c b/lib/libc/powerpc/gen/modf.c
deleted file mode 100644
index 612c506..0000000
--- a/lib/libc/powerpc/gen/modf.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1994, 1995 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- *
- * $NetBSD: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <machine/ieee.h>
-#include <errno.h>
-#include <math.h>
-
-/*
- * double modf(double val, double *iptr)
- * returns: f and i such that |f| < 1.0, (f + i) = val, and
- * sign(f) == sign(i) == sign(val).
- *
- * Beware signedness when doing subtraction, and also operand size!
- */
-double
-modf(val, iptr)
- double val, *iptr;
-{
- union doub {
- double v;
- struct ieee_double s;
- } u, v;
- u_int64_t frac;
-
- /*
- * If input is Inf or NaN, return it and leave i alone.
- */
- u.v = val;
- if (u.s.dbl_exp == DBL_EXP_INFNAN)
- return (u.v);
-
- /*
- * If input can't have a fractional part, return
- * (appropriately signed) zero, and make i be the input.
- */
- if ((int)u.s.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) {
- *iptr = u.v;
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- return (v.v);
- }
-
- /*
- * If |input| < 1.0, return it, and set i to the appropriately
- * signed zero.
- */
- if (u.s.dbl_exp < DBL_EXP_BIAS) {
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- *iptr = v.v;
- return (u.v);
- }
-
- /*
- * There can be a fractional part of the input.
- * If you look at the math involved for a few seconds, it's
- * plain to see that the integral part is the input, with the
- * low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed,
- * the fractional part is the part with the rest of the
- * bits zeroed. Just zeroing the high bits to get the
- * fractional part would yield a fraction in need of
- * normalization. Therefore, we take the easy way out, and
- * just use subtraction to get the fractional part.
- */
- v.v = u.v;
- /* Zero the low bits of the fraction, the sleazy way. */
- frac = ((u_int64_t)v.s.dbl_frach << 32) + v.s.dbl_fracl;
- frac >>= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- frac <<= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- v.s.dbl_fracl = frac & 0xffffffff;
- v.s.dbl_frach = frac >> 32;
- *iptr = v.v;
-
- u.v -= v.v;
- u.s.dbl_sign = v.s.dbl_sign;
- return (u.v);
-}
diff --git a/lib/libc/powerpc64/Symbol.map b/lib/libc/powerpc64/Symbol.map
index 0314d0d..018a193 100644
--- a/lib/libc/powerpc64/Symbol.map
+++ b/lib/libc/powerpc64/Symbol.map
@@ -24,7 +24,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
- modf;
setjmp;
longjmp;
sigsetjmp;
diff --git a/lib/libc/powerpc64/gen/Makefile.inc b/lib/libc/powerpc64/gen/Makefile.inc
index 4b381c3..3bfabda 100644
--- a/lib/libc/powerpc64/gen/Makefile.inc
+++ b/lib/libc/powerpc64/gen/Makefile.inc
@@ -2,7 +2,7 @@
SRCS += _ctx_start.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
fpgetsticky.c fpsetmask.c fpsetround.c \
- infinity.c ldexp.c makecontext.c modf.c _setjmp.S \
+ infinity.c ldexp.c makecontext.c _setjmp.S \
setjmp.S sigsetjmp.S signalcontext.c syncicache.c \
_set_tp.c
diff --git a/lib/libc/powerpc64/gen/modf.c b/lib/libc/powerpc64/gen/modf.c
deleted file mode 100644
index 612c506..0000000
--- a/lib/libc/powerpc64/gen/modf.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1994, 1995 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- *
- * $NetBSD: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <machine/ieee.h>
-#include <errno.h>
-#include <math.h>
-
-/*
- * double modf(double val, double *iptr)
- * returns: f and i such that |f| < 1.0, (f + i) = val, and
- * sign(f) == sign(i) == sign(val).
- *
- * Beware signedness when doing subtraction, and also operand size!
- */
-double
-modf(val, iptr)
- double val, *iptr;
-{
- union doub {
- double v;
- struct ieee_double s;
- } u, v;
- u_int64_t frac;
-
- /*
- * If input is Inf or NaN, return it and leave i alone.
- */
- u.v = val;
- if (u.s.dbl_exp == DBL_EXP_INFNAN)
- return (u.v);
-
- /*
- * If input can't have a fractional part, return
- * (appropriately signed) zero, and make i be the input.
- */
- if ((int)u.s.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) {
- *iptr = u.v;
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- return (v.v);
- }
-
- /*
- * If |input| < 1.0, return it, and set i to the appropriately
- * signed zero.
- */
- if (u.s.dbl_exp < DBL_EXP_BIAS) {
- v.v = 0.0;
- v.s.dbl_sign = u.s.dbl_sign;
- *iptr = v.v;
- return (u.v);
- }
-
- /*
- * There can be a fractional part of the input.
- * If you look at the math involved for a few seconds, it's
- * plain to see that the integral part is the input, with the
- * low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed,
- * the fractional part is the part with the rest of the
- * bits zeroed. Just zeroing the high bits to get the
- * fractional part would yield a fraction in need of
- * normalization. Therefore, we take the easy way out, and
- * just use subtraction to get the fractional part.
- */
- v.v = u.v;
- /* Zero the low bits of the fraction, the sleazy way. */
- frac = ((u_int64_t)v.s.dbl_frach << 32) + v.s.dbl_fracl;
- frac >>= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- frac <<= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
- v.s.dbl_fracl = frac & 0xffffffff;
- v.s.dbl_frach = frac >> 32;
- *iptr = v.v;
-
- u.v -= v.v;
- u.s.dbl_sign = v.s.dbl_sign;
- return (u.v);
-}
diff --git a/lib/libc/sparc64/Symbol.map b/lib/libc/sparc64/Symbol.map
index 73d0ed5..4f90486 100644
--- a/lib/libc/sparc64/Symbol.map
+++ b/lib/libc/sparc64/Symbol.map
@@ -6,7 +6,7 @@
* This only needs to contain symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
- */
+ */
FBSD_1.0 {
/* PSEUDO syscalls */
_exit;
@@ -24,7 +24,6 @@ FBSD_1.0 {
__infinity;
__nan;
makecontext;
- modf;
setjmp;
longjmp;
sigsetjmp;
diff --git a/lib/libc/sparc64/gen/Makefile.inc b/lib/libc/sparc64/gen/Makefile.inc
index 979c182..f82f225 100644
--- a/lib/libc/sparc64/gen/Makefile.inc
+++ b/lib/libc/sparc64/gen/Makefile.inc
@@ -2,5 +2,5 @@
SRCS+= _ctx_start.S _setjmp.S fabs.S fixunsdfsi.S flt_rounds.c fpgetmask.c \
fpgetround.c fpgetsticky.c fpsetmask.c fpsetround.c \
- infinity.c ldexp.c makecontext.c modf.S \
+ infinity.c ldexp.c makecontext.c \
signalcontext.c setjmp.S sigsetjmp.S _set_tp.c
diff --git a/lib/libc/sparc64/gen/modf.S b/lib/libc/sparc64/gen/modf.S
deleted file mode 100644
index cec2f94..0000000
--- a/lib/libc/sparc64/gen/modf.S
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Header: modf.s,v 1.3 92/06/20 00:00:54 torek Exp
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93"
-#if 0
- .asciz "$NetBSD: modf.S,v 1.2 2000/07/23 07:12:22 eeh Exp $"
-#endif
-#endif /* LIBC_SCCS and not lint */
-#include <machine/asm.h>
-__FBSDID("$FreeBSD$");
-
-#include "assym.s"
-
-/*
- * double modf(double val, double *iptr)
- *
- * Returns the fractional part of `val', storing the integer part of
- * `val' in *iptr. Both *iptr and the return value have the same sign
- * as `val'.
- *
- * Method:
- *
- * We use the fpu's normalization hardware to compute the integer portion
- * of the double precision argument. Sun IEEE double precision numbers
- * have 52 bits of mantissa, 11 bits of exponent, and one bit of sign,
- * with the sign occupying bit 31 of word 0, and the exponent bits 30:20
- * of word 0. Thus, values >= 2^52 are by definition integers.
- *
- * If we take a value that is in the range [+0..2^52) and add 2^52, all
- * of the fractional bits fall out and all of the integer bits are summed
- * with 2^52. If we then subtract 2^52, we get those integer bits back.
- * This must be done with rounding set to `towards 0' or `towards -inf'.
- * `Toward -inf' fails when the value is 0 (we get -0 back)....
- *
- * Note that this method will work anywhere, but is machine dependent in
- * various aspects.
- *
- * Stack usage:
- * 4@[%fp + SPOFF - 4] saved %fsr
- * 4@[%fp + SPOFF - 8] new %fsr with rounding set to `towards 0'
- * 8@[%fp + SPOFF - 16] space for moving between %i and %f registers
- * Register usage:
- * %f0:f1 double val;
- * %l0 scratch
- * %l1 sign bit (0x80000000)
- * %i1 double *iptr;
- * %f2:f3 `magic number' 2^52, in fpu registers
- * %f4:f5 double v, in fpu registers
- * %f6:f7 double temp.
- */
-
- .align 8
-.Lmagic:
- .word 0x43300000 ! sign = 0, exponent = 52 + 1023, mantissa = 0
- .word 0 ! (i.e., .double 0r4503599627370496e+00)
-
-.L0:
- .word 0 ! 0.0
- .word 0
-
-ENTRY(modf)
- save %sp, -CCFSZ - 16, %sp
- PIC_PROLOGUE(%l6, %l7)
-
- /*
- * First, compute v = abs(val)
- */
- fabsd %f0, %f4 ! %f4:f5 = v
- fcmped %fcc1, %f0, %f4 ! %fcc1 = (val == abs(val))
- SET(.Lmagic, %l7, %l0)
- ldd [%l0], %f2
-
- /*
- * Is %f4:f5 >= %f2:f3 ? If so, it is all integer bits.
- * It is probably less, though.
- */
- fcmped %f4, %f2
- fbuge .Lbig ! if >= (or unordered), go out
- nop
-
- /*
- * v < 2^52, so add 2^52, then subtract 2^52, but do it all
- * with rounding set towards zero. We leave any enabled
- * traps enabled, but change the rounding mode. This might
- * not be so good. Oh well....
- */
- st %fsr, [%fp + SPOFF - 4] ! %l5 = current FSR mode
- set FSR_RD_MASK, %l3 ! %l3 = rounding direction mask
- ld [%fp + SPOFF - 4], %l5
- set FSR_RD_RD_Z, %l4
- andn %l5, %l3, %l6
- or %l6, %l4, %l6 ! round towards zero, please
- and %l5, %l3, %l5 ! save original rounding mode
- st %l6, [%fp + SPOFF - 8]
- ld [%fp + SPOFF - 8], %fsr
-
- faddd %f4, %f2, %f4 ! %f4:f5 += 2^52
- fsubd %f4, %f2, %f4 ! %f4:f5 -= 2^52
-
- /*
- * Restore %fsr, but leave exceptions accrued.
- */
- st %fsr, [%fp + SPOFF - 4]
- ld [%fp + SPOFF - 4], %l6
- andn %l6, %l3, %l6 ! %l6 = %fsr & ~FSR_RD_MASK;
- or %l5, %l6, %l5 ! %l5 |= %l6;
- st %l5, [%fp + SPOFF - 4]
- ld [%fp + SPOFF - 4], %fsr ! restore %fsr, leaving accrued stuff
-
- /*
- * Now insert the original sign in %f4:f5.
- * %fcc1 should still have the results of (val == abs(val))
- * from above, so we use a conditional move on %fcc1 to:
- *
- * %f4 = (val == abs(val)) ? %f4 : -%f4
- *
- */
- fnegd %f4, %f6
- fmovdnz %fcc1, %f6, %f4
-1:
-
- /*
- * The value in %f4:f5 is now the integer portion of the original
- * argument. We need to store this in *ival (%i1), subtract it
- * from the original value argument (%d0), and return the result.
- */
- std %f4, [%i1] ! *ival = %f4:f5;
- fsubd %f0, %f4, %f0 ! %f0:f1 -= %f4:f5;
- ret
- restore
-
-.Lbig:
- /*
- * We get here if the original comparison of %f4:f5 (v) to
- * %f2:f3 (2^52) came out `greater or unordered'. In this
- * case the integer part is the original value, and the
- * fractional part is 0.
- */
- SET(.L0, %l7, %l0)
- std %f0, [%i1] ! *ival = val;
- ldd [%l0], %f0 ! return 0.0;
- ret
- restore
-END(modf)
diff --git a/lib/libc/stdio/flags.c b/lib/libc/stdio/flags.c
index 729b4d5..0b6b075 100644
--- a/lib/libc/stdio/flags.c
+++ b/lib/libc/stdio/flags.c
@@ -80,11 +80,30 @@ __sflags(mode, optr)
return (0);
}
- /* [rwa]\+ or [rwa]b\+ means read and write */
- if (*mode == '+' || (*mode == 'b' && mode[1] == '+')) {
+ /* 'b' (binary) is ignored */
+ if (*mode == 'b')
+ mode++;
+
+ /* [rwa][b]\+ means read and write */
+ if (*mode == '+') {
+ mode++;
ret = __SRW;
m = O_RDWR;
}
+
+ /* 'b' (binary) can appear here, too -- and is ignored again */
+ if (*mode == 'b')
+ mode++;
+
+ /* 'x' means exclusive (fail if the file exists) */
+ if (*mode == 'x') {
+ if (m == O_RDONLY) {
+ errno = EINVAL;
+ return (0);
+ }
+ o |= O_EXCL;
+ }
+
*optr = m | o;
return (ret);
}
diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3
index 5c1f2b1..64d033e 100644
--- a/lib/libc/stdio/fopen.3
+++ b/lib/libc/stdio/fopen.3
@@ -32,7 +32,7 @@
.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd January 26, 2003
+.Dd October 17, 2011
.Dt FOPEN 3
.Os
.Sh NAME
@@ -60,45 +60,51 @@ and associates a stream with it.
.Pp
The argument
.Fa mode
-points to a string beginning with one of the following
-sequences (Additional characters may follow these sequences.):
+points to a string beginning with one of the following letters:
.Bl -tag -width indent
.It Dq Li r
-Open text file for reading.
-The stream is positioned at the beginning of the file.
-.It Dq Li r+
-Open for reading and writing.
+Open for reading.
The stream is positioned at the beginning of the file.
+Fail if the file does not exist.
.It Dq Li w
-Truncate to zero length or create text file for writing.
-The stream is positioned at the beginning of the file.
-.It Dq Li w+
-Open for reading and writing.
-The file is created if it does not exist, otherwise it is truncated.
+Open for writing.
The stream is positioned at the beginning of the file.
+Create the file if it does not exist.
.It Dq Li a
Open for writing.
-The file is created if it does not exist.
-The stream is positioned at the end of the file.
-Subsequent writes to the file will always end up at the then current
-end of file, irrespective of any intervening
-.Xr fseek 3
-or similar.
-.It Dq Li a+
-Open for reading and writing.
-The file is created if it does not exist.
The stream is positioned at the end of the file.
Subsequent writes to the file will always end up at the then current
end of file, irrespective of any intervening
.Xr fseek 3
or similar.
+Create the file if it does not exist.
.El
.Pp
+An optional
+.Dq Li +
+following
+.Dq Li r ,
+.Dq Li w ,
+or
+.Dq Li a
+opens the file for both reading and writing.
+An optional
+.Dq Li x
+following
+.Dq Li w
+or
+.Dq Li w+
+causes the
+.Fn fopen
+call to fail if the file already exists.
+.Pp
The
.Fa mode
-string can also include the letter ``b'' either as last character or
-as a character between the characters in any of the two-character strings
-described above.
+string can also include the letter
+.Dq Li b
+after either the
+.Dq Li +
+or the first letter.
This is strictly for compatibility with
.St -isoC
and has no effect; the ``b'' is ignored.
@@ -135,6 +141,9 @@ function associates a stream with the existing file descriptor,
.Fa fildes .
The mode
of the stream must be compatible with the mode of the file descriptor.
+The
+.Dq Li x
+mode option is ignored.
When the stream is closed via
.Xr fclose 3 ,
.Fa fildes
@@ -165,29 +174,12 @@ attempts to re-open the file associated with
with a new mode.
The new mode must be compatible with the mode that the stream was originally
opened with:
-.Bl -bullet -offset indent
-.It
-Streams originally opened with mode
-.Dq Li r
-can only be reopened with that same mode.
-.It
-Streams originally opened with mode
-.Dq Li a
-can be reopened with the same mode, or mode
-.Dq Li w .
-.It
-Streams originally opened with mode
-.Dq Li w
-can be reopened with the same mode, or mode
-.Dq Li a .
-.It
-Streams originally opened with mode
-.Dq Li r+ ,
-.Dq Li w+ ,
-or
-.Dq Li a+
-can be reopened with any mode.
-.El
+Streams open for reading can only be re-opened for reading,
+streams open for writing can only be re-opened for writing,
+and streams open for reading and writing can be re-opened in any mode.
+The
+.Dq Li x
+mode option is not meaningful in this context.
.Pp
The primary use of the
.Fn freopen
diff --git a/lib/libc/sys/ktrace.2 b/lib/libc/sys/ktrace.2
index aaf6192..8ab4a33 100644
--- a/lib/libc/sys/ktrace.2
+++ b/lib/libc/sys/ktrace.2
@@ -28,7 +28,7 @@
.\" @(#)ktrace.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd July 13, 2008
+.Dd October 10, 2011
.Dt KTRACE 2
.Os
.Sh NAME
@@ -67,9 +67,9 @@ The
argument specifies the requested ktrace operation.
The defined operations are:
.Bl -column KTRFLAG_DESCENDXXX -offset indent
-.It "KTROP_SET Enable trace points specified in"
+.It "KTROP_SET Enable trace points specified in"
.Fa trpoints .
-.It "KTROP_CLEAR Disable trace points specified in
+.It "KTROP_CLEAR Disable trace points specified in"
.Fa trpoints .
.It "KTROP_CLEARFILE Stop all tracing."
.It "KTRFLAG_DESCEND The tracing change should apply to the"
@@ -80,7 +80,7 @@ The
.Fa trpoints
argument specifies the trace points of interest.
The defined trace points are:
-.Bl -column KTRFAC_SYSCALLXXX -offset indent
+.Bl -column KTRFAC_PROCCTORXXX -offset indent
.It "KTRFAC_SYSCALL Trace system calls."
.It "KTRFAC_SYSRET Trace return values from system calls."
.It "KTRFAC_NAMEI Trace name lookup operations."
@@ -88,6 +88,12 @@ The defined trace points are:
generate much output).
.It "KTRFAC_PSIG Trace posted signals."
.It "KTRFAC_CSW Trace context switch points."
+.It "KTRFAC_USER Trace application-specific events."
+.It "KTRFAC_STRUCT Trace certain data structures."
+.It "KTRFAC_SYSCTL Trace sysctls."
+.It "KTRFAC_PROCCTOR Trace process construction."
+.It "KTRFAC_PROCDTOR Trace process destruction."
+.It "KTRFAC_CAPFAIL Trace capability failures."
.It "KTRFAC_INHERIT Inherit tracing to future children."
.El
.Pp
@@ -96,12 +102,12 @@ followed by a trace point specific structure.
The generic header is:
.Bd -literal
struct ktr_header {
- int ktr_len; /* length of buf */
- short ktr_type; /* trace record type */
- pid_t ktr_pid; /* process id */
- char ktr_comm[MAXCOMLEN+1]; /* command name */
- struct timeval ktr_time; /* timestamp */
- intptr_t ktr_tid; /* was ktr_buffer */
+ int ktr_len; /* length of buf */
+ short ktr_type; /* trace record type */
+ pid_t ktr_pid; /* process id */
+ char ktr_comm[MAXCOMLEN+1]; /* command name */
+ struct timeval ktr_time; /* timestamp */
+ intptr_t ktr_tid; /* was ktr_buffer */
};
.Ed
.Pp
diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2
index 1b23c9b..4359228 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 January 23, 2011
+.Dd October 5, 2011
.Dt PTRACE 2
.Os
.Sh NAME
@@ -599,11 +599,3 @@ The
.Fn ptrace
function appeared in
.At v7 .
-.Sh BUGS
-The
-.Dv PL_FLAG_FORKED ,
-.Dv PL_FLAG_SCE ,
-.Dv PL_FLAG_SCX
-and
-.Dv PL_FLAG_EXEC
-are not implemented for MIPS and ARM architectures.
diff --git a/lib/libc/sys/timer_create.2 b/lib/libc/sys/timer_create.2
index 3fb415c..316cea3 100644
--- a/lib/libc/sys/timer_create.2
+++ b/lib/libc/sys/timer_create.2
@@ -151,7 +151,7 @@ memory protection fault.
.Sh SEE ALSO
.Xr clock_getres 2 ,
.Xr timer_delete 2 ,
-.Xr timer_getoverun 2 ,
+.Xr timer_getoverrun 2 ,
.Xr siginfo 3
.Sh STANDARDS
The
diff --git a/lib/libelf/elf_update.3 b/lib/libelf/elf_update.3
index 7f6f4f0..8803730 100644
--- a/lib/libelf/elf_update.3
+++ b/lib/libelf/elf_update.3
@@ -66,7 +66,7 @@ responsibility for the layout of the ELF object.
If this flag is not set, the ELF library will compute the layout of the
file from its associated section descriptors.
.Pp
-It is the application's responsibility to manage the the following
+It is the application's responsibility to manage the following
structure members in the ELF file:
.Bl -tag -width indent
.It "Executable Header"
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index fefc4c5..0d5f2d6 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 1998-2011 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libfetch/common.h b/lib/libfetch/common.h
index 05bee03..35e0dfd 100644
--- a/lib/libfetch/common.h
+++ b/lib/libfetch/common.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 1998-2011 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3
index aaf1a8d..40d66bf 100644
--- a/lib/libfetch/fetch.3
+++ b/lib/libfetch/fetch.3
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
+.\" Copyright (c) 1998-2011 Dag-Erling Smørgrav
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 26, 2010
+.Dd September 27, 2011
.Dt FETCH 3
.Os
.Sh NAME
@@ -318,9 +318,19 @@ and
implement the FTP protocol as described in RFC959.
.Pp
If the
+.Ql P
+(not passive) flag is specified, an active (rather than passive)
+connection will be attempted.
+.Pp
+The
.Ql p
-(passive) flag is specified, a passive (rather than active) connection
-will be attempted.
+flag is supported for compatibility with earlier versions where active
+connections were the default.
+It has precedence over the
+.Ql P
+flag, so if both are specified,
+.Nm
+will use a passive connection.
.Pp
If the
.Ql l
@@ -475,9 +485,11 @@ connections will be bound.
.It Ev FTP_LOGIN
Default FTP login if none was provided in the URL.
.It Ev FTP_PASSIVE_MODE
-If set to anything but
+If set to
.Ql no ,
-forces the FTP code to use passive mode.
+forces the FTP code to use active mode.
+If set to any other value, forces passive mode even if the application
+requested active mode.
.It Ev FTP_PASSWORD
Default FTP password if the remote server requests one and none was
provided in the URL.
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index 5044fe3..f4c4a70 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 1998-2004 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libfetch/fetch.h b/lib/libfetch/fetch.h
index e620a01..be49482 100644
--- a/lib/libfetch/fetch.h
+++ b/lib/libfetch/fetch.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 1998-2004 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c
index dffaad8..8569ff3 100644
--- a/lib/libfetch/file.c
+++ b/lib/libfetch/file.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 1998-2011 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c
index 04ae07e..4e650b9 100644
--- a/lib/libfetch/ftp.c
+++ b/lib/libfetch/ftp.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 1998-2011 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
*
* Major Changelog:
*
- * Dag-Erling Coïdan Smørgrav
+ * Dag-Erling Smørgrav
* 9 Jun 1998
*
* Incorporated into libfetch
@@ -633,13 +633,12 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file,
/* check flags */
low = CHECK_FLAG('l');
- pasv = CHECK_FLAG('p');
+ pasv = CHECK_FLAG('p') || !CHECK_FLAG('P');
verbose = CHECK_FLAG('v');
/* passive mode */
- if (!pasv)
- pasv = ((s = getenv("FTP_PASSIVE_MODE")) != NULL &&
- strncasecmp(s, "no", 2) != 0);
+ if ((s = getenv("FTP_PASSIVE_MODE")) != NULL)
+ pasv = (strncasecmp(s, "no", 2) != 0);
/* isolate filename */
filename = ftp_filename(file, &filenamelen, &type);
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index 309cbf2..b33d6f1 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 2000-2011 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libftpio/Makefile b/lib/libftpio/Makefile
deleted file mode 100644
index 2082ec5..0000000
--- a/lib/libftpio/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# $FreeBSD$
-
-.include <bsd.own.mk>
-
-LIB= ftpio
-SHLIB_MAJOR= 8
-
-SRCS= ftpio.c ftperr.c
-INCS= ftpio.h
-CFLAGS+= -I${.CURDIR} -Wall
-MAN= ftpio.3
-CLEANFILES= ftperr.c
-
-.if ${MK_INET6_SUPPORT} != "no"
-CFLAGS+= -DINET6
-.endif
-
-WARNS?= 2
-
-ftperr.c: ftp.errors
- @echo '#include <stdio.h>' > ${.TARGET}
- @echo '#include "ftpio.h"' >> ${.TARGET}
- @echo "struct ftperr ftpErrList[] = {" \ >> ${.TARGET}
- @cat ${.ALLSRC} \
- | grep -v ^# \
- | sort \
- | while read NUM STRING; do \
- echo " { $${NUM}, \"$${STRING}\" },"; \
- done >> ${.TARGET}
- @echo "};" >> ${.TARGET}
- @echo -n "int const ftpErrListLength = " >> ${.TARGET}
- @echo "sizeof(ftpErrList) / sizeof(*ftpErrList);" >> ${.TARGET}
-
-.include <bsd.lib.mk>
diff --git a/lib/libftpio/ftp.errors b/lib/libftpio/ftp.errors
deleted file mode 100644
index c03eeac..0000000
--- a/lib/libftpio/ftp.errors
+++ /dev/null
@@ -1,45 +0,0 @@
-# $FreeBSD$
-#
-# This list is taken from RFC 959.
-# It probably needs a going over.
-#
-110 Restart marker reply
-120 Service ready in a few minutes
-125 Data connection already open; transfer starting
-150 File status okay; about to open data connection
-200 Command okay
-202 Command not implemented, superfluous at this site
-211 System status, or system help reply
-212 Directory status
-213 File status
-214 Help message
-215 Set system type
-220 Service ready for new user
-221 Service closing control connection
-225 Data connection open; no transfer in progress
-226 Requested file action successful
-227 Entering Passive Mode
-229 Entering Extended Passive Mode
-230 User logged in, proceed
-250 Requested file action okay, completed
-257 File/directory created
-331 User name okay, need password
-332 Need account for login
-350 Requested file action pending further information
-421 Service not available, closing control connection
-425 Can't open data connection
-426 Connection closed; transfer aborted
-450 File unavailable (e.g., file busy)
-451 Requested action aborted: local error in processing
-452 Insufficient storage space in system
-500 Syntax error, command unrecognized
-501 Syntax error in parameters or arguments
-502 Command not implemented
-503 Bad sequence of commands
-504 Command not implemented for that parameter
-530 Not logged in
-532 Need account for storing files
-550 File unavailable (e.g., file not found, no access)
-551 Requested action aborted. Page type unknown
-552 Exceeded storage allocation
-553 File name not allowed
diff --git a/lib/libftpio/ftpio.3 b/lib/libftpio/ftpio.3
deleted file mode 100644
index 73a1072..0000000
--- a/lib/libftpio/ftpio.3
+++ /dev/null
@@ -1,260 +0,0 @@
-.\" Copyright (c) 1996 Jordan Hubbard <jkh@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 JORDAN HUBBARD ``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 17, 1996
-.Dt FTPIO 3
-.Os
-.Sh NAME
-.Nm ftpLogin ,
-.Nm ftpChdir ,
-.Nm ftpErrno ,
-.Nm ftpGetModtime ,
-.Nm ftpGetSize ,
-.Nm ftpGet ,
-.Nm ftpPut ,
-.Nm ftpBinary ,
-.Nm ftpPassive ,
-.Nm ftpVerbose ,
-.Nm ftpGetURL ,
-.Nm ftpPutURL ,
-.Nm ftpLoginAf ,
-.Nm ftpGetURLAf ,
-.Nm ftpPutURLAf
-.Nd FTPIO user library
-.Sh SYNOPSIS
-.In ftpio.h
-.Ft FILE *
-.Fn ftpLogin "char *host" "char *user" "char *passwd" "int ftp_port" "int verbose" "int *retcode"
-.Ft int
-.Fn ftpChdir "FILE *stream" "char *dirname"
-.Ft int
-.Fn ftpErrno "FILE *stream"
-.Ft const char *
-.Fn ftpErrString "int errno"
-.Ft time_t
-.Fn ftpGetModtime "FILE *stream" "char *file"
-.Ft off_t
-.Fn ftpGetSize "FILE *stream" "char *file"
-.Ft FILE *
-.Fn ftpGet "FILE *stream" "char *file" "off_t *seekto"
-.Ft FILE *
-.Fn ftpPut "FILE *stream" "char *file"
-.Ft int
-.Fn ftpAscii "FILE *stream"
-.Ft int
-.Fn ftpBinary "FILE *stream"
-.Ft int
-.Fn ftpPassive "FILE *stream" "int status"
-.Ft void
-.Fn ftpVerbose "FILE *stream" "int status"
-.Ft FILE *
-.Fn ftpGetURL "char *url" "char *user" "char *passwd" "int *retcode"
-.Ft FILE *
-.Fn ftpPutURL "char *url" "char *user" "char *passwd" "int *retcode"
-.Ft FILE *
-.Fn ftpLoginAf "char *host" "int af" "char *user" "char *passwd" "int ftp_port" "int verbose" "int *retcode"
-.Ft FILE *
-.Fn ftpGetURLAf "char *url" "int af" "char *user" "char *passwd" "int *retcode"
-.Ft FILE *
-.Fn ftpPutURLAf "char *url" "int af" "char *user" "char *passwd" "int *retcode"
-.Sh DESCRIPTION
-These functions implement a high-level library for managing FTP connections.
-.Pp
-The
-.Fn ftpLogin
-function attempts to log in using the supplied
-.Fa user ,
-.Fa passwd ,
-.Fa ftp_port
-(if passed as 0,
-.Fa ftp_port
-defaults to the standard ftp port of 21) and
-.Fa verbose
-fields.
-If it is successful, a
-standard stream descriptor is returned which should be passed to
-subsequent FTP operations.
-On failure, NULL is returned and
-.Fa retcode
-will have the error code returned by the foreign server.
-.Pp
-The
-.Fn ftpChdir
-function attempts to issue a server CD command to the directory named in
-.Fa dir .
-On success, zero is returned.
-On failure, the error code from the server.
-.Pp
-The
-.Fn ftpErrno
-function returns the server failure code for the last operation (useful for
-seeing more about what happened if you are familiar with FTP error codes).
-The
-.Fn ftpErrString
-function returns a human readable version of the supplied server failure code.
-.Pp
-The
-.Fn ftpGet
-function attempts to retrieve the file named by the
-.Fa file
-argument (which is assumed to be relative to the FTP server's current directory,
-see
-.Fn ftpChdir )
-and returns a new FILE* pointer for the file or NULL on failure.
-If
-.Fa seekto
-is non-NULL, the contents of the integer it points to will be used
-as a restart point for the file, that is to say that the stream
-returned will point
-.Fa *seekto
-bytes into the file gotten (this is handy for restarting failed
-transfers efficiently).
-If the seek operation fails, the value
-of
-.Fa *seekto
-will be zero'd.
-.Pp
-The
-.Fn ftpGetModtime
-function returns the last modification time of the file named by the
-.Fa file
-argument.
-If the file could not be opened or stat'd, 0 is returned.
-.Pp
-The
-.Fn ftpGetSize
-function returns the size in bytes of the file named by the
-.Fa file
-argument.
-If the file could not be opened or stat'd, -1 is returned.
-.Pp
-The
-.Fn ftpPut
-function attempts to create a new file named by the
-.Fa file
-argument (which is assumed to be relative to the FTP server's current directory,
-see
-.Fn ftpChdir )
-and returns a new
-.Fa stream
-pointer for the file or NULL on failure.
-.Pp
-The
-.Fn ftpAscii
-function sets
-.Tn ASCII
-mode for the current server connection named by
-.Fa stream .
-.Pp
-The
-.Fn ftpBinary
-function sets binary mode for the current server connection named by
-.Fa stream .
-.Pp
-The
-.Fn ftpPassive
-function sets passive mode (for firewalls) for the current server connection
-named by
-.Fa stream
-to boolean value
-.Fa status .
-.Pp
-The
-.Fn ftpVerbose
-function sets the verbosity mode for the current server connection named by
-.Fa stream
-to boolean value
-.Fa status .
-.Pp
-The
-.Fn ftpGetURL
-function attempts to retrieve the file named by the supplied
-.Fa URL
-and can be considered equivalent to the combined
-.Fn ftpLogin ,
-.Fn ftpChdir
-and
-.Fn ftpGet
-operations except that no server
-.Fa stream
-is ever returned - the connection to the server closes when
-the file has been completely read.
-Use the lower-level routines
-if multiple gets are required as it will be far more efficient.
-.Pp
-The
-.Fn ftpPutURL
-function attempts to create the file named by the supplied
-.Fa URL
-and can be considered equivalent to the combined
-.Fn ftpLogin ,
-.Fn ftpChdir
-and
-.Fn ftpPut
-operations except that no server stream is ever returned - the connection
-to the server closes when the file has been completely written.
-Use the
-lower-level routines if multiple puts are required as it will be far more
-efficient.
-.Pp
-The
-.Fn ftpLoginAf ,
-.Fn ftpGetURLAf ,
-.Fn ftpPutURLAf
-functions are same as
-.Fn ftpLogin ,
-.Fn ftpGetURL ,
-.Fn ftpPutURL
-except that they are able to specify address family
-.Fa af .
-.Sh ENVIRONMENT
-.Bl -tag -width FTP_PASSIVE_MODE -offset 3n
-.It Ev FTP_TIMEOUT
-Maximum time, in seconds, to wait for a response
-from the peer before aborting an
-.Tn FTP
-connection.
-.It Ev FTP_PASSIVE_MODE
-If defined, forces the use of passive mode, unless equal
-to ``NO'' or ``no'' in which case active mode is forced.
-If defined, the setting of this variable always overrides any calls to
-.Fn ftpPassive .
-.El
-.Sh HISTORY
-Started life as Poul-Henning Kamp's ftp driver for the system installation
-utility, later significantly mutated into a more general form as an
-extension of stdio by Jordan Hubbard.
-Also incorporates some ideas and
-extensions from Jean-Marc Zucconi.
-.Sh AUTHORS
-.An Jordan Hubbard ,
-.An Poul-Henning Kamp
-and
-.An Jean-Marc Zucconi
-.Sh BUGS
-I am sure you can get this thing's internal state machine confused if
-you really work at it, but so far it has proven itself pretty robust in
-all my tests.
diff --git a/lib/libftpio/ftpio.c b/lib/libftpio/ftpio.c
deleted file mode 100644
index a5c9343..0000000
--- a/lib/libftpio/ftpio.c
+++ /dev/null
@@ -1,1069 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * Major Changelog:
- *
- * Jordan K. Hubbard
- * 17 Jan 1996
- *
- * Turned inside out. Now returns xfers as new file ids, not as a special
- * `state' of FTP_t
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-
-#include <arpa/inet.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <ftpio.h>
-#include <netdb.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define SUCCESS 0
-#define FAILURE -1
-
-#ifndef TRUE
-#define TRUE (1)
-#define FALSE (0)
-#endif
-
-/* How to see by a given code whether or not the connection has timed out */
-#define FTP_TIMEOUT(code) (FtpTimedOut || code == FTP_TIMED_OUT)
-
-/* Internal routines - deal only with internal FTP_t type */
-static FTP_t ftp_new(void);
-static void check_passive(FILE *fp);
-static int ftp_read_method(void *n, char *buf, int nbytes);
-static int ftp_write_method(void *n, const char *buf, int nbytes);
-static int ftp_close_method(void *n);
-static int writes(int fd, char *s);
-static __inline char *get_a_line(FTP_t ftp);
-static int get_a_number(FTP_t ftp, char **q);
-static int botch(char *func, char *botch_state);
-static int cmd(FTP_t ftp, const char *fmt, ...);
-static int ftp_login_session(FTP_t ftp, char *host, int af, char *user, char *passwd, int port, int verbose);
-static int ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t *seekto);
-static int ftp_close(FTP_t ftp);
-static int get_url_info(char *url_in, char *host_ret, int *port_ret, char *name_ret);
-static void ftp_timeout(int sig);
-static void ftp_set_timeout(void);
-static void ftp_clear_timeout(void);
-static void ai_unmapped(struct addrinfo *);
-
-
-/* Global status variable - ick */
-int FtpTimedOut;
-
-/* FTP happy status codes */
-#define FTP_GENERALLY_HAPPY 200
-#define FTP_ASCII_HAPPY FTP_GENERALLY_HAPPY
-#define FTP_BINARY_HAPPY FTP_GENERALLY_HAPPY
-#define FTP_PORT_HAPPY FTP_GENERALLY_HAPPY
-#define FTP_HAPPY_COMMENT 220
-#define FTP_QUIT_HAPPY 221
-#define FTP_TRANSFER_HAPPY 226
-#define FTP_PASSIVE_HAPPY 227
-#define FTP_LPASSIVE_HAPPY 228
-#define FTP_EPASSIVE_HAPPY 229
-#define FTP_CHDIR_HAPPY 250
-
-/* FTP unhappy status codes */
-#define FTP_TIMED_OUT 421
-
-/*
- * XXX
- * gross! evil! bad! We really need an access primitive for cookie in stdio itself.
- * it's too convenient a hook to bury and it's already exported through funopen as it is, so...
- * XXX
- */
-#define fcookie(fp) ((fp)->_cookie)
-
-/* Placeholder in case we want to do any pre-init stuff at some point */
-int
-networkInit()
-{
- return SUCCESS; /* XXX dummy function for now XXX */
-}
-
-/* Check a return code with some lenience for back-dated garbage that might be in the buffer */
-static int
-check_code(FTP_t ftp, int var, int preferred)
-{
- ftp->error = 0;
- while (1) {
- if (var == preferred)
- return 0;
- else if (var == FTP_TRANSFER_HAPPY) /* last operation succeeded */
- var = get_a_number(ftp, NULL);
- else if (var == FTP_HAPPY_COMMENT) /* chit-chat */
- var = get_a_number(ftp, NULL);
- else if (var == FTP_GENERALLY_HAPPY) /* general success code */
- var = get_a_number(ftp, NULL);
- else {
- ftp->error = var;
- return 1;
- }
- }
-}
-
-int
-ftpAscii(FILE *fp)
-{
- FTP_t ftp = fcookie(fp);
- int i;
-
- if (!ftp->is_binary)
- return SUCCESS;
- i = cmd(ftp, "TYPE A");
- if (i < 0 || check_code(ftp, i, FTP_ASCII_HAPPY))
- return i;
- ftp->is_binary = FALSE;
- return SUCCESS;
-}
-
-int
-ftpBinary(FILE *fp)
-{
- FTP_t ftp = fcookie(fp);
- int i;
-
- if (ftp->is_binary)
- return SUCCESS;
- i = cmd(ftp, "TYPE I");
- if (i < 0 || check_code(ftp, i, FTP_BINARY_HAPPY))
- return i;
- ftp->is_binary = TRUE;
- return SUCCESS;
-}
-void
-ftpVerbose(FILE *fp, int status)
-{
- FTP_t ftp = fcookie(fp);
- ftp->is_verbose = status;
-}
-
-int
-ftpChdir(FILE *fp, char *dir)
-{
- int i;
- FTP_t ftp = fcookie(fp);
-
- i = cmd(ftp, "CWD %s", dir);
- if (i < 0 || check_code(ftp, i, FTP_CHDIR_HAPPY))
- return i;
- return SUCCESS;
-}
-
-int
-ftpErrno(FILE *fp)
-{
- FTP_t ftp = fcookie(fp);
- return ftp->error;
-}
-
-const char *
-ftpErrString(int error)
-{
- int k;
-
- if (error == -1)
- return("connection in wrong state");
- if (error < 100)
- /* XXX soon UNIX errnos will catch up with FTP protocol errnos */
- return strerror(error);
- for (k = 0; k < ftpErrListLength; k++)
- if (ftpErrList[k].num == error)
- return(ftpErrList[k].string);
- return("Unknown error");
-}
-
-off_t
-ftpGetSize(FILE *fp, char *name)
-{
- int i;
- char p[BUFSIZ], *cp, *ep;
- FTP_t ftp = fcookie(fp);
- off_t size;
-
- check_passive(fp);
- sprintf(p, "SIZE %s\r\n", name);
- if (ftp->is_verbose)
- fprintf(stderr, "Sending %s", p);
- if (writes(ftp->fd_ctrl, p))
- return (off_t)-1;
- i = get_a_number(ftp, &cp);
- if (check_code(ftp, i, 213))
- return (off_t)-1;
-
- errno = 0; /* to check for ERANGE */
- size = (off_t)strtoq(cp, &ep, 10);
- if (*ep != '\0' || errno == ERANGE)
- return (off_t)-1;
- return size;
-}
-
-time_t
-ftpGetModtime(FILE *fp, char *name)
-{
- char p[BUFSIZ], *cp;
- struct tm t;
- time_t t0 = time (0);
- FTP_t ftp = fcookie(fp);
- int i;
-
- check_passive(fp);
- sprintf(p, "MDTM %s\r\n", name);
- if (ftp->is_verbose)
- fprintf(stderr, "Sending %s", p);
- if (writes(ftp->fd_ctrl, p))
- return (time_t)0;
- i = get_a_number(ftp, &cp);
- if (check_code(ftp, i, 213))
- return (time_t)0;
- while (*cp && !isdigit(*cp))
- cp++;
- if (!*cp)
- return (time_t)0;
- t0 = localtime (&t0)->tm_gmtoff;
- sscanf(cp, "%04d%02d%02d%02d%02d%02d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec);
- t.tm_mon--;
- t.tm_year -= 1900;
- t.tm_isdst=-1;
- t.tm_gmtoff = 0;
- t0 += mktime (&t);
- return t0;
-}
-
-FILE *
-ftpGet(FILE *fp, char *file, off_t *seekto)
-{
- FILE *fp2;
- FTP_t ftp = fcookie(fp);
-
- check_passive(fp);
- if (ftpBinary(fp) != SUCCESS)
- return NULL;
-
- if (ftp_file_op(ftp, "RETR", file, &fp2, "r", seekto) == SUCCESS)
- return fp2;
- return NULL;
-}
-
-/* Returns a standard FILE pointer type representing an open control connection */
-FILE *
-ftpLogin(char *host, char *user, char *passwd, int port, int verbose, int *retcode)
-{
-#ifdef INET6
- return ftpLoginAf(host, AF_UNSPEC, user, passwd, port, verbose, retcode);
-#else
- return ftpLoginAf(host, AF_INET, user, passwd, port, verbose, retcode);
-#endif
-}
-
-FILE *
-ftpLoginAf(char *host, int af, char *user, char *passwd, int port, int verbose, int *retcode)
-{
- FTP_t n;
- FILE *fp;
-
- if (retcode)
- *retcode = 0;
- if (networkInit() != SUCCESS)
- return NULL;
-
- n = ftp_new();
- fp = NULL;
- if (n && ftp_login_session(n, host, af, user, passwd, port, verbose) == SUCCESS) {
- fp = funopen(n, ftp_read_method, ftp_write_method, NULL, ftp_close_method); /* BSD 4.4 function! */
- }
- if (retcode) {
- if (!n)
- *retcode = (FtpTimedOut ? FTP_TIMED_OUT : -1);
- /* Poor attempt at mapping real errnos to FTP error codes */
- else switch(n->error) {
- case EADDRNOTAVAIL:
- *retcode = FTP_TIMED_OUT; /* Actually no such host, but we have no way of saying that. :-( */
- break;
-
- case ETIMEDOUT:
- *retcode = FTP_TIMED_OUT;
- break;
-
- default:
- *retcode = n->error;
- break;
- }
- }
- return fp;
-}
-
-FILE *
-ftpPut(FILE *fp, char *file)
-{
- FILE *fp2;
- FTP_t ftp = fcookie(fp);
-
- check_passive(fp);
- if (ftp_file_op(ftp, "STOR", file, &fp2, "w", NULL) == SUCCESS)
- return fp2;
- return NULL;
-}
-
-int
-ftpPassive(FILE *fp, int st)
-{
- FTP_t ftp = fcookie(fp);
-
- ftp->is_passive = !!st; /* normalize "st" to zero or one */
- return SUCCESS;
-}
-
-FILE *
-ftpGetURL(char *url, char *user, char *passwd, int *retcode)
-{
-#ifdef INET6
- return ftpGetURLAf(url, AF_UNSPEC, user, passwd, retcode);
-#else
- return ftpGetURLAf(url, AF_INET, user, passwd, retcode);
-#endif
-}
-
-FILE *
-ftpGetURLAf(char *url, int af, char *user, char *passwd, int *retcode)
-{
- char host[255], name[255];
- int port;
- FILE *fp2;
- static FILE *fp = NULL;
- static char *prev_host;
-
- if (retcode)
- *retcode = 0;
- if (get_url_info(url, host, &port, name) == SUCCESS) {
- if (fp && prev_host) {
- if (!strcmp(prev_host, host)) {
- /* Try to use cached connection */
- fp2 = ftpGet(fp, name, NULL);
- if (!fp2) {
- /* Connection timed out or was no longer valid */
- fclose(fp);
- free(prev_host);
- prev_host = NULL;
- }
- else
- return fp2;
- }
- else {
- /* It's a different host now, flush old */
- fclose(fp);
- free(prev_host);
- prev_host = NULL;
- }
- }
- fp = ftpLoginAf(host, af, user, passwd, port, 0, retcode);
- if (fp) {
- fp2 = ftpGet(fp, name, NULL);
- if (!fp2) {
- /* Connection timed out or was no longer valid */
- if (retcode)
- *retcode = ftpErrno(fp);
- fclose(fp);
- fp = NULL;
- }
- else
- prev_host = strdup(host);
- return fp2;
- }
- }
- return NULL;
-}
-
-FILE *
-ftpPutURL(char *url, char *user, char *passwd, int *retcode)
-{
-#ifdef INET6
- return ftpPutURLAf(url, AF_UNSPEC, user, passwd, retcode);
-#else
- return ftpPutURLAf(url, AF_INET, user, passwd, retcode);
-#endif
-
-}
-
-FILE *
-ftpPutURLAf(char *url, int af, char *user, char *passwd, int *retcode)
-{
- char host[255], name[255];
- int port;
- static FILE *fp = NULL;
- FILE *fp2;
-
- if (retcode)
- *retcode = 0;
- if (fp) { /* Close previous managed connection */
- fclose(fp);
- fp = NULL;
- }
- if (get_url_info(url, host, &port, name) == SUCCESS) {
- fp = ftpLoginAf(host, af, user, passwd, port, 0, retcode);
- if (fp) {
- fp2 = ftpPut(fp, name);
- if (!fp2) {
- if (retcode)
- *retcode = ftpErrno(fp);
- fclose(fp);
- fp = NULL;
- }
- return fp2;
- }
- }
- return NULL;
-}
-
-/* Internal workhorse function for dissecting URLs. Takes a URL as the first argument and returns the
- result of such disection in the host, user, passwd, port and name variables. */
-static int
-get_url_info(char *url_in, char *host_ret, int *port_ret, char *name_ret)
-{
- char *name, *host, *cp, url[BUFSIZ];
- int port;
-
- name = host = NULL;
- /* XXX add http:// here or somewhere reasonable at some point XXX */
- if (strncmp("ftp://", url_in, 6) != 0)
- return FAILURE;
- /* We like to stomp a lot on the URL string in dissecting it, so copy it first */
- strncpy(url, url_in, BUFSIZ);
- host = url + 6;
- if ((cp = index(host, ':')) != NULL) {
- *(cp++) = '\0';
- port = strtol(cp, 0, 0);
- }
- else
- port = 0; /* use default */
- if (port_ret)
- *port_ret = port;
-
- if ((name = index(cp ? cp : host, '/')) != NULL)
- *(name++) = '\0';
- if (host_ret)
- strcpy(host_ret, host);
- if (name && name_ret)
- strcpy(name_ret, name);
- return SUCCESS;
-}
-
-static FTP_t
-ftp_new(void)
-{
- FTP_t ftp;
-
- ftp = (FTP_t)malloc(sizeof *ftp);
- if (!ftp)
- return NULL;
- memset(ftp, 0, sizeof *ftp);
- ftp->fd_ctrl = -1;
- ftp->con_state = init;
- ftp->is_binary = FALSE;
- ftp->is_passive = FALSE;
- ftp->is_verbose = FALSE;
- ftp->error = 0;
- return ftp;
-}
-
-static int
-ftp_read_method(void *vp, char *buf, int nbytes)
-{
- int i, fd;
- FTP_t n = (FTP_t)vp;
-
- fd = n->fd_ctrl;
- i = (fd >= 0) ? read(fd, buf, nbytes) : EOF;
- return i;
-}
-
-static int
-ftp_write_method(void *vp, const char *buf, int nbytes)
-{
- int i, fd;
- FTP_t n = (FTP_t)vp;
-
- fd = n->fd_ctrl;
- i = (fd >= 0) ? write(fd, buf, nbytes) : EOF;
- return i;
-}
-
-static int
-ftp_close_method(void *n)
-{
- int i;
-
- i = ftp_close((FTP_t)n);
- free(n);
- return i;
-}
-
-/*
- * This function checks whether the FTP_PASSIVE_MODE environment
- * variable is set, and, if so, enforces the desired mode.
- */
-static void
-check_passive(FILE *fp)
-{
- const char *cp = getenv("FTP_PASSIVE_MODE");
-
- if (cp != NULL)
- ftpPassive(fp, strncasecmp(cp, "no", 2));
-}
-
-static void
-ftp_timeout(int sig)
-{
- FtpTimedOut = TRUE;
- /* Debug("ftp_pkg: ftp_timeout called - operation timed out"); */
-}
-
-static void
-ftp_set_timeout(void)
-{
- struct sigaction new;
- char *cp;
- int ival;
-
- FtpTimedOut = FALSE;
- sigemptyset(&new.sa_mask);
- new.sa_flags = 0;
- new.sa_handler = ftp_timeout;
- sigaction(SIGALRM, &new, NULL);
- cp = getenv("FTP_TIMEOUT");
- if (!cp || !(ival = atoi(cp)))
- ival = 120;
- alarm(ival);
-}
-
-static void
-ftp_clear_timeout(void)
-{
- struct sigaction new;
-
- alarm(0);
- sigemptyset(&new.sa_mask);
- new.sa_flags = 0;
- new.sa_handler = SIG_DFL;
- sigaction(SIGALRM, &new, NULL);
-}
-
-static int
-writes(int fd, char *s)
-{
- int n, i = strlen(s);
-
- ftp_set_timeout();
- n = write(fd, s, i);
- ftp_clear_timeout();
- if (FtpTimedOut || i != n)
- return TRUE;
- return FALSE;
-}
-
-static __inline char *
-get_a_line(FTP_t ftp)
-{
- static char buf[BUFSIZ];
- int i,j;
-
- /* Debug("ftp_pkg: trying to read a line from %d", ftp->fd_ctrl); */
- for(i = 0; i < BUFSIZ;) {
- ftp_set_timeout();
- j = read(ftp->fd_ctrl, buf + i, 1);
- ftp_clear_timeout();
- if (FtpTimedOut || j != 1)
- return NULL;
- if (buf[i] == '\r' || buf[i] == '\n') {
- if (!i)
- continue;
- buf[i] = '\0';
- if (ftp->is_verbose == TRUE)
- fprintf(stderr, "%s\n",buf+4);
- return buf;
- }
- i++;
- }
- /* Debug("ftp_pkg: read string \"%s\" from %d", buf, ftp->fd_ctrl); */
- return buf;
-}
-
-static int
-get_a_number(FTP_t ftp, char **q)
-{
- char *p;
- int i = -1, j;
-
- while(1) {
- p = get_a_line(ftp);
- if (!p) {
- ftp_close(ftp);
- if (FtpTimedOut)
- return FTP_TIMED_OUT;
- return FAILURE;
- }
- if (!(isdigit(p[0]) && isdigit(p[1]) && isdigit(p[2])))
- continue;
- if (i == -1 && p[3] == '-') {
- i = strtol(p, 0, 0);
- continue;
- }
- if (p[3] != ' ' && p[3] != '\t')
- continue;
- j = strtol(p, 0, 0);
- if (i == -1) {
- if (q) *q = p+4;
- /* Debug("ftp_pkg: read reply %d from server (%s)", j, p); */
- return j;
- } else if (j == i) {
- if (q) *q = p+4;
- /* Debug("ftp_pkg: read reply %d from server (%s)", j, p); */
- return j;
- }
- }
-}
-
-static int
-ftp_close(FTP_t ftp)
-{
- int i, rcode;
-
- rcode = FAILURE;
- if (ftp->con_state == isopen) {
- ftp->con_state = quit;
- /* If last operation timed out, don't try to quit - just close */
- if (ftp->error != FTP_TIMED_OUT)
- i = cmd(ftp, "QUIT");
- else
- i = FTP_QUIT_HAPPY;
- if (!check_code(ftp, i, FTP_QUIT_HAPPY))
- rcode = SUCCESS;
- close(ftp->fd_ctrl);
- ftp->fd_ctrl = -1;
- }
- else if (ftp->con_state == quit)
- rcode = SUCCESS;
- return rcode;
-}
-
-static int
-botch(char *func, char *botch_state)
-{
- /* Debug("ftp_pkg: botch: %s(%s)", func, botch_state); */
- return FAILURE;
-}
-
-static int
-cmd(FTP_t ftp, const char *fmt, ...)
-{
- char p[BUFSIZ];
- int i;
-
- va_list ap;
- va_start(ap, fmt);
- (void)vsnprintf(p, sizeof p, fmt, ap);
- va_end(ap);
-
- if (ftp->con_state == init)
- return botch("cmd", "open");
-
- strcat(p, "\r\n");
- if (ftp->is_verbose)
- fprintf(stderr, "Sending: %s", p);
- if (writes(ftp->fd_ctrl, p)) {
- if (FtpTimedOut)
- return FTP_TIMED_OUT;
- return FAILURE;
- }
- while ((i = get_a_number(ftp, NULL)) == FTP_HAPPY_COMMENT);
- return i;
-}
-
-static int
-ftp_login_session(FTP_t ftp, char *host, int af,
- char *user, char *passwd, int port, int verbose)
-{
- char pbuf[10];
- struct addrinfo hints, *res, *res0;
- int err;
- int s;
- int i;
-
- if (networkInit() != SUCCESS)
- return FAILURE;
-
- if (ftp->con_state != init) {
- ftp_close(ftp);
- ftp->error = -1;
- return FAILURE;
- }
-
- if (!user)
- user = "ftp";
-
- if (!passwd)
- passwd = "setup@";
-
- if (!port)
- port = 21;
-
- snprintf(pbuf, sizeof(pbuf), "%d", port);
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = af;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = 0;
- err = getaddrinfo(host, pbuf, &hints, &res0);
- if (err) {
- ftp->error = 0;
- return FAILURE;
- }
-
- s = -1;
- for (res = res0; res; res = res->ai_next) {
- ai_unmapped(res);
- ftp->addrtype = res->ai_family;
-
- if ((s = socket(res->ai_family, res->ai_socktype,
- res->ai_protocol)) < 0)
- continue;
-
- if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
- (void)close(s);
- s = -1;
- continue;
- }
-
- break;
- }
- freeaddrinfo(res0);
- if (s < 0) {
- ftp->error = errno;
- return FAILURE;
- }
-
- ftp->fd_ctrl = s;
- ftp->con_state = isopen;
- ftp->is_verbose = verbose;
-
- i = cmd(ftp, "USER %s", user);
- if (i >= 300 && i < 400)
- i = cmd(ftp, "PASS %s", passwd);
- if (i >= 299 || i < 0) {
- ftp_close(ftp);
- if (i > 0)
- ftp->error = i;
- return FAILURE;
- }
- return SUCCESS;
-}
-
-static int
-ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t *seekto)
-{
- socklen_t sinlen;
- int i,l,s;
- char *q;
- unsigned char addr[64];
- union sockaddr_cmn {
- struct sockaddr_in sin4;
- struct sockaddr_in6 sin6;
- } sin;
- char *cmdstr;
-
- if (!fp)
- return FAILURE;
- *fp = NULL;
-
- if (ftp->con_state != isopen)
- return botch("ftp_file_op", "open");
-
- if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0) {
- ftp->error = errno;
- return FAILURE;
- }
-
- if (ftp->is_passive) {
- if (ftp->addrtype == AF_INET) {
- if (ftp->is_verbose)
- fprintf(stderr, "Sending PASV\n");
- if (writes(ftp->fd_ctrl, "PASV\r\n")) {
- ftp_close(ftp);
- if (FtpTimedOut)
- ftp->error = FTP_TIMED_OUT;
- return FTP_TIMED_OUT;
- }
- i = get_a_number(ftp, &q);
- if (check_code(ftp, i, FTP_PASSIVE_HAPPY)) {
- ftp_close(ftp);
- return i;
- }
- cmdstr = "PASV";
- } else {
- if (ftp->is_verbose)
- fprintf(stderr, "Sending EPSV\n");
- if (writes(ftp->fd_ctrl, "EPSV\r\n")) {
- ftp_close(ftp);
- if (FtpTimedOut)
- ftp->error = FTP_TIMED_OUT;
- return FTP_TIMED_OUT;
- }
- i = get_a_number(ftp, &q);
- if (check_code(ftp, i, FTP_EPASSIVE_HAPPY)) {
- if (ftp->is_verbose)
- fprintf(stderr, "Sending LPSV\n");
- if (writes(ftp->fd_ctrl, "LPSV\r\n")) {
- ftp_close(ftp);
- if (FtpTimedOut)
- ftp->error = FTP_TIMED_OUT;
- return FTP_TIMED_OUT;
- }
- i = get_a_number(ftp, &q);
- if (check_code(ftp, i, FTP_LPASSIVE_HAPPY)) {
- ftp_close(ftp);
- return i;
- }
- cmdstr = "LPSV";
- } else
- cmdstr = "EPSV";
- }
- if (strcmp(cmdstr, "PASV") == 0 || strcmp(cmdstr, "LPSV") == 0) {
- while (*q && !isdigit(*q))
- q++;
- if (!*q) {
- ftp_close(ftp);
- return FAILURE;
- }
- q--;
- l = (ftp->addrtype == AF_INET ? 6 : 21);
- for (i = 0; i < l; i++) {
- q++;
- addr[i] = strtol(q, &q, 10);
- }
-
- sin.sin4.sin_family = ftp->addrtype;
- if (ftp->addrtype == AF_INET6) {
- sin.sin6.sin6_len = sizeof(struct sockaddr_in6);
- bcopy(addr + 2, (char *)&sin.sin6.sin6_addr, 16);
- bcopy(addr + 19, (char *)&sin.sin6.sin6_port, 2);
- } else {
- sin.sin4.sin_len = sizeof(struct sockaddr_in);
- bcopy(addr, (char *)&sin.sin4.sin_addr, 4);
- bcopy(addr + 4, (char *)&sin.sin4.sin_port, 2);
- }
- } else if (strcmp(cmdstr, "EPSV") == 0) {
- int port;
- while (*q && *q != '(') /* ) */
- q++;
- if (!*q) {
- ftp_close(ftp);
- return FAILURE;
- }
- q++;
- if (sscanf(q, "%c%c%c%d%c", &addr[0], &addr[1], &addr[2],
- &port, &addr[3]) != 5
- || addr[0] != addr[1] || addr[0] != addr[2] || addr[0] != addr[3]) {
- ftp_close(ftp);
- return FAILURE;
- }
- sinlen = sizeof(sin);
- if (getpeername(ftp->fd_ctrl, (struct sockaddr *)&sin, &sinlen) < 0) {
- ftp_close(ftp);
- return FAILURE;
- }
- switch (sin.sin4.sin_family) {
- case AF_INET:
- sin.sin4.sin_port = htons(port);
- break;
- case AF_INET6:
- sin.sin6.sin6_port = htons(port);
- break;
- default:
- ftp_close(ftp);
- return FAILURE;
- }
- }
-
- if (connect(s, (struct sockaddr *)&sin, sin.sin4.sin_len) < 0) {
- (void)close(s);
- return FAILURE;
- }
-
- if (seekto && *seekto) {
- i = cmd(ftp, "REST %d", *seekto);
- if (i < 0 || FTP_TIMEOUT(i)) {
- close(s);
- ftp->error = i;
- *seekto = (off_t)0;
- return i;
- }
- }
- i = cmd(ftp, "%s %s", operation, file);
- if (i < 0 || i > 299) {
- close(s);
- ftp->error = i;
- return i;
- }
- *fp = fdopen(s, mode);
- }
- else {
- int fd,portrange;
-
-#ifdef IPV6_PORTRANGE
- if (ftp->addrtype == AF_INET6) {
- portrange = IPV6_PORTRANGE_HIGH;
- if (setsockopt(s, IPPROTO_IPV6, IPV6_PORTRANGE, (char *)
- &portrange, sizeof(portrange)) < 0) {
- close(s);
- return FAILURE;
- }
- }
-#endif
-#ifdef IP_PORTRANGE
- if (ftp->addrtype == AF_INET) {
- portrange = IP_PORTRANGE_HIGH;
- if (setsockopt(s, IPPROTO_IP, IP_PORTRANGE, (char *)
- &portrange, sizeof(portrange)) < 0) {
- close(s);
- return FAILURE;
- }
- }
-#endif
-
- sinlen = sizeof sin;
- getsockname(ftp->fd_ctrl, (struct sockaddr *)&sin, &sinlen);
- sin.sin4.sin_port = 0;
- i = ((struct sockaddr *)&sin)->sa_len;
- if (bind(s, (struct sockaddr *)&sin, i) < 0) {
- close(s);
- return FAILURE;
- }
- sinlen = sizeof sin;
- getsockname(s, (struct sockaddr *)&sin, &sinlen);
- if (listen(s, 1) < 0) {
- close(s);
- return FAILURE;
- }
- if (sin.sin4.sin_family == AF_INET) {
- u_long a;
- a = ntohl(sin.sin4.sin_addr.s_addr);
- i = cmd(ftp, "PORT %d,%d,%d,%d,%d,%d",
- (a >> 24) & 0xff,
- (a >> 16) & 0xff,
- (a >> 8) & 0xff,
- a & 0xff,
- (ntohs(sin.sin4.sin_port) >> 8) & 0xff,
- ntohs(sin.sin4.sin_port) & 0xff);
- if (check_code(ftp, i, FTP_PORT_HAPPY)) {
- close(s);
- return i;
- }
- } else {
-#define UC(b) (((int)b)&0xff)
- char *a;
- char hname[INET6_ADDRSTRLEN];
-
- sin.sin6.sin6_scope_id = 0;
- if (getnameinfo((struct sockaddr *)&sin, sin.sin6.sin6_len,
- hname, sizeof(hname),
- NULL, 0, NI_NUMERICHOST) != 0) {
- goto try_lprt;
- }
- i = cmd(ftp, "EPRT |%d|%s|%d|", 2, hname,
- htons(sin.sin6.sin6_port));
- if (check_code(ftp, i, FTP_PORT_HAPPY)) {
-try_lprt:
- a = (char *)&sin.sin6.sin6_addr;
- i = cmd(ftp,
-"LPRT %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
- 6, 16,
- UC(a[0]),UC(a[1]),UC(a[2]),UC(a[3]),
- UC(a[4]),UC(a[5]),UC(a[6]),UC(a[7]),
- UC(a[8]),UC(a[9]),UC(a[10]),UC(a[11]),
- UC(a[12]),UC(a[13]),UC(a[14]),UC(a[15]),
- 2,
- (ntohs(sin.sin4.sin_port) >> 8) & 0xff,
- ntohs(sin.sin4.sin_port) & 0xff);
- if (check_code(ftp, i, FTP_PORT_HAPPY)) {
- close(s);
- return i;
- }
- }
- }
- if (seekto && *seekto) {
- i = cmd(ftp, "REST %d", *seekto);
- if (i < 0 || FTP_TIMEOUT(i)) {
- close(s);
- ftp->error = i;
- return i;
- }
- else if (i != 350)
- *seekto = (off_t)0;
- }
- i = cmd(ftp, "%s %s", operation, file);
- if (i < 0 || i > 299) {
- close(s);
- ftp->error = i;
- return FAILURE;
- }
- fd = accept(s, 0, 0);
- if (fd < 0) {
- close(s);
- ftp->error = 401;
- return FAILURE;
- }
- close(s);
- *fp = fdopen(fd, mode);
- }
- if (*fp)
- return SUCCESS;
- else
- return FAILURE;
-}
-
-static void
-ai_unmapped(struct addrinfo *ai)
-{
- struct sockaddr_in6 *sin6;
- struct sockaddr_in sin;
-
- if (ai->ai_family != AF_INET6)
- return;
- if (ai->ai_addrlen != sizeof(struct sockaddr_in6) ||
- sizeof(sin) > ai->ai_addrlen)
- return;
- sin6 = (struct sockaddr_in6 *)ai->ai_addr;
- if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
- return;
-
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_len = sizeof(struct sockaddr_in);
- memcpy(&sin.sin_addr, &sin6->sin6_addr.s6_addr[12],
- sizeof(sin.sin_addr));
- sin.sin_port = sin6->sin6_port;
-
- ai->ai_family = AF_INET;
- memcpy(ai->ai_addr, &sin, sin.sin_len);
- ai->ai_addrlen = sin.sin_len;
-}
diff --git a/lib/libftpio/ftpio.h b/lib/libftpio/ftpio.h
deleted file mode 100644
index 879abea..0000000
--- a/lib/libftpio/ftpio.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef _FTP_H_INCLUDE
-#define _FTP_H_INCLUDE
-
-#include <sys/types.h>
-#include <sys/cdefs.h>
-#include <stdio.h>
-#include <time.h>
-
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * Major Changelog:
- *
- * Jordan K. Hubbard
- * 17 Jan 1996
- *
- * Turned inside out. Now returns xfers as new file ids, not as a special
- * `state' of FTP_t
- *
- * $FreeBSD$
- */
-
-/* Internal housekeeping data structure for FTP sessions */
-typedef struct {
- enum { init, isopen, quit } con_state;
- int fd_ctrl;
- int addrtype;
- char *host;
- char *file;
- int error;
- int is_binary;
- int is_passive;
- int is_verbose;
-} *FTP_t;
-
-/* Structure we use to match FTP error codes with readable strings */
-struct ftperr {
- const int num;
- const char *string;
-};
-
-__BEGIN_DECLS
-extern struct ftperr ftpErrList[];
-extern int const ftpErrListLength;
-
-/* Exported routines - deal only with FILE* type */
-extern FILE *ftpLogin(char *host, char *user, char *passwd, int port, int verbose, int *retcode);
-extern int ftpChdir(FILE *fp, char *dir);
-extern int ftpErrno(FILE *fp);
-extern off_t ftpGetSize(FILE *fp, char *file);
-extern FILE *ftpGet(FILE *fp, char *file, off_t *seekto);
-extern FILE *ftpPut(FILE *fp, char *file);
-extern int ftpAscii(FILE *fp);
-extern int ftpBinary(FILE *fp);
-extern int ftpPassive(FILE *fp, int status);
-extern void ftpVerbose(FILE *fp, int status);
-extern FILE *ftpGetURL(char *url, char *user, char *passwd, int *retcode);
-extern FILE *ftpPutURL(char *url, char *user, char *passwd, int *retcode);
-extern time_t ftpGetModtime(FILE *fp, char *s);
-extern const char *ftpErrString(int error);
-extern FILE *ftpLoginAf(char *host, int af, char *user, char *passwd, int port, int verbose, int *retcode);
-extern FILE *ftpGetURLAf(char *url, int af, char *user, char *passwd, int *retcode);
-extern FILE *ftpPutURLAf(char *url, int af, char *user, char *passwd, int *retcode);
-__END_DECLS
-
-#endif /* _FTP_H_INCLUDE */
diff --git a/lib/libgssapi/Symbol.map b/lib/libgssapi/Symbol.map
index 6df8f0c..717f1b9 100644
--- a/lib/libgssapi/Symbol.map
+++ b/lib/libgssapi/Symbol.map
@@ -1,6 +1,6 @@
/*
* $FreeBSD$
- */
+ */
FBSD_1.1 {
GSS_C_NT_ANONYMOUS;
diff --git a/lib/libipsec/ipsec_strerror.3 b/lib/libipsec/ipsec_strerror.3
index 73fe68d..45e1113 100644
--- a/lib/libipsec/ipsec_strerror.3
+++ b/lib/libipsec/ipsec_strerror.3
@@ -63,7 +63,7 @@ as an underlying function, calling
.Xr strerror 3
after
.Fn ipsec_strerror
-would overwrite the the return value from
+would overwrite the return value from
.Fn ipsec_strerror
and make it invalid.
.\"
diff --git a/lib/libmp/Symbol.map b/lib/libmp/Symbol.map
index 0bd8684..df04098 100644
--- a/lib/libmp/Symbol.map
+++ b/lib/libmp/Symbol.map
@@ -1,6 +1,6 @@
/*
* $FreeBSD$
- */
+ */
FBSD_1.1 {
mp_gcd;
diff --git a/lib/libncp/ncpl_bind.c b/lib/libncp/ncpl_bind.c
index d7c64ed..d00cfa8 100644
--- a/lib/libncp/ncpl_bind.c
+++ b/lib/libncp/ncpl_bind.c
@@ -85,7 +85,7 @@ ncp_read_property_value(NWCONN_HANDLE connid, int object_type,
int
ncp_scan_bindery_object(NWCONN_HANDLE connid, u_int32_t last_id,
- u_int16_t object_type, char *search_string,
+ u_int16_t object_type, const char *search_string,
struct ncp_bindery_object *target)
{
int error;
diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile
index 8b07458..12cd96a 100644
--- a/lib/libpam/libpam/Makefile
+++ b/lib/libpam/libpam/Makefile
@@ -148,7 +148,15 @@ HEADERS= security/openpam.h \
ADD_HEADERS= security/pam_mod_misc.h
+#
# Static modules
+#
+# We build static versions of all modules and of openpam_static.o,
+# then link them all together into openpam_static_modules.o. None of
+# the modules export any symbols, but they store structures with
+# pointers to their service functions in a linker set which the code
+# in openpam_static.c traverses to locate the individual modules.
+#
MODULE_DIR= ../modules
.include "${.CURDIR}/${MODULE_DIR}/modules.inc"
STATIC_MODULES= ${MODULES:C/.*/${MODULE_DIR}\/&\/lib&.a/}
@@ -159,7 +167,8 @@ CLEANFILES+= openpam_static.o \
openpam_static_modules.o: openpam_static.o ${STATIC_MODULES}
${LD} -o ${.TARGET} -r --whole-archive ${.ALLSRC}
-# Can't put openpam_static.c in SRCS but want .o in .depend.
+# We can't put openpam_static.c in SRCS, but we still want to scan it
+# for dependencies.
DPSRCS= openpam_static.c
# Headers
diff --git a/lib/libpam/modules/pam_ssh/pam_ssh.8 b/lib/libpam/modules/pam_ssh/pam_ssh.8
index 07e3176..ea41455 100644
--- a/lib/libpam/modules/pam_ssh/pam_ssh.8
+++ b/lib/libpam/modules/pam_ssh/pam_ssh.8
@@ -1,6 +1,6 @@
.\" Copyright (c) 2001 Mark R V Murray
-.\" All rights reserved.
.\" Copyright (c) 2001-2003 Networks Associates Technology, Inc.
+.\" Copyright (c) 2004-2011 Dag-Erling Smørgrav
.\" All rights reserved.
.\"
.\" This software was developed for the FreeBSD Project by ThinkSec AS and
@@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 26, 2001
+.Dd October 7, 2011
.Dt PAM_SSH 8
.Os
.Sh NAME
@@ -135,6 +135,8 @@ SSH1 RSA key
SSH2 RSA key
.It Pa $HOME/.ssh/id_dsa
SSH2 DSA key
+.It Pa $HOME/.ssh/id_ecdsa
+SSH2 ECDSA key
.El
.Sh SEE ALSO
.Xr ssh-agent 1 ,
diff --git a/lib/libpam/modules/pam_ssh/pam_ssh.c b/lib/libpam/modules/pam_ssh/pam_ssh.c
index bec9892..bc5f522 100644
--- a/lib/libpam/modules/pam_ssh/pam_ssh.c
+++ b/lib/libpam/modules/pam_ssh/pam_ssh.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003 Networks Associates Technology, Inc.
+ * Copyright (c) 2004-2011 Dag-Erling Smørgrav
* All rights reserved.
*
* This software was developed for the FreeBSD Project by ThinkSec AS and
@@ -78,6 +79,7 @@ static const char *pam_ssh_keyfiles[] = {
".ssh/identity", /* SSH1 RSA key */
".ssh/id_rsa", /* SSH2 RSA key */
".ssh/id_dsa", /* SSH2 DSA key */
+ ".ssh/id_ecdsa", /* SSH2 ECDSA key */
NULL
};
@@ -324,6 +326,7 @@ pam_ssh_add_keys_to_agent(pam_handle_t *pamh)
/* get a connection to the agent */
if ((ac = ssh_get_authentication_connection()) == NULL) {
+ openpam_log(PAM_LOG_DEBUG, "failed to connect to the agent");
pam_err = PAM_SYSTEM_ERR;
goto end;
}
diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index 1d86a82..f0d5b0c 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -2596,6 +2596,12 @@ pmc_flush_logfile(void)
}
int
+pmc_close_logfile(void)
+{
+ return (PMC_CALL(CLOSELOG,0));
+}
+
+int
pmc_get_driver_stats(struct pmc_driverstats *ds)
{
struct pmc_op_getdriverstats gms;
diff --git a/lib/libpmc/pmc.3 b/lib/libpmc/pmc.3
index 2403e64..2431080 100644
--- a/lib/libpmc/pmc.3
+++ b/lib/libpmc/pmc.3
@@ -322,6 +322,10 @@ to write logged events to.
Flush all pending log data in
.Xr hwpmc 4 Ns Ap s
buffers.
+.It Fn pmc_close_logfile
+Flush all pending log data and close
+.Xr hwpmc 4 Ns Ap s
+side of the stream.
.It Fn pmc_writelog
Append arbitrary user data to the current log file.
.El
diff --git a/lib/libpmc/pmc.core.3 b/lib/libpmc/pmc.core.3
index d32e62a..db4c769 100644
--- a/lib/libpmc/pmc.core.3
+++ b/lib/libpmc/pmc.core.3
@@ -459,7 +459,7 @@ The number of instruction fetch misses in the instruction cache and
streaming buffers.
.It Li ICache_Reads
.Pq Event 80H , Umask 00H
-The number of instruction fetches from the the instruction cache and
+The number of instruction fetches from the instruction cache and
streaming buffers counting both cacheable and un-cacheable fetches.
.It Li IFU_Mem_Stall
.Pq Event 86H , Umask 00H
diff --git a/lib/libpmc/pmc.h b/lib/libpmc/pmc.h
index 5b1ad07..2be88b1 100644
--- a/lib/libpmc/pmc.h
+++ b/lib/libpmc/pmc.h
@@ -76,6 +76,7 @@ int pmc_attach(pmc_id_t _pmcid, pid_t _pid);
int pmc_capabilities(pmc_id_t _pmc, uint32_t *_caps);
int pmc_configure_logfile(int _fd);
int pmc_flush_logfile(void);
+int pmc_close_logfile(void);
int pmc_detach(pmc_id_t _pmcid, pid_t _pid);
int pmc_disable(int _cpu, int _pmc);
int pmc_enable(int _cpu, int _pmc);
diff --git a/lib/libpmc/pmc_configure_logfile.3 b/lib/libpmc/pmc_configure_logfile.3
index a33688c..399f21a 100644
--- a/lib/libpmc/pmc_configure_logfile.3
+++ b/lib/libpmc/pmc_configure_logfile.3
@@ -29,7 +29,8 @@
.Sh NAME
.Nm pmc_configure_logfile ,
.Nm pmc_flush_logfile ,
-.Nm pmc_writelog
+.Nm pmc_writelog ,
+.Nm pmc_close_logfile
.Nd log file management
.Sh LIBRARY
.Lb libpmc
@@ -41,6 +42,8 @@
.Fn pmc_flush_logfile void
.Ft int
.Fn pmc_writelog "uint32_t userdata"
+.Ft int
+.Fn pmc_close_logfile void
.Sh DESCRIPTION
The functions manage logging of
.Xr hwpmc 4
@@ -72,6 +75,12 @@ Function
will append a log entry containing the value of argument
.Fa userdata
to the log file.
+.Pp
+Function
+.Fn pmc_close_logfile
+will flush all pending log data and close
+.Xr hwpmc 4 Ns Ap s
+side of the stream.
.Sh RETURN VALUES
.Rv -std
.Sh ERRORS
diff --git a/lib/libsdp/sdp.h b/lib/libsdp/sdp.h
index acb074a..35dbea7 100644
--- a/lib/libsdp/sdp.h
+++ b/lib/libsdp/sdp.h
@@ -312,13 +312,13 @@ typedef struct sdp_attr * sdp_attr_p;
/* Inline versions of get/put byte/short/long. Pointer is advanced */
#define SDP_GET8(b, cp) { \
- register uint8_t *t_cp = (uint8_t *)(cp); \
+ const uint8_t *t_cp = (const uint8_t *)(cp); \
(b) = *t_cp; \
(cp) ++; \
}
#define SDP_GET16(s, cp) { \
- register uint8_t *t_cp = (uint8_t *)(cp); \
+ const uint8_t *t_cp = (const uint8_t *)(cp); \
(s) = ((uint16_t)t_cp[0] << 8) \
| ((uint16_t)t_cp[1]) \
; \
@@ -326,7 +326,7 @@ typedef struct sdp_attr * sdp_attr_p;
}
#define SDP_GET32(l, cp) { \
- register uint8_t *t_cp = (uint8_t *)(cp); \
+ const uint8_t *t_cp = (const uint8_t *)(cp); \
(l) = ((uint32_t)t_cp[0] << 24) \
| ((uint32_t)t_cp[1] << 16) \
| ((uint32_t)t_cp[2] << 8) \
diff --git a/lib/libulog/Symbol.map b/lib/libulog/Symbol.map
index e0375ae..0abc40f 100644
--- a/lib/libulog/Symbol.map
+++ b/lib/libulog/Symbol.map
@@ -1,6 +1,6 @@
/*
* $FreeBSD$
- */
+ */
FBSD_1.2 {
ulog_login;
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
index c4396cc..b76618a 100644
--- a/lib/libusb/Makefile
+++ b/lib/libusb/Makefile
@@ -40,6 +40,7 @@ CFLAGS+= -DCOMPAT_32BIT
MLINKS += libusb.3 libusb_init.3
MLINKS += libusb.3 libusb_exit.3
MLINKS += libusb.3 libusb_strerror.3
+MLINKS += libusb.3 libusb_error_name.3
MLINKS += libusb.3 libusb_set_debug.3
MLINKS += libusb.3 libusb_get_device_list.3
MLINKS += libusb.3 libusb_free_device_list.3
@@ -210,3 +211,5 @@ MLINKS += libusb20.3 libusb20_me_get_2.3
MLINKS += libusb20.3 libusb20_me_encode.3
MLINKS += libusb20.3 libusb20_me_decode.3
MLINKS += libusb20.3 libusb20_desc_foreach.3
+MLINKS += libusb20.3 libusb20_strerror.3
+MLINKS += libusb20.3 libusb20_error_name.3
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index 1f52b9e..7255f2b 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -63,6 +63,14 @@ Other libusb routines may not be called after this function.
Get the ASCII representation of the error given by the
.Fa code
argument.
+This function does not return NULL.
+.Pp
+.Ft const char *
+.Fn libusb_error_name "int code"
+Get the ASCII representation of the error enum given by the
+.Fa code
+argument.
+This function does not return NULL.
.Pp
.Ft void
.Fn libusb_set_debug "libusb_context *ctx" "int level"
@@ -215,8 +223,8 @@ code on failure.
.Ft int
.Fn libusb_kernel_driver_active "libusb_device_handle *devh" "int interface"
Determine if a driver is active on a interface.
-Returns 0 if no kernel driver
-is active, 1 if a kernel driver is active, LIBUSB_ERROR_NO_DEVICE
+Returns 0 if no kernel driver is active
+and 1 if a kernel driver is active, LIBUSB_ERROR_NO_DEVICE
if the device has been disconnected and a LIBUSB_ERROR code on failure.
.Pp
.Ft int
@@ -502,7 +510,8 @@ The library is also compliant with LibUSB version 0.1.12.
.Sh SEE ALSO
.Xr libusb20 3 ,
.Xr usb 4 ,
-.Xr usbconfig 8
+.Xr usbconfig 8 ,
+.Xr usbdump 8
.Pp
.Pa http://libusb.sourceforge.net/
.Sh HISTORY
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
index bbde475..63e3ebc 100644
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -303,6 +303,7 @@ typedef struct libusb_transfer {
void libusb_set_debug(libusb_context * ctx, int level);
const char *libusb_strerror(int code);
+const char *libusb_error_name(int code);
int libusb_init(libusb_context ** context);
void libusb_exit(struct libusb_context *ctx);
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index b66ccb6..0a7c1e6 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -216,7 +216,6 @@ libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
libusb20_be_free(usb_backend);
return (LIBUSB_ERROR_NO_MEM);
}
-
/* get device into libUSB v1.0 list */
libusb20_be_dequeue_device(usb_backend, pdev);
@@ -718,8 +717,10 @@ libusb_kernel_driver_active(struct libusb20_device *pdev, int interface)
if (pdev == NULL)
return (LIBUSB_ERROR_INVALID_PARAM);
- return (libusb20_dev_kernel_driver_active(
- pdev, interface));
+ if (libusb20_dev_kernel_driver_active(pdev, interface))
+ return (0); /* no kernel driver is active */
+ else
+ return (1); /* kernel driver is active */
}
int
@@ -1449,6 +1450,73 @@ libusb_le16_to_cpu(uint16_t x)
const char *
libusb_strerror(int code)
{
- /* TODO */
- return ("Unknown error");
+ switch (code) {
+ case LIBUSB_SUCCESS:
+ return ("Success");
+ case LIBUSB_ERROR_IO:
+ return ("I/O error");
+ case LIBUSB_ERROR_INVALID_PARAM:
+ return ("Invalid parameter");
+ case LIBUSB_ERROR_ACCESS:
+ return ("Permissions error");
+ case LIBUSB_ERROR_NO_DEVICE:
+ return ("No device");
+ case LIBUSB_ERROR_NOT_FOUND:
+ return ("Not found");
+ case LIBUSB_ERROR_BUSY:
+ return ("Device busy");
+ case LIBUSB_ERROR_TIMEOUT:
+ return ("Timeout");
+ case LIBUSB_ERROR_OVERFLOW:
+ return ("Overflow");
+ case LIBUSB_ERROR_PIPE:
+ return ("Pipe error");
+ case LIBUSB_ERROR_INTERRUPTED:
+ return ("Interrupted");
+ case LIBUSB_ERROR_NO_MEM:
+ return ("Out of memory");
+ case LIBUSB_ERROR_NOT_SUPPORTED:
+ return ("Not supported");
+ case LIBUSB_ERROR_OTHER:
+ return ("Other error");
+ default:
+ return ("Unknown error");
+ }
+}
+
+const char *
+libusb_error_name(int code)
+{
+ switch (code) {
+ case LIBUSB_SUCCESS:
+ return ("LIBUSB_SUCCESS");
+ case LIBUSB_ERROR_IO:
+ return ("LIBUSB_ERROR_IO");
+ case LIBUSB_ERROR_INVALID_PARAM:
+ return ("LIBUSB_ERROR_INVALID_PARAM");
+ case LIBUSB_ERROR_ACCESS:
+ return ("LIBUSB_ERROR_ACCESS");
+ case LIBUSB_ERROR_NO_DEVICE:
+ return ("LIBUSB_ERROR_NO_DEVICE");
+ case LIBUSB_ERROR_NOT_FOUND:
+ return ("LIBUSB_ERROR_NOT_FOUND");
+ case LIBUSB_ERROR_BUSY:
+ return ("LIBUSB_ERROR_BUSY");
+ case LIBUSB_ERROR_TIMEOUT:
+ return ("LIBUSB_ERROR_TIMEOUT");
+ case LIBUSB_ERROR_OVERFLOW:
+ return ("LIBUSB_ERROR_OVERFLOW");
+ case LIBUSB_ERROR_PIPE:
+ return ("LIBUSB_ERROR_PIPE");
+ case LIBUSB_ERROR_INTERRUPTED:
+ return ("LIBUSB_ERROR_INTERRUPTED");
+ case LIBUSB_ERROR_NO_MEM:
+ return ("LIBUSB_ERROR_NO_MEM");
+ case LIBUSB_ERROR_NOT_SUPPORTED:
+ return ("LIBUSB_ERROR_NOT_SUPPORTED");
+ case LIBUSB_ERROR_OTHER:
+ return ("LIBUSB_ERROR_OTHER");
+ default:
+ return ("LIBUSB_ERROR_UNKNOWN");
+ }
}
diff --git a/lib/libusb/libusb20.3 b/lib/libusb/libusb20.3
index 042f885..bd167b2 100644
--- a/lib/libusb/libusb20.3
+++ b/lib/libusb/libusb20.3
@@ -212,6 +212,10 @@ USB access library (libusb -lusb)
.Fn libusb20_me_decode "const void *pdata" "uint16_t len" "void *pdecoded"
.Ft "const uint8_t *"
.Fn libusb20_desc_foreach "const struct libusb20_me_struct *me" "const uint8_t *pdesc"
+.Ft "const char *"
+.Fn libusb20_strerror "int code"
+.Ft "const char *"
+.Fn libusb20_error_name "int code"
.
.
.Sh DESCRIPTION
@@ -610,10 +614,9 @@ The file descriptor can be used for polling purposes.
.Pp
.
.Fn libusb20_dev_kernel_driver_active
-returns a non-zero value if a kernel driver is active on
-the given USB interface.
+returns zero if a kernel driver is active on the given USB interface.
.
-Else zero is returned.
+Else a LIBUSB20_ERROR value is returned.
.
.Pp
.
@@ -996,6 +999,22 @@ The total decoded length is returned.
The buffer pointer cannot be NULL.
.
.
+.Sh USB DEBUGGING
+.Pp
+.Ft const char *
+.Fn libusb20_strerror "int code"
+Get the ASCII representation of the error given by the
+.Fa code
+argument.
+This function does not return NULL.
+.Pp
+.Ft const char *
+.Fn libusb20_error_name "int code"
+Get the ASCII representation of the error enum given by the
+.Fa code
+argument.
+This function does not return NULL.
+.
.Sh FILES
.
.
@@ -1003,7 +1022,8 @@ The buffer pointer cannot be NULL.
.Sh SEE ALSO
.Xr usb 4 ,
.Xr libusb 3 ,
-.Xr usbconfig 8
+.Xr usbconfig 8 ,
+.Xr usbdump 8
.
.
.Sh HISTORY
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index b35e2bf..747c160 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -1244,3 +1244,77 @@ libusb20_be_dequeue_device(struct libusb20_backend *pbe,
{
TAILQ_REMOVE(&(pbe->usb_devs), pdev, dev_entry);
}
+
+const char *
+libusb20_strerror(int code)
+{
+ switch (code) {
+ case LIBUSB20_SUCCESS:
+ return ("Success");
+ case LIBUSB20_ERROR_IO:
+ return ("I/O error");
+ case LIBUSB20_ERROR_INVALID_PARAM:
+ return ("Invalid parameter");
+ case LIBUSB20_ERROR_ACCESS:
+ return ("Permissions error");
+ case LIBUSB20_ERROR_NO_DEVICE:
+ return ("No device");
+ case LIBUSB20_ERROR_NOT_FOUND:
+ return ("Not found");
+ case LIBUSB20_ERROR_BUSY:
+ return ("Device busy");
+ case LIBUSB20_ERROR_TIMEOUT:
+ return ("Timeout");
+ case LIBUSB20_ERROR_OVERFLOW:
+ return ("Overflow");
+ case LIBUSB20_ERROR_PIPE:
+ return ("Pipe error");
+ case LIBUSB20_ERROR_INTERRUPTED:
+ return ("Interrupted");
+ case LIBUSB20_ERROR_NO_MEM:
+ return ("Out of memory");
+ case LIBUSB20_ERROR_NOT_SUPPORTED:
+ return ("Not supported");
+ case LIBUSB20_ERROR_OTHER:
+ return ("Other error");
+ default:
+ return ("Unknown error");
+ }
+}
+
+const char *
+libusb20_error_name(int code)
+{
+ switch (code) {
+ case LIBUSB20_SUCCESS:
+ return ("LIBUSB20_SUCCESS");
+ case LIBUSB20_ERROR_IO:
+ return ("LIBUSB20_ERROR_IO");
+ case LIBUSB20_ERROR_INVALID_PARAM:
+ return ("LIBUSB20_ERROR_INVALID_PARAM");
+ case LIBUSB20_ERROR_ACCESS:
+ return ("LIBUSB20_ERROR_ACCESS");
+ case LIBUSB20_ERROR_NO_DEVICE:
+ return ("LIBUSB20_ERROR_NO_DEVICE");
+ case LIBUSB20_ERROR_NOT_FOUND:
+ return ("LIBUSB20_ERROR_NOT_FOUND");
+ case LIBUSB20_ERROR_BUSY:
+ return ("LIBUSB20_ERROR_BUSY");
+ case LIBUSB20_ERROR_TIMEOUT:
+ return ("LIBUSB20_ERROR_TIMEOUT");
+ case LIBUSB20_ERROR_OVERFLOW:
+ return ("LIBUSB20_ERROR_OVERFLOW");
+ case LIBUSB20_ERROR_PIPE:
+ return ("LIBUSB20_ERROR_PIPE");
+ case LIBUSB20_ERROR_INTERRUPTED:
+ return ("LIBUSB20_ERROR_INTERRUPTED");
+ case LIBUSB20_ERROR_NO_MEM:
+ return ("LIBUSB20_ERROR_NO_MEM");
+ case LIBUSB20_ERROR_NOT_SUPPORTED:
+ return ("LIBUSB20_ERROR_NOT_SUPPORTED");
+ case LIBUSB20_ERROR_OTHER:
+ return ("LIBUSB20_ERROR_OTHER");
+ default:
+ return ("LIBUSB20_ERROR_UNKNOWN");
+ }
+}
diff --git a/lib/libusb/libusb20.h b/lib/libusb/libusb20.h
index 22a2899..e4359fc 100644
--- a/lib/libusb/libusb20.h
+++ b/lib/libusb/libusb20.h
@@ -293,6 +293,11 @@ void libusb20_be_dequeue_device(struct libusb20_backend *pbe, struct libusb20_de
void libusb20_be_enqueue_device(struct libusb20_backend *pbe, struct libusb20_device *pdev);
void libusb20_be_free(struct libusb20_backend *pbe);
+/* USB debugging */
+
+const char *libusb20_strerror(int);
+const char *libusb20_error_name(int);
+
#if 0
{ /* style */
#endif
diff --git a/lib/libusbhid/data.c b/lib/libusbhid/data.c
index 3b90ac6..f607737 100644
--- a/lib/libusbhid/data.c
+++ b/lib/libusbhid/data.c
@@ -32,7 +32,10 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <assert.h>
#include <stdlib.h>
+#include <string.h>
+#include <dev/usb/usb_ioctl.h>
#include "usbhid.h"
+#include "usbvar.h"
int32_t
hid_get_data(const void *p, const hid_item_t *h)
@@ -114,3 +117,27 @@ hid_set_data(void *p, const hid_item_t *h, int32_t data)
buf[offs + i] = (buf[offs + i] & (mask >> (i*8))) |
((data >> (i*8)) & 0xff);
}
+
+int
+hid_get_report(int fd, enum hid_kind k, unsigned char *data, unsigned int size)
+{
+ struct usb_gen_descriptor ugd;
+
+ memset(&ugd, 0, sizeof(ugd));
+ ugd.ugd_data = hid_pass_ptr(data);
+ ugd.ugd_maxlen = size;
+ ugd.ugd_report_type = k + 1;
+ return (ioctl(fd, USB_GET_REPORT, &ugd));
+}
+
+int
+hid_set_report(int fd, enum hid_kind k, unsigned char *data, unsigned int size)
+{
+ struct usb_gen_descriptor ugd;
+
+ memset(&ugd, 0, sizeof(ugd));
+ ugd.ugd_data = hid_pass_ptr(data);
+ ugd.ugd_maxlen = size;
+ ugd.ugd_report_type = k + 1;
+ return (ioctl(fd, USB_SET_REPORT, &ugd));
+}
diff --git a/lib/libusbhid/parse.c b/lib/libusbhid/parse.c
index d2b49d4..f7c2cb1 100644
--- a/lib/libusbhid/parse.c
+++ b/lib/libusbhid/parse.c
@@ -43,10 +43,11 @@ __FBSDID("$FreeBSD$");
#define MAXUSAGE 100
#define MAXPUSH 4
#define MAXID 64
+#define ITEMTYPES 3
struct hid_pos_data {
int32_t rid;
- uint32_t pos;
+ uint32_t pos[ITEMTYPES];
};
struct hid_data {
@@ -55,6 +56,7 @@ struct hid_data {
const uint8_t *p;
struct hid_item cur[MAXPUSH];
struct hid_pos_data last_pos[MAXID];
+ uint32_t pos[ITEMTYPES];
int32_t usages_min[MAXUSAGE];
int32_t usages_max[MAXUSAGE];
int32_t usage_last; /* last seen usage */
@@ -92,7 +94,7 @@ hid_clear_local(hid_item_t *c)
static void
hid_switch_rid(struct hid_data *s, struct hid_item *c, int32_t next_rID)
{
- uint8_t i;
+ uint8_t i, j;
/* check for same report ID - optimise */
@@ -113,7 +115,8 @@ hid_switch_rid(struct hid_data *s, struct hid_item *c, int32_t next_rID)
}
if (i != MAXID) {
s->last_pos[i].rid = c->report_ID;
- s->last_pos[i].pos = c->pos;
+ for (j = 0; j < ITEMTYPES; j++)
+ s->last_pos[i].pos[j] = s->pos[j];
}
/* store next report ID */
@@ -134,9 +137,12 @@ hid_switch_rid(struct hid_data *s, struct hid_item *c, int32_t next_rID)
}
if (i != MAXID) {
s->last_pos[i].rid = next_rID;
- c->pos = s->last_pos[i].pos;
- } else
- c->pos = 0; /* Out of RID entries. */
+ for (j = 0; j < ITEMTYPES; j++)
+ s->pos[j] = s->last_pos[i].pos[j];
+ } else {
+ for (j = 0; j < ITEMTYPES; j++)
+ s->pos[j] = 0; /* Out of RID entries. */
+ }
}
/*------------------------------------------------------------------------*
@@ -206,7 +212,6 @@ hid_get_item(hid_data_t s, hid_item_t *h)
{
hid_item_t *c;
unsigned int bTag, bType, bSize;
- uint32_t oldpos;
int32_t mask;
int32_t dval;
@@ -240,7 +245,8 @@ hid_get_item(hid_data_t s, hid_item_t *h)
*/
if (s->kindset & (1 << c->kind)) {
*h = *c;
- c->pos += c->report_size * c->report_count;
+ h->pos = s->pos[c->kind];
+ s->pos[c->kind] += c->report_size * c->report_count;
return (1);
}
}
@@ -406,14 +412,10 @@ hid_get_item(hid_data_t s, hid_item_t *h)
case 11: /* Pop */
s->pushlevel --;
if (s->pushlevel < MAXPUSH) {
- /* preserve position */
- oldpos = c->pos;
c = &s->cur[s->pushlevel];
/* restore size and count */
s->loc_size = c->report_size;
s->loc_count = c->report_count;
- /* set default item location */
- c->pos = oldpos;
c->report_size = 0;
c->report_count = 0;
}
diff --git a/lib/libusbhid/usbhid.3 b/lib/libusbhid/usbhid.3
index b4951f2..c34a109 100644
--- a/lib/libusbhid/usbhid.3
+++ b/lib/libusbhid/usbhid.3
@@ -44,7 +44,9 @@
.Nm hid_usage_in_page ,
.Nm hid_init ,
.Nm hid_get_data ,
-.Nm hid_set_data
+.Nm hid_set_data ,
+.Nm hid_get_report ,
+.Nm hid_set_report
.Nd USB HID access routines
.Sh LIBRARY
.Lb libusbhid
@@ -84,6 +86,10 @@
.Fn hid_get_data "const void *data" "const hid_item_t *h"
.Ft void
.Fn hid_set_data "void *buf" "const hid_item_t *h" "int data"
+.Ft int
+.Fn hid_get_report "int fd" "enum hid_kind k" "unsigned char *data" "unsigned int size"
+.Ft int
+.Fn hid_set_report "int fd" "enum hid_kind k" "unsigned char *data" "unsigned int size"
.Sh DESCRIPTION
The
.Nm
@@ -105,6 +111,14 @@ Synchronous HID operation can be enabled or disabled by a call to
If the second argument is zero synchronous HID operation is disabled.
Else synchronous HID operation is enabled.
The function returns a negative value on failure.
+.Pp
+.Fn hid_get_report
+and
+.Fn hid_set_report
+functions allow to synchronously get and set specific report if device
+supports it.
+For devices with multiple report IDs, wanted ID should be provided in the
+first byte of the buffer for both get and set.
.Ss Descriptor Functions
The report descriptor ID can be obtained by calling
.Fn hid_get_report_id .
diff --git a/lib/libusbhid/usbhid.h b/lib/libusbhid/usbhid.h
index 5e098ea..231ee1f 100644
--- a/lib/libusbhid/usbhid.h
+++ b/lib/libusbhid/usbhid.h
@@ -76,6 +76,7 @@ typedef struct hid_item {
#define HID_PAGE(u) (((u) >> 16) & 0xffff)
#define HID_USAGE(u) ((u) & 0xffff)
+#define HID_HAS_GET_SET_REPORT 1
__BEGIN_DECLS
@@ -104,5 +105,9 @@ int hid_parse_usage_page(const char *name);
/* Extracting/insertion of data, data.c: */
int32_t hid_get_data(const void *p, const hid_item_t *h);
void hid_set_data(void *p, const hid_item_t *h, int32_t data);
+int hid_get_report(int fd, enum hid_kind k,
+ unsigned char *data, unsigned int size);
+int hid_set_report(int fd, enum hid_kind k,
+ unsigned char *data, unsigned int size);
__END_DECLS
diff --git a/lib/libutil/pidfile.3 b/lib/libutil/pidfile.3
index cc2b4bb..c42b95b 100644
--- a/lib/libutil/pidfile.3
+++ b/lib/libutil/pidfile.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 20, 2008
+.Dd October 16, 2011
.Dt PIDFILE 3
.Os
.Sh NAME
@@ -59,11 +59,14 @@ The
function opens (or creates) a file specified by the
.Fa path
argument and locks it.
-If a file can not be locked, a PID of an already running daemon is returned in
-the
+If
.Fa pidptr
-argument (if it is not
-.Dv NULL ) .
+argument is not
+.Dv NULL
+and file can not be locked, the function will use it to store a PID of an
+already running daemon or
+.Li -1
+in case daemon did not write its PID yet.
The function does not write process' PID into the file here, so it can be
used before
.Fn fork Ns ing
@@ -162,16 +165,18 @@ function will fail if:
.It Bq Er EEXIST
Some process already holds the lock on the given pidfile, meaning that a
daemon is already running.
+If
+.Fa pidptr
+argument is not
+.Dv NULL
+the function will use it to store a PID of an already running daemon or
+.Li -1
+in case daemon did not write its PID yet.
.It Bq Er ENAMETOOLONG
Specified pidfile's name is too long.
.It Bq Er EINVAL
Some process already holds the lock on the given pidfile, but PID read
from there is invalid.
-.It Bq Er EAGAIN
-Some process already holds the lock on the given pidfile, but the file
-is truncated.
-Most likely, the existing daemon is writing new PID into
-the file.
.El
.Pp
The
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index 6b99936..953d1e0 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -119,20 +119,20 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
fd = flopen(pfh->pf_path,
O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode);
if (fd == -1) {
- count = 0;
- rqtp.tv_sec = 0;
- rqtp.tv_nsec = 5000000;
if (errno == EWOULDBLOCK && pidptr != NULL) {
- again:
- errno = pidfile_read(pfh->pf_path, pidptr);
- if (errno == 0)
- errno = EEXIST;
- else if (errno == EAGAIN) {
- if (++count <= 3) {
- nanosleep(&rqtp, 0);
- goto again;
- }
+ count = 20;
+ rqtp.tv_sec = 0;
+ rqtp.tv_nsec = 5000000;
+ for (;;) {
+ errno = pidfile_read(pfh->pf_path, pidptr);
+ if (errno != EAGAIN || --count == 0)
+ break;
+ nanosleep(&rqtp, 0);
}
+ if (errno == EAGAIN)
+ *pidptr = -1;
+ if (errno == 0 || errno == EAGAIN)
+ errno = EEXIST;
}
free(pfh);
return (NULL);
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index bb99e45..f1385f1 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -49,7 +49,7 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \
e_pow.c e_powf.c e_rem_pio2.c \
e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c e_scalbf.c \
e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c fenv.c \
- k_cos.c k_cosf.c k_rem_pio2.c k_sin.c k_sinf.c \
+ k_cos.c k_cosf.c k_exp.c k_expf.c k_rem_pio2.c k_sin.c k_sinf.c \
k_tan.c k_tanf.c \
s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c s_cargl.c \
s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c \
@@ -101,9 +101,11 @@ COMMON_SRCS+= e_acosl.c e_asinl.c e_atan2l.c e_fmodl.c \
.endif
# C99 complex functions
-COMMON_SRCS+= s_cexp.c s_cexpf.c s_cimag.c s_cimagf.c s_cimagl.c \
+COMMON_SRCS+= 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
+ s_cproj.c s_cprojf.c s_creal.c s_crealf.c s_creall.c \
+ s_csinh.c s_csinhf.c s_ctanh.c s_ctanhf.c
# FreeBSD's C library supplies these functions:
#COMMON_SRCS+= s_fabs.c s_frexp.c s_isnan.c s_ldexp.c s_modf.c
@@ -125,7 +127,8 @@ 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 cexp.3 \
+MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \
+ ceil.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 \
@@ -143,6 +146,9 @@ MLINKS+=atan.3 atanf.3 atan.3 atanl.3
MLINKS+=atanh.3 atanhf.3
MLINKS+=atan2.3 atan2f.3 atan2.3 atan2l.3 \
atan2.3 carg.3 atan2.3 cargf.3 atan2.3 cargl.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
MLINKS+=ceil.3 ceilf.3 ceil.3 ceill.3
MLINKS+=cexp.3 cexpf.3
MLINKS+=cimag.3 cimagf.3 cimag.3 cimagl.3 \
diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map
index bb53ac3..f3d3000 100644
--- a/lib/msun/Symbol.map
+++ b/lib/msun/Symbol.map
@@ -228,3 +228,25 @@ FBSD_1.2 {
log2;
log2f;
};
+
+/* First added in 10.0-CURRENT */
+FBSD_1.3 {
+ feclearexcept;
+ fegetexceptflag;
+ fetestexcept;
+ fegetround;
+ fesetround;
+ fesetenv;
+ csin;
+ csinf;
+ csinh;
+ csinhf;
+ ccos;
+ ccosf;
+ ccosh;
+ ccoshf;
+ ctan;
+ ctanf;
+ ctanh;
+ ctanhf;
+};
diff --git a/lib/msun/amd64/Symbol.map b/lib/msun/amd64/Symbol.map
index f4c13a4..3da32ff 100644
--- a/lib/msun/amd64/Symbol.map
+++ b/lib/msun/amd64/Symbol.map
@@ -7,8 +7,6 @@ FBSD_1.0 {
fegetenv;
feholdexcept;
feupdateenv;
- __feenableexcept;
- __fedisableexcept;
feenableexcept;
fedisableexcept;
};
diff --git a/lib/msun/amd64/fenv.c b/lib/msun/amd64/fenv.c
index e126070..8b49b35 100644
--- a/lib/msun/amd64/fenv.c
+++ b/lib/msun/amd64/fenv.c
@@ -29,7 +29,13 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/fpu.h>
-#include <fenv.h>
+
+#define __fenv_static
+#include "fenv.h"
+
+#ifdef __GNUC_GNU_INLINE__
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
const fenv_t __fe_dfl_env = {
{ 0xffff0000 | __INITIAL_FPUCW__,
@@ -41,6 +47,9 @@ const fenv_t __fe_dfl_env = {
__INITIAL_MXCSR__
};
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+
int
fesetexceptflag(const fexcept_t *flagp, int excepts)
{
@@ -69,6 +78,10 @@ feraiseexcept(int excepts)
return (0);
}
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+
int
fegetenv(fenv_t *envp)
{
@@ -98,6 +111,8 @@ feholdexcept(fenv_t *envp)
return (0);
}
+extern inline int fesetenv(const fenv_t *__envp);
+
int
feupdateenv(const fenv_t *envp)
{
@@ -120,12 +135,12 @@ __feenableexcept(int mask)
mask &= FE_ALL_EXCEPT;
__fnstcw(&control);
__stmxcsr(&mxcsr);
- omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
+ omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
control &= ~mask;
__fldcw(control);
mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
__ldmxcsr(mxcsr);
- return (~omask);
+ return (omask);
}
int
@@ -137,12 +152,12 @@ __fedisableexcept(int mask)
mask &= FE_ALL_EXCEPT;
__fnstcw(&control);
__stmxcsr(&mxcsr);
- omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
+ omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
control |= mask;
__fldcw(control);
mxcsr |= mask << _SSE_EMASK_SHIFT;
__ldmxcsr(mxcsr);
- return (~omask);
+ return (omask);
}
__weak_reference(__feenableexcept, feenableexcept);
diff --git a/lib/msun/amd64/fenv.h b/lib/msun/amd64/fenv.h
index 875664a..b7c9873 100644
--- a/lib/msun/amd64/fenv.h
+++ b/lib/msun/amd64/fenv.h
@@ -32,6 +32,10 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
+#ifndef __fenv_static
+#define __fenv_static static
+#endif
+
typedef struct {
struct {
__uint32_t __control;
@@ -89,7 +93,7 @@ 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)))
-static __inline int
+__fenv_static inline int
feclearexcept(int __excepts)
{
fenv_t __env;
@@ -107,7 +111,7 @@ feclearexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
__uint32_t __mxcsr;
@@ -122,7 +126,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
int feraiseexcept(int __excepts);
-static __inline int
+__fenv_static inline int
fetestexcept(int __excepts)
{
__uint32_t __mxcsr;
@@ -133,7 +137,7 @@ fetestexcept(int __excepts)
return ((__status | __mxcsr) & __excepts);
}
-static __inline int
+__fenv_static inline int
fegetround(void)
{
__uint16_t __control;
@@ -148,7 +152,7 @@ fegetround(void)
return (__control & _ROUND_MASK);
}
-static __inline int
+__fenv_static inline int
fesetround(int __round)
{
__uint32_t __mxcsr;
@@ -173,7 +177,7 @@ fesetround(int __round)
int fegetenv(fenv_t *__envp);
int feholdexcept(fenv_t *__envp);
-static __inline int
+__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
@@ -197,7 +201,8 @@ int feupdateenv(const fenv_t *__envp);
int feenableexcept(int __mask);
int fedisableexcept(int __mask);
-static __inline int
+/* We currently provide no external definition of fegetexcept(). */
+static inline int
fegetexcept(void)
{
__uint16_t __control;
diff --git a/lib/msun/arm/Symbol.map b/lib/msun/arm/Symbol.map
index 3121177..971112e 100644
--- a/lib/msun/arm/Symbol.map
+++ b/lib/msun/arm/Symbol.map
@@ -3,3 +3,11 @@
*/
FBSD_1.0 {
};
+
+FBSD_1.3 {
+ fesetexceptflag;
+ feraiseexcept;
+ fegetenv;
+ feholdexcept;
+ feupdateenv;
+};
diff --git a/lib/msun/arm/fenv.c b/lib/msun/arm/fenv.c
index a6781e0..a5a5c03 100644
--- a/lib/msun/arm/fenv.c
+++ b/lib/msun/arm/fenv.c
@@ -26,10 +26,27 @@
* $FreeBSD$
*/
-#include <fenv.h>
+#define __fenv_static
+#include "fenv.h"
+
+#ifdef __GNUC_GNU_INLINE__
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
/*
* Hopefully the system ID byte is immutable, so it's valid to use
* this as a default environment.
*/
const fenv_t __fe_dfl_env = 0;
+
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+extern inline int feraiseexcept(int __excepts);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+extern inline int fegetenv(fenv_t *__envp);
+extern inline int feholdexcept(fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
+extern inline int feupdateenv(const fenv_t *__envp);
diff --git a/lib/msun/arm/fenv.h b/lib/msun/arm/fenv.h
index d540ae2..f114998 100644
--- a/lib/msun/arm/fenv.h
+++ b/lib/msun/arm/fenv.h
@@ -31,6 +31,10 @@
#include <sys/_types.h>
+#ifndef __fenv_static
+#define __fenv_static static
+#endif
+
typedef __uint32_t fenv_t;
typedef __uint32_t fexcept_t;
@@ -68,7 +72,7 @@ extern const fenv_t __fe_dfl_env;
#define __wfs(__fpsr)
#endif
-static __inline int
+__fenv_static inline int
feclearexcept(int __excepts)
{
fexcept_t __fpsr;
@@ -79,7 +83,7 @@ feclearexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
@@ -89,7 +93,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
@@ -101,7 +105,7 @@ fesetexceptflag(const fexcept_t *__flagp, int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
feraiseexcept(int __excepts)
{
fexcept_t __ex = __excepts;
@@ -110,7 +114,7 @@ feraiseexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fetestexcept(int __excepts)
{
fexcept_t __fpsr;
@@ -119,7 +123,7 @@ fetestexcept(int __excepts)
return (__fpsr & __excepts);
}
-static __inline int
+__fenv_static inline int
fegetround(void)
{
@@ -131,14 +135,14 @@ fegetround(void)
return (-1);
}
-static __inline int
+__fenv_static inline int
fesetround(int __round)
{
return (-1);
}
-static __inline int
+__fenv_static inline int
fegetenv(fenv_t *__envp)
{
@@ -146,7 +150,7 @@ fegetenv(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
fenv_t __env;
@@ -158,7 +162,7 @@ feholdexcept(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
@@ -166,7 +170,7 @@ fesetenv(const fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feupdateenv(const fenv_t *__envp)
{
fexcept_t __fpsr;
@@ -179,7 +183,9 @@ feupdateenv(const fenv_t *__envp)
#if __BSD_VISIBLE
-static __inline int
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
feenableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
@@ -190,7 +196,7 @@ feenableexcept(int __mask)
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
-static __inline int
+static inline int
fedisableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
@@ -201,7 +207,7 @@ fedisableexcept(int __mask)
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
-static __inline int
+static inline int
fegetexcept(void)
{
fenv_t __fpsr;
diff --git a/lib/msun/bsdsrc/b_exp.c b/lib/msun/bsdsrc/b_exp.c
index 6af1fe1..4400992 100644
--- a/lib/msun/bsdsrc/b_exp.c
+++ b/lib/msun/bsdsrc/b_exp.c
@@ -74,16 +74,16 @@ __FBSDID("$FreeBSD$");
#include "mathimpl.h"
-const static double p1 = 0x1.555555555553ep-3;
-const static double p2 = -0x1.6c16c16bebd93p-9;
-const static double p3 = 0x1.1566aaf25de2cp-14;
-const static double p4 = -0x1.bbd41c5d26bf1p-20;
-const static double p5 = 0x1.6376972bea4d0p-25;
-const static double ln2hi = 0x1.62e42fee00000p-1;
-const static double ln2lo = 0x1.a39ef35793c76p-33;
-const static double lnhuge = 0x1.6602b15b7ecf2p9;
-const static double lntiny = -0x1.77af8ebeae354p9;
-const static double invln2 = 0x1.71547652b82fep0;
+static const double p1 = 0x1.555555555553ep-3;
+static const double p2 = -0x1.6c16c16bebd93p-9;
+static const double p3 = 0x1.1566aaf25de2cp-14;
+static const double p4 = -0x1.bbd41c5d26bf1p-20;
+static const double p5 = 0x1.6376972bea4d0p-25;
+static const double ln2hi = 0x1.62e42fee00000p-1;
+static const double ln2lo = 0x1.a39ef35793c76p-33;
+static const double lnhuge = 0x1.6602b15b7ecf2p9;
+static const double lntiny = -0x1.77af8ebeae354p9;
+static const double invln2 = 0x1.71547652b82fep0;
#if 0
double exp(x)
diff --git a/lib/msun/i387/Symbol.map b/lib/msun/i387/Symbol.map
index aa81690..35e6e18 100644
--- a/lib/msun/i387/Symbol.map
+++ b/lib/msun/i387/Symbol.map
@@ -9,8 +9,6 @@ FBSD_1.0 {
fegetenv;
feholdexcept;
feupdateenv;
- __feenableexcept;
- __fedisableexcept;
feenableexcept;
fedisableexcept;
};
diff --git a/lib/msun/i387/fenv.c b/lib/msun/i387/fenv.c
index 5c996b3..6f51ba2 100644
--- a/lib/msun/i387/fenv.c
+++ b/lib/msun/i387/fenv.c
@@ -29,8 +29,14 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/npx.h>
+
+#define __fenv_static
#include "fenv.h"
+#ifdef __GNUC_GNU_INLINE__
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
+
const fenv_t __fe_dfl_env = {
__INITIAL_NPXCW__,
0x0000,
@@ -83,6 +89,9 @@ __test_sse(void)
return (0);
}
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+
int
fesetexceptflag(const fexcept_t *flagp, int excepts)
{
@@ -114,6 +123,10 @@ feraiseexcept(int excepts)
return (0);
}
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+
int
fegetenv(fenv_t *envp)
{
@@ -149,6 +162,8 @@ feholdexcept(fenv_t *envp)
return (0);
}
+extern inline int fesetenv(const fenv_t *__envp);
+
int
feupdateenv(const fenv_t *envp)
{
@@ -177,14 +192,14 @@ __feenableexcept(int mask)
__stmxcsr(&mxcsr);
else
mxcsr = 0;
- omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
+ omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
control &= ~mask;
__fldcw(control);
if (__HAS_SSE()) {
mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
__ldmxcsr(mxcsr);
}
- return (~omask);
+ return (omask);
}
int
@@ -199,14 +214,14 @@ __fedisableexcept(int mask)
__stmxcsr(&mxcsr);
else
mxcsr = 0;
- omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
+ omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
control |= mask;
__fldcw(control);
if (__HAS_SSE()) {
mxcsr |= mask << _SSE_EMASK_SHIFT;
__ldmxcsr(mxcsr);
}
- return (~omask);
+ return (omask);
}
__weak_reference(__feenableexcept, feenableexcept);
diff --git a/lib/msun/i387/fenv.h b/lib/msun/i387/fenv.h
index cc58a92..329dfe1 100644
--- a/lib/msun/i387/fenv.h
+++ b/lib/msun/i387/fenv.h
@@ -32,6 +32,10 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
+#ifndef __fenv_static
+#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).
@@ -110,7 +114,7 @@ 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)))
-static __inline int
+__fenv_static inline int
feclearexcept(int __excepts)
{
fenv_t __env;
@@ -131,7 +135,7 @@ feclearexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
__uint32_t __mxcsr;
@@ -149,7 +153,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
int feraiseexcept(int __excepts);
-static __inline int
+__fenv_static inline int
fetestexcept(int __excepts)
{
__uint32_t __mxcsr;
@@ -163,7 +167,7 @@ fetestexcept(int __excepts)
return ((__status | __mxcsr) & __excepts);
}
-static __inline int
+__fenv_static inline int
fegetround(void)
{
__uint16_t __control;
@@ -178,7 +182,7 @@ fegetround(void)
return (__control & _ROUND_MASK);
}
-static __inline int
+__fenv_static inline int
fesetround(int __round)
{
__uint32_t __mxcsr;
@@ -205,7 +209,7 @@ fesetround(int __round)
int fegetenv(fenv_t *__envp);
int feholdexcept(fenv_t *__envp);
-static __inline int
+__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
fenv_t __env = *__envp;
@@ -234,7 +238,8 @@ int feupdateenv(const fenv_t *__envp);
int feenableexcept(int __mask);
int fedisableexcept(int __mask);
-static __inline int
+/* We currently provide no external definition of fegetexcept(). */
+static inline int
fegetexcept(void)
{
__uint16_t __control;
diff --git a/lib/msun/ia64/Symbol.map b/lib/msun/ia64/Symbol.map
index 00ed4ee..c92e75d 100644
--- a/lib/msun/ia64/Symbol.map
+++ b/lib/msun/ia64/Symbol.map
@@ -4,3 +4,10 @@
FBSD_1.0 {
feupdateenv;
};
+
+FBSD_1.3 {
+ fesetexceptflag;
+ feraiseexcept;
+ fegetenv;
+ feholdexcept;
+};
diff --git a/lib/msun/ia64/fenv.c b/lib/msun/ia64/fenv.c
index 95a5809..09d2d4e 100644
--- a/lib/msun/ia64/fenv.c
+++ b/lib/msun/ia64/fenv.c
@@ -27,10 +27,27 @@
*/
#include <sys/types.h>
-#include <fenv.h>
+
+#define __fenv_static
+#include "fenv.h"
+
+#ifdef __GNUC_GNU_INLINE__
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
const fenv_t __fe_dfl_env = 0x0009804c8a70033fULL;
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+extern inline int feraiseexcept(int __excepts);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+extern inline int fegetenv(fenv_t *__envp);
+extern inline int feholdexcept(fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
+
/*
* It doesn't pay to inline feupdateenv() because it includes one of
* the rare uses of feraiseexcept() where the argument is not a
diff --git a/lib/msun/ia64/fenv.h b/lib/msun/ia64/fenv.h
index 6f0240f..0f001db 100644
--- a/lib/msun/ia64/fenv.h
+++ b/lib/msun/ia64/fenv.h
@@ -31,6 +31,10 @@
#include <sys/_types.h>
+#ifndef __fenv_static
+#define __fenv_static static
+#endif
+
typedef __uint64_t fenv_t;
typedef __uint16_t fexcept_t;
@@ -63,7 +67,7 @@ extern const fenv_t __fe_dfl_env;
#define __stfpsr(__r) __asm __volatile("mov %0=ar.fpsr" : "=r" (*(__r)))
#define __ldfpsr(__r) __asm __volatile("mov ar.fpsr=%0;;" : : "r" (__r))
-static __inline int
+__fenv_static inline int
feclearexcept(int __excepts)
{
fenv_t __fpsr;
@@ -74,7 +78,7 @@ feclearexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fenv_t __fpsr;
@@ -84,7 +88,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fenv_t __fpsr;
@@ -103,7 +107,7 @@ fesetexceptflag(const fexcept_t *__flagp, int __excepts)
* figure this out automatically, and there's no way to tell it.
* We assume that constant arguments will be the common case.
*/
-static __inline int
+__fenv_static inline int
feraiseexcept(int __excepts)
{
volatile double d;
@@ -138,7 +142,7 @@ feraiseexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fetestexcept(int __excepts)
{
fenv_t __fpsr;
@@ -148,7 +152,7 @@ fetestexcept(int __excepts)
}
-static __inline int
+__fenv_static inline int
fegetround(void)
{
fenv_t __fpsr;
@@ -157,7 +161,7 @@ fegetround(void)
return (__fpsr & _ROUND_MASK);
}
-static __inline int
+__fenv_static inline int
fesetround(int __round)
{
fenv_t __fpsr;
@@ -171,7 +175,7 @@ fesetround(int __round)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetenv(fenv_t *__envp)
{
@@ -179,7 +183,7 @@ fegetenv(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
fenv_t __fpsr;
@@ -192,7 +196,7 @@ feholdexcept(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
@@ -204,7 +208,9 @@ int feupdateenv(const fenv_t *__envp);
#if __BSD_VISIBLE
-static __inline int
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
feenableexcept(int __mask)
{
fenv_t __newfpsr, __oldfpsr;
@@ -215,7 +221,7 @@ feenableexcept(int __mask)
return (~__oldfpsr & FE_ALL_EXCEPT);
}
-static __inline int
+static inline int
fedisableexcept(int __mask)
{
fenv_t __newfpsr, __oldfpsr;
@@ -226,7 +232,7 @@ fedisableexcept(int __mask)
return (~__oldfpsr & FE_ALL_EXCEPT);
}
-static __inline int
+static inline int
fegetexcept(void)
{
fenv_t __fpsr;
diff --git a/lib/msun/man/ccos.3 b/lib/msun/man/ccos.3
new file mode 100644
index 0000000..cf708c1
--- /dev/null
+++ b/lib/msun/man/ccos.3
@@ -0,0 +1,80 @@
+.\" Copyright (c) 2011 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 October 17, 2011
+.Dt CCOS 3
+.Os
+.Sh NAME
+.Nm ccos ,
+.Nm ccosf ,
+.Nm csin ,
+.Nm csinf
+.Nm ctan ,
+.Nm ctanf
+.Nd complex trigonometric functions
+.Sh LIBRARY
+.Lb libm
+.Sh SYNOPSIS
+.In complex.h
+.Ft double complex
+.Fn ccos "double complex z"
+.Ft float complex
+.Fn ccosf "float complex z"
+.Ft double complex
+.Fn csin "double complex z"
+.Ft float complex
+.Fn csinf "float complex z"
+.Ft double complex
+.Fn ctan "double complex z"
+.Ft float complex
+.Fn ctanf "float complex z"
+.Sh DESCRIPTION
+The
+.Fn ccos ,
+.Fn csin ,
+and
+.Fn ctan
+functions compute the cosine, sine, and tangent of the complex number
+.Fa z ,
+respectively.
+The
+.Fn ccosf ,
+.Fn csinf ,
+and
+.Fn ctanf
+functions perform the same operations in
+.Fa float
+precision.
+.Sh SEE ALSO
+.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/ccosh.3 b/lib/msun/man/ccosh.3
new file mode 100644
index 0000000..01688b5
--- /dev/null
+++ b/lib/msun/man/ccosh.3
@@ -0,0 +1,80 @@
+.\" Copyright (c) 2011 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 October 17, 2011
+.Dt CCOSH 3
+.Os
+.Sh NAME
+.Nm ccosh ,
+.Nm ccoshf ,
+.Nm csinh ,
+.Nm csinhf
+.Nm ctanh ,
+.Nm ctanhf
+.Nd complex hyperbolic functions
+.Sh LIBRARY
+.Lb libm
+.Sh SYNOPSIS
+.In complex.h
+.Ft double complex
+.Fn ccosh "double complex z"
+.Ft float complex
+.Fn ccoshf "float complex z"
+.Ft double complex
+.Fn csinh "double complex z"
+.Ft float complex
+.Fn csinhf "float complex z"
+.Ft double complex
+.Fn ctanh "double complex z"
+.Ft float complex
+.Fn ctanhf "float complex z"
+.Sh DESCRIPTION
+The
+.Fn ccosh ,
+.Fn csinh ,
+and
+.Fn ctanh
+functions compute the hyperbolic cosine, sine, and tangent of the complex number
+.Fa z ,
+respectively.
+The
+.Fn ccoshf ,
+.Fn csinhf ,
+and
+.Fn ctanhf
+functions perform the same operations in
+.Fa float
+precision.
+.Sh SEE ALSO
+.Xr ccos 3 ,
+.Xr complex 3 ,
+.Xr cosh 3 ,
+.Xr math 3 ,
+.Xr sinh 3 ,
+.Xr tanh 3
+.Sh STANDARDS
+These functions conform to
+.St -isoC-99 .
diff --git a/lib/msun/man/complex.3 b/lib/msun/man/complex.3
index 3f7c18c..a8d9f95 100644
--- a/lib/msun/man/complex.3
+++ b/lib/msun/man/complex.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 7, 2011
+.Dd October 17, 2011
.Dt COMPLEX 3
.Os
.Sh NAME
@@ -86,6 +86,16 @@ conj compute the complex conjugate
cproj compute projection onto Riemann sphere
creal compute the real part
.El
+.\" Section 7.3.5-6 of ISO C99 standard
+.Ss Trigonometric and Hyperbolic Functions
+.Cl
+ccos cosine
+ccosh hyperbolic cosine
+csin sine
+csinh hyperbolic sine
+ctan tangent
+ctanh hyperbolic tangent
+.El
.Sh SEE ALSO
.Xr math 3 ,
.Xr fenv 3 ,
@@ -101,20 +111,14 @@ The
functions described here conform to
.St -isoC-99 .
.Sh BUGS
-The trigonmetric and hyperbolic functions
+The inverse trigonmetric and hyperbolic functions
.Fn cacos ,
.Fn cacosh ,
.Fn casin ,
.Fn casinh ,
.Fn catan ,
-.Fn catanh ,
-.Fn ccos ,
-.Fn ccosh ,
-.Fn csin ,
-.Fn csinh ,
-.Fn ctan ,
and
-.Fn ctanh
+.Fn catanh
are not implemented.
.Pp
The logarithmic functions
diff --git a/lib/msun/man/cos.3 b/lib/msun/man/cos.3
index d0cdf68..a430f81 100644
--- a/lib/msun/man/cos.3
+++ b/lib/msun/man/cos.3
@@ -71,6 +71,7 @@ functions return the cosine value.
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
+.Xr ccos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
diff --git a/lib/msun/man/cosh.3 b/lib/msun/man/cosh.3
index 517ec61..96abc5a 100644
--- a/lib/msun/man/cosh.3
+++ b/lib/msun/man/cosh.3
@@ -55,6 +55,7 @@ functions compute the hyperbolic cosine of
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
+.Xr ccosh 3 ,
.Xr cos 3 ,
.Xr math 3 ,
.Xr sin 3 ,
diff --git a/lib/msun/man/fenv.3 b/lib/msun/man/fenv.3
index aaea5f5..6fee216 100644
--- a/lib/msun/man/fenv.3
+++ b/lib/msun/man/fenv.3
@@ -91,24 +91,35 @@ The following macros expand to bit flags of type
representing the five standard floating-point exceptions.
.Bl -tag -width ".Dv FE_DIVBYZERO"
.It Dv FE_DIVBYZERO
-A divide-by-zero exception occurs when the program attempts to
-divide a finite non-zero number by zero.
+A divide-by-zero exception occurs when the
+.Em exact
+result of a computation is infinite (according to the limit definition).
+For example, dividing a finite non-zero number by zero or computing
+.Fn log 0
+raises a divide-by-zero exception.
.It Dv FE_INEXACT
-An inexact exception is raised whenever there is a loss of precision
+An inexact exception is raised whenever there is a loss of accuracy
due to rounding.
.It Dv FE_INVALID
Invalid operation exceptions occur when a program attempts to
perform calculations for which there is no reasonable representable
answer.
-For instance, subtraction of infinities, division of zero by zero,
-ordered comparison involving \*(Nas, and taking the square root of a
+For instance, subtraction of like-signed infinities, division of zero by zero,
+ordered comparison involving \*(Nas, and taking the real square root of a
negative number are all invalid operations.
.It Dv FE_OVERFLOW
-An overflow exception occurs when the magnitude of the result of a
-computation is too large to fit in the destination type.
+In contrast with divide-by-zero,
+an overflow exception occurs when an infinity is produced because
+the magnitude of the exact result is
+.Em finite
+but too large to fit in the destination type.
+For example, computing
+.Li DBL_MAX * 2
+raises an overflow exception.
.It Dv FE_UNDERFLOW
-Underflow occurs when the result of a computation is too close to zero
-to be represented as a non-zero value in the destination type.
+Underflow occurs when the result of a computation loses precision
+because it is too close to zero.
+The result is a subnormal number or zero.
.El
.Pp
Additionally, the
@@ -183,9 +194,9 @@ as usual, but no
.Dv SIGFPE
signals will be generated as a result.
Non-stop mode is the default, but it may be altered by
-non-standard mechanisms.
-.\" XXX Mention fe[gs]etmask() here after the interface is finalized
-.\" XXX and ready to be officially documented.
+.Fn feenableexcept
+and
+.Fn fedisableexcept .
The
.Fn feupdateenv
function restores a saved environment similarly to
diff --git a/lib/msun/man/ieee.3 b/lib/msun/man/ieee.3
index c99a628..d25a98f 100644
--- a/lib/msun/man/ieee.3
+++ b/lib/msun/man/ieee.3
@@ -183,7 +183,7 @@ Type name:
.Bd -ragged -offset indent -compact
On some architectures,
.Vt long double
-is the the same as
+is the same as
.Vt double .
.Ed
.Pp
diff --git a/lib/msun/man/math.3 b/lib/msun/man/math.3
index 9ffe080..f6b1289 100644
--- a/lib/msun/man/math.3
+++ b/lib/msun/man/math.3
@@ -39,7 +39,21 @@
.Sh SYNOPSIS
.In math.h
.Sh DESCRIPTION
-These functions constitute the C math library.
+The math library includes the following components:
+.Bl -column "<complex.h>" "polymorphic (type-generic) versions of functions" -compact -offset indent
+.In math.h Ta basic routines and real-valued functions
+.In complex.h Ta complex number support
+.In tgmath.h Ta polymorphic (type-generic) versions of functions
+.In fenv.h Ta routines to control rounding and exceptions
+.El
+The rest of this manual page describes the functions provided by
+.In math.h .
+Please consult
+.Xr complex 3 ,
+.Xr tgmath 3 ,
+and
+.Xr fenv 3
+for information on the other components.
.Sh "LIST OF FUNCTIONS"
Each of the following
.Vt double
@@ -200,6 +214,7 @@ so reproducible results cannot be guaranteed across platforms.
For most of these functions, however, incorrect rounding occurs
rarely, and then only in very-close-to-halfway cases.
.Sh SEE ALSO
+.Xr complex 3 ,
.Xr fenv 3 ,
.Xr ieee 3 ,
.Xr tgmath 3
diff --git a/lib/msun/man/sin.3 b/lib/msun/man/sin.3
index 2a34281..c7daf09 100644
--- a/lib/msun/man/sin.3
+++ b/lib/msun/man/sin.3
@@ -70,6 +70,7 @@ functions return the sine value.
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
+.Xr csin 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
diff --git a/lib/msun/man/sinh.3 b/lib/msun/man/sinh.3
index a2a2d8c..02944cc 100644
--- a/lib/msun/man/sinh.3
+++ b/lib/msun/man/sinh.3
@@ -56,6 +56,7 @@ functions compute the hyperbolic sine of
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
+.Xr csinh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr tan 3 ,
diff --git a/lib/msun/man/tan.3 b/lib/msun/man/tan.3
index 1577815..f73c612 100644
--- a/lib/msun/man/tan.3
+++ b/lib/msun/man/tan.3
@@ -73,6 +73,7 @@ functions return the tangent value.
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
+.Xr ctan 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
diff --git a/lib/msun/man/tanh.3 b/lib/msun/man/tanh.3
index 699abe5..6fb185c 100644
--- a/lib/msun/man/tanh.3
+++ b/lib/msun/man/tanh.3
@@ -65,6 +65,7 @@ functions return the hyperbolic tangent value.
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
+.Xr ctanh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
diff --git a/lib/msun/mips/Symbol.map b/lib/msun/mips/Symbol.map
index 3121177..971112e 100644
--- a/lib/msun/mips/Symbol.map
+++ b/lib/msun/mips/Symbol.map
@@ -3,3 +3,11 @@
*/
FBSD_1.0 {
};
+
+FBSD_1.3 {
+ fesetexceptflag;
+ feraiseexcept;
+ fegetenv;
+ feholdexcept;
+ feupdateenv;
+};
diff --git a/lib/msun/mips/fenv.c b/lib/msun/mips/fenv.c
index a6781e0..a5a5c03 100644
--- a/lib/msun/mips/fenv.c
+++ b/lib/msun/mips/fenv.c
@@ -26,10 +26,27 @@
* $FreeBSD$
*/
-#include <fenv.h>
+#define __fenv_static
+#include "fenv.h"
+
+#ifdef __GNUC_GNU_INLINE__
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
/*
* Hopefully the system ID byte is immutable, so it's valid to use
* this as a default environment.
*/
const fenv_t __fe_dfl_env = 0;
+
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+extern inline int feraiseexcept(int __excepts);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+extern inline int fegetenv(fenv_t *__envp);
+extern inline int feholdexcept(fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
+extern inline int feupdateenv(const fenv_t *__envp);
diff --git a/lib/msun/mips/fenv.h b/lib/msun/mips/fenv.h
index d540ae2..f114998 100644
--- a/lib/msun/mips/fenv.h
+++ b/lib/msun/mips/fenv.h
@@ -31,6 +31,10 @@
#include <sys/_types.h>
+#ifndef __fenv_static
+#define __fenv_static static
+#endif
+
typedef __uint32_t fenv_t;
typedef __uint32_t fexcept_t;
@@ -68,7 +72,7 @@ extern const fenv_t __fe_dfl_env;
#define __wfs(__fpsr)
#endif
-static __inline int
+__fenv_static inline int
feclearexcept(int __excepts)
{
fexcept_t __fpsr;
@@ -79,7 +83,7 @@ feclearexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
@@ -89,7 +93,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
@@ -101,7 +105,7 @@ fesetexceptflag(const fexcept_t *__flagp, int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
feraiseexcept(int __excepts)
{
fexcept_t __ex = __excepts;
@@ -110,7 +114,7 @@ feraiseexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fetestexcept(int __excepts)
{
fexcept_t __fpsr;
@@ -119,7 +123,7 @@ fetestexcept(int __excepts)
return (__fpsr & __excepts);
}
-static __inline int
+__fenv_static inline int
fegetround(void)
{
@@ -131,14 +135,14 @@ fegetround(void)
return (-1);
}
-static __inline int
+__fenv_static inline int
fesetround(int __round)
{
return (-1);
}
-static __inline int
+__fenv_static inline int
fegetenv(fenv_t *__envp)
{
@@ -146,7 +150,7 @@ fegetenv(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
fenv_t __env;
@@ -158,7 +162,7 @@ feholdexcept(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
@@ -166,7 +170,7 @@ fesetenv(const fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feupdateenv(const fenv_t *__envp)
{
fexcept_t __fpsr;
@@ -179,7 +183,9 @@ feupdateenv(const fenv_t *__envp)
#if __BSD_VISIBLE
-static __inline int
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
feenableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
@@ -190,7 +196,7 @@ feenableexcept(int __mask)
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
-static __inline int
+static inline int
fedisableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
@@ -201,7 +207,7 @@ fedisableexcept(int __mask)
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
-static __inline int
+static inline int
fegetexcept(void)
{
fenv_t __fpsr;
diff --git a/lib/msun/powerpc/Symbol.map b/lib/msun/powerpc/Symbol.map
index 3121177..971112e 100644
--- a/lib/msun/powerpc/Symbol.map
+++ b/lib/msun/powerpc/Symbol.map
@@ -3,3 +3,11 @@
*/
FBSD_1.0 {
};
+
+FBSD_1.3 {
+ fesetexceptflag;
+ feraiseexcept;
+ fegetenv;
+ feholdexcept;
+ feupdateenv;
+};
diff --git a/lib/msun/powerpc/fenv.c b/lib/msun/powerpc/fenv.c
index 04bbeaf..3f4801b 100644
--- a/lib/msun/powerpc/fenv.c
+++ b/lib/msun/powerpc/fenv.c
@@ -26,6 +26,23 @@
* $FreeBSD$
*/
-#include <fenv.h>
+#define __fenv_static
+#include "fenv.h"
+
+#ifdef __GNUC_GNU_INLINE__
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
const fenv_t __fe_dfl_env = 0x00000000;
+
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+extern inline int feraiseexcept(int __excepts);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+extern inline int fegetenv(fenv_t *__envp);
+extern inline int feholdexcept(fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
+extern inline int feupdateenv(const fenv_t *__envp);
diff --git a/lib/msun/powerpc/fenv.h b/lib/msun/powerpc/fenv.h
index c29f8a0..b96fdee 100644
--- a/lib/msun/powerpc/fenv.h
+++ b/lib/msun/powerpc/fenv.h
@@ -31,6 +31,10 @@
#include <sys/_types.h>
+#ifndef __fenv_static
+#define __fenv_static static
+#endif
+
typedef __uint32_t fenv_t;
typedef __uint32_t fexcept_t;
@@ -98,7 +102,7 @@ union __fpscr {
} __bits;
};
-static __inline int
+__fenv_static inline int
feclearexcept(int __excepts)
{
union __fpscr __r;
@@ -111,7 +115,7 @@ feclearexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
union __fpscr __r;
@@ -121,7 +125,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
union __fpscr __r;
@@ -135,7 +139,7 @@ fesetexceptflag(const fexcept_t *__flagp, int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
feraiseexcept(int __excepts)
{
union __fpscr __r;
@@ -148,7 +152,7 @@ feraiseexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fetestexcept(int __excepts)
{
union __fpscr __r;
@@ -157,7 +161,7 @@ fetestexcept(int __excepts)
return (__r.__bits.__reg & __excepts);
}
-static __inline int
+__fenv_static inline int
fegetround(void)
{
union __fpscr __r;
@@ -166,7 +170,7 @@ fegetround(void)
return (__r.__bits.__reg & _ROUND_MASK);
}
-static __inline int
+__fenv_static inline int
fesetround(int __round)
{
union __fpscr __r;
@@ -180,7 +184,7 @@ fesetround(int __round)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetenv(fenv_t *__envp)
{
union __fpscr __r;
@@ -190,7 +194,7 @@ fegetenv(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
union __fpscr __r;
@@ -202,7 +206,7 @@ feholdexcept(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
union __fpscr __r;
@@ -212,7 +216,7 @@ fesetenv(const fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feupdateenv(const fenv_t *__envp)
{
union __fpscr __r;
@@ -226,7 +230,9 @@ feupdateenv(const fenv_t *__envp)
#if __BSD_VISIBLE
-static __inline int
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
feenableexcept(int __mask)
{
union __fpscr __r;
@@ -239,7 +245,7 @@ feenableexcept(int __mask)
return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
}
-static __inline int
+static inline int
fedisableexcept(int __mask)
{
union __fpscr __r;
@@ -252,7 +258,7 @@ fedisableexcept(int __mask)
return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
}
-static __inline int
+static inline int
fegetexcept(void)
{
union __fpscr __r;
diff --git a/lib/msun/sparc64/Symbol.map b/lib/msun/sparc64/Symbol.map
index 3121177..971112e 100644
--- a/lib/msun/sparc64/Symbol.map
+++ b/lib/msun/sparc64/Symbol.map
@@ -3,3 +3,11 @@
*/
FBSD_1.0 {
};
+
+FBSD_1.3 {
+ fesetexceptflag;
+ feraiseexcept;
+ fegetenv;
+ feholdexcept;
+ feupdateenv;
+};
diff --git a/lib/msun/sparc64/fenv.c b/lib/msun/sparc64/fenv.c
index 6e8220f..c4d3e5d 100644
--- a/lib/msun/sparc64/fenv.c
+++ b/lib/msun/sparc64/fenv.c
@@ -26,7 +26,12 @@
* $FreeBSD$
*/
-#include <fenv.h>
+#define __fenv_static
+#include "fenv.h"
+
+#ifdef __GNUC_GNU_INLINE__
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
/*
* The FSR_version field may be different on different
@@ -34,3 +39,15 @@
* application. Thus, 0 is valid as the default environment.
*/
const fenv_t __fe_dfl_env = 0;
+
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+extern inline int feraiseexcept(int __excepts);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+extern inline int fegetenv(fenv_t *__envp);
+extern inline int feholdexcept(fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
+extern inline int feupdateenv(const fenv_t *__envp);
diff --git a/lib/msun/sparc64/fenv.h b/lib/msun/sparc64/fenv.h
index 8273299..d17361f 100644
--- a/lib/msun/sparc64/fenv.h
+++ b/lib/msun/sparc64/fenv.h
@@ -31,6 +31,10 @@
#include <sys/_types.h>
+#ifndef __fenv_static
+#define __fenv_static static
+#endif
+
typedef __uint64_t fenv_t;
typedef __uint64_t fexcept_t;
@@ -70,7 +74,7 @@ extern const fenv_t __fe_dfl_env;
#define __ldxfsr(__r) __asm __volatile("ldx %0, %%fsr" : : "m" (__r))
#define __stxfsr(__r) __asm __volatile("stx %%fsr, %0" : "=m" (*(__r)))
-static __inline int
+__fenv_static __inline int
feclearexcept(int __excepts)
{
fexcept_t __r;
@@ -81,7 +85,7 @@ feclearexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fexcept_t __r;
@@ -91,7 +95,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fexcept_t __r;
@@ -108,7 +112,7 @@ fesetexceptflag(const fexcept_t *__flagp, int __excepts)
* inline this function on sparc64 even when the arguments are not
* compile-time constants. Perhaps this depends on the register window.
*/
-static __inline int
+__fenv_static inline int
feraiseexcept(int __excepts)
{
volatile double d;
@@ -143,7 +147,7 @@ feraiseexcept(int __excepts)
return (0);
}
-static __inline int
+__fenv_static inline int
fetestexcept(int __excepts)
{
fexcept_t __r;
@@ -152,7 +156,7 @@ fetestexcept(int __excepts)
return (__r & __excepts);
}
-static __inline int
+__fenv_static inline int
fegetround(void)
{
fenv_t __r;
@@ -161,7 +165,7 @@ fegetround(void)
return ((__r >> _ROUND_SHIFT) & _ROUND_MASK);
}
-static __inline int
+__fenv_static inline int
fesetround(int __round)
{
fenv_t __r;
@@ -175,7 +179,7 @@ fesetround(int __round)
return (0);
}
-static __inline int
+__fenv_static inline int
fegetenv(fenv_t *__envp)
{
@@ -183,7 +187,7 @@ fegetenv(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
fenv_t __r;
@@ -195,7 +199,7 @@ feholdexcept(fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
@@ -203,7 +207,7 @@ fesetenv(const fenv_t *__envp)
return (0);
}
-static __inline int
+__fenv_static inline int
feupdateenv(const fenv_t *__envp)
{
fexcept_t __r;
@@ -216,7 +220,9 @@ feupdateenv(const fenv_t *__envp)
#if __BSD_VISIBLE
-static __inline int
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
feenableexcept(int __mask)
{
fenv_t __old_r, __new_r;
@@ -227,7 +233,7 @@ feenableexcept(int __mask)
return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
-static __inline int
+static inline int
fedisableexcept(int __mask)
{
fenv_t __old_r, __new_r;
@@ -238,7 +244,7 @@ fedisableexcept(int __mask)
return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
-static __inline int
+static inline int
fegetexcept(void)
{
fenv_t __r;
diff --git a/lib/msun/src/e_cosh.c b/lib/msun/src/e_cosh.c
index 11e6590..a363695 100644
--- a/lib/msun/src/e_cosh.c
+++ b/lib/msun/src/e_cosh.c
@@ -45,7 +45,6 @@ __ieee754_cosh(double x)
{
double t,w;
int32_t ix;
- u_int32_t lx;
/* High word of |x|. */
GET_HIGH_WORD(ix,x);
@@ -72,13 +71,8 @@ __ieee754_cosh(double x)
if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x));
/* |x| in [log(maxdouble), overflowthresold] */
- GET_LOW_WORD(lx,x);
- if (ix<0x408633CE ||
- ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
- w = __ieee754_exp(half*fabs(x));
- t = half*w;
- return t*w;
- }
+ if (ix<=0x408633CE)
+ return __ldexp_exp(fabs(x), -1);
/* |x| > overflowthresold, cosh(x) overflow */
return huge*huge;
diff --git a/lib/msun/src/e_coshf.c b/lib/msun/src/e_coshf.c
index 4a1d499..95a0d6e 100644
--- a/lib/msun/src/e_coshf.c
+++ b/lib/msun/src/e_coshf.c
@@ -51,11 +51,8 @@ __ieee754_coshf(float x)
if (ix < 0x42b17217) return half*__ieee754_expf(fabsf(x));
/* |x| in [log(maxfloat), overflowthresold] */
- if (ix<=0x42b2d4fc) {
- w = __ieee754_expf(half*fabsf(x));
- t = half*w;
- return t*w;
- }
+ if (ix<=0x42b2d4fc)
+ return __ldexp_expf(fabsf(x), -1);
/* |x| > overflowthresold, cosh(x) overflow */
return huge*huge;
diff --git a/lib/msun/src/e_exp.c b/lib/msun/src/e_exp.c
index 5b9a10c..b47aef5 100644
--- a/lib/msun/src/e_exp.c
+++ b/lib/msun/src/e_exp.c
@@ -76,6 +76,8 @@ __FBSDID("$FreeBSD$");
* to produce the hexadecimal values shown.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -133,7 +135,7 @@ __ieee754_exp(double x) /* default IEEE double exp */
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
- x = hi - lo;
+ STRICT_ASSIGN(double, x, hi - lo);
}
else if(hx < 0x3e300000) { /* when |x|<2**-28 */
if(huge+x>one) return one+x;/* trigger inexact */
diff --git a/lib/msun/src/e_expf.c b/lib/msun/src/e_expf.c
index 502e421..a479076 100644
--- a/lib/msun/src/e_expf.c
+++ b/lib/msun/src/e_expf.c
@@ -16,6 +16,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -40,7 +42,7 @@ P2 = -2.7667332906e-3; /* -0xb55215.0p-32 */
static volatile float twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
float
-__ieee754_expf(float x) /* default IEEE double exp */
+__ieee754_expf(float x)
{
float y,hi=0.0,lo=0.0,c,t,twopk;
int32_t k=0,xsb;
@@ -70,7 +72,7 @@ __ieee754_expf(float x) /* default IEEE double exp */
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
- x = hi - lo;
+ STRICT_ASSIGN(float, x, hi - lo);
}
else if(hx < 0x39000000) { /* when |x|<2**-14 */
if(huge+x>one) return one+x;/* trigger inexact */
diff --git a/lib/msun/src/e_hypot.c b/lib/msun/src/e_hypot.c
index fb498c1..2398e98 100644
--- a/lib/msun/src/e_hypot.c
+++ b/lib/msun/src/e_hypot.c
@@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$");
double
__ieee754_hypot(double x, double y)
{
- double a=x,b=y,t1,t2,y1,y2,w;
+ double a,b,t1,t2,y1,y2,w;
int32_t j,k,ha,hb;
GET_HIGH_WORD(ha,x);
diff --git a/lib/msun/src/e_hypotf.c b/lib/msun/src/e_hypotf.c
index c82c6e7..6d083e4 100644
--- a/lib/msun/src/e_hypotf.c
+++ b/lib/msun/src/e_hypotf.c
@@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$");
float
__ieee754_hypotf(float x, float y)
{
- float a=x,b=y,t1,t2,y1,y2,w;
+ float a,b,t1,t2,y1,y2,w;
int32_t j,k,ha,hb;
GET_FLOAT_WORD(ha,x);
diff --git a/lib/msun/src/e_hypotl.c b/lib/msun/src/e_hypotl.c
index 0c899bf..7b5ab89 100644
--- a/lib/msun/src/e_hypotl.c
+++ b/lib/msun/src/e_hypotl.c
@@ -21,13 +21,6 @@ __FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
-#define GET_LDBL_EXPSIGN(i, v) do { \
- union IEEEl2bits uv; \
- \
- uv.e = v; \
- i = uv.xbits.expsign; \
-} while (0)
-
#define GET_LDBL_MAN(h, l, v) do { \
union IEEEl2bits uv; \
\
@@ -36,14 +29,6 @@ __FBSDID("$FreeBSD$");
l = uv.bits.manl; \
} while (0)
-#define SET_LDBL_EXPSIGN(v, i) do { \
- union IEEEl2bits uv; \
- \
- uv.e = v; \
- uv.xbits.expsign = i; \
- v = uv.e; \
-} while (0)
-
#undef GET_HIGH_WORD
#define GET_HIGH_WORD(i, v) GET_LDBL_EXPSIGN(i, v)
#undef SET_HIGH_WORD
diff --git a/lib/msun/src/e_lgamma_r.c b/lib/msun/src/e_lgamma_r.c
index a587b8f..1cff592 100644
--- a/lib/msun/src/e_lgamma_r.c
+++ b/lib/msun/src/e_lgamma_r.c
@@ -269,7 +269,6 @@ __ieee754_lgamma_r(double x, int *signgamp)
}
else if(ix<0x40200000) { /* x < 8.0 */
i = (int)x;
- t = zero;
y = x-(double)i;
p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
diff --git a/lib/msun/src/e_lgammaf_r.c b/lib/msun/src/e_lgammaf_r.c
index 47c6ed0..e2d90ef 100644
--- a/lib/msun/src/e_lgammaf_r.c
+++ b/lib/msun/src/e_lgammaf_r.c
@@ -202,7 +202,6 @@ __ieee754_lgammaf_r(float x, int *signgamp)
}
else if(ix<0x41000000) { /* x < 8.0 */
i = (int)x;
- t = zero;
y = x-(float)i;
p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
diff --git a/lib/msun/src/e_log10.c b/lib/msun/src/e_log10.c
index 135f0dc..104d257 100644
--- a/lib/msun/src/e_log10.c
+++ b/lib/msun/src/e_log10.c
@@ -15,7 +15,11 @@
__FBSDID("$FreeBSD$");
/*
- * Return the base 10 logarithm of x. See k_log.c for details on the algorithm.
+ * Return the base 10 logarithm of x. See e_log.c and k_log.h for most
+ * comments.
+ *
+ * log10(x) = (f - 0.5*f*f + k_log1p(f)) / ln10 + k * log10(2)
+ * in not-quite-routine extra precision.
*/
#include "math.h"
@@ -34,31 +38,50 @@ static const double zero = 0.0;
double
__ieee754_log10(double x)
{
- double f,hi,lo,y,z;
+ double f,hfsq,hi,lo,r,val_hi,val_lo,w,y,y2;
int32_t i,k,hx;
u_int32_t lx;
EXTRACT_WORDS(hx,lx,x);
- k=0;
- if (hx < 0x00100000) { /* x < 2**-1022 */
- if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 54; x *= two54; /* subnormal number, scale up x */
+ k=0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx&0x7fffffff)|lx)==0)
+ return -two54/zero; /* 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);
- }
+ }
if (hx >= 0x7ff00000) return x+x;
+ if (hx == 0x3ff00000 && lx == 0)
+ return zero; /* log(1) = +0 */
k += (hx>>20)-1023;
hx &= 0x000fffff;
i = (hx+0x95f64)&0x100000;
SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
k += (i>>20);
y = (double)k;
- f = __kernel_log(x);
- hi = x = x - 1;
+ f = x - 1.0;
+ hfsq = 0.5*f*f;
+ r = k_log1p(f);
+
+ /* See e_log2.c for most details. */
+ hi = f - hfsq;
SET_LOW_WORD(hi,0);
- lo = x - hi;
- z = y*log10_2lo + (x+f)*ivln10lo + (lo+f)*ivln10hi + hi*ivln10hi;
- return z+y*log10_2hi;
+ lo = (f - hi) - hfsq + r;
+ val_hi = hi*ivln10hi;
+ y2 = y*log10_2hi;
+ val_lo = y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi;
+
+ /*
+ * Extra precision in for adding y*log10_2hi is not strictly needed
+ * since there is no very large cancellation near x = sqrt(2) or
+ * x = 1/sqrt(2), but we do it anyway since it costs little on CPUs
+ * with some parallelism and it reduces the error for many args.
+ */
+ w = y2 + val_hi;
+ val_lo += (y2 - w) + val_hi;
+ val_hi = w;
+
+ return val_lo + val_hi;
}
diff --git a/lib/msun/src/e_log10f.c b/lib/msun/src/e_log10f.c
index 940b831..c876594 100644
--- a/lib/msun/src/e_log10f.c
+++ b/lib/msun/src/e_log10f.c
@@ -13,7 +13,7 @@
__FBSDID("$FreeBSD$");
/*
- * Return the base 10 logarithm of x. See k_log.c for details on the algorithm.
+ * Float version of e_log10.c. See the latter for most comments.
*/
#include "math.h"
@@ -32,31 +32,40 @@ static const float zero = 0.0;
float
__ieee754_log10f(float x)
{
- float f,hi,lo,y,z;
+ float f,hfsq,hi,lo,r,y;
int32_t i,k,hx;
GET_FLOAT_WORD(hx,x);
- k=0;
- if (hx < 0x00800000) { /* x < 2**-126 */
- if ((hx&0x7fffffff)==0)
- return -two25/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 25; x *= two25; /* subnormal number, scale up x */
+ k=0;
+ if (hx < 0x00800000) { /* x < 2**-126 */
+ if ((hx&0x7fffffff)==0)
+ return -two25/zero; /* 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);
- }
+ }
if (hx >= 0x7f800000) return x+x;
+ if (hx == 0x3f800000)
+ return zero; /* log(1) = +0 */
k += (hx>>23)-127;
hx &= 0x007fffff;
i = (hx+(0x4afb0d))&0x800000;
SET_FLOAT_WORD(x,hx|(i^0x3f800000)); /* normalize x or x/2 */
k += (i>>23);
y = (float)k;
- f = __kernel_logf(x);
- x = x - (float)1.0;
- GET_FLOAT_WORD(hx,x);
+ f = x - (float)1.0;
+ hfsq = (float)0.5*f*f;
+ r = k_log1pf(f);
+
+ /* See e_log2f.c and e_log2.c for details. */
+ if (sizeof(float_t) > sizeof(float))
+ return (r - hfsq + f) * ((float_t)ivln10lo + ivln10hi) +
+ y * ((float_t)log10_2lo + log10_2hi);
+ hi = f - hfsq;
+ GET_FLOAT_WORD(hx,hi);
SET_FLOAT_WORD(hi,hx&0xfffff000);
- lo = x - hi;
- z = y*log10_2lo + (x+f)*ivln10lo + (lo+f)*ivln10hi + hi*ivln10hi;
- return z+y*log10_2hi;
+ lo = (f - hi) - hfsq + r;
+ return y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi + hi*ivln10hi +
+ y*log10_2hi;
}
diff --git a/lib/msun/src/e_log2.c b/lib/msun/src/e_log2.c
index 6cf3dbc..1fc44a5 100644
--- a/lib/msun/src/e_log2.c
+++ b/lib/msun/src/e_log2.c
@@ -15,7 +15,13 @@
__FBSDID("$FreeBSD$");
/*
- * Return the base 2 logarithm of x. See k_log.c for details on the algorithm.
+ * Return the base 2 logarithm of x. See e_log.c and k_log.h for most
+ * comments.
+ *
+ * This reduces x to {k, 1+f} exactly as in e_log.c, then calls the kernel,
+ * then does the combining and scaling steps
+ * log2(x) = (f - 0.5*f*f + k_log1p(f)) / ln2 + k
+ * in not-quite-routine extra precision.
*/
#include "math.h"
@@ -32,29 +38,73 @@ static const double zero = 0.0;
double
__ieee754_log2(double x)
{
- double f,hi,lo;
+ double f,hfsq,hi,lo,r,val_hi,val_lo,w,y;
int32_t i,k,hx;
u_int32_t lx;
EXTRACT_WORDS(hx,lx,x);
- k=0;
- if (hx < 0x00100000) { /* x < 2**-1022 */
- if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 54; x *= two54; /* subnormal number, scale up x */
+ k=0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx&0x7fffffff)|lx)==0)
+ return -two54/zero; /* 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);
- }
+ }
if (hx >= 0x7ff00000) return x+x;
+ if (hx == 0x3ff00000 && lx == 0)
+ return zero; /* log(1) = +0 */
k += (hx>>20)-1023;
hx &= 0x000fffff;
i = (hx+0x95f64)&0x100000;
SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
k += (i>>20);
- f = __kernel_log(x);
- hi = x = x - 1;
+ y = (double)k;
+ f = x - 1.0;
+ hfsq = 0.5*f*f;
+ r = k_log1p(f);
+
+ /*
+ * f-hfsq must (for args near 1) be evaluated in extra precision
+ * to avoid a large cancellation when x is near sqrt(2) or 1/sqrt(2).
+ * This is fairly efficient since f-hfsq only depends on f, so can
+ * be evaluated in parallel with R. Not combining hfsq with R also
+ * keeps R small (though not as small as a true `lo' term would be),
+ * so that extra precision is not needed for terms involving R.
+ *
+ * Compiler bugs involving extra precision used to break Dekker's
+ * theorem for spitting f-hfsq as hi+lo, unless double_t was used
+ * or the multi-precision calculations were avoided when double_t
+ * has extra precision. These problems are now automatically
+ * avoided as a side effect of the optimization of combining the
+ * Dekker splitting step with the clear-low-bits step.
+ *
+ * y must (for args near sqrt(2) and 1/sqrt(2)) be added in extra
+ * precision to avoid a very large cancellation when x is very near
+ * these values. Unlike the above cancellations, this problem is
+ * specific to base 2. It is strange that adding +-1 is so much
+ * harder than adding +-ln2 or +-log10_2.
+ *
+ * This uses Dekker's theorem to normalize y+val_hi, so the
+ * compiler bugs are back in some configurations, sigh. And I
+ * don't want to used double_t to avoid them, since that gives a
+ * pessimization and the support for avoiding the pessimization
+ * is not yet available.
+ *
+ * The multi-precision calculations for the multiplications are
+ * routine.
+ */
+ hi = f - hfsq;
SET_LOW_WORD(hi,0);
- lo = x - hi;
- return (x+f)*ivln2lo + (lo+f)*ivln2hi + hi*ivln2hi + k;
+ lo = (f - hi) - hfsq + r;
+ val_hi = hi*ivln2hi;
+ val_lo = (lo+hi)*ivln2lo + lo*ivln2hi;
+
+ /* spadd(val_hi, val_lo, y), except for not using double_t: */
+ w = y + val_hi;
+ val_lo += (y - w) + val_hi;
+ val_hi = w;
+
+ return val_lo + val_hi;
}
diff --git a/lib/msun/src/e_log2f.c b/lib/msun/src/e_log2f.c
index bb308d3..7166346 100644
--- a/lib/msun/src/e_log2f.c
+++ b/lib/msun/src/e_log2f.c
@@ -13,7 +13,7 @@
__FBSDID("$FreeBSD$");
/*
- * Return the base 2 logarithm of x. See k_log.c for details on the algorithm.
+ * Float version of e_log2.c. See the latter for most comments.
*/
#include "math.h"
@@ -30,29 +30,52 @@ static const float zero = 0.0;
float
__ieee754_log2f(float x)
{
- float f,hi,lo;
+ float f,hfsq,hi,lo,r,y;
int32_t i,k,hx;
GET_FLOAT_WORD(hx,x);
- k=0;
- if (hx < 0x00800000) { /* x < 2**-126 */
- if ((hx&0x7fffffff)==0)
- return -two25/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 25; x *= two25; /* subnormal number, scale up x */
+ k=0;
+ if (hx < 0x00800000) { /* x < 2**-126 */
+ if ((hx&0x7fffffff)==0)
+ return -two25/zero; /* 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);
- }
+ }
if (hx >= 0x7f800000) return x+x;
+ if (hx == 0x3f800000)
+ return zero; /* log(1) = +0 */
k += (hx>>23)-127;
hx &= 0x007fffff;
i = (hx+(0x4afb0d))&0x800000;
SET_FLOAT_WORD(x,hx|(i^0x3f800000)); /* normalize x or x/2 */
k += (i>>23);
- f = __kernel_logf(x);
- x = x - (float)1.0;
- GET_FLOAT_WORD(hx,x);
+ y = (float)k;
+ f = x - (float)1.0;
+ hfsq = (float)0.5*f*f;
+ r = k_log1pf(f);
+
+ /*
+ * We no longer need to avoid falling into the multi-precision
+ * calculations due to compiler bugs breaking Dekker's theorem.
+ * Keep avoiding this as an optimization. See e_log2.c for more
+ * details (some details are here only because the optimization
+ * is not yet available in double precision).
+ *
+ * Another compiler bug turned up. With gcc on i386,
+ * (ivln2lo + ivln2hi) would be evaluated in float precision
+ * despite runtime evaluations using double precision. So we
+ * must cast one of its terms to float_t. This makes the whole
+ * expression have type float_t, so return is forced to waste
+ * time clobbering its extra precision.
+ */
+ if (sizeof(float_t) > sizeof(float))
+ return (r - hfsq + f) * ((float_t)ivln2lo + ivln2hi) + y;
+
+ hi = f - hfsq;
+ GET_FLOAT_WORD(hx,hi);
SET_FLOAT_WORD(hi,hx&0xfffff000);
- lo = x - hi;
- return (x+f)*ivln2lo + (lo+f)*ivln2hi + hi*ivln2hi + k;
+ lo = (f - hi) - hfsq + r;
+ return (lo+hi)*ivln2lo + lo*ivln2hi + hi*ivln2hi + y;
}
diff --git a/lib/msun/src/e_pow.c b/lib/msun/src/e_pow.c
index 4aa00d5..7607a4a 100644
--- a/lib/msun/src/e_pow.c
+++ b/lib/msun/src/e_pow.c
@@ -109,6 +109,9 @@ __ieee754_pow(double x, double y)
/* y==zero: x**0 = 1 */
if((iy|ly)==0) return one;
+ /* x==1: 1**y = 1, even if y is NaN */
+ if (hx==0x3ff00000 && lx == 0) return one;
+
/* y!=zero: result is NaN if either arg is NaN */
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
@@ -138,7 +141,7 @@ __ieee754_pow(double x, double y)
if(ly==0) {
if (iy==0x7ff00000) { /* y is +-inf */
if(((ix-0x3ff00000)|lx)==0)
- return y - y; /* inf**+-1 is NaN */
+ return one; /* (-1)**+-inf is NaN */
else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */
diff --git a/lib/msun/src/e_powf.c b/lib/msun/src/e_powf.c
index 466ed72..5c46478 100644
--- a/lib/msun/src/e_powf.c
+++ b/lib/msun/src/e_powf.c
@@ -67,6 +67,9 @@ __ieee754_powf(float x, float y)
/* y==zero: x**0 = 1 */
if(iy==0) return one;
+ /* x==1: 1**y = 1, even if y is NaN */
+ if (hx==0x3f800000) return one;
+
/* y!=zero: result is NaN if either arg is NaN */
if(ix > 0x7f800000 ||
iy > 0x7f800000)
@@ -90,7 +93,7 @@ __ieee754_powf(float x, float y)
/* special value of y */
if (iy==0x7f800000) { /* y is +-inf */
if (ix==0x3f800000)
- return y - y; /* inf**+-1 is NaN */
+ return one; /* (-1)**+-inf is NaN */
else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */
diff --git a/lib/msun/src/e_sinh.c b/lib/msun/src/e_sinh.c
index afb8e43..17442d0 100644
--- a/lib/msun/src/e_sinh.c
+++ b/lib/msun/src/e_sinh.c
@@ -40,9 +40,8 @@ static const double one = 1.0, shuge = 1.0e307;
double
__ieee754_sinh(double x)
{
- double t,w,h;
+ double t,h;
int32_t ix,jx;
- u_int32_t lx;
/* High word of |x|. */
GET_HIGH_WORD(jx,x);
@@ -66,12 +65,8 @@ __ieee754_sinh(double x)
if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x));
/* |x| in [log(maxdouble), overflowthresold] */
- GET_LOW_WORD(lx,x);
- if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
- w = __ieee754_exp(0.5*fabs(x));
- t = h*w;
- return t*w;
- }
+ if (ix<=0x408633CE)
+ return h*2.0*__ldexp_exp(fabs(x), -1);
/* |x| > overflowthresold, sinh(x) overflow */
return x*shuge;
diff --git a/lib/msun/src/e_sinhf.c b/lib/msun/src/e_sinhf.c
index 0f96b2b..1be2dc3 100644
--- a/lib/msun/src/e_sinhf.c
+++ b/lib/msun/src/e_sinhf.c
@@ -24,7 +24,7 @@ static const float one = 1.0, shuge = 1.0e37;
float
__ieee754_sinhf(float x)
{
- float t,w,h;
+ float t,h;
int32_t ix,jx;
GET_FLOAT_WORD(jx,x);
@@ -48,11 +48,8 @@ __ieee754_sinhf(float x)
if (ix < 0x42b17217) return h*__ieee754_expf(fabsf(x));
/* |x| in [logf(maxfloat), overflowthresold] */
- if (ix<=0x42b2d4fc) {
- w = __ieee754_expf((float)0.5*fabsf(x));
- t = h*w;
- return t*w;
- }
+ if (ix<=0x42b2d4fc)
+ return h*2.0F*__ldexp_expf(fabsf(x), -1);
/* |x| > overflowthresold, sinh(x) overflow */
return x*shuge;
diff --git a/lib/msun/src/k_exp.c b/lib/msun/src/k_exp.c
new file mode 100644
index 0000000..f592f69
--- /dev/null
+++ b/lib/msun/src/k_exp.c
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2011 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const uint32_t k = 1799; /* constant for reduction */
+static const double kln2 = 1246.97177782734161156; /* k * ln2 */
+
+/*
+ * Compute exp(x), scaled to avoid spurious overflow. An exponent is
+ * returned separately in 'expt'.
+ *
+ * Input: ln(DBL_MAX) <= x < ln(2 * DBL_MAX / DBL_MIN_DENORM) ~= 1454.91
+ * Output: 2**1023 <= y < 2**1024
+ */
+static double
+__frexp_exp(double x, int *expt)
+{
+ double exp_x;
+ uint32_t hx;
+
+ /*
+ * We use exp(x) = exp(x - kln2) * 2**k, carefully chosen to
+ * minimize |exp(kln2) - 2**k|. We also scale the exponent of
+ * exp_x to MAX_EXP so that the result can be multiplied by
+ * a tiny number without losing accuracy due to denormalization.
+ */
+ exp_x = exp(x - kln2);
+ GET_HIGH_WORD(hx, exp_x);
+ *expt = (hx >> 20) - (0x3ff + 1023) + k;
+ SET_HIGH_WORD(exp_x, (hx & 0xfffff) | ((0x3ff + 1023) << 20));
+ return (exp_x);
+}
+
+/*
+ * __ldexp_exp(x, expt) and __ldexp_cexp(x, expt) compute exp(x) * 2**expt.
+ * They are intended for large arguments (real part >= ln(DBL_MAX))
+ * where care is needed to avoid overflow.
+ *
+ * The present implementation is narrowly tailored for our hyperbolic and
+ * exponential functions. We assume expt is small (0 or -1), and the caller
+ * has filtered out very large x, for which overflow would be inevitable.
+ */
+
+double
+__ldexp_exp(double x, int expt)
+{
+ double exp_x, scale;
+ int ex_expt;
+
+ exp_x = __frexp_exp(x, &ex_expt);
+ expt += ex_expt;
+ INSERT_WORDS(scale, (0x3ff + expt) << 20, 0);
+ return (exp_x * scale);
+}
+
+double complex
+__ldexp_cexp(double complex z, int expt)
+{
+ double x, y, exp_x, scale1, scale2;
+ int ex_expt, half_expt;
+
+ x = creal(z);
+ y = cimag(z);
+ exp_x = __frexp_exp(x, &ex_expt);
+ expt += ex_expt;
+
+ /*
+ * Arrange so that scale1 * scale2 == 2**expt. We use this to
+ * compensate for scalbn being horrendously slow.
+ */
+ half_expt = expt / 2;
+ INSERT_WORDS(scale1, (0x3ff + half_expt) << 20, 0);
+ half_expt = expt - half_expt;
+ INSERT_WORDS(scale2, (0x3ff + half_expt) << 20, 0);
+
+ return (cpack(cos(y) * exp_x * scale1 * scale2,
+ sin(y) * exp_x * scale1 * scale2));
+}
diff --git a/lib/msun/src/k_expf.c b/lib/msun/src/k_expf.c
new file mode 100644
index 0000000..a860b9f
--- /dev/null
+++ b/lib/msun/src/k_expf.c
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2011 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+
+#include "math.h"
+#include "math_private.h"
+
+static const uint32_t k = 235; /* constant for reduction */
+static const float kln2 = 162.88958740F; /* k * ln2 */
+
+/*
+ * See k_exp.c for details.
+ *
+ * Input: ln(FLT_MAX) <= x < ln(2 * FLT_MAX / FLT_MIN_DENORM) ~= 192.7
+ * Output: 2**127 <= y < 2**128
+ */
+static float
+__frexp_expf(float x, int *expt)
+{
+ double exp_x;
+ uint32_t hx;
+
+ exp_x = expf(x - kln2);
+ GET_FLOAT_WORD(hx, exp_x);
+ *expt = (hx >> 23) - (0x7f + 127) + k;
+ SET_FLOAT_WORD(exp_x, (hx & 0x7fffff) | ((0x7f + 127) << 23));
+ return (exp_x);
+}
+
+float
+__ldexp_expf(float x, int expt)
+{
+ float exp_x, scale;
+ int ex_expt;
+
+ exp_x = __frexp_expf(x, &ex_expt);
+ expt += ex_expt;
+ SET_FLOAT_WORD(scale, (0x7f + expt) << 23);
+ return (exp_x * scale);
+}
+
+float complex
+__ldexp_cexpf(float complex z, int expt)
+{
+ float x, y, exp_x, scale1, scale2;
+ int ex_expt, half_expt;
+
+ x = crealf(z);
+ y = cimagf(z);
+ exp_x = __frexp_expf(x, &ex_expt);
+ expt += ex_expt;
+
+ half_expt = expt / 2;
+ SET_FLOAT_WORD(scale1, (0x7f + half_expt) << 23);
+ half_expt = expt - half_expt;
+ SET_FLOAT_WORD(scale2, (0x7f + half_expt) << 23);
+
+ return (cpackf(cosf(y) * exp_x * scale1 * scale2,
+ sinf(y) * exp_x * scale1 * scale2));
+}
diff --git a/lib/msun/src/k_log.h b/lib/msun/src/k_log.h
index 206355c..aaff8bd 100644
--- a/lib/msun/src/k_log.h
+++ b/lib/msun/src/k_log.h
@@ -14,8 +14,9 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-/* __kernel_log(x)
- * Return log(x) - (x-1) for x in ~[sqrt(2)/2, sqrt(2)].
+/*
+ * k_log1p(f):
+ * Return log(1+f) - f for 1+f in ~[sqrt(2)/2, sqrt(2)].
*
* The following describes the overall strategy for computing
* logarithms in base e. The argument reduction and adding the final
@@ -80,37 +81,20 @@ Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
/*
- * We always inline __kernel_log(), since doing so produces a
+ * We always inline k_log1p(), since doing so produces a
* substantial performance improvement (~40% on amd64).
*/
static inline double
-__kernel_log(double x)
+k_log1p(double f)
{
- double hfsq,f,s,z,R,w,t1,t2;
- int32_t hx,i,j;
- u_int32_t lx;
-
- EXTRACT_WORDS(hx,lx,x);
+ double hfsq,s,z,R,w,t1,t2;
- f = x-1.0;
- if((0x000fffff&(2+hx))<3) { /* -2**-20 <= f < 2**-20 */
- if(f==0.0) return 0.0;
- return f*f*(0.33333333333333333*f-0.5);
- }
- s = f/(2.0+f);
+ s = f/(2.0+f);
z = s*s;
- hx &= 0x000fffff;
- i = hx-0x6147a;
w = z*z;
- j = 0x6b851-hx;
- t1= w*(Lg2+w*(Lg4+w*Lg6));
- t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- i |= j;
+ t1= w*(Lg2+w*(Lg4+w*Lg6));
+ t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
R = t2+t1;
- if (i>0) {
- hfsq=0.5*f*f;
- return s*(hfsq+R) - hfsq;
- } else {
- return s*(R-f);
- }
+ hfsq=0.5*f*f;
+ return s*(hfsq+R);
}
diff --git a/lib/msun/src/k_logf.h b/lib/msun/src/k_logf.h
index d9f0f3d..71c547e 100644
--- a/lib/msun/src/k_logf.h
+++ b/lib/msun/src/k_logf.h
@@ -13,7 +13,7 @@
__FBSDID("$FreeBSD$");
/*
- * float version of __kernel_log(x). See k_log.c for details.
+ * Float version of k_log.h. See the latter for most comments.
*/
static const float
@@ -24,32 +24,16 @@ Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
static inline float
-__kernel_logf(float x)
+k_log1pf(float f)
{
- float hfsq,f,s,z,R,w,t1,t2;
- int32_t ix,i,j;
+ float hfsq,s,z,R,w,t1,t2;
- GET_FLOAT_WORD(ix,x);
-
- f = x-(float)1.0;
- if((0x007fffff&(0x8000+ix))<0xc000) { /* -2**-9 <= f < 2**-9 */
- if(f==0.0f) return 0.0f;
- return f*f*((float)0.33333333333333333*f-(float)0.5);
- }
s = f/((float)2.0+f);
z = s*s;
- ix &= 0x007fffff;
- i = ix-(0x6147a<<3);
w = z*z;
- j = (0x6b851<<3)-ix;
t1= w*(Lg2+w*Lg4);
t2= z*(Lg1+w*Lg3);
- i |= j;
R = t2+t1;
- if(i>0) {
- hfsq=(float)0.5*f*f;
- return s*(hfsq+R) - hfsq;
- } else {
- return s*(R-f);
- }
+ hfsq=(float)0.5*f*f;
+ return s*(hfsq+R);
}
diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h
index 8ad13ed..69b138e 100644
--- a/lib/msun/src/math.h
+++ b/lib/msun/src/math.h
@@ -68,14 +68,11 @@ extern const union __nan_un {
#define MATH_ERREXCEPT 2
#define math_errhandling MATH_ERREXCEPT
-/* XXX We need a <machine/math.h>. */
-#if defined(__ia64__) || defined(__sparc64__)
-#define FP_FAST_FMA 1
-#endif
+#define FP_FAST_FMAF 1
#ifdef __ia64__
+#define FP_FAST_FMA 1
#define FP_FAST_FMAL 1
#endif
-#define FP_FAST_FMAF 1
/* Symbolic constants to classify floating point numbers. */
#define FP_INFINITE 0x01
diff --git a/lib/msun/src/math_private.h b/lib/msun/src/math_private.h
index d79f808..79280e3 100644
--- a/lib/msun/src/math_private.h
+++ b/lib/msun/src/math_private.h
@@ -58,6 +58,10 @@ typedef union
u_int32_t msw;
u_int32_t lsw;
} parts;
+ struct
+ {
+ u_int64_t w;
+ } xparts;
} ieee_double_shape_type;
#endif
@@ -72,6 +76,10 @@ typedef union
u_int32_t lsw;
u_int32_t msw;
} parts;
+ struct
+ {
+ u_int64_t w;
+ } xparts;
} ieee_double_shape_type;
#endif
@@ -86,6 +94,14 @@ do { \
(ix1) = ew_u.parts.lsw; \
} while (0)
+/* Get a 64-bit int from a double. */
+#define EXTRACT_WORD64(ix,d) \
+do { \
+ ieee_double_shape_type ew_u; \
+ ew_u.value = (d); \
+ (ix) = ew_u.xparts.w; \
+} while (0)
+
/* Get the more significant 32 bit int from a double. */
#define GET_HIGH_WORD(i,d) \
@@ -114,6 +130,14 @@ do { \
(d) = iw_u.value; \
} while (0)
+/* Set a double from a 64-bit int. */
+#define INSERT_WORD64(d,ix) \
+do { \
+ ieee_double_shape_type iw_u; \
+ iw_u.xparts.w = (ix); \
+ (d) = iw_u.value; \
+} while (0)
+
/* Set the more significant 32 bits of a double from an int. */
#define SET_HIGH_WORD(d,v) \
@@ -164,6 +188,25 @@ do { \
(d) = sf_u.value; \
} while (0)
+/* Get expsign as a 16 bit int from a long double. */
+
+#define GET_LDBL_EXPSIGN(i,d) \
+do { \
+ union IEEEl2bits ge_u; \
+ ge_u.e = (d); \
+ (i) = ge_u.xbits.expsign; \
+} while (0)
+
+/* Set expsign of a long double from a 16 bit int. */
+
+#define SET_LDBL_EXPSIGN(d,v) \
+do { \
+ union IEEEl2bits se_u; \
+ se_u.e = (d); \
+ se_u.xbits.expsign = (v); \
+ (d) = se_u.e; \
+} while (0)
+
#ifdef FLT_EVAL_METHOD
/*
* Attempt to get strict C99 semantics for assignment with non-C99 compilers.
@@ -354,6 +397,10 @@ int __ieee754_rem_pio2(double,double*);
double __kernel_sin(double,double,int);
double __kernel_cos(double,double);
double __kernel_tan(double,double,int);
+double __ldexp_exp(double,int);
+#ifdef _COMPLEX_H
+double complex __ldexp_cexp(double complex,int);
+#endif
/* float precision kernel functions */
#ifdef INLINE_REM_PIO2F
@@ -372,6 +419,10 @@ float __kernel_cosdf(double);
__inline
#endif
float __kernel_tandf(double,int);
+float __ldexp_expf(float,int);
+#ifdef _COMPLEX_H
+float complex __ldexp_cexpf(float complex,int);
+#endif
/* long double precision kernel functions */
long double __kernel_sinl(long double, long double, int);
diff --git a/lib/msun/src/s_ccosh.c b/lib/msun/src/s_ccosh.c
new file mode 100644
index 0000000..9ea962b
--- /dev/null
+++ b/lib/msun/src/s_ccosh.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * 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.
+ */
+
+/*
+ * Hyperbolic cosine of a complex argument z = x + i y.
+ *
+ * cosh(z) = cosh(x+iy)
+ * = cosh(x) cos(y) + i sinh(x) sin(y).
+ *
+ * Exceptional values are noted in the comments within the source code.
+ * These values and the return value were taken from n1124.pdf.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const double huge = 0x1p1023;
+
+double complex
+ccosh(double complex z)
+{
+ double x, y, h;
+ int32_t hx, hy, ix, iy, lx, ly;
+
+ x = creal(z);
+ y = cimag(z);
+
+ EXTRACT_WORDS(hx, lx, x);
+ EXTRACT_WORDS(hy, ly, y);
+
+ ix = 0x7fffffff & hx;
+ iy = 0x7fffffff & hy;
+
+ /* Handle the nearly-non-exceptional cases where x and y are finite. */
+ if (ix < 0x7ff00000 && iy < 0x7ff00000) {
+ if ((iy | ly) == 0)
+ return (cpack(cosh(x), x * y));
+ if (ix < 0x40360000) /* small x: normal case */
+ return (cpack(cosh(x) * cos(y), sinh(x) * sin(y)));
+
+ /* |x| >= 22, so cosh(x) ~= exp(|x|) */
+ if (ix < 0x40862e42) {
+ /* x < 710: exp(|x|) won't overflow */
+ h = exp(fabs(x)) * 0.5;
+ return (cpack(h * cos(y), copysign(h, x) * sin(y)));
+ } else if (ix < 0x4096bbaa) {
+ /* x < 1455: scale to avoid overflow */
+ z = __ldexp_cexp(cpack(fabs(x), y), -1);
+ return (cpack(creal(z), cimag(z) * copysign(1, x)));
+ } else {
+ /* x >= 1455: the result always overflows */
+ h = huge * x;
+ return (cpack(h * h * cos(y), h * sin(y)));
+ }
+ }
+
+ /*
+ * cosh(+-0 +- I Inf) = dNaN + I sign(d(+-0, dNaN))0.
+ * The sign of 0 in the result is unspecified. Choice = normally
+ * the same as dNaN. Raise the invalid floating-point exception.
+ *
+ * cosh(+-0 +- I NaN) = d(NaN) + I sign(d(+-0, NaN))0.
+ * The sign of 0 in the result is unspecified. Choice = normally
+ * the same as d(NaN).
+ */
+ if ((ix | lx) == 0 && iy >= 0x7ff00000)
+ return (cpack(y - y, copysign(0, x * (y - y))));
+
+ /*
+ * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0.
+ *
+ * cosh(NaN +- I 0) = d(NaN) + I sign(d(NaN, +-0))0.
+ * The sign of 0 in the result is unspecified.
+ */
+ if ((iy | ly) == 0 && ix >= 0x7ff00000) {
+ if (((hx & 0xfffff) | lx) == 0)
+ return (cpack(x * x, copysign(0, x) * y));
+ return (cpack(x * x, copysign(0, (x + x) * y)));
+ }
+
+ /*
+ * cosh(x +- I Inf) = dNaN + I dNaN.
+ * Raise the invalid floating-point exception for finite nonzero x.
+ *
+ * cosh(x + I NaN) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception for finite
+ * nonzero x. Choice = don't raise (except for signaling NaNs).
+ */
+ if (ix < 0x7ff00000 && iy >= 0x7ff00000)
+ return (cpack(y - y, x * (y - y)));
+
+ /*
+ * cosh(+-Inf + I NaN) = +Inf + I d(NaN).
+ *
+ * cosh(+-Inf +- I Inf) = +Inf + I dNaN.
+ * The sign of Inf in the result is unspecified. Choice = always +.
+ * Raise the invalid floating-point exception.
+ *
+ * cosh(+-Inf + I y) = +Inf cos(y) +- I Inf sin(y)
+ */
+ if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) {
+ if (iy >= 0x7ff00000)
+ return (cpack(x * x, x * (y - y)));
+ return (cpack((x * x) * cos(y), x * sin(y)));
+ }
+
+ /*
+ * cosh(NaN + I NaN) = d(NaN) + I d(NaN).
+ *
+ * cosh(NaN +- I Inf) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception.
+ * Choice = raise.
+ *
+ * cosh(NaN + I y) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception for finite
+ * nonzero y. Choice = don't raise (except for signaling NaNs).
+ */
+ return (cpack((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+double complex
+ccos(double complex z)
+{
+
+ /* ccos(z) = ccosh(I * z) */
+ return (ccosh(cpack(-cimag(z), creal(z))));
+}
diff --git a/lib/msun/src/s_ccoshf.c b/lib/msun/src/s_ccoshf.c
new file mode 100644
index 0000000..1de9ad4
--- /dev/null
+++ b/lib/msun/src/s_ccoshf.c
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * 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.
+ */
+
+/*
+ * Hyperbolic cosine of a complex argument. See s_ccosh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const float huge = 0x1p127;
+
+float complex
+ccoshf(float complex z)
+{
+ float x, y, h;
+ int32_t hx, hy, ix, iy;
+
+ x = crealf(z);
+ y = cimagf(z);
+
+ GET_FLOAT_WORD(hx, x);
+ GET_FLOAT_WORD(hy, y);
+
+ ix = 0x7fffffff & hx;
+ iy = 0x7fffffff & hy;
+
+ if (ix < 0x7f800000 && iy < 0x7f800000) {
+ if (iy == 0)
+ return (cpackf(coshf(x), x * y));
+ if (ix < 0x41100000) /* small x: normal case */
+ return (cpackf(coshf(x) * cosf(y), sinhf(x) * sinf(y)));
+
+ /* |x| >= 9, so cosh(x) ~= exp(|x|) */
+ if (ix < 0x42b17218) {
+ /* x < 88.7: expf(|x|) won't overflow */
+ h = expf(fabsf(x)) * 0.5f;
+ return (cpackf(h * cosf(y), copysignf(h, x) * sinf(y)));
+ } else if (ix < 0x4340b1e7) {
+ /* x < 192.7: scale to avoid overflow */
+ z = __ldexp_cexpf(cpackf(fabsf(x), y), -1);
+ return (cpackf(crealf(z), cimagf(z) * copysignf(1, x)));
+ } else {
+ /* x >= 192.7: the result always overflows */
+ h = huge * x;
+ return (cpackf(h * h * cosf(y), h * sinf(y)));
+ }
+ }
+
+ if (ix == 0 && iy >= 0x7f800000)
+ return (cpackf(y - y, copysignf(0, x * (y - y))));
+
+ if (iy == 0 && ix >= 0x7f800000) {
+ if ((hx & 0x7fffff) == 0)
+ return (cpackf(x * x, copysignf(0, x) * y));
+ return (cpackf(x * x, copysignf(0, (x + x) * y)));
+ }
+
+ if (ix < 0x7f800000 && iy >= 0x7f800000)
+ return (cpackf(y - y, x * (y - y)));
+
+ if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) {
+ if (iy >= 0x7f800000)
+ return (cpackf(x * x, x * (y - y)));
+ return (cpackf((x * x) * cosf(y), x * sinf(y)));
+ }
+
+ return (cpackf((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+float complex
+ccosf(float complex z)
+{
+
+ return (ccoshf(cpackf(-cimagf(z), crealf(z))));
+}
diff --git a/lib/msun/src/s_cexp.c b/lib/msun/src/s_cexp.c
index ecf0992..abe178f 100644
--- a/lib/msun/src/s_cexp.c
+++ b/lib/msun/src/s_cexp.c
@@ -34,18 +34,13 @@ __FBSDID("$FreeBSD$");
static const uint32_t
exp_ovfl = 0x40862e42, /* high bits of MAX_EXP * ln2 ~= 710 */
-cexp_ovfl = 0x4096b8e4, /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
-k = 1799; /* constant for reduction */
-
-static const double
-kln2 = 1246.97177782734161156; /* k * ln2 */
+cexp_ovfl = 0x4096b8e4; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
double complex
cexp(double complex z)
{
double x, y, exp_x;
uint32_t hx, hy, lx, ly;
- int scale;
x = creal(z);
y = cimag(z);
@@ -56,8 +51,12 @@ cexp(double complex z)
/* cexp(x + I 0) = exp(x) + I 0 */
if ((hy | ly) == 0)
return (cpack(exp(x), y));
+ EXTRACT_WORDS(hx, lx, x);
+ /* cexp(0 + I y) = cos(y) + I sin(y) */
+ if (((hx & 0x7fffffff) | lx) == 0)
+ return (cpack(cos(y), sin(y)));
+
if (hy >= 0x7ff00000) {
- EXTRACT_WORDS(hx, lx, x);
if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000) {
/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
return (cpack(y - y, y - y));
@@ -70,21 +69,12 @@ cexp(double complex z)
}
}
- GET_HIGH_WORD(hx, x);
if (hx >= exp_ovfl && hx <= cexp_ovfl) {
/*
* x is between 709.7 and 1454.3, so we must scale to avoid
- * overflow in exp(x). We use exp(x) = exp(x - kln2) * 2**k,
- * carefully chosen to minimize |exp(kln2) - 2**k|. We also
- * scale the exponent of exp(x) to MANT_DIG to avoid loss of
- * accuracy due to underflow if sin(y) is tiny.
+ * overflow in exp(x).
*/
- exp_x = exp(x - kln2);
- GET_HIGH_WORD(hx, exp_x);
- SET_HIGH_WORD(exp_x, (hx & 0xfffff) | ((0x3ff + 52) << 20));
- scale = (hx >> 20) - (0x3ff + 52) + k;
- return (cpack(scalbn(cos(y) * exp_x, scale),
- scalbn(sin(y) * exp_x, scale)));
+ return (__ldexp_cexp(z, 0));
} else {
/*
* Cases covered here:
diff --git a/lib/msun/src/s_cexpf.c b/lib/msun/src/s_cexpf.c
index 4ea3931..0e30d08 100644
--- a/lib/msun/src/s_cexpf.c
+++ b/lib/msun/src/s_cexpf.c
@@ -34,18 +34,13 @@ __FBSDID("$FreeBSD$");
static const uint32_t
exp_ovfl = 0x42b17218, /* MAX_EXP * ln2 ~= 88.722839355 */
-cexp_ovfl = 0x43400074, /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
-k = 235; /* constant for reduction */
-
-static const float
-kln2 = 162.88958740f; /* k * ln2 */
+cexp_ovfl = 0x43400074; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
float complex
cexpf(float complex z)
{
float x, y, exp_x;
uint32_t hx, hy;
- int scale;
x = crealf(z);
y = cimagf(z);
@@ -57,6 +52,10 @@ cexpf(float complex z)
if (hy == 0)
return (cpackf(expf(x), y));
GET_FLOAT_WORD(hx, x);
+ /* cexp(0 + I y) = cos(y) + I sin(y) */
+ if ((hx & 0x7fffffff) == 0)
+ return (cpackf(cosf(y), sinf(y)));
+
if (hy >= 0x7f800000) {
if ((hx & 0x7fffffff) != 0x7f800000) {
/* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */
@@ -73,17 +72,9 @@ cexpf(float complex z)
if (hx >= exp_ovfl && hx <= cexp_ovfl) {
/*
* x is between 88.7 and 192, so we must scale to avoid
- * overflow in expf(x). We use exp(x) = exp(x - kln2) * 2**k,
- * carefully chosen to minimize |exp(kln2) - 2**k|. We also
- * scale the exponent of exp(x) to MANT_DIG to avoid loss of
- * accuracy due to underflow if sin(y) is tiny.
+ * overflow in expf(x).
*/
- exp_x = expf(x - kln2);
- GET_FLOAT_WORD(hx, exp_x);
- SET_FLOAT_WORD(exp_x, (hx & 0x7fffff) | ((0x7f + 23) << 23));
- scale = (hx >> 23) - (0x7f + 23) + k;
- return (cpackf(scalbnf(cosf(y) * exp_x, scale),
- scalbnf(sinf(y) * exp_x, scale)));
+ return (__ldexp_cexpf(z, 0));
} else {
/*
* Cases covered here:
diff --git a/lib/msun/src/s_csinh.c b/lib/msun/src/s_csinh.c
new file mode 100644
index 0000000..c192f30
--- /dev/null
+++ b/lib/msun/src/s_csinh.c
@@ -0,0 +1,157 @@
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * 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.
+ */
+
+/*
+ * Hyperbolic sine of a complex argument z = x + i y.
+ *
+ * sinh(z) = sinh(x+iy)
+ * = sinh(x) cos(y) + i cosh(x) sin(y).
+ *
+ * Exceptional values are noted in the comments within the source code.
+ * These values and the return value were taken from n1124.pdf.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const double huge = 0x1p1023;
+
+double complex
+csinh(double complex z)
+{
+ double x, y, h;
+ int32_t hx, hy, ix, iy, lx, ly;
+
+ x = creal(z);
+ y = cimag(z);
+
+ EXTRACT_WORDS(hx, lx, x);
+ EXTRACT_WORDS(hy, ly, y);
+
+ ix = 0x7fffffff & hx;
+ iy = 0x7fffffff & hy;
+
+ /* Handle the nearly-non-exceptional cases where x and y are finite. */
+ if (ix < 0x7ff00000 && iy < 0x7ff00000) {
+ if ((iy | ly) == 0)
+ return (cpack(sinh(x), y));
+ if (ix < 0x40360000) /* small x: normal case */
+ return (cpack(sinh(x) * cos(y), cosh(x) * sin(y)));
+
+ /* |x| >= 22, so cosh(x) ~= exp(|x|) */
+ if (ix < 0x40862e42) {
+ /* x < 710: exp(|x|) won't overflow */
+ h = exp(fabs(x)) * 0.5;
+ return (cpack(copysign(h, x) * cos(y), h * sin(y)));
+ } else if (ix < 0x4096bbaa) {
+ /* x < 1455: scale to avoid overflow */
+ z = __ldexp_cexp(cpack(fabs(x), y), -1);
+ return (cpack(creal(z) * copysign(1, x), cimag(z)));
+ } else {
+ /* x >= 1455: the result always overflows */
+ h = huge * x;
+ return (cpack(h * cos(y), h * h * sin(y)));
+ }
+ }
+
+ /*
+ * sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN.
+ * The sign of 0 in the result is unspecified. Choice = normally
+ * the same as dNaN. Raise the invalid floating-point exception.
+ *
+ * sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN).
+ * The sign of 0 in the result is unspecified. Choice = normally
+ * the same as d(NaN).
+ */
+ if ((ix | lx) == 0 && iy >= 0x7ff00000)
+ return (cpack(copysign(0, x * (y - y)), y - y));
+
+ /*
+ * sinh(+-Inf +- I 0) = +-Inf + I +-0.
+ *
+ * sinh(NaN +- I 0) = d(NaN) + I +-0.
+ */
+ if ((iy | ly) == 0 && ix >= 0x7ff00000) {
+ if (((hx & 0xfffff) | lx) == 0)
+ return (cpack(x, y));
+ return (cpack(x, copysign(0, y)));
+ }
+
+ /*
+ * sinh(x +- I Inf) = dNaN + I dNaN.
+ * Raise the invalid floating-point exception for finite nonzero x.
+ *
+ * sinh(x + I NaN) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception for finite
+ * nonzero x. Choice = don't raise (except for signaling NaNs).
+ */
+ if (ix < 0x7ff00000 && iy >= 0x7ff00000)
+ return (cpack(y - y, x * (y - y)));
+
+ /*
+ * sinh(+-Inf + I NaN) = +-Inf + I d(NaN).
+ * The sign of Inf in the result is unspecified. Choice = normally
+ * the same as d(NaN).
+ *
+ * sinh(+-Inf +- I Inf) = +Inf + I dNaN.
+ * The sign of Inf in the result is unspecified. Choice = always +.
+ * Raise the invalid floating-point exception.
+ *
+ * sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y)
+ */
+ if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) {
+ if (iy >= 0x7ff00000)
+ return (cpack(x * x, x * (y - y)));
+ return (cpack(x * cos(y), INFINITY * sin(y)));
+ }
+
+ /*
+ * sinh(NaN + I NaN) = d(NaN) + I d(NaN).
+ *
+ * sinh(NaN +- I Inf) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception.
+ * Choice = raise.
+ *
+ * sinh(NaN + I y) = d(NaN) + I d(NaN).
+ * Optionally raises the invalid floating-point exception for finite
+ * nonzero y. Choice = don't raise (except for signaling NaNs).
+ */
+ return (cpack((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+double complex
+csin(double complex z)
+{
+
+ /* csin(z) = -I * csinh(I * z) */
+ z = csinh(cpack(-cimag(z), creal(z)));
+ return (cpack(cimag(z), -creal(z)));
+}
diff --git a/lib/msun/src/s_csinhf.c b/lib/msun/src/s_csinhf.c
new file mode 100644
index 0000000..c523125
--- /dev/null
+++ b/lib/msun/src/s_csinhf.c
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+ * 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.
+ */
+
+/*
+ * Hyperbolic sine of a complex argument z. See s_csinh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+static const float huge = 0x1p127;
+
+float complex
+csinhf(float complex z)
+{
+ float x, y, h;
+ int32_t hx, hy, ix, iy;
+
+ x = crealf(z);
+ y = cimagf(z);
+
+ GET_FLOAT_WORD(hx, x);
+ GET_FLOAT_WORD(hy, y);
+
+ ix = 0x7fffffff & hx;
+ iy = 0x7fffffff & hy;
+
+ if (ix < 0x7f800000 && iy < 0x7f800000) {
+ if (iy == 0)
+ return (cpackf(sinhf(x), y));
+ if (ix < 0x41100000) /* small x: normal case */
+ return (cpackf(sinhf(x) * cosf(y), coshf(x) * sinf(y)));
+
+ /* |x| >= 9, so cosh(x) ~= exp(|x|) */
+ if (ix < 0x42b17218) {
+ /* x < 88.7: expf(|x|) won't overflow */
+ h = expf(fabsf(x)) * 0.5f;
+ return (cpackf(copysignf(h, x) * cosf(y), h * sinf(y)));
+ } else if (ix < 0x4340b1e7) {
+ /* x < 192.7: scale to avoid overflow */
+ z = __ldexp_cexpf(cpackf(fabsf(x), y), -1);
+ return (cpackf(crealf(z) * copysignf(1, x), cimagf(z)));
+ } else {
+ /* x >= 192.7: the result always overflows */
+ h = huge * x;
+ return (cpackf(h * cosf(y), h * h * sinf(y)));
+ }
+ }
+
+ if (ix == 0 && iy >= 0x7f800000)
+ return (cpackf(copysignf(0, x * (y - y)), y - y));
+
+ if (iy == 0 && ix >= 0x7f800000) {
+ if ((hx & 0x7fffff) == 0)
+ return (cpackf(x, y));
+ return (cpackf(x, copysignf(0, y)));
+ }
+
+ if (ix < 0x7f800000 && iy >= 0x7f800000)
+ return (cpackf(y - y, x * (y - y)));
+
+ if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) {
+ if (iy >= 0x7f800000)
+ return (cpackf(x * x, x * (y - y)));
+ return (cpackf(x * cosf(y), INFINITY * sinf(y)));
+ }
+
+ return (cpackf((x * x) * (y - y), (x + x) * (y - y)));
+}
+
+float complex
+csinf(float complex z)
+{
+
+ z = csinhf(cpackf(-cimagf(z), crealf(z)));
+ return (cpackf(cimagf(z), -crealf(z)));
+}
diff --git a/lib/msun/src/s_ctanh.c b/lib/msun/src/s_ctanh.c
new file mode 100644
index 0000000..d427e28
--- /dev/null
+++ b/lib/msun/src/s_ctanh.c
@@ -0,0 +1,144 @@
+/*-
+ * Copyright (c) 2011 David Schultz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice 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.
+ */
+
+/*
+ * Hyperbolic tangent of a complex argument z = x + i y.
+ *
+ * The algorithm is from:
+ *
+ * W. Kahan. Branch Cuts for Complex Elementary Functions or Much
+ * Ado About Nothing's Sign Bit. In The State of the Art in
+ * Numerical Analysis, pp. 165 ff. Iserles and Powell, eds., 1987.
+ *
+ * Method:
+ *
+ * Let t = tan(x)
+ * beta = 1/cos^2(y)
+ * s = sinh(x)
+ * rho = cosh(x)
+ *
+ * We have:
+ *
+ * tanh(z) = sinh(z) / cosh(z)
+ *
+ * sinh(x) cos(y) + i cosh(x) sin(y)
+ * = ---------------------------------
+ * cosh(x) cos(y) + i sinh(x) sin(y)
+ *
+ * cosh(x) sinh(x) / cos^2(y) + i tan(y)
+ * = -------------------------------------
+ * 1 + sinh^2(x) / cos^2(y)
+ *
+ * beta rho s + i t
+ * = ----------------
+ * 1 + beta s^2
+ *
+ * Modifications:
+ *
+ * I omitted the original algorithm's handling of overflow in tan(x) after
+ * verifying with nearpi.c that this can't happen in IEEE single or double
+ * precision. I also handle large x differently.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+double complex
+ctanh(double complex z)
+{
+ double x, y;
+ double t, beta, s, rho, denom;
+ uint32_t hx, ix, lx;
+
+ x = creal(z);
+ y = cimag(z);
+
+ EXTRACT_WORDS(hx, lx, x);
+ ix = hx & 0x7fffffff;
+
+ /*
+ * ctanh(NaN + i 0) = NaN + i 0
+ *
+ * ctanh(NaN + i y) = NaN + i NaN for y != 0
+ *
+ * The imaginary part has the sign of x*sin(2*y), but there's no
+ * special effort to get this right.
+ *
+ * ctanh(+-Inf +- i Inf) = +-1 +- 0
+ *
+ * ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite
+ *
+ * The imaginary part of the sign is unspecified. This special
+ * case is only needed to avoid a spurious invalid exception when
+ * y is infinite.
+ */
+ if (ix >= 0x7ff00000) {
+ if ((ix & 0xfffff) | lx) /* x is NaN */
+ return (cpack(x, (y == 0 ? y : x * y)));
+ SET_HIGH_WORD(x, hx - 0x40000000); /* x = copysign(1, x) */
+ return (cpack(x, copysign(0, isinf(y) ? y : sin(y) * cos(y))));
+ }
+
+ /*
+ * ctanh(x + i NAN) = NaN + i NaN
+ * ctanh(x +- i Inf) = NaN + i NaN
+ */
+ if (!isfinite(y))
+ return (cpack(y - y, y - y));
+
+ /*
+ * ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the
+ * approximation sinh^2(huge) ~= exp(2*huge) / 4.
+ * We use a modified formula to avoid spurious overflow.
+ */
+ if (ix >= 0x40360000) { /* x >= 22 */
+ double exp_mx = exp(-fabs(x));
+ return (cpack(copysign(1, x),
+ 4 * sin(y) * cos(y) * exp_mx * exp_mx));
+ }
+
+ /* Kahan's algorithm */
+ t = tan(y);
+ beta = 1.0 + t * t; /* = 1 / cos^2(y) */
+ s = sinh(x);
+ rho = sqrt(1 + s * s); /* = cosh(x) */
+ denom = 1 + beta * s * s;
+ return (cpack((beta * rho * s) / denom, t / denom));
+}
+
+double complex
+ctan(double complex z)
+{
+
+ /* ctan(z) = -I * ctanh(I * z) */
+ z = ctanh(cpack(-cimag(z), creal(z)));
+ return (cpack(cimag(z), -creal(z)));
+}
diff --git a/lib/msun/src/s_ctanhf.c b/lib/msun/src/s_ctanhf.c
new file mode 100644
index 0000000..4be28d8
--- /dev/null
+++ b/lib/msun/src/s_ctanhf.c
@@ -0,0 +1,84 @@
+/*-
+ * Copyright (c) 2011 David Schultz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice 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.
+ */
+
+/*
+ * Hyperbolic tangent of a complex argument z. See s_ctanh.c for details.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+float complex
+ctanhf(float complex z)
+{
+ float x, y;
+ float t, beta, s, rho, denom;
+ uint32_t hx, ix;
+
+ x = crealf(z);
+ y = cimagf(z);
+
+ GET_FLOAT_WORD(hx, x);
+ ix = hx & 0x7fffffff;
+
+ if (ix >= 0x7f800000) {
+ if (ix & 0x7fffff)
+ return (cpackf(x, (y == 0 ? y : x * y)));
+ SET_FLOAT_WORD(x, hx - 0x40000000);
+ return (cpackf(x,
+ copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))));
+ }
+
+ if (!isfinite(y))
+ return (cpackf(y - y, y - y));
+
+ if (ix >= 0x41300000) { /* x >= 11 */
+ float exp_mx = expf(-fabsf(x));
+ return (cpackf(copysignf(1, x),
+ 4 * sinf(y) * cosf(y) * exp_mx * exp_mx));
+ }
+
+ t = tanf(y);
+ beta = 1.0 + t * t;
+ s = sinhf(x);
+ rho = sqrtf(1 + s * s);
+ denom = 1 + beta * s * s;
+ return (cpackf((beta * rho * s) / denom, t / denom));
+}
+
+float complex
+ctanf(float complex z)
+{
+
+ z = ctanhf(cpackf(-cimagf(z), crealf(z)));
+ return (cpackf(cimagf(z), -crealf(z)));
+}
+
diff --git a/lib/msun/src/s_expm1.c b/lib/msun/src/s_expm1.c
index 3de7bfb..5aa1917 100644
--- a/lib/msun/src/s_expm1.c
+++ b/lib/msun/src/s_expm1.c
@@ -108,6 +108,8 @@ __FBSDID("$FreeBSD$");
* to produce the hexadecimal values shown.
*/
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -135,7 +137,6 @@ expm1(double x)
GET_HIGH_WORD(hx,x);
xsb = hx&0x80000000; /* sign bit of x */
- if(xsb==0) y=x; else y= -x; /* y = |x| */
hx &= 0x7fffffff; /* high word of |x| */
/* filter out huge and non-finite argument */
@@ -169,7 +170,7 @@ expm1(double x)
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
lo = t*ln2_lo;
}
- x = hi - lo;
+ STRICT_ASSIGN(double, x, hi - lo);
c = (hi-x)-lo;
}
else if(hx < 0x3c900000) { /* when |x|<2**-54, return x */
diff --git a/lib/msun/src/s_expm1f.c b/lib/msun/src/s_expm1f.c
index 483472c..fb37494 100644
--- a/lib/msun/src/s_expm1f.c
+++ b/lib/msun/src/s_expm1f.c
@@ -16,6 +16,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -44,7 +46,6 @@ expm1f(float x)
GET_FLOAT_WORD(hx,x);
xsb = hx&0x80000000; /* sign bit of x */
- if(xsb==0) y=x; else y= -x; /* y = |x| */
hx &= 0x7fffffff; /* high word of |x| */
/* filter out huge and non-finite argument */
@@ -75,7 +76,7 @@ expm1f(float x)
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
lo = t*ln2_lo;
}
- x = hi - lo;
+ STRICT_ASSIGN(float, x, hi - lo);
c = (hi-x)-lo;
}
else if(hx < 0x33000000) { /* when |x|<2**-25, return x */
diff --git a/lib/msun/src/s_fma.c b/lib/msun/src/s_fma.c
index ad1fc4a..dfbd13c 100644
--- a/lib/msun/src/s_fma.c
+++ b/lib/msun/src/s_fma.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,132 @@ __FBSDID("$FreeBSD$");
#include <float.h>
#include <math.h>
+#include "math_private.h"
+
+/*
+ * A struct dd represents a floating-point number with twice the precision
+ * of a double. We maintain the invariant that "hi" stores the 53 high-order
+ * bits of the result.
+ */
+struct dd {
+ double hi;
+ double lo;
+};
+
+/*
+ * Compute a+b exactly, returning the exact result in a struct dd. We assume
+ * that both a and b are finite, but make no assumptions about their relative
+ * magnitudes.
+ */
+static inline struct dd
+dd_add(double a, double b)
+{
+ struct dd ret;
+ double s;
+
+ ret.hi = a + b;
+ s = ret.hi - a;
+ ret.lo = (a - (ret.hi - s)) + (b - s);
+ return (ret);
+}
+
+/*
+ * Compute a+b, with a small tweak: The least significant bit of the
+ * result is adjusted into a sticky bit summarizing all the bits that
+ * were lost to rounding. This adjustment negates the effects of double
+ * rounding when the result is added to another number with a higher
+ * exponent. For an explanation of round and sticky bits, see any reference
+ * on FPU design, e.g.,
+ *
+ * J. Coonen. An Implementation Guide to a Proposed Standard for
+ * Floating-Point Arithmetic. Computer, vol. 13, no. 1, Jan 1980.
+ */
+static inline double
+add_adjusted(double a, double b)
+{
+ struct dd sum;
+ uint64_t hibits, lobits;
+
+ sum = dd_add(a, b);
+ if (sum.lo != 0) {
+ EXTRACT_WORD64(hibits, sum.hi);
+ if ((hibits & 1) == 0) {
+ /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
+ EXTRACT_WORD64(lobits, sum.lo);
+ hibits += 1 - ((hibits ^ lobits) >> 62);
+ INSERT_WORD64(sum.hi, hibits);
+ }
+ }
+ return (sum.hi);
+}
+
+/*
+ * Compute ldexp(a+b, scale) with a single rounding error. It is assumed
+ * that the result will be subnormal, and care is taken to ensure that
+ * double rounding does not occur.
+ */
+static inline double
+add_and_denormalize(double a, double b, int scale)
+{
+ struct dd sum;
+ uint64_t hibits, lobits;
+ int bits_lost;
+
+ sum = dd_add(a, b);
+
+ /*
+ * If we are losing at least two bits of accuracy to denormalization,
+ * then the first lost bit becomes a round bit, and we adjust the
+ * lowest bit of sum.hi to make it a sticky bit summarizing all the
+ * bits in sum.lo. With the sticky bit adjusted, the hardware will
+ * break any ties in the correct direction.
+ *
+ * If we are losing only one bit to denormalization, however, we must
+ * break the ties manually.
+ */
+ if (sum.lo != 0) {
+ EXTRACT_WORD64(hibits, sum.hi);
+ bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 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);
+ INSERT_WORD64(sum.hi, hibits);
+ }
+ }
+ return (ldexp(sum.hi, scale));
+}
+
+/*
+ * Compute a*b exactly, returning the exact result in a struct dd. We assume
+ * that both a and b are normalized, so no underflow or overflow will occur.
+ * The current rounding mode must be round-to-nearest.
+ */
+static inline struct dd
+dd_mul(double a, double b)
+{
+ static const double split = 0x1p27 + 1.0;
+ struct dd ret;
+ double ha, hb, la, lb, p, q;
+
+ p = a * split;
+ ha = a - p;
+ ha += p;
+ la = a - ha;
+
+ p = b * split;
+ hb = b - p;
+ hb += p;
+ lb = b - hb;
+
+ p = ha * hb;
+ q = ha * lb + la * hb;
+
+ ret.hi = p + q;
+ ret.lo = p - ret.hi + q + la * lb;
+ return (ret);
+}
+
/*
* Fused multiply-add: Compute x * y + z with a single rounding error.
*
@@ -48,14 +174,11 @@ __FBSDID("$FreeBSD$");
* Hardware instructions should be used on architectures that support it,
* since this implementation will likely be several times slower.
*/
-#if LDBL_MANT_DIG != 113
double
fma(double x, double y, double z)
{
- static const double split = 0x1p27 + 1.0;
- double xs, ys, zs;
- double c, cc, hx, hy, p, q, tx, ty;
- double r, rr, s;
+ double xs, ys, zs, adj;
+ struct dd xy, r;
int oround;
int ex, ey, ez;
int spread;
@@ -85,41 +208,6 @@ fma(double x, double y, double z)
* will overflow, so we handle these cases specially. Rounding
* modes other than FE_TONEAREST are painful.
*/
- if (spread > DBL_MANT_DIG * 2) {
- fenv_t env;
- feraiseexcept(FE_INEXACT);
- switch(oround) {
- case FE_TONEAREST:
- return (x * y);
- case FE_TOWARDZERO:
- if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
- return (x * y);
- feholdexcept(&env);
- r = x * y;
- if (!fetestexcept(FE_INEXACT))
- r = nextafter(r, 0);
- feupdateenv(&env);
- return (r);
- case FE_DOWNWARD:
- if (z > 0.0)
- return (x * y);
- feholdexcept(&env);
- r = x * y;
- if (!fetestexcept(FE_INEXACT))
- r = nextafter(r, -INFINITY);
- feupdateenv(&env);
- return (r);
- default: /* FE_UPWARD */
- if (z < 0.0)
- return (x * y);
- feholdexcept(&env);
- r = x * y;
- if (!fetestexcept(FE_INEXACT))
- r = nextafter(r, INFINITY);
- feupdateenv(&env);
- return (r);
- }
- }
if (spread < -DBL_MANT_DIG) {
feraiseexcept(FE_INEXACT);
if (!isnormal(z))
@@ -144,63 +232,52 @@ fma(double x, double y, double z)
return (z);
}
}
+ if (spread <= DBL_MANT_DIG * 2)
+ zs = ldexp(zs, -spread);
+ else
+ zs = copysign(DBL_MIN, zs);
- /*
- * Use Dekker's algorithm to perform the multiplication and
- * subsequent addition in twice the machine precision.
- * Arrange so that x * y = c + cc, and x * y + z = r + rr.
- */
fesetround(FE_TONEAREST);
- p = xs * split;
- hx = xs - p;
- hx += p;
- tx = xs - hx;
-
- p = ys * split;
- hy = ys - p;
- hy += p;
- ty = ys - hy;
-
- p = hx * hy;
- q = hx * ty + tx * hy;
- c = p + q;
- cc = p - c + q + tx * ty;
-
- zs = ldexp(zs, -spread);
- r = c + zs;
- s = r - c;
- rr = (c - (r - s)) + (zs - s) + cc;
+ /*
+ * Basic approach for round-to-nearest:
+ *
+ * (xy.hi, xy.lo) = x * y (exact)
+ * (r.hi, r.lo) = xy.hi + z (exact)
+ * adj = xy.lo + r.lo (inexact; low bit is sticky)
+ * result = r.hi + adj (correctly rounded)
+ */
+ xy = dd_mul(xs, ys);
+ r = dd_add(xy.hi, zs);
spread = ex + ey;
- if (spread + ilogb(r) > -1023) {
+
+ if (r.hi == 0.0) {
+ /*
+ * When the addends cancel to 0, ensure that the result has
+ * the correct sign.
+ */
fesetround(oround);
- r = r + rr;
- } else {
+ volatile double vzs = zs; /* XXX gcc CSE bug workaround */
+ return (xy.hi + vzs + ldexp(xy.lo, spread));
+ }
+
+ if (oround != FE_TONEAREST) {
/*
- * The result is subnormal, so we round before scaling to
- * avoid double rounding.
+ * There is no need to worry about double rounding in directed
+ * rounding modes.
*/
- p = ldexp(copysign(0x1p-1022, r), -spread);
- c = r + p;
- s = c - r;
- cc = (r - (c - s)) + (p - s) + rr;
fesetround(oround);
- r = (c + cc) - p;
+ adj = r.lo + xy.lo;
+ return (ldexp(r.hi + adj, spread));
}
- return (ldexp(r, spread));
-}
-#else /* LDBL_MANT_DIG == 113 */
-/*
- * 113 bits of precision is more than twice the precision of a double,
- * so it is enough to represent the intermediate product exactly.
- */
-double
-fma(double x, double y, double z)
-{
- return ((long double)x * y + z);
+
+ adj = add_adjusted(r.lo, xy.lo);
+ if (spread + ilogb(r.hi) > -1023)
+ return (ldexp(r.hi + adj, spread));
+ else
+ return (add_and_denormalize(r.hi, adj, spread));
}
-#endif /* LDBL_MANT_DIG != 113 */
#if (LDBL_MANT_DIG == 53)
__weak_reference(fma, fmal);
diff --git a/lib/msun/src/s_fmaf.c b/lib/msun/src/s_fmaf.c
index 7c699e5..3695823 100644
--- a/lib/msun/src/s_fmaf.c
+++ b/lib/msun/src/s_fmaf.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,23 +27,43 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <fenv.h>
+
#include "math.h"
+#include "math_private.h"
/*
* Fused multiply-add: Compute x * y + z with a single rounding error.
*
* A double has more than twice as much precision than a float, so
- * direct double-precision arithmetic suffices.
- *
- * XXX We are relying on the compiler to convert from double to float
- * using the current rounding mode and with the appropriate
- * side-effects. But on at least one platform (gcc 3.4.2/sparc64),
- * this appears to be too much to ask for. The precision
- * reduction should be done manually.
+ * direct double-precision arithmetic suffices, except where double
+ * rounding occurs.
*/
float
fmaf(float x, float y, float z)
{
+ double xy, result;
+ uint32_t hr, lr;
+
+ xy = (double)x * y;
+ result = xy + z;
+ EXTRACT_WORDS(hr, lr, result);
+ /* Common case: The double precision result is fine. */
+ if ((lr & 0x1fffffff) != 0x10000000 || /* not a halfway case */
+ (hr & 0x7ff00000) == 0x7ff00000 || /* NaN */
+ result - xy == z || /* exact */
+ fegetround() != FE_TONEAREST) /* not round-to-nearest */
+ return (result);
- return ((double)x * y + z);
+ /*
+ * If result is inexact, and exactly halfway between two float values,
+ * we need to adjust the low-order bit in the direction of the error.
+ */
+ fesetround(FE_TOWARDZERO);
+ volatile double vxy = xy; /* XXX work around gcc CSE bug */
+ double adjusted_result = vxy + z;
+ fesetround(FE_TONEAREST);
+ if (result == adjusted_result)
+ SET_LOW_WORD(adjusted_result, lr + 1);
+ return (adjusted_result);
}
diff --git a/lib/msun/src/s_fmal.c b/lib/msun/src/s_fmal.c
index 4d5d114..c2a6913 100644
--- a/lib/msun/src/s_fmal.c
+++ b/lib/msun/src/s_fmal.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+ * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,128 @@ __FBSDID("$FreeBSD$");
#include <float.h>
#include <math.h>
+#include "fpmath.h"
+
+/*
+ * A struct dd represents a floating-point number with twice the precision
+ * of a long double. We maintain the invariant that "hi" stores the high-order
+ * bits of the result.
+ */
+struct dd {
+ long double hi;
+ long double lo;
+};
+
+/*
+ * Compute a+b exactly, returning the exact result in a struct dd. We assume
+ * that both a and b are finite, but make no assumptions about their relative
+ * magnitudes.
+ */
+static inline struct dd
+dd_add(long double a, long double b)
+{
+ struct dd ret;
+ long double s;
+
+ ret.hi = a + b;
+ s = ret.hi - a;
+ ret.lo = (a - (ret.hi - s)) + (b - s);
+ return (ret);
+}
+
+/*
+ * Compute a+b, with a small tweak: The least significant bit of the
+ * result is adjusted into a sticky bit summarizing all the bits that
+ * were lost to rounding. This adjustment negates the effects of double
+ * rounding when the result is added to another number with a higher
+ * exponent. For an explanation of round and sticky bits, see any reference
+ * on FPU design, e.g.,
+ *
+ * J. Coonen. An Implementation Guide to a Proposed Standard for
+ * Floating-Point Arithmetic. Computer, vol. 13, no. 1, Jan 1980.
+ */
+static inline long double
+add_adjusted(long double a, long double b)
+{
+ struct dd sum;
+ union IEEEl2bits u;
+
+ sum = dd_add(a, b);
+ if (sum.lo != 0) {
+ u.e = sum.hi;
+ if ((u.bits.manl & 1) == 0)
+ sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
+ }
+ return (sum.hi);
+}
+
+/*
+ * Compute ldexp(a+b, scale) with a single rounding error. It is assumed
+ * that the result will be subnormal, and care is taken to ensure that
+ * double rounding does not occur.
+ */
+static inline long double
+add_and_denormalize(long double a, long double b, int scale)
+{
+ struct dd sum;
+ int bits_lost;
+ union IEEEl2bits u;
+
+ sum = dd_add(a, b);
+
+ /*
+ * If we are losing at least two bits of accuracy to denormalization,
+ * then the first lost bit becomes a round bit, and we adjust the
+ * lowest bit of sum.hi to make it a sticky bit summarizing all the
+ * bits in sum.lo. With the sticky bit adjusted, the hardware will
+ * break any ties in the correct direction.
+ *
+ * If we are losing only one bit to denormalization, however, we must
+ * break the ties manually.
+ */
+ if (sum.lo != 0) {
+ u.e = sum.hi;
+ bits_lost = -u.bits.exp - scale + 1;
+ if (bits_lost != 1 ^ (int)(u.bits.manl & 1))
+ sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
+ }
+ return (ldexp(sum.hi, scale));
+}
+
+/*
+ * Compute a*b exactly, returning the exact result in a struct dd. We assume
+ * that both a and b are normalized, so no underflow or overflow will occur.
+ * The current rounding mode must be round-to-nearest.
+ */
+static inline struct dd
+dd_mul(long double a, long double b)
+{
+#if LDBL_MANT_DIG == 64
+ static const long double split = 0x1p32L + 1.0;
+#elif LDBL_MANT_DIG == 113
+ static const long double split = 0x1p57L + 1.0;
+#endif
+ struct dd ret;
+ long double ha, hb, la, lb, p, q;
+
+ p = a * split;
+ ha = a - p;
+ ha += p;
+ la = a - ha;
+
+ p = b * split;
+ hb = b - p;
+ hb += p;
+ lb = b - hb;
+
+ p = ha * hb;
+ q = ha * lb + la * hb;
+
+ ret.hi = p + q;
+ ret.lo = p - ret.hi + q + la * lb;
+ return (ret);
+}
+
/*
* Fused multiply-add: Compute x * y + z with a single rounding error.
*
@@ -43,14 +165,8 @@ __FBSDID("$FreeBSD$");
long double
fmal(long double x, long double y, long double z)
{
-#if LDBL_MANT_DIG == 64
- static const long double split = 0x1p32L + 1.0;
-#elif LDBL_MANT_DIG == 113
- static const long double split = 0x1p57L + 1.0;
-#endif
- long double xs, ys, zs;
- long double c, cc, hx, hy, p, q, tx, ty;
- long double r, rr, s;
+ long double xs, ys, zs, adj;
+ struct dd xy, r;
int oround;
int ex, ey, ez;
int spread;
@@ -80,41 +196,6 @@ fmal(long double x, long double y, long double z)
* will overflow, so we handle these cases specially. Rounding
* modes other than FE_TONEAREST are painful.
*/
- if (spread > LDBL_MANT_DIG * 2) {
- fenv_t env;
- feraiseexcept(FE_INEXACT);
- switch(oround) {
- case FE_TONEAREST:
- return (x * y);
- case FE_TOWARDZERO:
- if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
- return (x * y);
- feholdexcept(&env);
- r = x * y;
- if (!fetestexcept(FE_INEXACT))
- r = nextafterl(r, 0);
- feupdateenv(&env);
- return (r);
- case FE_DOWNWARD:
- if (z > 0.0)
- return (x * y);
- feholdexcept(&env);
- r = x * y;
- if (!fetestexcept(FE_INEXACT))
- r = nextafterl(r, -INFINITY);
- feupdateenv(&env);
- return (r);
- default: /* FE_UPWARD */
- if (z < 0.0)
- return (x * y);
- feholdexcept(&env);
- r = x * y;
- if (!fetestexcept(FE_INEXACT))
- r = nextafterl(r, INFINITY);
- feupdateenv(&env);
- return (r);
- }
- }
if (spread < -LDBL_MANT_DIG) {
feraiseexcept(FE_INEXACT);
if (!isnormal(z))
@@ -139,49 +220,49 @@ fmal(long double x, long double y, long double z)
return (z);
}
}
+ if (spread <= LDBL_MANT_DIG * 2)
+ zs = ldexpl(zs, -spread);
+ else
+ zs = copysignl(LDBL_MIN, zs);
- /*
- * Use Dekker's algorithm to perform the multiplication and
- * subsequent addition in twice the machine precision.
- * Arrange so that x * y = c + cc, and x * y + z = r + rr.
- */
fesetround(FE_TONEAREST);
- p = xs * split;
- hx = xs - p;
- hx += p;
- tx = xs - hx;
-
- p = ys * split;
- hy = ys - p;
- hy += p;
- ty = ys - hy;
-
- p = hx * hy;
- q = hx * ty + tx * hy;
- c = p + q;
- cc = p - c + q + tx * ty;
-
- zs = ldexpl(zs, -spread);
- r = c + zs;
- s = r - c;
- rr = (c - (r - s)) + (zs - s) + cc;
+ /*
+ * Basic approach for round-to-nearest:
+ *
+ * (xy.hi, xy.lo) = x * y (exact)
+ * (r.hi, r.lo) = xy.hi + z (exact)
+ * adj = xy.lo + r.lo (inexact; low bit is sticky)
+ * result = r.hi + adj (correctly rounded)
+ */
+ xy = dd_mul(xs, ys);
+ r = dd_add(xy.hi, zs);
spread = ex + ey;
- if (spread + ilogbl(r) > -16383) {
+
+ if (r.hi == 0.0) {
+ /*
+ * When the addends cancel to 0, ensure that the result has
+ * the correct sign.
+ */
fesetround(oround);
- r = r + rr;
- } else {
+ volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
+ return (xy.hi + vzs + ldexpl(xy.lo, spread));
+ }
+
+ if (oround != FE_TONEAREST) {
/*
- * The result is subnormal, so we round before scaling to
- * avoid double rounding.
+ * There is no need to worry about double rounding in directed
+ * rounding modes.
*/
- p = ldexpl(copysignl(0x1p-16382L, r), -spread);
- c = r + p;
- s = c - r;
- cc = (r - (c - s)) + (p - s) + rr;
fesetround(oround);
- r = (c + cc) - p;
+ adj = r.lo + xy.lo;
+ return (ldexpl(r.hi + adj, spread));
}
- return (ldexpl(r, spread));
+
+ adj = add_adjusted(r.lo, xy.lo);
+ if (spread + ilogbl(r.hi) > -16383)
+ return (ldexpl(r.hi + adj, spread));
+ else
+ return (add_and_denormalize(r.hi, adj, spread));
}
OpenPOWER on IntegriCloud